Firmware SDK
twr_ds18b20

Driver for 1wire ds18b20. More...

Typedefs

typedef struct twr_ds18b20_t twr_ds18b20_t
 BigClown ds18b20 instance.
 
typedef struct twr_ds18b20_sensor_t twr_ds18b20_sensor_t
 

Enumerations

enum  twr_ds18b20_event_t {
  TWR_DS18B20_EVENT_ERROR = -1 ,
  TWR_DS18B20_EVENT_UPDATE = 0
}
 Callback events. More...
 

Functions

void twr_ds18b20_init_single (twr_ds18b20_t *self, twr_ds18b20_resolution_bits_t resolution)
 Initialize single ds18b20 over channel B on Sensor Module. More...
 
void twr_ds18b20_init_multiple (twr_ds18b20_t *self, twr_ds18b20_sensor_t *sensors, int sensor_count, twr_ds18b20_resolution_bits_t resolution)
 Initialize multiple ds18b20 over channel B on Sensor Module. More...
 
void twr_ds18b20_init (twr_ds18b20_t *self, twr_onewire_t *onewire, twr_ds18b20_sensor_t *sensors, int sensor_count, twr_ds18b20_resolution_bits_t resolution)
 Initialize ds18b20. More...
 
void twr_ds18b20_set_event_handler (twr_ds18b20_t *self, void(*event_handler)(twr_ds18b20_t *, uint64_t _device_address, twr_ds18b20_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_ds18b20_set_update_interval (twr_ds18b20_t *self, twr_tick_t interval)
 Set measurement interval. More...
 
bool twr_ds18b20_measure (twr_ds18b20_t *self)
 Start measurement manually. More...
 
bool twr_ds18b20_get_temperature_raw (twr_ds18b20_t *self, uint64_t device_address, int16_t *raw)
 Get measured temperature in degrees of Celsius. More...
 
bool twr_ds18b20_get_temperature_celsius (twr_ds18b20_t *self, uint64_t _device_address, float *celsius)
 Get measured temperature in degrees of Celsius. More...
 
int twr_ds18b20_get_index_by_device_address (twr_ds18b20_t *self, uint64_t device_address)
 Get device index by its device address. More...
 
uint64_t twr_ds182b0_get_short_address (twr_ds18b20_t *self, uint8_t index)
 Get device index by its device address. More...
 
int twr_ds18b20_get_sensor_found (twr_ds18b20_t *self)
 Get number of found sensor. More...
 
void twr_ds18b20_rescan (twr_ds18b20_t *self)
 Request to rescan the bus.
 
void twr_ds18b20_set_power_dynamic (twr_ds18b20_t *self, bool on)
 Set power dynamic, Turns VDD on and pull 4k7 only for measurement. More...
 

Detailed Description

Driver for 1wire ds18b20.

Enumeration Type Documentation

◆ twr_ds18b20_event_t

Callback events.

Enumerator
TWR_DS18B20_EVENT_ERROR 

Error event.

TWR_DS18B20_EVENT_UPDATE 

Update event.

Definition at line 15 of file twr_ds18b20.h.

Function Documentation

◆ twr_ds182b0_get_short_address()

uint64_t twr_ds182b0_get_short_address ( twr_ds18b20_t self,
uint8_t  index 
)

Get device index by its device address.

Parameters
[in]selfInstance
[in]indexIndex
Returns
short addres or 0

Definition at line 106 of file twr_ds18b20.c.

◆ twr_ds18b20_get_index_by_device_address()

int twr_ds18b20_get_index_by_device_address ( twr_ds18b20_t self,
uint64_t  device_address 
)

Get device index by its device address.

Parameters
[in]selfInstance
[in]device_address64b device address

Definition at line 93 of file twr_ds18b20.c.

Referenced by twr_ds18b20_get_temperature_celsius(), and twr_ds18b20_get_temperature_raw().

Here is the caller graph for this function:

◆ twr_ds18b20_get_sensor_found()

int twr_ds18b20_get_sensor_found ( twr_ds18b20_t self)

Get number of found sensor.

Parameters
[in]selfInstance

Definition at line 120 of file twr_ds18b20.c.

◆ twr_ds18b20_get_temperature_celsius()

bool twr_ds18b20_get_temperature_celsius ( twr_ds18b20_t self,
uint64_t  _device_address,
float *  celsius 
)

Get measured temperature in degrees of Celsius.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]celsiusPointer to variables where results will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 166 of file twr_ds18b20.c.

Here is the call graph for this function:

◆ twr_ds18b20_get_temperature_raw()

bool twr_ds18b20_get_temperature_raw ( twr_ds18b20_t self,
uint64_t  device_address,
int16_t *  raw 
)

Get measured temperature in degrees of Celsius.

Parameters
[in]selfInstance
[in]device_address64b device address

Get measured temperature as raw values

Returns
true When value is valid
false When value is invalid

Definition at line 147 of file twr_ds18b20.c.

Here is the call graph for this function:

◆ twr_ds18b20_init()

void twr_ds18b20_init ( twr_ds18b20_t self,
twr_onewire_t onewire,
twr_ds18b20_sensor_t *  sensors,
int  sensor_count,
twr_ds18b20_resolution_bits_t  resolution 
)

Initialize ds18b20.

Parameters
[in]selfInstance
[in]onewirePointer on instance 1-Wire
[in]sensorsSensor array
[in]sensor_countMax count sensors
[in]resolutionResolution

Definition at line 36 of file twr_ds18b20.c.

Referenced by twr_ds18b20_init_multiple(), and twr_ds18b20_init_single().

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

◆ twr_ds18b20_init_multiple()

void twr_ds18b20_init_multiple ( twr_ds18b20_t self,
twr_ds18b20_sensor_t *  sensors,
int  sensor_count,
twr_ds18b20_resolution_bits_t  resolution 
)

Initialize multiple ds18b20 over channel B on Sensor Module.

Parameters
[in]selfInstance
[in]sensorsSensor array
[in]sensor_countMax count sensors
[in]resolutionResolution

Definition at line 30 of file twr_ds18b20.c.

Here is the call graph for this function:

◆ twr_ds18b20_init_single()

void twr_ds18b20_init_single ( twr_ds18b20_t self,
twr_ds18b20_resolution_bits_t  resolution 
)

Initialize single ds18b20 over channel B on Sensor Module.

Parameters
[in]selfInstance
[in]resolutionResolution

Definition at line 23 of file twr_ds18b20.c.

Here is the call graph for this function:

◆ twr_ds18b20_measure()

bool twr_ds18b20_measure ( twr_ds18b20_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 79 of file twr_ds18b20.c.

Referenced by twr_ds18b20_set_update_interval().

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

◆ twr_ds18b20_set_event_handler()

void twr_ds18b20_set_event_handler ( twr_ds18b20_t self,
void(*)(twr_ds18b20_t *, uint64_t _device_address, twr_ds18b20_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 56 of file twr_ds18b20.c.

◆ twr_ds18b20_set_power_dynamic()

void twr_ds18b20_set_power_dynamic ( twr_ds18b20_t self,
bool  on 
)

Set power dynamic, Turns VDD on and pull 4k7 only for measurement.

Parameters
[in]selfInstance
[in]onTrue enable dynamic, False disable dynamic

Definition at line 142 of file twr_ds18b20.c.

◆ twr_ds18b20_set_update_interval()

void twr_ds18b20_set_update_interval ( twr_ds18b20_t self,
twr_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 63 of file twr_ds18b20.c.

Here is the call graph for this function: