Successive Approximation Analog-to-Digital Converter (SAADC) peripheral legacy driver.
More...
Successive Approximation Analog-to-Digital Converter (SAADC) peripheral legacy driver.
#define NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL |
( |
|
PIN_P, |
|
|
|
PIN_N |
|
) |
| |
Value:
Macro for setting nrf_saadc_channel_config_t to default settings in differential mode.
- Parameters
-
PIN_P | Positive analog input. |
PIN_N | Negative analog input. |
#define NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE |
( |
|
PIN_P | ) |
|
#define NRFX_SAADC_DEFAULT_CONFIG |
SAADC driver event handler.
- Parameters
-
[in] | p_event | Pointer to an SAADC driver event. The event structure is allocated on the stack, so it is valid only within the context of the event handler. |
SAADC driver event types.
Enumerator |
---|
NRFX_SAADC_EVT_DONE |
Event generated when the buffer is filled with samples.
|
NRFX_SAADC_EVT_LIMIT |
Event generated after one of the limits is reached.
|
NRFX_SAADC_EVT_CALIBRATEDONE |
Event generated when the calibration is complete.
|
NRFX_SAADC_EVT_DONE |
Event generated when the buffer is filled with samples.
|
NRFX_SAADC_EVT_LIMIT |
Event generated when one of the limits is reached.
|
NRFX_SAADC_EVT_CALIBRATEDONE |
Event generated when the calibration is complete.
|
NRFX_SAADC_EVT_BUF_REQ |
Event generated when the next buffer for continuous conversion is requested.
|
NRFX_SAADC_EVT_READY |
Event generated when the first buffer is acquired by the peripheral and sampling can be started.
|
NRFX_SAADC_EVT_FINISHED |
Event generated when all supplied buffers are filled with results.
|
void nrfx_saadc_abort |
( |
void |
| ) |
|
Function for aborting the ongoing and buffered conversions.
- Note
- NRFX_SAADC_EVT_DONE event will be generated if there is a conversion in progress. Event will contain number of words in the sample buffer.
- Warning
- This function must not be called from the context of event handler of the SAADC driver or from the context of interrupt with priority equal to or higher than priority of the SAADC interrupt.
Function for issuing conversion of data to the buffer.
This function is non-blocking. The application is notified about filling the buffer by the event handler. Conversion will be done on all enabled channels. If the SAADC is in idle state, the function will set up EasyDMA for the conversion. The SAADC will be ready for sampling and wait for the SAMPLE task. It can be triggered manually by the nrfx_saadc_sample function or by PPI using the NRF_SAADC_TASK_SAMPLE task. If one buffer is already set and the conversion is ongoing, calling this function will result in queuing the given buffer. The driver will start filling the issued buffer when the first one is completed. If the function is called again before the first buffer is filled or calibration is in progress, it will return with error.
- Parameters
-
[in] | buffer | Result buffer. |
[in] | size | Buffer size in words. |
- Return values
-
NRFX_SUCCESS | The conversion was successful. |
NRFX_ERROR_BUSY | The driver already has two buffers set or the calibration is in progress. |
Function for triggering the SAADC offset calibration.
This function is non-blocking. The application is notified about completion by the event handler. Calibration will also trigger DONE and RESULTDONE events.
The function will fail if the SAADC is busy or calibration is already in progress.
- Return values
-
NRFX_SUCCESS | The calibration was started successfully. |
NRFX_ERROR_BUSY | The SAADC driver is busy. |
Function for initializing an SAADC channel.
This function configures and enables the channel.
- Parameters
-
[in] | channel | Channel index. |
[in] | p_config | Pointer to the structure with the initial configuration. |
- Return values
-
NRFX_SUCCESS | Initialization was successful. |
NRFX_ERROR_INVALID_STATE | The SAADC was not initialized. |
NRFX_ERROR_NO_MEM | The specified channel was already allocated. |
nrfx_err_t nrfx_saadc_channel_uninit |
( |
uint8_t |
channel | ) |
|
Function for uninitializing an SAADC channel.
- Parameters
-
[in] | channel | Channel index. |
- Return values
-
NRFX_SUCCESS | Uninitialization was successful. |
NRFX_ERROR_BUSY | The SAADC is busy. |
Function for initializing the SAADC.
- Parameters
-
[in] | p_config | Pointer to the structure with initial configuration. |
[in] | event_handler | Event handler provided by the user. Must not be NULL. |
- Return values
-
NRFX_SUCCESS | Initialization was successful. |
NRFX_ERROR_INVALID_STATE | The driver is already initialized. |
bool nrfx_saadc_is_busy |
( |
void |
| ) |
|
Function for retrieving the SAADC state.
- Return values
-
true | The SAADC is busy. |
false | The SAADC is ready. |
void nrfx_saadc_limits_set |
( |
uint8_t |
channel, |
|
|
int16_t |
limit_low, |
|
|
int16_t |
limit_high |
|
) |
| |
Function for setting the SAADC channel limits. When limits are enabled and the result exceeds the defined bounds, the limit handler function is called.
- Parameters
-
Function for starting the SAADC sampling.
- Return values
-
NRFX_SUCCESS | The SAADC sampling was triggered. |
NRFX_ERROR_INVALID_STATE | The SAADC is in idle state. |
Blocking function for executing a single SAADC conversion.
This function selects the desired input, starts a single conversion, waits for it to finish, and returns the result.
The function fails if the SAADC is busy.
- Parameters
-
[in] | channel | Channel. |
[out] | p_value | Pointer to the location where the result is to be placed. |
- Return values
-
NRFX_SUCCESS | The conversion was successful. |
NRFX_ERROR_BUSY | The SAADC driver is busy. |
uint32_t nrfx_saadc_sample_task_get |
( |
void |
| ) |
|
Function for getting the address of a SAMPLE SAADC task.
- Returns
- Task address.
void nrfx_saadc_uninit |
( |
void |
| ) |
|
Function for uninitializing the SAADC.
This function stops all ongoing conversions and disables all channels.