CuVoodoo STM32F1 firmware template
|
library for 1-wire protocol as master (code) More...
Go to the source code of this file.
Macros | |
#define | ONEWIRE_MASTER_TIMER 2 |
timer ID | |
Enumerations | |
enum | { ONEWIRE_STATE_IDLE, ONEWIRE_STATE_DONE, ONEWIRE_STATE_ERROR, ONEWIRE_STATE_MASTER_RESET, ONEWIRE_STATE_SLAVE_PRESENCE, ONEWIRE_STATE_MASTER_WRITE, ONEWIRE_STATE_MASTER_READ, ONEWIRE_MAX } |
state of 1-Wire communication More... | |
Functions | |
void | onewire_master_setup (void) |
setup 1-wire peripheral | |
void | onewire_master_release (void) |
release 1-wire peripheral | |
bool | onewire_master_reset (void) |
send reset pulse More... | |
static bool | onewire_master_write (void) |
write bits on 1-Wire bus More... | |
static bool | onewire_master_read (void) |
read bits on 1-Wire bus More... | |
uint8_t | onewire_master_crc (uint8_t *data, uint32_t length) |
compute CRC for 1-Wire More... | |
bool | onewire_master_read_byte (uint8_t *data) |
read data byte More... | |
bool | onewire_master_write_byte (uint8_t data) |
write data byte More... | |
bool | onewire_master_function_read (uint8_t function, uint8_t *data, uint32_t bits) |
issue function and read data More... | |
bool | onewire_master_function_write (uint8_t function, uint8_t *data, uint32_t bits) |
issue function and write data More... | |
uint64_t | onewire_master_rom_read (void) |
send READ ROM command and read ROM code response More... | |
bool | onewire_master_rom_search (uint64_t *code, bool alarm) |
send SEARCH ROM command More... | |
bool | onewire_master_rom_skip (void) |
send SKIP ROM command (all slaves on the bus will be selected) More... | |
bool | onewire_master_rom_match (uint64_t code) |
send MATCH ROM command to select a specific slave More... | |
void TIM_ISR() | ONEWIRE_MASTER_TIMER (void) |
interrupt service routine called for timer | |
Variables | |
enum { ... } | onewire_master_state = ONEWIRE_STATE_IDLE |
state of 1-Wire communication | |
static volatile bool | slave_presence = false |
if slaves have been detected | |
static uint8_t * | buffer = NULL |
input/output buffer for read/write commands/functions | |
static uint32_t | buffer_size = 0 |
size of buffer in bits | |
static volatile uint32_t | buffer_bit = 0 |
number of bits read/written | |
library for 1-wire protocol as master (code)
Definition in file onewire_master.c.
anonymous enum |
state of 1-Wire communication
Definition at line 47 of file onewire_master.c.
uint8_t onewire_master_crc | ( | uint8_t * | data, |
uint32_t | length | ||
) |
compute CRC for 1-Wire
[in] | data | bytes on which to calculate CRC checksum on |
[in] | length | number of bytes in data |
Definition at line 197 of file onewire_master.c.
bool onewire_master_function_read | ( | uint8_t | function, |
uint8_t * | data, | ||
uint32_t | bits | ||
) |
issue function and read data
[in] | function | function command to send |
[out] | data | buffer to save read bits (NULL if only the function command should be sent) |
[in] | bits | number of bits to read (0 if only the function command should be sent) |
Definition at line 243 of file onewire_master.c.
bool onewire_master_function_write | ( | uint8_t | function, |
uint8_t * | data, | ||
uint32_t | bits | ||
) |
issue function and write data
[in] | function | function command to send |
[out] | data | data to write (NULL if only the function command should be sent) |
[in] | bits | number of bits to write (0 if only the function command should be sent) |
Definition at line 264 of file onewire_master.c.
|
static |
read bits on 1-Wire bus
Definition at line 165 of file onewire_master.c.
bool onewire_master_read_byte | ( | uint8_t * | data | ) |
read data byte
[out] | data | buffer to save data read |
Definition at line 217 of file onewire_master.c.
bool onewire_master_reset | ( | void | ) |
send reset pulse
Definition at line 106 of file onewire_master.c.
bool onewire_master_rom_match | ( | uint64_t | code | ) |
send MATCH ROM command to select a specific slave
[in] | code | ROM code of slave to select |
Definition at line 381 of file onewire_master.c.
uint64_t onewire_master_rom_read | ( | void | ) |
send READ ROM command and read ROM code response
Definition at line 286 of file onewire_master.c.
bool onewire_master_rom_search | ( | uint64_t * | code, |
bool | alarm | ||
) |
send SEARCH ROM command
[in,out] | code | use 0 to start search ROM code from scratch, or last know value to search next; writes back next ROM code found, or 0 if error occurred |
[in] | alarm | search only for ROM codes for slaves with an alarm flag set |
Definition at line 305 of file onewire_master.c.
bool onewire_master_rom_skip | ( | void | ) |
send SKIP ROM command (all slaves on the bus will be selected)
Definition at line 373 of file onewire_master.c.
|
static |
write bits on 1-Wire bus
Definition at line 134 of file onewire_master.c.
bool onewire_master_write_byte | ( | uint8_t | data | ) |
write data byte
[in] | data | byte to write |
Definition at line 232 of file onewire_master.c.