TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_ds18b20.h
1 
72 #ifndef TM_DS18B20_H
73 #define TM_DS18B20_H 200
74 
115 #include "stm32f4xx.h"
116 #include "tm_stm32f4_onewire.h"
117 #include "defines.h"
118 
119 /* OneWire version check */
120 #if TM_ONEWIRE_H < 200
121 #error "Please update TM ONEWIRE LIB, minimum required version is 2.0.0. Download available on stm32f4-discovery.com website"
122 #endif
123 
130 /* Every onewire chip has different ROM code, but all the same chips has same family code */
131 /* in case of DS18B20 this is 0x28 and this is first byte of ROM address */
132 #define DS18B20_FAMILY_CODE 0x28
133 #define DS18B20_CMD_ALARMSEARCH 0xEC
134 
135 /* DS18B20 read temperature command */
136 #define DS18B20_CMD_CONVERTTEMP 0x44 /* Convert temperature */
137 #define DS18B20_DECIMAL_STEPS_12BIT 0.0625
138 #define DS18B20_DECIMAL_STEPS_11BIT 0.125
139 #define DS18B20_DECIMAL_STEPS_10BIT 0.25
140 #define DS18B20_DECIMAL_STEPS_9BIT 0.5
141 
142 /* Bits locations for resolution */
143 #define DS18B20_RESOLUTION_R1 6
144 #define DS18B20_RESOLUTION_R0 5
145 
146 /* CRC enabled */
147 #ifdef DS18B20_USE_CRC
148 #define DS18B20_DATA_LEN 9
149 #else
150 #define DS18B20_DATA_LEN 2
151 #endif
152 
166 typedef enum {
172 
190 uint8_t TM_DS18B20_Start(TM_OneWire_t* OneWireStruct, uint8_t* ROM);
191 
198 void TM_DS18B20_StartAll(TM_OneWire_t* OneWireStruct);
199 
210 uint8_t TM_DS18B20_Read(TM_OneWire_t* OneWireStruct, uint8_t* ROM, float* destination);
211 
221 uint8_t TM_DS18B20_GetResolution(TM_OneWire_t* OneWireStruct, uint8_t* ROM);
222 
233 uint8_t TM_DS18B20_SetResolution(TM_OneWire_t* OneWireStruct, uint8_t* ROM, TM_DS18B20_Resolution_t resolution);
234 
243 uint8_t TM_DS18B20_Is(uint8_t* ROM);
244 
255 uint8_t TM_DS18B20_SetAlarmHighTemperature(TM_OneWire_t* OneWireStruct, uint8_t* ROM, int8_t temp);
256 
267 uint8_t TM_DS18B20_SetAlarmLowTemperature(TM_OneWire_t* OneWireStruct, uint8_t* ROM, int8_t temp);
268 
278 uint8_t TM_DS18B20_DisableAlarmTemperature(TM_OneWire_t* OneWireStruct, uint8_t* ROM);
279 
295 uint8_t TM_DS18B20_AlarmSearch(TM_OneWire_t* OneWireStruct);
296 
304 uint8_t TM_DS18B20_AllDone(TM_OneWire_t* OneWireStruct);
305 
318 #endif
319 
Definition: tm_stm32f4_ds18b20.h:168
uint8_t TM_DS18B20_SetResolution(TM_OneWire_t *OneWireStruct, uint8_t *ROM, TM_DS18B20_Resolution_t resolution)
Sets resolution for specific DS18B20 device.
OneWire working struct.
Definition: tm_stm32f4_onewire.h:132
TM_DS18B20_Resolution_t
DS18B0 Resolutions available.
Definition: tm_stm32f4_ds18b20.h:166
uint8_t TM_DS18B20_GetResolution(TM_OneWire_t *OneWireStruct, uint8_t *ROM)
Gets resolution for temperature conversion from DS18B20 device.
uint8_t TM_DS18B20_Read(TM_OneWire_t *OneWireStruct, uint8_t *ROM, float *destination)
Reads temperature from DS18B20.
void TM_DS18B20_StartAll(TM_OneWire_t *OneWireStruct)
Starts temperature conversion for all DS18B20 devices on specific onewire channel.
uint8_t TM_DS18B20_Is(uint8_t *ROM)
Checks if device with specific ROM number is DS18B20.
Definition: tm_stm32f4_ds18b20.h:167
Definition: tm_stm32f4_ds18b20.h:170
uint8_t TM_DS18B20_DisableAlarmTemperature(TM_OneWire_t *OneWireStruct, uint8_t *ROM)
Disables alarm temperature for specific DS18B20 sensor.
Definition: tm_stm32f4_ds18b20.h:169
uint8_t TM_DS18B20_SetAlarmLowTemperature(TM_OneWire_t *OneWireStruct, uint8_t *ROM, int8_t temp)
Sets low alarm temperature to specific DS18B20 sensor.
uint8_t TM_DS18B20_SetAlarmHighTemperature(TM_OneWire_t *OneWireStruct, uint8_t *ROM, int8_t temp)
Sets high alarm temperature to specific DS18B20 sensor.
uint8_t TM_DS18B20_Start(TM_OneWire_t *OneWireStruct, uint8_t *ROM)
Starts temperature conversion for specific DS18B20 on specific onewire channel.
uint8_t TM_DS18B20_AlarmSearch(TM_OneWire_t *OneWireStruct)
Searches for devices with alarm flag set.
uint8_t TM_DS18B20_AllDone(TM_OneWire_t *OneWireStruct)
Checks if all DS18B20 sensors are done with temperature conversion.