From d84f4ba08fe8e2fab4d60a631bb38cfe4c083159 Mon Sep 17 00:00:00 2001 From: Adrian Marquis Date: Sat, 26 Aug 2023 15:13:36 +0200 Subject: [PATCH] Working struct attribute type! --- src/webee.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/webee.rs b/src/webee.rs index 2698395..8fe68a8 100644 --- a/src/webee.rs +++ b/src/webee.rs @@ -1,9 +1,12 @@ use arduino_hal::clock::Clock; use arduino_hal::hal::Atmega; +use arduino_hal::port; +use arduino_hal::port::mode::{Input, Output}; // use arduino_hal::port; // use arduino_hal::port::mode::{Input, Output}; use arduino_hal::usart::{Usart, UsartOps}; use arduino_hal::prelude::*; +use avr_device::atmega2560::{USART1, USART2, USART3}; use embedded_hal::serial::{Read}; @@ -11,20 +14,28 @@ mod vector; pub use vector::Vector; -pub struct Webee, RX, TX> //where -// USART: UsartOps, port::Pin> + +pub struct Webee, RX, TX> { webee: Usart, } enum SEND_CMD {} -impl, RX, TX> Webee // where - // USART: UsartOps, port::Pin> +impl + Webee< + USART, + port::Pin, + port::Pin + > +where + USART: UsartOps, port::Pin>, + RX: port::PinOps, + TX: port::PinOps { const STOP: u8 = 0xFF; - pub fn new(device: USART, rx: RX, tx: TX) -> Self { + pub fn new(device: USART, rx: port::Pin, tx: port::Pin) -> Self { Self { webee: Usart::new(device, rx, tx, 38400.into_baudrate()) }