This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Private function prototypes -----------------------------------------------*/ | |
#ifdef __GNUC__ | |
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf | |
set to 'Yes') calls __io_putchar() */ | |
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) | |
#else | |
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) | |
#endif /* __GNUC__ */ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcu | |
# set gpio47 to output mode | |
mcu.mem32[int("0x20200010")] = 2**21 | |
# set gpio47 to L (LED on) | |
mcu.mem32[int("0x2020002C")] = 2**15 | |
# set gpio47 to H (LED off) | |
mcu.mem32[int("0x20200020")] = 2**15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcu, utime | |
# set gpio47 to output mode | |
mcu.mem32[mcu.GPFSEL4] = 2**21 | |
while(1): | |
mcu.mem32[mcu.GPCLR1] = 2**15 | |
utime.sleep_ms(300) | |
mcu.mem32[mcu.GPSET1] = 2**15 | |
utime.sleep_ms(300) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pi@pi-zero-w:~ $ echo 4 > /sys/class/gpio/export | |
pi@pi-zero-w:~ $ ls /sys/class/gpio/ | |
export gpio4 gpiochip0 unexport | |
pi@pi-zero-w:~ $ echo out > /sys/class/gpio/gpio4/direction | |
pi@pi-zero-w:~ $ echo 1 > /sys/class/gpio/gpio4/value | |
pi@pi-zero-w:~ $ echo 0 > /sys/class/gpio/gpio4/value | |
pi@pi-zero-w:~ $ echo 4 > /sys/class/gpio/unexport | |
pi@pi-zero-w:~ $ ls /sys/class/gpio/ | |
export gpiochip0 unexport | |
pi@pi-zero-w:~ $ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pi@pi-zero-w:~$ i2cdetect -a 1 | |
WARNING! This program can confuse your I2C bus, cause data loss and worse! | |
I will probe file /dev/i2c-1. | |
I will probe address range 0x00-0x7f. | |
Continue? [Y/n] | |
0 1 2 3 4 5 6 7 8 9 a b c d e f | |
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
i2cset -y 1 0x3c 0x00 0xae # display off | |
i2cset -y 1 0x3c 0x00 0xd5 # clockdiv | |
i2cset -y 1 0x3c 0x00 0x80 | |
i2cset -y 1 0x3c 0x00 0xa8 # multiplex | |
i2cset -y 1 0x3c 0x00 0x3f | |
i2cset -y 1 0x3c 0x00 0xd3 # offset | |
i2cset -y 1 0x3c 0x00 0x00 | |
i2cset -y 1 0x3c 0x00 0x40 # startline | |
i2cset -y 1 0x3c 0x00 0x8d # charge pump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pi@pi-zero-w:~$ raspi-gpio get | |
BANK0 (GPIO 0 to 27): | |
GPIO 0: level=1 fsel=0 func=INPUT | |
GPIO 1: level=1 fsel=0 func=INPUT | |
GPIO 2: level=1 fsel=4 alt=0 func=SDA1 | |
GPIO 3: level=1 fsel=4 alt=0 func=SCL1 | |
GPIO 4: level=1 fsel=0 func=INPUT | |
GPIO 5: level=1 fsel=0 func=INPUT | |
GPIO 6: level=1 fsel=0 func=INPUT | |
GPIO 7: level=1 fsel=1 func=OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pi@pi-zero-w:~$ gpio mode 1 pwm | |
pi@pi-zero-w:~$ gpio pwm-ms | |
pi@pi-zero-w:~$ gpio pwmc 192 | |
pi@pi-zero-w:~$ gpio pwmr 2000 | |
pi@pi-zero-w:~$ gpio pwm 1 150 | |
pi@pi-zero-w:~$ gpio pwm 1 100 | |
pi@pi-zero-w:~$ gpio pwm 1 200 | |
pi@pi-zero-w:~$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize usb | |
UsbInitialise(); | |
while (1) { | |
unsigned int kbd_addr; | |
unsigned int keys[6]; | |
unsigned int key; | |
if (kbd_addr == 0) { | |
// Is there a keyboard ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
hid = pyb.USB_HID() | |
def osc(n, d): | |
for i in range(n): | |
hid.send((0, int(20 * math.sin(i / 10)), 0, 0)) | |
pyb.delay(d) | |
# osc(100, 50) |