TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
TM_DS18B20_Functions

Library Functions. More...

Functions

uint8_t TM_DS18B20_Start (TM_OneWire_t *OneWireStruct, uint8_t *ROM)
 Starts temperature conversion for specific DS18B20 on specific onewire channel. More...
 
void TM_DS18B20_StartAll (TM_OneWire_t *OneWireStruct)
 Starts temperature conversion for all DS18B20 devices on specific onewire channel. More...
 
uint8_t TM_DS18B20_Read (TM_OneWire_t *OneWireStruct, uint8_t *ROM, float *destination)
 Reads temperature from DS18B20. More...
 
uint8_t TM_DS18B20_GetResolution (TM_OneWire_t *OneWireStruct, uint8_t *ROM)
 Gets resolution for temperature conversion from DS18B20 device. More...
 
uint8_t TM_DS18B20_SetResolution (TM_OneWire_t *OneWireStruct, uint8_t *ROM, TM_DS18B20_Resolution_t resolution)
 Sets resolution for specific DS18B20 device. More...
 
uint8_t TM_DS18B20_Is (uint8_t *ROM)
 Checks if device with specific ROM number is DS18B20. More...
 
uint8_t TM_DS18B20_SetAlarmHighTemperature (TM_OneWire_t *OneWireStruct, uint8_t *ROM, int8_t temp)
 Sets high alarm temperature to specific DS18B20 sensor. More...
 
uint8_t TM_DS18B20_SetAlarmLowTemperature (TM_OneWire_t *OneWireStruct, uint8_t *ROM, int8_t temp)
 Sets low alarm temperature to specific DS18B20 sensor. More...
 
uint8_t TM_DS18B20_DisableAlarmTemperature (TM_OneWire_t *OneWireStruct, uint8_t *ROM)
 Disables alarm temperature for specific DS18B20 sensor. More...
 
uint8_t TM_DS18B20_AlarmSearch (TM_OneWire_t *OneWireStruct)
 Searches for devices with alarm flag set. More...
 
uint8_t TM_DS18B20_AllDone (TM_OneWire_t *OneWireStruct)
 Checks if all DS18B20 sensors are done with temperature conversion. More...
 

Detailed Description

Library Functions.

Function Documentation

uint8_t TM_DS18B20_AlarmSearch ( TM_OneWire_t OneWireStruct)

Searches for devices with alarm flag set.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
Return values
Alarmsearch status
  • 0: No device found with alarm flag set
  • > 0: Device is found with alarm flag
Note
To get all devices on one onewire channel with alarm flag set, you can do this:
while (TM_DS18B20_AlarmSearch(&OneWireStruct)) {
    //Read device ID here 
    //Print to user device by device
}
Return values
1if any device has flag, otherwise 0
uint8_t TM_DS18B20_AllDone ( TM_OneWire_t OneWireStruct)

Checks if all DS18B20 sensors are done with temperature conversion.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
Return values
Conversionstatus
  • 0: Not all devices are done
  • > 0: All devices are done with conversion
uint8_t TM_DS18B20_DisableAlarmTemperature ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM 
)

Disables alarm temperature for specific DS18B20 sensor.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
Return values
Successstatus:
  • 0: Device is not DS18B20
  • > 0: Alarm disabled OK
uint8_t TM_DS18B20_GetResolution ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM 
)

Gets resolution for temperature conversion from DS18B20 device.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
Return values
Resolution
  • 0: Device is not DS18B20
  • 9 - 12: Resolution of DS18B20
uint8_t TM_DS18B20_Is ( uint8_t *  ROM)

Checks if device with specific ROM number is DS18B20.

Parameters
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
Return values
Devicestatus
  • 0: Device is not DS18B20
  • > 0: Device is DS18B20
uint8_t TM_DS18B20_Read ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM,
float *  destination 
)

Reads temperature from DS18B20.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
*destinationPointer to float variable to store temperature
Return values
Temperaturestatus:
  • 0: Device is not DS18B20 or conversion is not done yet or CRC failed
  • > 0: Temperature is read OK
uint8_t TM_DS18B20_SetAlarmHighTemperature ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM,
int8_t  temp 
)

Sets high alarm temperature to specific DS18B20 sensor.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
tempinteger value for temperature between -55 to 125 degrees
Return values
Successstatus:
  • 0: Device is not DS18B20
  • > 0: High alarm set OK
uint8_t TM_DS18B20_SetAlarmLowTemperature ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM,
int8_t  temp 
)

Sets low alarm temperature to specific DS18B20 sensor.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
tempinteger value for temperature between -55 to 125 degrees
Return values
Successstatus:
  • 0: Device is not DS18B20
  • > 0: Low alarm set OK
uint8_t TM_DS18B20_SetResolution ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM,
TM_DS18B20_Resolution_t  resolution 
)

Sets resolution for specific DS18B20 device.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
resolutionResolution for DS18B20 device. This parameter can be a value of TM_DS18B20_Resolution_t enumeration.
Return values
Successstatus:
  • 0: Device is not DS18B20
  • > 0: Resolution set OK
uint8_t TM_DS18B20_Start ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM 
)

Starts temperature conversion for specific DS18B20 on specific onewire channel.

Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
*ROMPointer to first byte of ROM address for desired DS12B80 device. Entire ROM address is 8-bytes long
Return values
1if device is DS18B20 or 0 if not
void TM_DS18B20_StartAll ( TM_OneWire_t OneWireStruct)

Starts temperature conversion for all DS18B20 devices on specific onewire channel.

Note
This mode will skip ROM addressing
Parameters
*OneWireStructPointer to TM_OneWire_t working structure (OneWire channel)
Return values
None