Firmware SDK
twr_onewire

Driver for 1-Wire. More...

Macros

#define TWR_ONEWIRE_DEVICE_NUMBER_SKIP_ROM   0
 

Typedefs

typedef struct twr_onewire_t twr_onewire_t
 1-Wire instance
 

Functions

void twr_onewire_init_gpio (twr_onewire_t *self, twr_gpio_channel_t channel)
 
bool twr_onewire_init (twr_onewire_t *self, const twr_onewire_driver_t *driver, void *driver_ctx)
 Initialize 1-Wire. More...
 
bool twr_onewire_transaction_start (twr_onewire_t *self)
 Start transaction, enable pll and run timer. More...
 
bool twr_onewire_transaction_stop (twr_onewire_t *self)
 Stop transaction. More...
 
bool twr_onewire_is_transaction (twr_onewire_t *self)
 Is transaction run. More...
 
bool twr_onewire_reset (twr_onewire_t *self)
 Reset the 1-Wire bus and return the presence of any device. More...
 
void twr_onewire_select (twr_onewire_t *self, uint64_t *device_number)
 Select device. More...
 
void twr_onewire_skip_rom (twr_onewire_t *self)
 Skip ROM. More...
 
void twr_onewire_write (twr_onewire_t *self, const void *buffer, size_t length)
 Select device. More...
 
void twr_onewire_read (twr_onewire_t *self, void *buffer, size_t length)
 Select device. More...
 
void twr_onewire_write_byte (twr_onewire_t *self, uint8_t data)
 Select device. More...
 
uint8_t twr_onewire_read_byte (twr_onewire_t *self)
 Select device. More...
 
void twr_onewire_write_bit (twr_onewire_t *self, int bit)
 Select device. More...
 
int twr_onewire_read_bit (twr_onewire_t *self)
 Select device. More...
 
int twr_onewire_search_all (twr_onewire_t *self, uint64_t *device_list, size_t device_list_size)
 Search for all devices on 1-Wire. More...
 
int twr_onewire_search_family (twr_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 twr_onewire_search_start (twr_onewire_t *self, uint8_t family_code)
 Start of manual search, see also twr_onewire_search_next. More...
 
bool twr_onewire_search_next (twr_onewire_t *self, uint64_t *device_number)
 Manual search of next device. More...
 
void twr_onewire_auto_ds28e17_sleep_mode (twr_onewire_t *self, bool on)
 Enable call sleep mode for all ds28e17 after transaction. More...
 
uint8_t twr_onewire_crc8 (const void *buffer, size_t length, uint8_t crc)
 Calculate 8-bit CRC. More...
 
uint16_t twr_onewire_crc16 (const void *buffer, size_t length, uint16_t crc)
 Calculate 16-bit CRC, polynomial 0x8005. More...
 
void twr_onewire_ds2484_init (twr_onewire_t *onewire, twr_ds2484_t *twr_ds2484)
 Initialize 1-Wire. More...
 
void twr_onewire_gpio_init (twr_onewire_t *onewire, twr_gpio_channel_t channel)
 Initialize 1-Wire. More...
 
const twr_onewire_driver_t * twr_onewire_gpio_det_driver (void)
 

Detailed Description

Driver for 1-Wire.

Driver for GPIO 1-Wire.

Function Documentation

◆ twr_onewire_auto_ds28e17_sleep_mode()

void twr_onewire_auto_ds28e17_sleep_mode ( twr_onewire_t self,
bool  on 
)

Enable call sleep mode for all ds28e17 after transaction.

Parameters
[in]on

Definition at line 160 of file twr_onewire.c.

Referenced by twr_ds28e17_init(), twr_soil_sensor_get_error(), and twr_soil_sensor_init_multiple().

Here is the caller graph for this function:

◆ twr_onewire_crc16()

uint16_t twr_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 twr_onewire.c.

Referenced by twr_ds28e17_memory_read(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_crc8()

uint8_t twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius().

Here is the caller graph for this function:

◆ twr_onewire_ds2484_init()

void twr_onewire_ds2484_init ( twr_onewire_t onewire,
twr_ds2484_t twr_ds2484 
)

Initialize 1-Wire.

Parameters
[in]onewireInstance 1-Wire

Definition at line 30 of file twr_onewire_ds2484.c.

Referenced by twr_module_x1_init().

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

◆ twr_onewire_gpio_init()

void twr_onewire_gpio_init ( twr_onewire_t onewire,
twr_gpio_channel_t  channel 
)

Initialize 1-Wire.

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

Definition at line 30 of file twr_onewire_gpio.c.

Referenced by twr_module_sensor_get_onewire().

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

◆ twr_onewire_init()

bool twr_onewire_init ( twr_onewire_t self,
const twr_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 twr_onewire.c.

Referenced by twr_onewire_ds2484_init(), and twr_onewire_gpio_init().

Here is the caller graph for this function:

◆ twr_onewire_is_transaction()

bool twr_onewire_is_transaction ( twr_onewire_t self)

Is transaction run.

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

Definition at line 50 of file twr_onewire.c.

◆ twr_onewire_read()

void twr_onewire_read ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), and twr_ds28e17_memory_read().

Here is the caller graph for this function:

◆ twr_onewire_read_bit()

int twr_onewire_read_bit ( twr_onewire_t self)

Select device.

Parameters
[in]selfInstance
Returns
bit which have been read

Definition at line 138 of file twr_onewire.c.

Referenced by twr_ds28e17_memory_read().

Here is the caller graph for this function:

◆ twr_onewire_read_byte()

uint8_t twr_onewire_read_byte ( twr_onewire_t self)

Select device.

Parameters
[in]selfInstance
Returns
data which have been read

Definition at line 123 of file twr_onewire.c.

Referenced by twr_ds28e17_memory_read(), twr_onewire_relay_get_state(), and twr_onewire_relay_set_state().

Here is the caller graph for this function:

◆ twr_onewire_reset()

bool twr_onewire_reset ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), twr_ds28e17_memory_read(), twr_ds28e17_set_speed(), twr_onewire_relay_get_state(), twr_onewire_relay_set_state(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_search_all()

int twr_onewire_search_all ( twr_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 twr_onewire.c.

◆ twr_onewire_search_family()

int twr_onewire_search_family ( twr_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 twr_onewire.c.

◆ twr_onewire_search_next()

bool twr_onewire_search_next ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_search_start()

void twr_onewire_search_start ( twr_onewire_t self,
uint8_t  family_code 
)

Start of manual search, see also twr_onewire_search_next.

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

Definition at line 214 of file twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_select()

void twr_onewire_select ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), twr_ds28e17_memory_read(), twr_ds28e17_set_speed(), twr_onewire_relay_get_state(), and twr_onewire_relay_set_state().

Here is the caller graph for this function:

◆ twr_onewire_skip_rom()

void twr_onewire_skip_rom ( twr_onewire_t self)

Skip ROM.

Parameters
[in]selfInstance

Definition at line 89 of file twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius().

Here is the caller graph for this function:

◆ twr_onewire_transaction_start()

bool twr_onewire_transaction_start ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), twr_ds28e17_memory_read(), twr_ds28e17_set_speed(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_transaction_stop()

bool twr_onewire_transaction_stop ( twr_onewire_t self)

Stop transaction.

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

Definition at line 43 of file twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), twr_ds28e17_memory_read(), twr_ds28e17_set_speed(), and twr_soil_sensor_get_error().

Here is the caller graph for this function:

◆ twr_onewire_write()

void twr_onewire_write ( twr_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 twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), twr_ds28e17_memory_read(), twr_ds28e17_set_speed(), and twr_onewire_relay_set_state().

Here is the caller graph for this function:

◆ twr_onewire_write_bit()

void twr_onewire_write_bit ( twr_onewire_t self,
int  bit 
)

Select device.

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

Definition at line 131 of file twr_onewire.c.

◆ twr_onewire_write_byte()

void twr_onewire_write_byte ( twr_onewire_t self,
uint8_t  data 
)

Select device.

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

Definition at line 116 of file twr_onewire.c.

Referenced by twr_ds18b20_get_temperature_celsius(), and twr_onewire_relay_get_state().

Here is the caller graph for this function: