From 5521cef24babd2d0283f74e6f9ac69f4ecb6aa5c Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Thu, 24 Jul 2025 18:07:00 -0500 Subject: [PATCH 1/4] some example rationalization and readme cleanup --- README.md | 39 ++++++++++--------- pio/CMakeLists.txt | 2 +- pio/ir_nec/nec_receive_library/CMakeLists.txt | 11 +++--- .../nec_transmit_library/CMakeLists.txt | 11 +++--- pio/uart_dma/CMakeLists.txt | 11 ++++++ .../uart_pio_dma.c => uart_dma/uart_dma.c} | 0 pio/uart_pio_dma/CMakeLists.txt | 11 ------ 7 files changed, 45 insertions(+), 40 deletions(-) create mode 100644 pio/uart_dma/CMakeLists.txt rename pio/{uart_pio_dma/uart_pio_dma.c => uart_dma/uart_dma.c} (100%) delete mode 100644 pio/uart_pio_dma/CMakeLists.txt diff --git a/README.md b/README.md index 25e994667..f2e92e8dc 100644 --- a/README.md +++ b/README.md @@ -304,28 +304,31 @@ App|Description App|Description ---|--- [hello_pio](pio/hello_pio) | Absolutely minimal example showing how to control an LED by pushing values into a PIO FIFO. -[apa102](pio/apa102) | Rainbow pattern on on a string of APA102 addressable RGB LEDs. -[clocked_input](pio/clocked_input) | Shift in serial data, sampling with an external clock. -[differential_manchester](pio/differential_manchester) | Send and receive differential Manchester-encoded serial (BMC). -[hub75](pio/hub75) | Display an image on a 128x64 HUB75 RGB LED matrix. -[i2c](pio/i2c) | Scan an I2C bus. -[ir_nec](pio/ir_nec) | Sending and receiving IR (infra-red) codes using the PIO. -[logic_analyser](pio/logic_analyser) | Use PIO and DMA to capture a logic trace of some GPIOs, whilst a PWM unit is driving them. -[manchester_encoding](pio/manchester_encoding) | Send and receive Manchester-encoded serial. -[onewire](pio/onewire)| A library for interfacing to 1-Wire devices, with an example for the DS18B20 temperature sensor. +[pio_apa102](pio/apa102) | Rainbow pattern on on a string of APA102 addressable RGB LEDs. +[pio_clocked_input](pio/clocked_input) | Shift in serial data, sampling with an external clock. +[pio_differential_manchester](pio/differential_manchester) | Send and receive differential Manchester-encoded serial (BMC). +[pio_hub75](pio/hub75) | Display an image on a 128x64 HUB75 RGB LED matrix. +[pio_i2c_bus_scan](pio/i2c) | Scan an I2C bus. +[pio_ir_loopback](pio/ir_nec) | Sending and receiving IR (infra-red) codes using the PIO. +[pio_logic_analyser](pio/logic_analyser) | Use PIO and DMA to capture a logic trace of some GPIOs, whilst a PWM unit is driving them. +[pio_manchester_encoding](pio/manchester_encoding) | Send and receive Manchester-encoded serial. +[pio_onewire](pio/onewire)| A library for interfacing to 1-Wire devices, with an example for the DS18B20 temperature sensor. [pio_blink](pio/pio_blink) | Set up some PIO state machines to blink LEDs at different frequencies, according to delay counts pushed into their FIFOs. -[pwm](pio/pwm) | Pulse width modulation on PIO. Use it to gradually fade the brightness of an LED. -[spi](pio/spi) | Use PIO to erase, program and read an external SPI flash chip. A second example runs a loopback test with all four CPHA/CPOL combinations. -[squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions. -[squarewave_div_sync](pio/squarewave) | Generates a square wave on three GPIOs and synchronises the divider on all the state machines -[st7789_lcd](pio/st7789_lcd) | Set up PIO for 62.5 Mbps serial output, and use this to display a spinning image on a ST7789 serial LCD. +[pio_pwm](pio/pwm) | Pulse width modulation on PIO. Use it to gradually fade the brightness of an LED. [quadrature_encoder](pio/quadrature_encoder) | A quadrature encoder using PIO to maintain counts independent of the CPU. [quadrature_encoder_substep](pio/quadrature_encoder_substep) | High resolution speed measurement using a standard quadrature encoder -[uart_rx](pio/uart_rx) | Implement the receive component of a UART serial port. Attach it to the spare Arm UART to see it receive characters. -[uart_tx](pio/uart_tx) | Implement the transmit component of a UART serial port, and print hello world. -[ws2812](pio/ws2812) | Examples of driving WS2812 addressable RGB LEDs. -[addition](pio/addition) | Add two integers together using PIO. Only around 8 billion times slower than Cortex-M0+. +[pio_spi_flash](pio/spi) | Use PIO to erase, program and read an external SPI flash chip +[pio_spi_loopback](pio/spi) | Use PIO to run a loopback test with all four CPHA/CPOL combinations. +[pio_squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions. +[pio_squarewave_div_sync](pio/squarewave) | Generates a square wave on three GPIOs and synchronises the divider on all the state machines +[pio_st7789_lcd](pio/st7789_lcd) | Set up PIO for 62.5 Mbps serial output, and use this to display a spinning image on a ST7789 serial LCD. [uart_pio_dma](pio/uart_pio_dma) | Send and receive data from a UART implemented using the PIO and DMA +[pio_uart_rx](pio/uart_rx) | Implement the receive component of a UART serial port. Attach it to the spare Arm UART to see it receive characters. +[pio_uart_rx_intr](pio/uart_rx) | Implement the receive component of a UART serial port with an interrupt for received characters. Attach it to the spare Arm UART to see it receive characters. +[pio_uart_tx](pio/uart_tx) | Implement the transmit component of a UART serial port, and print hello world. +[pio_ws2812](pio/ws2812) | Example of driving a string WS2812 addressable RGB LEDs. +[pio_ws2812_parallel](pio/ws2812) | Examples of driving multiple strings of WS2812 addressable RGB LEDs efficiently. +[pio_addition](pio/addition) | Add two integers together using PIO. Only around 8 billion times slower than Cortex-M0+. ### PWM diff --git a/pio/CMakeLists.txt b/pio/CMakeLists.txt index 7b33a38a1..023bd4ea8 100644 --- a/pio/CMakeLists.txt +++ b/pio/CMakeLists.txt @@ -17,10 +17,10 @@ if (TARGET hardware_pio) add_subdirectory_exclude_platforms(spi) add_subdirectory_exclude_platforms(squarewave) add_subdirectory_exclude_platforms(st7789_lcd) + add_subdirectory_exclude_platforms(uart_dma) add_subdirectory_exclude_platforms(uart_rx) add_subdirectory_exclude_platforms(uart_tx) add_subdirectory_exclude_platforms(ws2812) - add_subdirectory_exclude_platforms(uart_pio_dma) else() message("Skipping PIO examples as hardware_pio is unavailable on this platform") endif() diff --git a/pio/ir_nec/nec_receive_library/CMakeLists.txt b/pio/ir_nec/nec_receive_library/CMakeLists.txt index 72d296d59..a3c30b42e 100644 --- a/pio/ir_nec/nec_receive_library/CMakeLists.txt +++ b/pio/ir_nec/nec_receive_library/CMakeLists.txt @@ -1,19 +1,20 @@ -# build a normal library -# -add_library(nec_receive_library nec_receive.c) +add_library(nec_receive_library INTERFACE) + +target_sources(nec_receive_library INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/nec_receive.c) # invoke pio_asm to assemble the state machine program # pico_generate_pio_header(nec_receive_library ${CMAKE_CURRENT_LIST_DIR}/nec_receive.pio) -target_link_libraries(nec_receive_library PRIVATE +target_link_libraries(nec_receive_library INTERFACE pico_stdlib hardware_pio ) # add the `binary` directory so that the generated headers are included in the project # -target_include_directories (nec_receive_library PUBLIC +target_include_directories (nec_receive_library INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/pio/ir_nec/nec_transmit_library/CMakeLists.txt b/pio/ir_nec/nec_transmit_library/CMakeLists.txt index dfb96bf28..9ae2bed27 100644 --- a/pio/ir_nec/nec_transmit_library/CMakeLists.txt +++ b/pio/ir_nec/nec_transmit_library/CMakeLists.txt @@ -1,20 +1,21 @@ -# build a normal library -# -add_library(nec_transmit_library nec_transmit.c) +add_library(nec_transmit_library INTERFACE) + +target_sources(nec_transmit_library INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/nec_transmit.c) # invoke pio_asm to assemble the PIO state machine programs # pico_generate_pio_header(nec_transmit_library ${CMAKE_CURRENT_LIST_DIR}/nec_carrier_burst.pio) pico_generate_pio_header(nec_transmit_library ${CMAKE_CURRENT_LIST_DIR}/nec_carrier_control.pio) -target_link_libraries(nec_transmit_library PRIVATE +target_link_libraries(nec_transmit_library INTERFACE pico_stdlib hardware_pio ) # add the `binary` directory so that the generated headers are included in the project # -target_include_directories (nec_transmit_library PUBLIC +target_include_directories (nec_transmit_library INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/pio/uart_dma/CMakeLists.txt b/pio/uart_dma/CMakeLists.txt new file mode 100644 index 000000000..d87a50928 --- /dev/null +++ b/pio/uart_dma/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(pio_uart_dma) +pico_generate_pio_header(pio_uart_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_rx/uart_rx.pio) +pico_generate_pio_header(pio_uart_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_tx/uart_tx.pio) +target_sources(pio_uart_dma PRIVATE uart_dma.c) +target_link_libraries(pio_uart_dma PRIVATE + pico_stdlib + hardware_pio + hardware_dma + ) +pico_add_extra_outputs(pio_uart_dma) +example_auto_set_url(pio_uart_dma) diff --git a/pio/uart_pio_dma/uart_pio_dma.c b/pio/uart_dma/uart_dma.c similarity index 100% rename from pio/uart_pio_dma/uart_pio_dma.c rename to pio/uart_dma/uart_dma.c diff --git a/pio/uart_pio_dma/CMakeLists.txt b/pio/uart_pio_dma/CMakeLists.txt deleted file mode 100644 index 108477610..000000000 --- a/pio/uart_pio_dma/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_executable(uart_pio_dma) -pico_generate_pio_header(uart_pio_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_rx/uart_rx.pio) -pico_generate_pio_header(uart_pio_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_tx/uart_tx.pio) -target_sources(uart_pio_dma PRIVATE uart_pio_dma.c) -target_link_libraries(uart_pio_dma PRIVATE - pico_stdlib - hardware_pio - hardware_dma - ) -pico_add_extra_outputs(uart_pio_dma) -example_auto_set_url(uart_pio_dma) From c0a3c53971dc909a1735eb6734e6e2d2093a5dc7 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Fri, 25 Jul 2025 09:23:25 -0500 Subject: [PATCH 2/4] quad->pio_quad --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2e92e8dc..cfbc0d23d 100644 --- a/README.md +++ b/README.md @@ -315,8 +315,8 @@ App|Description [pio_onewire](pio/onewire)| A library for interfacing to 1-Wire devices, with an example for the DS18B20 temperature sensor. [pio_blink](pio/pio_blink) | Set up some PIO state machines to blink LEDs at different frequencies, according to delay counts pushed into their FIFOs. [pio_pwm](pio/pwm) | Pulse width modulation on PIO. Use it to gradually fade the brightness of an LED. -[quadrature_encoder](pio/quadrature_encoder) | A quadrature encoder using PIO to maintain counts independent of the CPU. -[quadrature_encoder_substep](pio/quadrature_encoder_substep) | High resolution speed measurement using a standard quadrature encoder +[pio_quadrature_encoder](pio/quadrature_encoder) | A quadrature encoder using PIO to maintain counts independent of the CPU. +[pio_quadrature_encoder_substep](pio/quadrature_encoder_substep) | High resolution speed measurement using a standard quadrature encoder [pio_spi_flash](pio/spi) | Use PIO to erase, program and read an external SPI flash chip [pio_spi_loopback](pio/spi) | Use PIO to run a loopback test with all four CPHA/CPOL combinations. [pio_squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions. From 846df2a5ab081c9d67541cb9cb90ecddd573709a Mon Sep 17 00:00:00 2001 From: Graham Sanderson Date: Fri, 25 Jul 2025 09:34:11 -0500 Subject: [PATCH 3/4] Update README.md Co-authored-by: will-v-pi <108662275+will-v-pi@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfbc0d23d..c764e756d 100644 --- a/README.md +++ b/README.md @@ -322,7 +322,7 @@ App|Description [pio_squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions. [pio_squarewave_div_sync](pio/squarewave) | Generates a square wave on three GPIOs and synchronises the divider on all the state machines [pio_st7789_lcd](pio/st7789_lcd) | Set up PIO for 62.5 Mbps serial output, and use this to display a spinning image on a ST7789 serial LCD. -[uart_pio_dma](pio/uart_pio_dma) | Send and receive data from a UART implemented using the PIO and DMA +[pio_uart_dma](pio/uart_dma) | Send and receive data from a UART implemented using the PIO and DMA [pio_uart_rx](pio/uart_rx) | Implement the receive component of a UART serial port. Attach it to the spare Arm UART to see it receive characters. [pio_uart_rx_intr](pio/uart_rx) | Implement the receive component of a UART serial port with an interrupt for received characters. Attach it to the spare Arm UART to see it receive characters. [pio_uart_tx](pio/uart_tx) | Implement the transmit component of a UART serial port, and print hello world. From 74219bebbac89af6d92226848aadb6719ba66f0f Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Fri, 25 Jul 2025 09:42:34 -0500 Subject: [PATCH 4/4] remove space --- pio/ir_nec/ir_loopback/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pio/ir_nec/ir_loopback/CMakeLists.txt b/pio/ir_nec/ir_loopback/CMakeLists.txt index 8c7d8f4b7..66d251061 100644 --- a/pio/ir_nec/ir_loopback/CMakeLists.txt +++ b/pio/ir_nec/ir_loopback/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable (pio_ir_loopback ir_loopback.c) +add_executable(pio_ir_loopback ir_loopback.c) # link the executable using the IR transmit and receive libraries #