stm32-async-1wire 3.2.0
Non-blocking 1-Wire master for STM32 with DS18B20 temperature and DS2431 EEPROM drivers
Loading...
Searching...
No Matches
DS2413 Exported Functions

Functions

void ds2413_init (void)
 Initialize the DS2413 driver hardware.
void ds2413_select (const uint8_t *rom)
 Select the DS2413 to address.
uint8_t ds2413_read_pio (uint8_t *out)
 Read the PIO pin levels (non-blocking).
uint8_t ds2413_read_pio_poll (void)
 Advance the non-blocking PIO read.
uint8_t ds2413_write_pio (uint8_t states)
 Write the PIO output latches (non-blocking).
uint8_t ds2413_write_pio_poll (void)
 Advance the non-blocking PIO write.
uint8_t ds2413_last_command_ok (void)
 Result of the last completed operation.
uint8_t ds2413_last_pio (void)
 Last valid PIO pin levels read by ds2413_read_pio().
uint8_t ds2413_last_latches (void)
 Last valid PIO latch states read by ds2413_read_pio().
uint8_t ds2413_last_reply (void)
 Raw reply byte of the last read or write operation.

Detailed Description

Function Documentation

◆ ds2413_init()

void ds2413_init ( void )

Initialize the DS2413 driver hardware.

Precondition
Call after MCU reset, after the system clock is configured and before any 1-Wire bus operation.
Note
Calls onewire_init(), which takes exclusive ownership of the shared TIM1/DMA/GPIO resources. The DS18B20 and DS2431 drivers share that bus; all three inits may run before any operation, but only one driver may own the timer at a time.
Warning
A second call is a bootstrap operation, not a reinitialization hook.

◆ ds2413_last_command_ok()

uint8_t ds2413_last_command_ok ( void )

Result of the last completed operation.

Returns
1 when the last poll finished a read with a valid reply or a write with the 0xAA acknowledge, 0 when it aborted (no presence, no response, a malformed read byte or a rejected write) or nothing ran

◆ ds2413_last_latches()

uint8_t ds2413_last_latches ( void )

Last valid PIO latch states read by ds2413_read_pio().

Returns
Bits 0/1 with the PIOA/PIOB output latches; 0 before the first valid read. This is the commanded state, even when an external load holds a pin at the opposite level.

◆ ds2413_last_pio()

uint8_t ds2413_last_pio ( void )

Last valid PIO pin levels read by ds2413_read_pio().

Returns
Bits 0/1 with the actual PIOA/PIOB pin levels; 0 before the first valid read

◆ ds2413_last_reply()

uint8_t ds2413_last_reply ( void )

Raw reply byte of the last read or write operation.

Returns
The byte the device drove (0xFF when it did not answer); useful to tell a missing device from a malformed PIO reply. 0 before the first operation.

◆ ds2413_read_pio()

uint8_t ds2413_read_pio ( uint8_t * out)

Read the PIO pin levels (non-blocking).

Parameters
[out]outDestination byte; on success it receives the actual PIOA/PIOB pin levels in bits 0/1 (DS2413_PIOA, DS2413_PIOB), the same layout ds2413_write_pio() takes. A pin held externally does not match its latch; use ds2413_last_latches() for the commanded state.
Returns
1 if the read was scheduled, 0 if the request was rejected (NULL destination, an operation in flight, or a device search running)
Note
The result is valid only when ds2413_read_pio_poll() returns 1 and ds2413_last_command_ok() is 1. out must stay valid until then.

◆ ds2413_read_pio_poll()

uint8_t ds2413_read_pio_poll ( void )

Advance the non-blocking PIO read.

Returns
1 when finished (successfully or aborted), 0 while running

◆ ds2413_select()

void ds2413_select ( const uint8_t * rom)

Select the DS2413 to address.

Parameters
[in]romPointer to the 8-byte ROM address (LSB first), or NULL to use Skip ROM (broadcast)
Note
Accepted only while the driver is idle and no search is running. With a non-NULL ROM the driver sends Match ROM before every command. A broadcast read is only meaningful with one DS2413 on the bus.

◆ ds2413_write_pio()

uint8_t ds2413_write_pio ( uint8_t states)

Write the PIO output latches (non-blocking).

Parameters
[in]statesPIOA/PIOB latch levels in bits 0/1 (DS2413_PIOA, DS2413_PIOB); other bits are ignored
Returns
1 if the write was scheduled, 0 if the request was rejected (an operation in flight or a device search running)
Note
Both latches are written together. To change one channel, take the current latch byte from ds2413_last_latches(), modify it and pass it; the device has no read-modify-write command, and the pin read cannot recover a released latch that an external load overrides. A broadcast write addresses every DS2413 on the bus.

◆ ds2413_write_pio_poll()

uint8_t ds2413_write_pio_poll ( void )

Advance the non-blocking PIO write.

Returns
1 when finished (successfully or aborted), 0 while running