gpio_put(PIN_SCL, true);
delay(100);
gpio_put(PIN_SDA, true);
delay(100);
gpio_put(PIN_SCL, false);
delay(100);
gpio_put(PIN_SDA, false);
delay(100);
bool state = ON;
int handler() {
gpio_put(PIN_SCL, state);
state = !state;
}
int main() {
struct repeating_timer timer;
add_repeating_timer_ms(100, handler, NULL, &timer);
}
RP2040 × 2, RP2350 × 3
.program squarewave set pindirs, 1 again: set pins, 1 [1] set pins, 0 jmp again
+ autopush & autopull
.program auto_push_pull .wrap_target out x, 32 in x, 32 .wrap
!X
: scratch X zeroX--
: scratch X non-zero, prior to decrement!Y
: scratch Y zeroY--
: scratch Y non-zero, prior to decrementX!=Y
: scratch X not equal scratch YPIN
: branch on input pin!OSRE
: output shift register not empty.program spi_tx_fast .side_set 1 loop: out pins, 1 side 0 jmp loop side 1
MOV EXEC
& OUT EXEC
OUT
, SET
, IN
and for side-setting.program addition ; Pop two 32 bit integers from the TX FIFO, add them together, and push the ; result to the TX FIFO. Autopush/pull should be disabled as we're using ; explicit push and pull instructions. ; ; This program uses the two's complement identity x + y == ~(~x - y) pull mov x, ~osr pull mov y, osr jmp test ; this loop is equivalent to the following C code: incr: ; while (y--) jmp x-- test ; x--; test: ; This has the effect of subtracting y from x, eventually. jmp y-- incr mov isr, ~x push