TEMP driver

group nrfx_temp

Temperature sensor (TEMP) driver.

Defines

NRFX_TEMP_DEFAULT_CONFIG

TEMP default configuration.

Typedefs

typedef void (*nrfx_temp_data_handler_t)(int32_t temperature)

TEMP driver data ready handler type.

Param temperature:

Raw temperature in a 2’s complement signed value representation. This value can be converted to Celsius scale using the nrfx_temp_calculate() function.

Functions

nrfx_err_t nrfx_temp_init(nrfx_temp_config_t const *p_config, nrfx_temp_data_handler_t handler)

Function for initializing the TEMP driver.

Parameters:
  • p_config[in] Pointer to the structure with initial configuration.

  • handler[in] Data handler provided by the user. If not provided, the driver is initialized in blocking mode.

Return values:
  • NRFX_SUCCESS – Driver was successfully initialized.

  • NRFX_ERROR_ALREADY – Driver was already initialized.

void nrfx_temp_uninit(void)

Function for uninitializing the TEMP driver.

bool nrfx_temp_init_check(void)

Function for checking if the TEMP driver is initialized.

Return values:
  • true – Driver is already initialized.

  • false – Driver is not initialized.

NRFX_STATIC_INLINE int32_t nrfx_temp_result_get(void)

Function for getting the temperature measurement in a 2’s complement signed value representation.

This function returns the last value prepared by the TEMP peripheral. In blocking mode, it should be used after calling the nrfx_temp_measure() function. In non-blocking mode, it is called internally by the driver, and the value it returns is passed to the data handler.

Returns:

Temperature measurement result in a 2’s complement signed value representation.

int32_t nrfx_temp_calculate(int32_t raw_measurement)

Function for calculating the temperature value in Celsius scale from raw data.

The returned temperature value is in Celsius scale, multiplied by 100 For example, the actual temperature of 25.75[C] will be returned as a 2575 signed integer. Measurement accuracy is 0.25[C].

Parameters:
  • raw_measurement[in] Temperature value in a 2’s complement signed value representation.

Returns:

Temperature measurement result.

nrfx_err_t nrfx_temp_measure(void)

Function for starting the temperature measurement.

Non-blocking mode: This function returns immediately. After a measurement, the handler specified during initialization is called, with measurement result as the parameter.

Blocking mode: This function waits until the measurement is finished. The value should be read using the nrfx_temp_result_get() function.

Return values:
  • NRFX_SUCCESS

    In non-blocking mode: Measurement was started. An interrupt will be generated soon.

    In blocking mode: Measurement was started and finished. Data can be read using the

    nrfx_temp_result_get() function.

  • NRFX_ERROR_INTERNAL

    In non-blocking mode: Not applicable.

    In blocking mode: Measurement data ready event did not occur.

struct nrfx_temp_config_t
#include <nrfx_temp.h>

Structure for TEMP configuration.

Public Members

uint8_t interrupt_priority

Interrupt priority.