feat: move sync and handshake methods to struct implementation
This commit is contained in:
parent
6defd8963f
commit
caa1ff9f24
21
src/lib.rs
21
src/lib.rs
|
@ -69,11 +69,7 @@ where
|
|||
|
||||
}
|
||||
|
||||
impl<P> SoftSerial<P> for HalfDuplexSerial<P>
|
||||
where
|
||||
P: PinOps + StaticPinOps,
|
||||
{
|
||||
fn poll(&self) -> PollResult {
|
||||
pub fn poll(&self) -> PollResult {
|
||||
P::into_output();
|
||||
delay_cycles(1);
|
||||
P::into_pull_up_input();
|
||||
|
@ -95,7 +91,7 @@ where
|
|||
PollResult::Ok(())
|
||||
}
|
||||
|
||||
fn response(&self) {
|
||||
pub fn response(&self) {
|
||||
P::into_output_high();
|
||||
|
||||
delay_us(FIRST_HALF_SERIAL_DELAY);
|
||||
|
@ -108,21 +104,27 @@ where
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn sync_transmitter(&self) {
|
||||
pub fn sync_transmitter(&self) {
|
||||
P::into_output();
|
||||
|
||||
delay_us(SERIAL_DELAY);
|
||||
delay_us(SERIAL_DELAY / 2);
|
||||
|
||||
P::set_high();
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn sync_reciever(&self) {
|
||||
pub fn sync_reciever(&self) {
|
||||
while P::is_high() {}
|
||||
|
||||
while P::is_low() {}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn reset(&self) {
|
||||
P::into_pull_up_input();
|
||||
while P::is_low() {}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SoftSerialWriter<P, T>
|
||||
where
|
||||
|
@ -228,4 +230,3 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue