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
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
#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
// 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
#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
import machine | |
counter = 0 | |
def inc_ctr(t): | |
global counter | |
counter += 1 | |
print(t) | |
t = machine.Timer(0) | |
t.init(period=1000000,mode=t.PERIODIC,callback=lambda t:inc_ctr(t)) |
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 enum _timer_mode_t { | |
ONE_SHOT = 0, | |
PERIODIC = 1, | |
} timer_mode_t; | |
typedef struct _machine_timer_obj_t { | |
mp_obj_base_t base; | |
uint32_t id; | |
uint32_t period; | |
timer_mode_t mode; |
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
from machine import Pin,Timer | |
led = Pin(47) | |
led.init(led.OUT) | |
def led_toggle(t): | |
global led | |
led.value(1 - led.value()) | |
tim = Timer(3) | |
tim.init(period=500000,mode=tim.PERIODIC,callback=lambda t:led_toggle(t)) |
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 machine, utime | |
log = [] | |
def add_log(t): | |
global log | |
log.append((utime.ticks_us() & 0xffffffff) + 1000 - t.compare_register()) | |
times = 1000 | |
tim = machine.Timer(3) | |
tim.init(period=1000,mode=tim.PERIODIC,callback=lambda t:add_log(t)) |
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 gpu, framebuf | |
gpu.fb_init(240, 135, screen_w=1920, screen_h=1080) | |
fb = framebuf.FrameBuffer(gpu.fb_data(), 240, 135, framebuf.RGB565) | |
fb.fill_rect(0,0,240,135,0) | |
minX = -2.0 | |
maxX = 1.0 | |
width = 240 | |
height = 135 | |
aspectRatio = 1.0 |