diff --git a/src/main.rs b/src/main.rs index ba74d9c..26f6bc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,24 +1,30 @@ #![no_std] #![no_main] + +use arduino_hal::Peripherals; +use arduino_hal::prelude::*; +use panic_halt as _; + +use embedded_hal::serial::Read; + mod webee; use webee::Webee; use crate::webee::SendCmd::{Baudrate, Channel, MAC, PanId, Role, TransmitPower, ZigbeeNetworkKey}; -use arduino_hal::Peripherals; -use arduino_hal::prelude::*; -use panic_halt as _; - - #[arduino_hal::entry] fn main() -> ! { let dp = Peripherals::take().unwrap(); let pins = arduino_hal::pins!(dp); - let _status = pins.d13.into_output(); + let mut status = pins.d13.into_output(); let mut serial = arduino_hal::default_serial!(dp, pins, 57600); + unsafe { + avr_device::interrupt::enable(); + } + let mut webee = Webee::new( dp.USART1, pins.d19.forget_imode(), diff --git a/src/webee.rs b/src/webee.rs index 025f596..ff20d7a 100644 --- a/src/webee.rs +++ b/src/webee.rs @@ -56,8 +56,11 @@ Webee< TX: PinOps { pub fn new(device: USART, rx: Pin, tx: Pin) -> Self { + let mut interface = Usart::new(device, rx, tx, 38400.into_baudrate()); + // interface.listen(arduino_hal::hal::usart::Event::RxComplete); + let instance = Self { - webee: Usart::new(device, rx, tx, 38400.into_baudrate()) + webee: interface }; delay_ms(1000);