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
#define IOREG(X) (*(volatile uint32_t *) (X)) | |
#define IRQ_PEND1 IOREG(0x2000B204) | |
#define SYST_CS IOREG(0x20003000) | |
#define SYST_C0 IOREG(0x2000300C) | |
#define SYST_C1 IOREG(0x20003010) | |
#define SYST_C2 IOREG(0x20003014) | |
#define SYST_C3 IOREG(0x20003018) |
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
// ldr pc, [pc, #24] | |
#define JMP_PC_24 0xe59ff018 | |
typedef void (*exception_hander_t)(void); | |
typedef struct __attribute__((aligned(32))) _vector_table_t { | |
const unsigned int vector[8]; // all elements shoud be JMP_PC_24 | |
exception_hander_t reset; | |
exception_hander_t undef; | |
exception_hander_t svc; |
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
#include "py/runtime.h" | |
#include "py/mphal.h" | |
#include "py/obj.h" | |
// キーワード型引数を持つ関数 | |
// pos_argsはpositional args、kw_argsはkeyword args | |
STATIC mp_obj_t gpu_fb_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { | |
return mp_const_none; | |
} | |
// 関数から関数オブジェクトを生成。第二引数の「2」はpositional argsの個数(必須の引数の個数) |
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
typedef volatile struct \ | |
__attribute__((aligned(16))) _fb_info_t { | |
uint32_t display_w; //write display width | |
uint32_t display_h; //write display height | |
uint32_t w; //write framebuffer width | |
uint32_t h; //write framebuffer height | |
uint32_t row_bytes; //write 0 to get value | |
uint32_t bpp; //write bits per pixel | |
uint32_t ofs_x; //write x offset of framebuffer | |
uint32_t ofs_y; //write y offset of framebuffer |
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
#define IOREG(X) (*(volatile uint32_t *) (X)) | |
#define MAILBOX0_FIFO IOREG(0x2000B880) | |
#define MAILBOX0_POLL IOREG(0x2000B890) | |
#define MAILBOX0_SENDER IOREG(0x2000B894) | |
#define MAILBOX0_STATUS IOREG(0x2000B898) | |
#define MAILBOX0_CONFIG IOREG(0x2000B89C) | |
#define MAILBOX1_FIFO IOREG(0x2000B8A0) | |
#define MAILBOX1_POLL IOREG(0x2000B8B0) | |
#define MAILBOX1_SENDER IOREG(0x2000B8B4) | |
#define MAILBOX1_STATUS IOREG(0x2000B8B8) |
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) |
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
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
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
#!/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 |