|
stm32-async-1wire 3.2.0
Non-blocking 1-Wire master for STM32 with DS18B20 temperature and DS2431 EEPROM drivers
|
Universal non-blocking 1-Wire bus layer for STM32. More...
Go to the source code of this file.
Macros | |
| #define | ONEWIRE_ROM_BYTES 8 |
| Bytes in a device ROM address. | |
| #define | ONEWIRE_ROM_BITS (ONEWIRE_ROM_BYTES * 8) |
| Bits in a device ROM address. | |
| #define | ONEWIRE_BITS_PER_BYTE 8 |
| Bits per byte. | |
| #define | ONEWIRE_MAX_SLOTS 256u |
| Maximum bit slots per hardware operation (TIM1 RCR is 8-bit: RCR = slots - 1). | |
| #define | ONEWIRE_MAX_READ_BYTES (ONEWIRE_MAX_SLOTS / ONEWIRE_BITS_PER_BYTE) |
| Maximum bytes per onewire_read_data() pass (256 slots / 8 bits). | |
| #define | ONEWIRE_RELEASE_PULSE 0u |
| Value that releases the bus (idle HIGH) at the end of a multi-slot write or merged write+read operation. | |
| #define | ONEWIRE_SEARCH_ROM 0xF0 |
| 1-Wire ROM command: Search ROM (all devices respond with their ROM) | |
| #define | ONEWIRE_ALARM_SEARCH 0xEC |
| 1-Wire ROM command: Alarm Search (only alarming devices respond) | |
| #define | ONEWIRE_MATCH_ROM 0x55 |
| 1-Wire ROM command: Match ROM (address one device by its 8-byte ROM) | |
| #define | ONEWIRE_SKIP_ROM 0xCC |
| 1-Wire ROM command: Skip ROM (broadcast to every device on the bus) | |
Typedefs | |
| typedef uint8_t(* | onewire_search_sink_t) (const uint8_t *rom) |
| Per-device callback invoked by the search engine. | |
Functions | |
| void | onewire_init (void) |
| Initialize the shared 1-Wire timer/DMA/GPIO resources. | |
| uint32_t | onewire_config_token (void) |
| Configuration token the library was compiled with. | |
| uint8_t | onewire_clock_ok (uint32_t sysclk_mhz) |
| Whether the runtime core clock agrees with the build. | |
| uint8_t | onewire_bus_done (void) |
| Non-blocking completion check for the scheduled bus operation. | |
| void | onewire_reset (volatile uint16_t *reset_pulses) |
| Schedule a 1-Wire bus reset (presence pulse captured via DMA). | |
| uint8_t | onewire_reset_captured (void) |
| Edges captured by the last capture operation armed. | |
| uint8_t | onewire_present (const volatile uint16_t *pulses, uint8_t captured) |
| Decode the presence pulse captured by onewire_reset(). | |
| uint8_t | onewire_write_slots (const ow_pulse_t *pulses, uint16_t slots) |
| Schedule a write of slots bit slots. | |
| uint8_t | onewire_write_bit (uint8_t bit) |
| Schedule a single-slot write of one raw bit. | |
| void | onewire_read_pair (volatile uint16_t *pair_pulses) |
| Schedule a two-slot read of a Search ROM id/cmp bit pair. | |
| void | onewire_pair_bits (const volatile uint16_t *pair_pulses, uint8_t *id_bit, uint8_t *cmp_bit) |
| Decode the id/cmp bits of a two-slot read pair. | |
| void | onewire_write_then_read (uint8_t bit) |
| Schedule a merged single-slot write followed by a two-slot read pair. | |
| uint8_t | onewire_read_data (volatile uint8_t *dst, uint8_t bytes) |
| Schedule a read of bytes bytes from the bus. | |
| void | onewire_decode_pulses (uint8_t *dst, const volatile uint8_t *pulse, uint8_t nbytes) |
| Decode captured pulse durations into data bytes (LSB-first bits). | |
| void | onewire_encode_byte (ow_pulse_t *out, uint8_t byte) |
| Encode a byte into write-pulse durations. | |
| void | onewire_strong_pullup (uint8_t on) |
| Engage or release the parasite-power strong pull-up on the bus. | |
| void | onewire_search_start (onewire_search_sink_t sink, uint8_t max_devices, uint8_t command, uint8_t family) |
| Start a non-blocking search (Search ROM or Alarm Search). | |
| uint8_t | onewire_search_poll (void) |
| Advance the non-blocking search by one hardware operation. | |
| uint8_t | onewire_search_count (void) |
| Number of devices found (valid once the search finished). | |
| uint8_t | onewire_search_active (void) |
| Check whether a search is currently running. | |
| uint8_t | onewire_crc8 (const uint8_t *data, uint8_t len) |
| Calculate the Dallas/Maxim 1-Wire CRC-8 over a byte buffer. | |
| uint16_t | onewire_crc16 (const uint8_t *data, uint8_t len) |
| Calculate the Maxim 1-Wire CRC-16 over a byte buffer. | |
Universal non-blocking 1-Wire bus layer for STM32.
The driver (ds18b20.c) and any other 1-Wire slave driver (DS2413, DS2431, ...) are built on top of this layer. Every operation is scheduled on TIM1/DMA and completes asynchronously: callers poll onewire_bus_done() / onewire_search_poll() to advance, never wait. The layer owns TIM1, its DMA feed/capture pair and the bus GPIO pin from onewire_init() until reset (see there); access the bus only through this API.