LibDriver NTC
Loading...
Searching...
No Matches
ntc basic driver function

ntc basic driver modules More...

Collaboration diagram for ntc basic driver function:

Data Structures

struct  ntc_table_s
 ntc table structure definition More...
struct  ntc_handle_s
 ntc handle structure definition More...
struct  ntc_info_s
 ntc information structure definition More...

Macros

#define NTC_FILTER_BUFFER_SIZE   32
 ntc filter buffer size definition

Typedefs

typedef struct ntc_table_s ntc_table_t
 ntc table structure definition
typedef struct ntc_handle_s ntc_handle_t
 ntc handle structure definition
typedef struct ntc_info_s ntc_info_t
 ntc information structure definition

Enumerations

enum  ntc_circuit_t { NTC_CIRCUIT_VCC_NTC_R_GND = 0x00 , NTC_CIRCUIT_VCC_R_NTC_GND = 0x01 }
 ntc circuit enumeration definition More...
enum  ntc_algorithm_t { NTC_ALGORITHM_BETA_FORMULA = 0x00 , NTC_ALGORITHM_STEINHART_HART = 0x01 , NTC_ALGORITHM_LOOKUP_TABLE = 0x02 }
 ntc algorithm enumeration definition More...
enum  ntc_filter_t {
  NTC_FILTER_NONE = 0x00 , NTC_FILTER_FIRST_ORDER_LAG = 0x01 , NTC_FILTER_MEDIAN = 0x02 , NTC_FILTER_ANTI_SPIKE_AVERAGE = 0x03 ,
  NTC_FILTER_MOVING_AVERAGE = 0x04 , NTC_FILTER_WEIGHTED_MOVING_AVERAGE = 0x05 , NTC_FILTER_LIMITING = 0x06 , NTC_FILTER_KALMAN = 0x07
}
 ntc filter enumeration definition More...

Functions

uint8_t ntc_info (ntc_info_t *info)
 get chip's information
uint8_t ntc_init (ntc_handle_t *handle)
 initialize the chip
uint8_t ntc_deinit (ntc_handle_t *handle)
 close the chip
uint8_t ntc_read_temperature (ntc_handle_t *handle, float *ohm, float *degrees_celsius)
 read temperature
uint8_t ntc_calculate_temperature (ntc_handle_t *handle, float ohm, float *degrees_celsius)
 calculate temperature
uint8_t ntc_calculate_temperature_with_filter (ntc_handle_t *handle, float *ohm, uint16_t len, float *degrees_celsius)
 calculate temperature with filter
uint8_t ntc_set_algorithm (ntc_handle_t *handle, ntc_algorithm_t algorithm)
 set algorithm
uint8_t ntc_get_algorithm (ntc_handle_t *handle, ntc_algorithm_t *algorithm)
 get algorithm
uint8_t ntc_set_algorithm_beta_formula_beta_value (ntc_handle_t *handle, float beta)
 set algorithm beta formula beta value
uint8_t ntc_get_algorithm_beta_formula_beta_value (ntc_handle_t *handle, float *beta)
 get algorithm beta formula beta value
uint8_t ntc_set_algorithm_beta_formula_r25_ohm (ntc_handle_t *handle, float r25_ohm)
 set algorithm beta formula r25 ohm
uint8_t ntc_get_algorithm_beta_formula_r25_ohm (ntc_handle_t *handle, float *r25_ohm)
 get algorithm beta formula r25 ohm
uint8_t ntc_set_algorithm_steinhart_hart (ntc_handle_t *handle, double a, double b, double c)
 set algorithm steinhart hart
uint8_t ntc_get_algorithm_steinhart_hart (ntc_handle_t *handle, double *a, double *b, double *c)
 get algorithm steinhart hart
uint8_t ntc_load_algorithm_lookup_table (ntc_handle_t *handle, const ntc_table_t *table, uint16_t table_len)
 load algorithm lookup table
uint8_t ntc_set_circuit (ntc_handle_t *handle, ntc_circuit_t circuit)
 set circuit
uint8_t ntc_get_circuit (ntc_handle_t *handle, ntc_circuit_t *circuit)
 get circuit
uint8_t ntc_set_circuit_fixed_resistor (ntc_handle_t *handle, float r_fixed_ohm)
 set circuit fixed resistor
uint8_t ntc_get_circuit_fixed_resistor (ntc_handle_t *handle, float *r_fixed_ohm)
 get circuit fixed resistor

Detailed Description

ntc basic driver modules

Macro Definition Documentation

◆ NTC_FILTER_BUFFER_SIZE

#define NTC_FILTER_BUFFER_SIZE   32

ntc filter buffer size definition

32

Definition at line 64 of file driver_ntc.h.

Typedef Documentation

◆ ntc_handle_t

typedef struct ntc_handle_s ntc_handle_t

ntc handle structure definition

◆ ntc_info_t

typedef struct ntc_info_s ntc_info_t

ntc information structure definition

◆ ntc_table_t

typedef struct ntc_table_s ntc_table_t

ntc table structure definition

Enumeration Type Documentation

◆ ntc_algorithm_t

ntc algorithm enumeration definition

Enumerator
NTC_ALGORITHM_BETA_FORMULA 

beta formula

NTC_ALGORITHM_STEINHART_HART 

stein-hart hart

NTC_ALGORITHM_LOOKUP_TABLE 

lookup table

Definition at line 79 of file driver_ntc.h.

◆ ntc_circuit_t

ntc circuit enumeration definition

Enumerator
NTC_CIRCUIT_VCC_NTC_R_GND 

vcc -> ntc -> r_fixed -> gnd

NTC_CIRCUIT_VCC_R_NTC_GND 

vcc -> r_fixed -> ntc -> gnd

Definition at line 70 of file driver_ntc.h.

◆ ntc_filter_t

ntc filter enumeration definition

Enumerator
NTC_FILTER_NONE 

no filter

NTC_FILTER_FIRST_ORDER_LAG 

first order lag filter

NTC_FILTER_MEDIAN 

median filter

NTC_FILTER_ANTI_SPIKE_AVERAGE 

anti spike average filter

NTC_FILTER_MOVING_AVERAGE 

moving average filter

NTC_FILTER_WEIGHTED_MOVING_AVERAGE 

weighted moving average filter

NTC_FILTER_LIMITING 

limiting filter

NTC_FILTER_KALMAN 

kalman filter

Definition at line 89 of file driver_ntc.h.

Function Documentation

◆ ntc_calculate_temperature()

uint8_t ntc_calculate_temperature ( ntc_handle_t * handle,
float ohm,
float * degrees_celsius )

calculate temperature

Parameters
[in]*handlepointer to a ntc handle structure
[in]ohmresistor in ohm
[out]*degrees_celsiuspointer to a degrees celsius buffer
Returns
status code
  • 0 success
  • 1 convert failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
this function does not perform any filtering processing, does not rely on any adc read values, and directly performs temperature conversion based on the resistance value

Definition at line 1728 of file driver_ntc.c.

◆ ntc_calculate_temperature_with_filter()

uint8_t ntc_calculate_temperature_with_filter ( ntc_handle_t * handle,
float * ohm,
uint16_t len,
float * degrees_celsius )

calculate temperature with filter

Parameters
[in]*handlepointer to a ntc handle structure
[in]*ohmpointer to a resistor in ohm
[in]lenresistor length
[out]*degrees_celsiuspointer to a degrees celsius buffer
Returns
status code
  • 0 success
  • 1 filter failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 convert failed
Note
this function can perform filtering processing, does not rely on any adc read values

Definition at line 1765 of file driver_ntc.c.

◆ ntc_deinit()

uint8_t ntc_deinit ( ntc_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a ntc handle structure
Returns
status code
  • 0 success
  • 1 adc deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1369 of file driver_ntc.c.

◆ ntc_get_algorithm()

uint8_t ntc_get_algorithm ( ntc_handle_t * handle,
ntc_algorithm_t * algorithm )

get algorithm

Parameters
[in]*handlepointer to a ntc handle structure
[out]*algorithmpointer to a ntc algorithm type buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 699 of file driver_ntc.c.

◆ ntc_get_algorithm_beta_formula_beta_value()

uint8_t ntc_get_algorithm_beta_formula_beta_value ( ntc_handle_t * handle,
float * beta )

get algorithm beta formula beta value

Parameters
[in]*handlepointer to a ntc handle structure
[out]*betapointer to a beta value buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 751 of file driver_ntc.c.

◆ ntc_get_algorithm_beta_formula_r25_ohm()

uint8_t ntc_get_algorithm_beta_formula_r25_ohm ( ntc_handle_t * handle,
float * r25_ohm )

get algorithm beta formula r25 ohm

Parameters
[in]*handlepointer to a ntc handle structure
[out]*r25_ohmpointer to a r25 ohm buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 803 of file driver_ntc.c.

◆ ntc_get_algorithm_steinhart_hart()

uint8_t ntc_get_algorithm_steinhart_hart ( ntc_handle_t * handle,
double * a,
double * b,
double * c )

get algorithm steinhart hart

Parameters
[in]*handlepointer to a ntc handle structure
[out]*apointer to a param a buffer
[out]*bpointer to a param b buffer
[out]*cpointer to a param c buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 861 of file driver_ntc.c.

◆ ntc_get_circuit()

uint8_t ntc_get_circuit ( ntc_handle_t * handle,
ntc_circuit_t * circuit )

get circuit

Parameters
[in]*handlepointer to a ntc handle structure
[out]*circuitpointer to a ntc circuit buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 602 of file driver_ntc.c.

◆ ntc_get_circuit_fixed_resistor()

uint8_t ntc_get_circuit_fixed_resistor ( ntc_handle_t * handle,
float * r_fixed_ohm )

get circuit fixed resistor

Parameters
[in]*handlepointer to a ntc handle structure
[out]*r_fixed_ohmpointer to a fixed resistor buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 654 of file driver_ntc.c.

◆ ntc_info()

uint8_t ntc_info ( ntc_info_t * info)

get chip's information

Parameters
[out]*infopointer to a ntc info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 1807 of file driver_ntc.c.

◆ ntc_init()

uint8_t ntc_init ( ntc_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a ntc handle structure
Returns
status code
  • 0 success
  • 1 adc initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
  • 4 vcc counter is invalid
Note
none

Definition at line 1282 of file driver_ntc.c.

◆ ntc_load_algorithm_lookup_table()

uint8_t ntc_load_algorithm_lookup_table ( ntc_handle_t * handle,
const ntc_table_t * table,
uint16_t table_len )

load algorithm lookup table

Parameters
[in]*handlepointer to a ntc handle structure
[in]*tablepointer to a ntc table buffer
[in]table_lentable length
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 table_len is 0
  • 5 table ohm is invalid
  • 6 table degrees celsius is invalid
Note
none

Definition at line 893 of file driver_ntc.c.

◆ ntc_read_temperature()

uint8_t ntc_read_temperature ( ntc_handle_t * handle,
float * ohm,
float * degrees_celsius )

read temperature

Parameters
[in]*handlepointer to a ntc handle structure
[out]*ohmpointer to a resistor in ohm
[out]*degrees_celsiuspointer to a degrees celsius buffer
Returns
status code
  • 0 success
  • 1 read adc failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 open circuit
  • 5 short circuit
  • 6 filter error
  • 7 temperature convert failed
Note
none

Definition at line 1410 of file driver_ntc.c.

◆ ntc_set_algorithm()

uint8_t ntc_set_algorithm ( ntc_handle_t * handle,
ntc_algorithm_t algorithm )

set algorithm

Parameters
[in]*handlepointer to a ntc handle structure
[in]algorithmntc algorithm type
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
\( \begin{align} & \text{beta formula} \\ & t = \frac{1} {\frac {\ln (\frac{r} {{{r}_{25}}})} {b} + \frac{1} {{{t}_{25}}}} - 273.15 \\ & \text{steinhart-hart} \\ & \text{t = } \frac{1} {a + b \ln (r) + c{{(\ln (r))}^{3}}} \\ \end{align} \)

Definition at line 673 of file driver_ntc.c.

◆ ntc_set_algorithm_beta_formula_beta_value()

uint8_t ntc_set_algorithm_beta_formula_beta_value ( ntc_handle_t * handle,
float beta )

set algorithm beta formula beta value

Parameters
[in]*handlepointer to a ntc handle structure
[in]betabeta value
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 725 of file driver_ntc.c.

◆ ntc_set_algorithm_beta_formula_r25_ohm()

uint8_t ntc_set_algorithm_beta_formula_r25_ohm ( ntc_handle_t * handle,
float r25_ohm )

set algorithm beta formula r25 ohm

Parameters
[in]*handlepointer to a ntc handle structure
[in]r25_ohmr25 ohm
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 777 of file driver_ntc.c.

◆ ntc_set_algorithm_steinhart_hart()

uint8_t ntc_set_algorithm_steinhart_hart ( ntc_handle_t * handle,
double a,
double b,
double c )

set algorithm steinhart hart

Parameters
[in]*handlepointer to a ntc handle structure
[in]aparam a
[in]bparam b
[in]cparam c
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 831 of file driver_ntc.c.

◆ ntc_set_circuit()

uint8_t ntc_set_circuit ( ntc_handle_t * handle,
ntc_circuit_t circuit )

set circuit

Parameters
[in]*handlepointer to a ntc handle structure
[in]circuitntc circuit
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 576 of file driver_ntc.c.

◆ ntc_set_circuit_fixed_resistor()

uint8_t ntc_set_circuit_fixed_resistor ( ntc_handle_t * handle,
float r_fixed_ohm )

set circuit fixed resistor

Parameters
[in]*handlepointer to a ntc handle structure
[in]r_fixed_ohmfixed resistor in ohm
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 628 of file driver_ntc.c.