BeRTOS
Data Structures | Defines | Typedefs | Functions
ntc.h File Reference

Driver for NTC sensors (reads a temperature through an ADC). More...

#include "hw/ntc_map.h"
#include <cfg/compiler.h>
#include <cfg/debug.h>

Go to the source code of this file.

Data Structures

struct  NtcHwInfo
 type for defining amplifications amp_t = A, where A is a pure number More...

Defines

#define DEG_TO_DEG_T(x)   ((deg_t)((x) * 10))
 type for celsius degrees deg_t = °C * 10
#define DEG_T_TO_INTDEG(x)   ((x) / 10)
 Macro for converting from deg_t to celsius degrees (returns only the integer part)
#define DEG_T_TO_DECIMALDEG(x)   ((x) % 10)
 Macro for converting from deg_t to celsius degrees (returns only the decimal part)
#define DEG_T_TO_FLOATDEG(x)   ((x) / 10.0)
 Macro for converting from deg_t to celsius degrees (returns type is float)

Typedefs

typedef float amp_t
 type for resistor res_t = Ohm * 100

Functions

void ntc_init (void)
 Initialize the NTC module.
deg_t ntc_read (NtcDev dev)
 Read a single temperature value from the NTC.

Detailed Description

Driver for NTC sensors (reads a temperature through an ADC).

Author:
Giovanni Bajo <rasky@develer.com>
Francesco Sacchi <batt@develer.com>

Definition in file ntc.h.


Define Documentation

#define DEG_TO_DEG_T (   x)    ((deg_t)((x) * 10))

type for celsius degrees deg_t = °C * 10

Macro for converting from deg to deg_t type

Definition at line 57 of file ntc.h.


Function Documentation

deg_t ntc_read ( NtcDev  dev)

Read a single temperature value from the NTC.

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.

Definition at line 104 of file ntc.c.