diff --git a/Makefile b/Makefile index 4705810..64f9b4c 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,22 @@ CMAKE_ZEPHYR_PATH=../zephyrproject/zephyr CMAKE_ZEPHYR_COMMAND=west build CMAKE_ZEPHYR_FLAGS=-b $(TARGET) -all: compile flash +all: compile flash_pico + +setup: + west init + west update compile: $(CMAKE_ZEPHYR_COMMAND) $(CMAKE_ZEPHYR_FLAGS) cp build/zephyr/zephyr.uf2 ./zephyr.uf2 + echo "Copied zephyr.uf2 to project root" + +flash_pico: + # mount then copy the uf2 + sudo mount -L RPI-RP2 /mnt + sudo cp zephyr.uf2 /mnt + echo "Copied zephyr.uf2 to pico" # FIXME: This is entirely board specific, for example the pi pico will vibe differently flash: diff --git a/SPI EPaper.sal b/SPI EPaper.sal new file mode 100644 index 0000000..b3892f6 Binary files /dev/null and b/SPI EPaper.sal differ diff --git a/boards/rpi_pico.overlay b/boards/rpi_pico.overlay index a32294d..e30bcd8 100644 --- a/boards/rpi_pico.overlay +++ b/boards/rpi_pico.overlay @@ -1,3 +1,12 @@ &spi1 { + compatible = "raspberrypi,pico-spi", "arm,pl022"; + cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; +#address-cells = <1>; +#size-cells = <0>; + reg = <0x40040000 DT_SIZE_K(4)>; + resets = <&reset RPI_PICO_RESETS_RESET_SPI1>; + clocks = <&peripheral_clk>; + interrupts = <19 RPI_PICO_DEFAULT_IRQ_PRIORITY>; + interrupt-names = "spi1"; status = "okay"; }; diff --git a/prj.conf b/prj.conf index 65e647e..d516a57 100644 --- a/prj.conf +++ b/prj.conf @@ -1,3 +1,4 @@ CONFIG_BUILD_OUTPUT_UF2=y CONFIG_GPIO=y -CONFIG_SPI=y +CONFIG_SPI_ASYNC=y +CONFIG_SPI_PL022_INTERRUPT=y diff --git a/src/main.c b/src/main.c index cb41180..997d7ce 100644 --- a/src/main.c +++ b/src/main.c @@ -21,18 +21,25 @@ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); void main(void) { - // set up the led - while (!device_is_ready(led.port)) { } - gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); - gpio_pin_set_dt(&led, GPIO_OUTPUT_LOW); - - while (!device_is_ready(spi1_dev)) { } - - gpio_pin_set_dt(&led, GPIO_OUTPUT_HIGH); - - while (1) { - k_msleep(500); - gpio_pin_toggle_dt(&led); + while (!device_is_ready(spi1_dev)) { + } + + if (!device_is_ready(led.port)) { + return; + } + + int ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + return; + } + + while (1) { + ret = gpio_pin_toggle_dt(&led); + if (ret < 0) { + return; + } + k_msleep(500); + } } diff --git a/zephyr.uf2 b/zephyr.uf2 index 5dcc676..73e9ac5 100644 Binary files a/zephyr.uf2 and b/zephyr.uf2 differ