From caa1ff9f24629add1f37ab40a1aa72027ae1ab4d Mon Sep 17 00:00:00 2001 From: doryan Date: Wed, 30 Apr 2025 18:07:36 +0400 Subject: [PATCH] feat: move sync and handshake methods to struct implementation --- src/lib.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1289fba..28d3314 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,11 +69,7 @@ where } -impl

SoftSerial

for HalfDuplexSerial

-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 where @@ -228,4 +230,3 @@ where } } } -