BeRTOS
|
Driver for NTC (reads a temperature through an ADC) More...
#include "hw/hw_ntc.h"
#include "hw/ntc_map.h"
#include "cfg/cfg_ntc.h"
#include <cfg/log.h>
#include <cfg/debug.h>
#include <drv/ntc.h>
Go to the source code of this file.
Functions | |
static size_t | upper_bound (const res_t *orig_table, size_t size, res_t val) |
Find in a table of values orig_table of size size, the index which value is less or equal to val. | |
deg_t | ntc_read (NtcDev dev) |
Read the temperature for the NTC channel dev. | |
void | ntc_init (void) |
Init NTC hardware. |
Driver for NTC (reads a temperature through an ADC)
This module handles an external NTC bound to an AD converter. As usual, it relies on a low-level API (ntc_hw_*) (see below):
Definition in file ntc.c.
void ntc_init | ( | void | ) |
deg_t ntc_read | ( | NtcDev | dev | ) |
Read the temperature for the NTC channel dev.
Read a single temperature value from the NTC.
First read the resistence of the NTC through ntc_hw_read(), then, for the conversion from resistance to temperature, since the formula varies from device to device, we implemented a generic system using a table of data which maps temperature (index) to resistance (data). The range of the table (min/max temperature) and the step (temperature difference between two consecutive elements of the table) is variable and can be specified. Notice that values inbetween the table elements are still possible as the library does a linear interpolation using the actual calculated resistance to find out the exact temperature.
The low-level API provides a function to get access to a description of the NTC (ntc_hw_getInfo()), including the resistance table.
static size_t upper_bound | ( | const res_t * | orig_table, |
size_t | size, | ||
res_t | val | ||
) | [static] |