Vector type hell
This commit is contained in:
30
src/webee.rs
30
src/webee.rs
@@ -1,12 +1,10 @@
|
||||
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::port::{Pin, PinOps};
|
||||
use arduino_hal::port::mode::{Input, Output, PullUp};
|
||||
use arduino_hal::usart::{Usart, UsartOps};
|
||||
use arduino_hal::prelude::*;
|
||||
use avr_device::atmega2560::{USART1, USART2, USART3};
|
||||
use avr_device::atmega2560::usart0::ucsr0c::USBS0_A::STOP1;
|
||||
|
||||
use embedded_hal::serial::{Read};
|
||||
|
||||
@@ -20,22 +18,22 @@ pub struct Webee<USART: UsartOps<Atmega, RX, TX>, RX, TX>
|
||||
webee: Usart<USART, RX, TX>,
|
||||
}
|
||||
|
||||
enum SEND_CMD {}
|
||||
enum SendCmd {}
|
||||
|
||||
const STOP: u8 = 0xFF;
|
||||
|
||||
impl<USART, RX, TX>
|
||||
Webee<
|
||||
USART,
|
||||
port::Pin<Input, RX>,
|
||||
port::Pin<Output, TX>
|
||||
Pin<Input, RX>,
|
||||
Pin<Output, TX>
|
||||
>
|
||||
where
|
||||
USART: UsartOps<Atmega, port::Pin<Input, RX>, port::Pin<Output, TX>>,
|
||||
RX: port::PinOps,
|
||||
TX: port::PinOps
|
||||
USART: UsartOps<Atmega, Pin<Input, RX>, Pin<Output, TX>>,
|
||||
RX: PinOps,
|
||||
TX: PinOps
|
||||
{
|
||||
const STOP: u8 = 0xFF;
|
||||
|
||||
pub fn new(device: USART, rx: port::Pin<Input, RX>, tx: port::Pin<Output, TX>) -> Self {
|
||||
pub fn new(device: USART, rx: Pin<Input, RX>, tx: Pin<Output, TX>) -> Self {
|
||||
Self {
|
||||
webee: Usart::new(device, rx, tx, 38400.into_baudrate())
|
||||
}
|
||||
@@ -50,10 +48,10 @@ where
|
||||
}
|
||||
|
||||
fn recv(&mut self) -> Vector<u8> {
|
||||
const buffer: Vector<u8> = Vector::new(0, &[]);
|
||||
let mut buffer: Vector<u8> = Vector::new(0, &mut []);
|
||||
let byte: u8 = self.webee.read_byte();
|
||||
|
||||
while byte != self.STOP {
|
||||
while byte != STOP {
|
||||
buffer.push(byte);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user