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

Functions

uint8_t ds18b20_crc8 (const uint8_t *data, uint8_t len)
 Calculate Dallas/Maxim CRC-8 over a byte buffer.
void ds18b20_init (void)
 Initialize DS18B20 driver hardware and peripherals.
void ds18b20_poll (void)
 Advance the state machine (non-blocking).
void ds18b20_start_measure (void)
 Start one measurement cycle (non-blocking).
void ds18b20_select (const uint8_t *rom)
 Select which DS18B20 device to measure by its ROM address.
void ds18b20_busy (unsigned action)
 Busy indicator callback (weak).
void ds18b20_complete (int16_t temp)
 Measurement complete callback (weak).

Detailed Description

Function Documentation

◆ ds18b20_busy()

void ds18b20_busy ( unsigned action)

Busy indicator callback (weak).

Parameters
[in]action0 = idle, non-zero = busy

◆ ds18b20_complete()

void ds18b20_complete ( int16_t temp)

Measurement complete callback (weak).

Parameters
[in]tempTemperature in tenths of degrees Celsius, or error code

◆ ds18b20_crc8()

uint8_t ds18b20_crc8 ( const uint8_t * data,
uint8_t len )

Calculate Dallas/Maxim CRC-8 over a byte buffer.

Parameters
[in]dataInput buffer
[in]lenNumber of bytes to process
Returns
CRC-8 checksum value

◆ ds18b20_init()

void ds18b20_init ( void )

Initialize DS18B20 driver hardware and peripherals.

◆ ds18b20_poll()

void ds18b20_poll ( void )

Advance the state machine (non-blocking).

Note
Call periodically from main loop

This function implements the core non-blocking state machine that manages the 1-Wire communication protocol with the DS18B20 sensor. It uses hardware timer and DMA to handle timing-critical operations without software delays. At DS18B20_ST_IDLE it does nothing until ds18b20_start_measure() requests a cycle.

◆ ds18b20_select()

void ds18b20_select ( const uint8_t * rom)

Select which DS18B20 device to measure by its ROM address.

Parameters
[in]romPointer to the 8-byte ROM address (LSB first), or NULL to return to Skip ROM (broadcast) addressing
Note
With a non-NULL address, the state machine sends Match ROM (0x55) plus the device address before each command, so only that device responds. Pass NULL to keep the legacy single-sensor Skip ROM behaviour. To measure a specific device, pass its ROM address (e.g., from a bus search) to ds18b20_select().
The selection is applied only when no bus transaction is in flight (driver IDLE). Calls made mid-cycle are ignored, including from the per-device scan callback, which the driver invokes at DS18B20_ST_DECODE mid-round: a select() there is rejected and the scan round continues. To switch out of scan mode, call ds18b20_select() from ds18b20_complete() in single-device mode (the callback runs at IDLE) or while the driver is parked between measurement cycles.

◆ ds18b20_start_measure()

void ds18b20_start_measure ( void )

Start one measurement cycle (non-blocking).

Note
Schedules the first bus operation of a single conversion + scratchpad-read cycle on the currently selected device (every discovered device in scan mode); ds18b20_poll() then advances it and the result is reported through ds18b20_complete(). When the cycle finishes the driver parks at DS18B20_ST_IDLE and waits for the next request, so the measurement cadence is entirely the application's decision - the driver itself starts no cycle and retries nothing on its own.
Ignored (no-op) while a measurement cycle, a device search, a resolution change or a command transaction owns the bus.