Working struct attribute type!

This commit is contained in:
2023-08-26 15:13:36 +02:00
parent 359617ad67
commit d84f4ba08f

View File

@@ -1,9 +1,12 @@
use arduino_hal::clock::Clock; use arduino_hal::clock::Clock;
use arduino_hal::hal::Atmega; use arduino_hal::hal::Atmega;
use arduino_hal::port;
use arduino_hal::port::mode::{Input, Output};
// use arduino_hal::port; // use arduino_hal::port;
// use arduino_hal::port::mode::{Input, Output}; // use arduino_hal::port::mode::{Input, Output};
use arduino_hal::usart::{Usart, UsartOps}; use arduino_hal::usart::{Usart, UsartOps};
use arduino_hal::prelude::*; use arduino_hal::prelude::*;
use avr_device::atmega2560::{USART1, USART2, USART3};
use embedded_hal::serial::{Read}; use embedded_hal::serial::{Read};
@@ -11,20 +14,28 @@ mod vector;
pub use vector::Vector; pub use vector::Vector;
pub struct Webee<USART: UsartOps<Atmega, RX, TX>, RX, TX> //where
// USART: UsartOps<Atmega, port::Pin<Input, RX>, port::Pin<Output, TX>> pub struct Webee<USART: UsartOps<Atmega, RX, TX>, RX, TX>
{ {
webee: Usart<USART, RX, TX>, webee: Usart<USART, RX, TX>,
} }
enum SEND_CMD {} enum SEND_CMD {}
impl<USART: UsartOps<Atmega, RX, TX>, RX, TX> Webee<USART, RX, TX> // where impl<USART, RX, TX>
// USART: UsartOps<Atmega, port::Pin<Input, RX>, port::Pin<Output, TX>> Webee<
USART,
port::Pin<Input, RX>,
port::Pin<Output, TX>
>
where
USART: UsartOps<Atmega, port::Pin<Input, RX>, port::Pin<Output, TX>>,
RX: port::PinOps,
TX: port::PinOps
{ {
const STOP: u8 = 0xFF; const STOP: u8 = 0xFF;
pub fn new(device: USART, rx: RX, tx: TX) -> Self { pub fn new(device: USART, rx: port::Pin<Input, RX>, tx: port::Pin<Output, TX>) -> Self {
Self { Self {
webee: Usart::new(device, rx, tx, 38400.into_baudrate()) webee: Usart::new(device, rx, tx, 38400.into_baudrate())
} }