This commit is contained in:
Benjamin Kyd
2023-05-26 15:19:16 +01:00
parent c91949fa0f
commit e78432a258
6 changed files with 42 additions and 14 deletions

View File

@@ -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:

BIN
SPI EPaper.sal Normal file

Binary file not shown.

View File

@@ -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";
};

View File

@@ -1,3 +1,4 @@
CONFIG_BUILD_OUTPUT_UF2=y
CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_ASYNC=y
CONFIG_SPI_PL022_INTERRUPT=y

View File

@@ -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)) {
while (!device_is_ready(spi1_dev)) { }
gpio_pin_set_dt(&led, GPIO_OUTPUT_HIGH);
while (1) {
k_msleep(500);
gpio_pin_toggle_dt(&led);
}
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);
}
}

Binary file not shown.