From 82dcc6ffe0e37b6226c262897b834c77980b2a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Wed, 21 Jun 2023 12:11:20 +0200 Subject: [PATCH] feat: add serial to main --- src/main.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main.rs b/src/main.rs index 486b14a83cd6f08b7507b129a730ac91f468c7c0..aa6cc2f473dc8997243f21db035a4dc21b62b311 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,11 @@ mod strip; use embedded_hal::serial::{Read, Write}; use esp_backtrace as _; +use esp_println::println; use hal::{clock::ClockControl, pulse_control::{ClockSource}, peripherals::Peripherals, prelude::*, timer::{TimerGroup, Timer, Timer0}, Rtc, IO, Delay, interrupt, PulseControl, Uart}; use hal::uart::config::{Config, DataBits, Parity, StopBits}; +use hal::uart::TxRxPins; +use nb::block; use nb::Error::{WouldBlock, Other}; use smart_leds::{RGB8, SmartLedsWrite}; use crate::strip::StripTiming; @@ -38,6 +41,25 @@ fn main() -> ! { wdt1.disable(); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let pins = TxRxPins::new_tx_rx( + io.pins.gpio1.into_push_pull_output(), + io.pins.gpio3.into_floating_input(), + ); + + let config = Config { + baudrate: 115200, + data_bits: DataBits::DataBits8, + parity: Parity::ParityNone, + stop_bits: StopBits::STOP1, + }; + + let mut serial = Uart::new_with_config( + peripherals.UART0, + Some(config), + Some(pins), + &clocks, + &mut system.peripheral_clock_control, + ); let mut delay = Delay::new(&clocks);