Firmware SDK
bc_onewire

Driver for 1-Wire. More...

Macros

#define BC_ONEWIRE_DEVICE_NUMBER_SKIP_ROM   0
 

Typedefs

typedef struct bc_onewire_t bc_onewire_t
 1-Wire instance
 

Functions

void bc_onewire_init_gpio (bc_onewire_t *self, bc_gpio_channel_t channel)
 
bool bc_onewire_init (bc_onewire_t *self, const bc_onewire_driver_t *driver, void *driver_ctx)
 Initialize 1-Wire. More...
 
bool bc_onewire_transaction_start (bc_onewire_t *self)
 Start transaction, enable pll and run timer. More...
 
bool bc_onewire_transaction_stop (bc_onewire_t *self)
 Stop transaction. More...
 
bool bc_onewire_is_transaction (bc_onewire_t *self)
 Is transaction run. More...
 
bool bc_onewire_reset (bc_onewire_t *self)
 Reset the 1-Wire bus and return the presence of any device. More...
 
void bc_onewire_select (bc_onewire_t *self, uint64_t *device_number)
 Select device. More...
 
void bc_onewire_skip_rom (bc_onewire_t *self)
 Skip ROM. More...
 
void bc_onewire_write (bc_onewire_t *self, const void *buffer, size_t length)
 Select device. More...
 
void bc_onewire_read (bc_onewire_t *self, void *buffer, size_t length)
 Select device. More...
 
void bc_onewire_write_byte (bc_onewire_t *self, uint8_t data)
 Select device. More...
 
uint8_t bc_onewire_read_byte (bc_onewire_t *self)
 Select device. More...
 
void bc_onewire_write_bit (bc_onewire_t *self, int bit)
 Select device. More...
 
int bc_onewire_read_bit (bc_onewire_t *self)
 Select device. More...
 
int bc_onewire_search_all (bc_onewire_t *self, uint64_t *device_list, size_t device_list_size)
 Search for all devices on 1-Wire. More...
 
int bc_onewire_search_family (bc_onewire_t *self, uint8_t family_code, uint64_t *device_list, size_t device_list_size)
 Search for all devices on 1-Wire with family code. More...
 
void bc_onewire_search_start (bc_onewire_t *self, uint8_t family_code)
 Start of manual search, see also bc_onewire_search_next. More...
 
bool bc_onewire_search_next (bc_onewire_t *self, uint64_t *device_number)
 Manual search of next device. More...
 
void bc_onewire_auto_ds28e17_sleep_mode (bc_onewire_t *self, bool on)
 Enable call sleep mode for all ds28e17 after transaction. More...
 
uint8_t bc_onewire_crc8 (const void *buffer, size_t length, uint8_t crc)
 Calculate 8-bit CRC. More...
 
uint16_t bc_onewire_crc16 (const void *buffer, size_t length, uint16_t crc)
 Calculate 16-bit CRC, polynomial 0x8005. More...
 
void bc_onewire_ds2484_init (bc_onewire_t *onewire, bc_ds2484_t *bc_ds2484)
 Initialize 1-Wire. More...
 
void bc_onewire_gpio_init (bc_onewire_t *onewire, bc_gpio_channel_t channel)
 Initialize 1-Wire. More...
 
const bc_onewire_driver_t * bc_onewire_gpio_det_driver (void)
 

Detailed Description

Driver for 1-Wire.

Driver for GPIO 1-Wire.

Function Documentation

◆ bc_onewire_auto_ds28e17_sleep_mode()

void bc_onewire_auto_ds28e17_sleep_mode ( bc_onewire_t self,
bool  on 
)

Enable call sleep mode for all ds28e17 after transaction.

Parameters
[in]on

Definition at line 160 of file bc_onewire.c.

Referenced by bc_ds28e17_init(), bc_soil_sensor_get_error(), and bc_soil_sensor_init_multiple().

Here is the caller graph for this function:

◆ bc_onewire_crc16()

uint16_t bc_onewire_crc16 ( const void *  buffer,
size_t  length,
uint16_t  crc 
)

Calculate 16-bit CRC, polynomial 0x8005.

Parameters
[in]buffer
[in]lengthNumber of bytes
[in]Thecrc starting value
Returns
Calculated CRC

Definition at line 192 of file bc_onewire.c.

Referenced by bc_ds28e17_memory_read(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_crc8()

uint8_t bc_onewire_crc8 ( const void *  buffer,
size_t  length,
uint8_t  crc 
)

Calculate 8-bit CRC.

Parameters
[in]buffer
[in]lengthNumber of bytes
[in]Thecrc starting value
Returns
Calculated CRC

Definition at line 165 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius().

Here is the caller graph for this function:

◆ bc_onewire_ds2484_init()

void bc_onewire_ds2484_init ( bc_onewire_t onewire,
bc_ds2484_t bc_ds2484 
)

Initialize 1-Wire.

Parameters
[in]onewireInstance 1-Wire

Definition at line 30 of file bc_onewire_ds2484.c.

Here is the call graph for this function:

◆ bc_onewire_gpio_init()

void bc_onewire_gpio_init ( bc_onewire_t onewire,
bc_gpio_channel_t  channel 
)

Initialize 1-Wire.

Parameters
[in]onewireInstance 1-Wire
[in]gpio_channelGPIO channel

Definition at line 30 of file bc_onewire_gpio.c.

Referenced by bc_module_sensor_get_onewire().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bc_onewire_init()

bool bc_onewire_init ( bc_onewire_t self,
const bc_onewire_driver_t *  driver,
void *  driver_ctx 
)

Initialize 1-Wire.

Parameters
[in]selfInstance
[in]driverDriver
[in]driver_ctxDriver context

Definition at line 12 of file bc_onewire.c.

Referenced by bc_onewire_ds2484_init(), and bc_onewire_gpio_init().

Here is the caller graph for this function:

◆ bc_onewire_is_transaction()

bool bc_onewire_is_transaction ( bc_onewire_t self)

Is transaction run.

Parameters
[in]selfInstance
Returns
true Transaction is run
false Transaction is stop

Definition at line 50 of file bc_onewire.c.

◆ bc_onewire_read()

void bc_onewire_read ( bc_onewire_t self,
void *  buffer,
size_t  length 
)

Select device.

Parameters
[in]selfInstance
[out]dataOutput which have been read
[in]lengthNumber of bytes to be read

Definition at line 106 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_ds28e17_memory_read().

Here is the caller graph for this function:

◆ bc_onewire_read_bit()

int bc_onewire_read_bit ( bc_onewire_t self)

Select device.

Parameters
[in]selfInstance
Returns
bit which have been read

Definition at line 138 of file bc_onewire.c.

Referenced by bc_ds28e17_memory_read().

Here is the caller graph for this function:

◆ bc_onewire_read_byte()

uint8_t bc_onewire_read_byte ( bc_onewire_t self)

Select device.

Parameters
[in]selfInstance
Returns
data which have been read

Definition at line 123 of file bc_onewire.c.

Referenced by bc_ds28e17_memory_read(), bc_onewire_relay_get_state(), and bc_onewire_relay_set_state().

Here is the caller graph for this function:

◆ bc_onewire_reset()

bool bc_onewire_reset ( bc_onewire_t self)

Reset the 1-Wire bus and return the presence of any device.

Parameters
[in]selfInstance
Returns
true Device present
false No device present

Definition at line 55 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), bc_ds28e17_memory_read(), bc_ds28e17_set_speed(), bc_onewire_relay_get_state(), bc_onewire_relay_set_state(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_search_all()

int bc_onewire_search_all ( bc_onewire_t self,
uint64_t *  device_list,
size_t  device_list_size 
)

Search for all devices on 1-Wire.

Parameters
[in]channelGPIO channel
[out]device_listPointer to destination array holding list of devices
[in]device_list_sizeSize of array holding list of devices
Returns
Number of found devices

Definition at line 146 of file bc_onewire.c.

◆ bc_onewire_search_family()

int bc_onewire_search_family ( bc_onewire_t self,
uint8_t  family_code,
uint64_t *  device_list,
size_t  device_list_size 
)

Search for all devices on 1-Wire with family code.

Parameters
[in]channelGPIO channel
[in]family_code
[out]device_listPointer to destination array holding list of devices
[in]device_list_sizeSize of array holding list of devices
Returns
Number of found devices

Definition at line 153 of file bc_onewire.c.

◆ bc_onewire_search_next()

bool bc_onewire_search_next ( bc_onewire_t self,
uint64_t *  device_number 
)

Manual search of next device.

Parameters
[in]device_numberGPIO channel
[in]device_number64b device number
Returns
true if new device was found, false if ther are no more devices on the bus

Definition at line 226 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_search_start()

void bc_onewire_search_start ( bc_onewire_t self,
uint8_t  family_code 
)

Start of manual search, see also bc_onewire_search_next.

Parameters
[in]channelGPIO channel
[in]family_codeFamily code of 1-Wire device or NULL

Definition at line 214 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_select()

void bc_onewire_select ( bc_onewire_t self,
uint64_t *  device_number 
)

Select device.

Parameters
[in]selfInstance
[in]device_numberDevice number (for 0 skip ROM)

Definition at line 68 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), bc_ds28e17_memory_read(), bc_ds28e17_set_speed(), bc_onewire_relay_get_state(), and bc_onewire_relay_set_state().

Here is the caller graph for this function:

◆ bc_onewire_skip_rom()

void bc_onewire_skip_rom ( bc_onewire_t self)

Skip ROM.

Parameters
[in]selfInstance

Definition at line 89 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius().

Here is the caller graph for this function:

◆ bc_onewire_transaction_start()

bool bc_onewire_transaction_start ( bc_onewire_t self)

Start transaction, enable pll and run timer.

Parameters
[in]selfInstance
Returns
true On success
false On failure

Definition at line 31 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), bc_ds28e17_memory_read(), bc_ds28e17_set_speed(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_transaction_stop()

bool bc_onewire_transaction_stop ( bc_onewire_t self)

Stop transaction.

Parameters
[in]selfInstance
Returns
true On success
false On failure

Definition at line 43 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), bc_ds28e17_memory_read(), bc_ds28e17_set_speed(), and bc_soil_sensor_get_error().

Here is the caller graph for this function:

◆ bc_onewire_write()

void bc_onewire_write ( bc_onewire_t self,
const void *  buffer,
size_t  length 
)

Select device.

Parameters
[in]selfInstance
[in]dataInput data to be written
[in]lengthNumber of bytes to be written

Definition at line 96 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), bc_ds28e17_memory_read(), bc_ds28e17_set_speed(), and bc_onewire_relay_set_state().

Here is the caller graph for this function:

◆ bc_onewire_write_bit()

void bc_onewire_write_bit ( bc_onewire_t self,
int  bit 
)

Select device.

Parameters
[in]selfInstance
[in]bitInput bit to be written

Definition at line 131 of file bc_onewire.c.

◆ bc_onewire_write_byte()

void bc_onewire_write_byte ( bc_onewire_t self,
uint8_t  data 
)

Select device.

Parameters
[in]selfInstance
[in]dataInput data to be written

Definition at line 116 of file bc_onewire.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_onewire_relay_get_state().

Here is the caller graph for this function: