thomson

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 7f4dc611334adefd31a672304707695e4f382967
parent c2e813ce07affd49e117216ac0833e7f25fd1ccf
Author: Daniel Barlow <dan@telent.net>
Date:   Fri, 19 Jun 2026 01:04:26 +0100

create a OneWire and reset the bus

Diffstat:
Msrc/bin/main.rs | 30++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/bin/main.rs b/src/bin/main.rs @@ -11,11 +11,20 @@ use defmt::info; use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp_hal::{ + delay::Delay, clock::CpuClock, timer::timg::TimerGroup, - gpio::{Level, Output, OutputConfig} + gpio::{Level, Flex, + Output, OutputConfig, + Input, InputConfig, + DriveMode, + Pull + } + }; +use onewire::OneWire; + use esp_radio::ble::controller::BleConnector; use panic_rtt_target as _; @@ -58,12 +67,29 @@ async fn main(spawner: Spawner) -> ! { // TODO: Spawn some tasks let _ = spawner; + let in_config = InputConfig::default().with_pull(Pull::Up); + + let out_config = OutputConfig::default() + .with_drive_mode(DriveMode::OpenDrain) + .with_pull(Pull::None); // Use an external 4.7k pull-up resistor + + let mut flex = Flex::new(peripherals.GPIO3); + flex.apply_input_config(&in_config); + flex.apply_output_config(&out_config); + flex.set_input_enable(true); + flex.set_output_enable(true); + + let mut wire = OneWire::new(&mut flex, false); + let mut delay = Delay::new(); + + info!("{:?}", wire.reset(&mut delay)); + let mut led = Output::new(peripherals.GPIO8, Level::Low, OutputConfig::default()); led.set_high(); loop { info!("Hello world!"); - Timer::after(Duration::from_secs(1)).await; + delay.delay_millis(500); led.toggle(); }