2020-11-24 15:56:00 +01:00
|
|
|
/** library for Maxim DS18B20 digital temperature sensor (using 1-Wire protocol)
|
2020-06-06 14:35:55 +02:00
|
|
|
* @file
|
2017-03-28 12:39:11 +02:00
|
|
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
2020-06-06 14:35:55 +02:00
|
|
|
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
|
2020-12-07 19:07:21 +01:00
|
|
|
* @date 2017-2020
|
2017-03-28 12:39:11 +02:00
|
|
|
* @note peripherals used: 1-Wire (timer @ref onewire_master_timer, GPIO @ref onewire_master_gpio)
|
|
|
|
* @warning this library does not support parasite power mode and alarms
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/** setup 1-Wire peripheral to communicate with sensors on bus */
|
|
|
|
void sensor_ds18b20_setup(void);
|
|
|
|
/** get number of DS18B20 sensors on bus
|
|
|
|
* @return number of DS18B20 sensors on bus
|
|
|
|
*/
|
|
|
|
uint64_t sensor_ds18b20_number(void);
|
|
|
|
/** verify if only DS18B20 sensors are on the bus
|
|
|
|
* @return if only DS18B20 sensors are on the bus
|
|
|
|
*/
|
|
|
|
bool sensor_ds18b20_only(void);
|
|
|
|
/** send all DS18B20 slaves on the bus
|
|
|
|
* @param[out] code ROM code for sensor (0 if error occurred)
|
|
|
|
* @return if an additional sensors have been detected
|
|
|
|
*/
|
|
|
|
bool sensor_ds18b20_list(uint64_t* code);
|
|
|
|
/** start converting (e.g. measuring) temperature
|
2017-08-01 19:13:27 +02:00
|
|
|
* @warning conversion time to wait before reading temperature depends on the resolution set (9 bits: 93.75ms, 10 bits: 187.5ms, 11 bits: 375ms, 12 bits: 950ms)
|
2017-03-28 12:39:11 +02:00
|
|
|
* @param[in] code ROM code of sensor to start conversion on (0 for all, if only DS18B20 sensors are on the bus)
|
|
|
|
* @return if conversion started
|
|
|
|
*/
|
|
|
|
bool sensor_ds18b20_convert(uint64_t code);
|
|
|
|
/** get converted temperature
|
|
|
|
* @note 85.0 C is the default temperature when no conversion has been performed
|
|
|
|
* @param[in] code ROM code of sensor
|
|
|
|
* @return temperature (NaN if error)
|
|
|
|
*/
|
|
|
|
float sensor_ds18b20_temperature(uint64_t code);
|
|
|
|
/** set conversion precision
|
2020-12-07 19:07:56 +01:00
|
|
|
* @param[in] code ROM code of sensor to start conversion on (0 for single DS18B20 sensor are on the bus)
|
2017-03-28 12:39:11 +02:00
|
|
|
* @param[in] precision precision in bits (9-12)
|
|
|
|
* @return if operation succeeded
|
|
|
|
*/
|
|
|
|
bool sensor_ds18b20_precision(uint64_t code, uint8_t precision);
|