File syn_soft_onewire.c¶
FileList > drivers > syn_soft_onewire.c
Go to the source code of this file
Software bit-bang 1-Wire master implementation. More...
#include "../util/syn_assert.h"#include "syn_soft_onewire.h"
Public Functions¶
| Type | Name |
|---|---|
| void | syn_soft_onewire_init (SYN_SoftOneWire * ow, SYN_GPIO_Pin pin, uint32_t delay_loops) Initialize a 1-Wire bus instance. |
| uint8_t | syn_soft_onewire_read_byte (const SYN_SoftOneWire * ow) Read one byte LSB-first from the 1-Wire bus. |
| void | syn_soft_onewire_read_rom (const SYN_SoftOneWire * ow, uint8_t rom) Read an 8-byte ROM code from the bus (after READ ROM command). |
| bool | syn_soft_onewire_reset (const SYN_SoftOneWire * ow) Issue a 1-Wire reset pulse and detect device presence. |
| void | syn_soft_onewire_write_byte (const SYN_SoftOneWire * ow, uint8_t byte) Write one byte LSB-first onto the 1-Wire bus. |
| void | syn_soft_onewire_write_rom (const SYN_SoftOneWire * ow, const uint8_t rom) Write an 8-byte ROM code to the bus (for MATCH ROM command). |
Public Static Functions¶
| Type | Name |
|---|---|
| void | ow_delay (const SYN_SoftOneWire * ow, uint32_t us) NOP-loop delay. |
| void | ow_drive_low (const SYN_SoftOneWire * ow) Drive the 1-Wire pin low (open-drain). |
| uint8_t | ow_read_bit (const SYN_SoftOneWire * ow) Read a single bit from the 1-Wire bus. |
| void | ow_release (const SYN_SoftOneWire * ow) Release the 1-Wire pin (pullup takes over). |
| void | ow_write_bit (const SYN_SoftOneWire * ow, uint8_t bit) Write a single bit to the 1-Wire bus. |
Detailed Description¶
Timing slots (standard speed): Write-0 slot : drive LOW 60 µs, release 10 µs recovery Write-1 slot : drive LOW 6 µs, release 64 µs recovery Read slot : drive LOW 6 µs, release, sample at ~9 µs, release 55 µs Reset pulse : drive LOW 480 µs, release, detect presence 60–240 µs, total reset cycle ~960 µs
All timing is approximated via a volatile NOP loop (delay_loops per µs). All I/O uses syn_port_gpio: output = drive low, input = release/read.
Public Functions Documentation¶
function syn_soft_onewire_init¶
Initialize a 1-Wire bus instance.
Parameters:
owBus handle to initialize. Must not be NULL.pinGPIO pin for the data line.delay_loopsNOP loop iterations per µs at your CPU frequency. Use SYN_SOFT_ONEWIRE_LOOPS_PER_US(F_CPU) or SYN_SOFT_ONEWIRE_LOOPS_PER_US(16000000UL) for 16 MHz.
function syn_soft_onewire_read_byte¶
Read one byte LSB-first from the 1-Wire bus.
Parameters:
owInitialized bus handle.
Returns:
Byte received.
function syn_soft_onewire_read_rom¶
Read an 8-byte ROM code from the bus (after READ ROM command).
Parameters:
owInitialized bus handle.romOutput buffer, must be at least 8 bytes.
function syn_soft_onewire_reset¶
Issue a 1-Wire reset pulse and detect device presence.
Parameters:
owInitialized bus handle.
Returns:
true if at least one device acknowledged (presence pulse detected), false if the bus is empty.
function syn_soft_onewire_write_byte¶
Write one byte LSB-first onto the 1-Wire bus.
Parameters:
owInitialized bus handle.byteByte to transmit.
function syn_soft_onewire_write_rom¶
Write an 8-byte ROM code to the bus (for MATCH ROM command).
Parameters:
owInitialized bus handle.rom8-byte ROM code, LSB first.
Public Static Functions Documentation¶
function ow_delay¶
NOP-loop delay.
Parameters:
ow1-Wire instance.usMicroseconds to delay.
function ow_drive_low¶
Drive the 1-Wire pin low (open-drain).
Parameters:
ow1-Wire instance.
function ow_read_bit¶
Read a single bit from the 1-Wire bus.
Parameters:
ow1-Wire instance.
Returns:
Bit value (0 or 1).
function ow_release¶
Release the 1-Wire pin (pullup takes over).
Parameters:
ow1-Wire instance.
function ow_write_bit¶
Write a single bit to the 1-Wire bus.
Parameters:
ow1-Wire instance.bitBit value (0 or 1).
The documentation for this class was generated from the following file src/syntropic/drivers/syn_soft_onewire.c