diff options
| author | Caleb Jamison <[email protected]> | 2024-08-07 23:20:26 -0400 |
|---|---|---|
| committer | Caleb Jamison <[email protected]> | 2024-08-08 21:35:21 -0400 |
| commit | b185e02a42ad751ec6c31ffa6a1b87503f15489d (patch) | |
| tree | 0f0c66747267d24d95b5957b22db7e5c525cb00e /examples/rp23/src/bin/uart.rs | |
| parent | 891c5ee10584cd990dad529e3506fe1328e4e69d (diff) | |
Initial rp235x support
Examples have been run, but there is not yet a test suite.
Diffstat (limited to 'examples/rp23/src/bin/uart.rs')
| -rw-r--r-- | examples/rp23/src/bin/uart.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/rp23/src/bin/uart.rs b/examples/rp23/src/bin/uart.rs new file mode 100644 index 000000000..7b82fa350 --- /dev/null +++ b/examples/rp23/src/bin/uart.rs | |||
| @@ -0,0 +1,40 @@ | |||
| 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 | use embassy_rp::block::ImageDef; | ||
| 14 | |||
| 15 | #[link_section = ".start_block"] | ||
| 16 | #[used] | ||
| 17 | pub static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); | ||
| 18 | |||
| 19 | // Program metadata for `picotool info` | ||
| 20 | #[link_section = ".bi_entries"] | ||
| 21 | #[used] | ||
| 22 | pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [ | ||
| 23 | embassy_rp::binary_info_rp_cargo_bin_name!(), | ||
| 24 | embassy_rp::binary_info_rp_cargo_version!(), | ||
| 25 | embassy_rp::binary_info_rp_program_description!(c"Blinky"), | ||
| 26 | embassy_rp::binary_info_rp_program_build_attribute!(), | ||
| 27 | ]; | ||
| 28 | |||
| 29 | #[embassy_executor::main] | ||
| 30 | async fn main(_spawner: Spawner) { | ||
| 31 | let p = embassy_rp::init(Default::default()); | ||
| 32 | let config = uart::Config::default(); | ||
| 33 | let mut uart = uart::Uart::new_blocking(p.UART1, p.PIN_4, p.PIN_5, config); | ||
| 34 | uart.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); | ||
| 35 | |||
| 36 | loop { | ||
| 37 | uart.blocking_write("hello there!\r\n".as_bytes()).unwrap(); | ||
| 38 | cortex_m::asm::delay(1_000_000); | ||
| 39 | } | ||
| 40 | } | ||
