Firmware SDK
bc_ds18b20

Driver for 1wire ds18b20. More...

Typedefs

typedef struct bc_ds18b20_t bc_ds18b20_t
 BigClown ds18b20 instance.
 
typedef struct bc_ds18b20_sensor_t bc_ds18b20_sensor_t
 

Enumerations

enum  bc_ds18b20_event_t {
  BC_DS18B20_EVENT_ERROR = -1,
  BC_DS18B20_EVENT_UPDATE = 0
}
 Callback events. More...
 

Functions

void bc_ds18b20_init_single (bc_ds18b20_t *self, bc_ds18b20_resolution_bits_t resolution)
 Initialize single ds18b20 over channel B on Sensor Module. More...
 
void bc_ds18b20_init_multiple (bc_ds18b20_t *self, bc_ds18b20_sensor_t *sensors, int sensor_count, bc_ds18b20_resolution_bits_t resolution)
 Initialize multiple ds18b20 over channel B on Sensor Module. More...
 
void bc_ds18b20_init (bc_ds18b20_t *self, bc_onewire_t *onewire, bc_ds18b20_sensor_t *sensors, int sensor_count, bc_ds18b20_resolution_bits_t resolution)
 Initialize ds18b20. More...
 
void bc_ds18b20_set_event_handler (bc_ds18b20_t *self, void(*event_handler)(bc_ds18b20_t *, uint64_t _device_address, bc_ds18b20_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_ds18b20_set_update_interval (bc_ds18b20_t *self, bc_tick_t interval)
 Set measurement interval. More...
 
bool bc_ds18b20_measure (bc_ds18b20_t *self)
 Start measurement manually. More...
 
bool bc_ds18b20_get_temperature_raw (bc_ds18b20_t *self, uint64_t device_address, int16_t *raw)
 Get measured temperature in degrees of Celsius. More...
 
bool bc_ds18b20_get_temperature_celsius (bc_ds18b20_t *self, uint64_t _device_address, float *celsius)
 Get measured temperature in degrees of Celsius. More...
 
int bc_ds18b20_get_index_by_device_address (bc_ds18b20_t *self, uint64_t device_address)
 Get device index by its device address. More...
 
uint64_t bc_ds182b0_get_short_address (bc_ds18b20_t *self, uint8_t index)
 Get device index by its device address. More...
 
int bc_ds18b20_get_sensor_found (bc_ds18b20_t *self)
 Get number of found sensor. More...
 
void bc_ds18b20_set_power_dynamic (bc_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

◆ bc_ds18b20_event_t

Callback events.

Enumerator
BC_DS18B20_EVENT_ERROR 

Error event.

BC_DS18B20_EVENT_UPDATE 

Update event.

Definition at line 15 of file bc_ds18b20.h.

Function Documentation

◆ bc_ds182b0_get_short_address()

uint64_t bc_ds182b0_get_short_address ( bc_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 102 of file bc_ds18b20.c.

◆ bc_ds18b20_get_index_by_device_address()

int bc_ds18b20_get_index_by_device_address ( bc_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 89 of file bc_ds18b20.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_ds18b20_get_temperature_raw().

Here is the caller graph for this function:

◆ bc_ds18b20_get_sensor_found()

int bc_ds18b20_get_sensor_found ( bc_ds18b20_t self)

Get number of found sensor.

Parameters
[in]selfInstance

Definition at line 116 of file bc_ds18b20.c.

◆ bc_ds18b20_get_temperature_celsius()

bool bc_ds18b20_get_temperature_celsius ( bc_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 145 of file bc_ds18b20.c.

Here is the call graph for this function:

◆ bc_ds18b20_get_temperature_raw()

bool bc_ds18b20_get_temperature_raw ( bc_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 126 of file bc_ds18b20.c.

Here is the call graph for this function:

◆ bc_ds18b20_init()

void bc_ds18b20_init ( bc_ds18b20_t self,
bc_onewire_t onewire,
bc_ds18b20_sensor_t *  sensors,
int  sensor_count,
bc_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 38 of file bc_ds18b20.c.

Referenced by bc_ds18b20_init_multiple(), and bc_ds18b20_init_single().

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

◆ bc_ds18b20_init_multiple()

void bc_ds18b20_init_multiple ( bc_ds18b20_t self,
bc_ds18b20_sensor_t *  sensors,
int  sensor_count,
bc_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 31 of file bc_ds18b20.c.

Here is the call graph for this function:

◆ bc_ds18b20_init_single()

void bc_ds18b20_init_single ( bc_ds18b20_t self,
bc_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 bc_ds18b20.c.

Here is the call graph for this function:

◆ bc_ds18b20_measure()

bool bc_ds18b20_measure ( bc_ds18b20_t self)

Start measurement manually.

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

Definition at line 75 of file bc_ds18b20.c.

Referenced by bc_ds18b20_get_temperature_celsius(), and bc_ds18b20_set_update_interval().

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

◆ bc_ds18b20_set_event_handler()

void bc_ds18b20_set_event_handler ( bc_ds18b20_t self,
void(*)(bc_ds18b20_t *, uint64_t _device_address, bc_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 52 of file bc_ds18b20.c.

◆ bc_ds18b20_set_power_dynamic()

void bc_ds18b20_set_power_dynamic ( bc_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 121 of file bc_ds18b20.c.

◆ bc_ds18b20_set_update_interval()

void bc_ds18b20_set_update_interval ( bc_ds18b20_t self,
bc_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 59 of file bc_ds18b20.c.

Here is the call graph for this function: