diff options
Diffstat (limited to 'examples/rp235x/src/bin/uart.rs')
| -rw-r--r-- | examples/rp235x/src/bin/uart.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/rp235x/src/bin/uart.rs b/examples/rp235x/src/bin/uart.rs new file mode 100644 index 000000000..a59f537bf --- /dev/null +++ b/examples/rp235x/src/bin/uart.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | //! This example shows how to use UART (Universal asynchronous receiver-transmitter) in the RP2040 chip. | ||
| 2 | //! | ||
| 3 | //! No specific hardware is specified in this example. Only output on pin 0 is tested. | ||
| 4 | //! The Raspberry Pi Debug Probe (https://www.raspberrypi.com/products/debug-probe/) could be used | ||
| 5 | //! with its UART port. | ||
| 6 | |||
| 7 | #![no_std] | ||
| 8 | #![no_main] | ||
| 9 | |||
| 10 | use embassy_executor::Spawner; | ||
| 11 | use embassy_rp::uart; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | |||
| 14 | #[embassy_executor::main] | ||
| 15 | async fn main(_spawner: Spawner) { | ||
| 16 | let p = embassy_rp::init(Default::default()); | ||
| 17 | let config = uart::Config::default(); | ||
| 18 | let mut uart = uart::Uart::new_blocking(p.UART1, p.PIN_4, p.PIN_5, config); | ||
| 19 | uart.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); | ||
| 20 | |||
| 21 | loop { | ||
| 22 | uart.blocking_write("hello there!\r\n".as_bytes()).unwrap(); | ||
| 23 | cortex_m::asm::delay(1_000_000); | ||
| 24 | } | ||
| 25 | } | ||
