![]() |
Synergy Software Package User's Manual
|
Driver for the 24-bit Sigma Delta A/D Converter (SDADC). More...
Data Structures | |
| struct | sdadc_calibrate_args_t |
| struct | sdadc_channel_cfg_t |
| struct | adc_on_sdadc_cfg_t |
| struct | sdadc_instance_ctrl_t |
Macros | |
| #define | SDADC_CODE_VERSION_MAJOR (2U) |
Driver for the 24-bit Sigma Delta A/D Converter (SDADC).
This module supports the SDADC peripheral. It implements the following interfaces:
| #define SDADC_CODE_VERSION_MAJOR (2U) |
Version of code that implements the API defined in this file
| enum sdadc_calibration_t |
Per channel number of conversions to average before conversion end callback.
Select a formula to specify the number of conversions. The following symbols are used in the formulas:
Either m or n must be non-zero.
| Enumerator | |
|---|---|
| SDADC_CHANNEL_COUNT_FORMULA_EXPONENTIAL | N = 32 * (2 ^ n - 1) + m * 2 ^ n. |
| SDADC_CHANNEL_COUNT_FORMULA_LINEAR | N = (32 * n) + m. |
Per channel oversampling ratio.
| enum sdadc_vref_src_t |
| enum sdadc_vref_voltage_t |
Voltage of Vref.
| ssp_err_t R_SDADC_Calibrate | ( | adc_ctrl_t *const | p_api_ctrl, |
| void *const | p_extend | ||
| ) |
Requires sdadc_calibrate_args_t passed to p_extend. Calibrates the specified channel. Calibration is not required or supported for single-ended mode. Internal calibration is automatically done during open() unless it is disabled in the user configuration. This API is provided primarily for external calibration. A callback with the event ADC_EVENT_CALIBRATION_COMPLETE is called when calibration completes. The calibration status can also be monitored using adc_api_t::statusGet(). Implements adc_api_t::calibrate().
During external offset calibration, apply a differential voltage of 0 to ANSDnP - ANSDnN, where n is the input channel and ANSDnP is OPAMP0 for channel 4 and ANSDnN is OPAMP1 for channel 4. Complete external offset calibration before external gain calibration.
During external gain calibration apply a voltage between 0.4 V / total_gain and 0.8 V / total_gain. The differential voltage applied during calibration is corrected to a conversion result of 0x7FFFFF, which is the maximum possible positive differential measurement.
This function clears the offset value. If offset is required after calibration, it must be reapplied after calibration is complete using adc_api_t::offsetSet.
| SSP_SUCCESS | Calibration began successfully. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_IN_USE | A conversion or calibration is in progress. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Calibration cannot be performed if conversion or calibration is already in progress.
Select software trigger.
Select single scan mode.
Enable calibration.
Set the offset voltage to 0 mV.
Set the calibration mode.
Start calibration.
Confirm that calibration started.
Return the error code
| ssp_err_t R_SDADC_CheckScanDone | ( | adc_ctrl_t * | p_api_ctrl | ) |
Returns the status of a scan started by software, including calibration scans. It is not possible to determine the status of a scan started by a hardware trigger. Implements adc_api_t::scanStatusGet().
| SSP_SUCCESS | No software scan or calibration is in progress. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_IN_USE | A conversion or calibration is in progress. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
If calibration is in progress, return an error.
Return the scan status of a scan triggered by software.
| ssp_err_t R_SDADC_Close | ( | adc_ctrl_t * | p_api_ctrl | ) |
Stops any scan in progress, disables interrupts, and powers down the SDADC peripheral. Implements adc_api_t::close().
| SSP_SUCCESS | Instance control block closed successfully. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Perform parameter checking
Mark driver as closed
Disable hardware triggers.
Stop A/D conversion.
Disable interrupts.
Wait 3 us in normal mode as required by the hardware manual.
Turn off the power of VBIAS, channel, and sigma-delta A/D converter.
Turn off the power of ADBGR, SBIAS, and ADREG.
Stop the input clock for the 24-bit sigma-delta A/D converter (SDADCCLK).
Enter the module-stop state.
Release the hardware lock
Return the error code
| ssp_err_t R_SDADC_InfoGet | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_info_t * | p_adc_info | ||
| ) |
Returns the address of the lowest number configured channel, the total number of results to be read in order to read the results of all configured channels, the size of each result, and the ELC event enumerations. Implements adc_api_t::infoGet().
| SSP_SUCCESS | Information stored in p_adc_info. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Retrieve the scan mask of active channels from the control block
Determine the lowest channel that is configured.
Determine the highest channel that is configured.
Determine the size of data that must be read to read all the channels between and including the highest and lowest channels.
Determine the base address and transfer size.
Specify the peripheral name in the ELC list
Set sensor information to invalid value
| ssp_err_t R_SDADC_OffsetSet | ( | adc_ctrl_t *const | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| int32_t const | offset | ||
| ) |
Sets the offset. Offset is applied after stage 1 of the input channel. Offset can only be applied when the channel is configured for differential input. Implements adc_api_t::offsetSet().
Note: The offset is cleared if adc_api_t::calibrate() is called. The offset can be re-applied if necessary after the the callback with event ADC_EVENT_CALIBRATION_COMPLETE is called.
| [in] | p_api_ctrl | See p_ctrl in adc_api_t::offsetSet(). |
| [in] | reg_id | See reg_id in adc_api_t::offsetSet(). |
| [in] | offset | Must be between -15 and 15, offset (mV) = 10.9376 mV * offset_steps / stage 1 gain. |
| SSP_SUCCESS | Offset updated successfully. |
| SSP_ERR_INVALID_ARGUMENT | An input argument was outside the valid range. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_IN_USE | A conversion or calibration is in progress. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Offset cannot be updated if conversion or calibration is in progress.
Set the offset.
| ssp_err_t R_SDADC_Open | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_cfg_t const *const | p_cfg | ||
| ) |
Applies power to the SDADC and initializes the hardware based on the user configuration. As part of this initialization, the SDADC clock is configured and enabled. If an interrupt priority is non-zero, enables an interrupt which will call a callback to notify the user when a conversion, scan, or calibration is complete. For all channels that are configured in differential mode, calibration is performed unless it is disabled in the user configuration. Implements adc_api_t::open().
| SSP_SUCCESS | Configuration and calibration successful. |
| SSP_ERR_CALIBRATE_FAILED | Calibration failed. |
| SSP_ERR_ASSERTION | An input pointer is NULL. |
| SSP_ERR_INVALID_ARGUMENT | An input argument is invalid. |
| SSP_ERR_IN_USE | Control block is already open. |
| SSP_ERR_IRQ_BSP_DISABLED | A required interrupt is disabled |
Ensure the SDADC exists on the hardware, enable interrupts, and reserve the SDADC hardware lock.
Initialize the hardware based on the configuration.
Start the SDADC.
Configure the SDADC clock source and divisor to the clock source selected in the clock configuration.
Set the reference voltage for sensors (internal or external VREF mode).
Set the A/D conversion operation mode (normal or low power mode).
Supply the 24-bit sigma-delta A/D converter clock (SDADCCLK).
Turn on the power of ADBGR, SBIAS, and ADREG.
Stabilization wait time of 2 ms is required between power on of ADBGR/SBIAS/ADREG and VBIAS/channel/SDADC.
Turn on the power of VBIAS, channel, and sigma-delta A/D converter.
For each channel:
Set the A/D conversion count.
Configure enabled channels and autoscan mode.
If the A/D conversion trigger is ELC hardware events, the hardware events are enabled in adc_api_t::scanStart().
Mark driver as open by initializing it to "SDAD" - its ASCII equivalent.
If at least one channel is configured for differential mode and calibration is not disabled in the user configuration, calibrate all PGAs configured for differential mode.
The calibration takes approximately 3.4 ms per channel in normal mode or 27 ms in low power mode. The open() API blocks waiting for calibration to complete unless calibration is skipped. Calibration during open can be skipped and handled in at the application level by setting adc_on_sdadc_cfg_t::skip_internal_calibration to true, then calling adc_api_t::calibrate().
| ssp_err_t R_SDADC_Read | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| uint16_t *const | p_data | ||
| ) |
Reads the most recent conversion result from a channel. Truncates 24-bit results to the upper 16 bits. Implements adc_api_t::read().
| SSP_SUCCESS | Conversion result in p_data. |
| SSP_ERR_INVALID_ARGUMENT | An input argument was outside the valid range. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Read the most recent conversion value into a 16-bit result.
| ssp_err_t R_SDADC_Read32 | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| uint32_t *const | p_data | ||
| ) |
Reads the most recent conversion result from a channel. Implements adc_api_t::read32().
| SSP_SUCCESS | Conversion result in p_data. |
| SSP_ERR_INVALID_ARGUMENT | An input argument was outside the valid range. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
Read the most recent conversion value into a 32-bit result.
| ssp_err_t R_SDADC_SampleStateCountSet | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_sample_state_t * | p_sample | ||
| ) |
adc_api_t::sampleStateCountSet is not supported on the SDADC.
| SSP_ERR_UNSUPPORTED | This API is not supported. |
Return the unsupported error.
| ssp_err_t R_SDADC_ScanConfigure | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_channel_cfg_t const *const | p_channel_cfg | ||
| ) |
Configures the enabled channels of the ADC. Only adc_channel_cfg_t::scan_mask is used. Implements adc_api_t::scanCfg().
| SSP_SUCCESS | Information stored in p_adc_info. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
| SSP_ERR_INVALID_ARGUMENT | An input argument is invalid. |
Update the enabled channels.
| ssp_err_t R_SDADC_ScanStart | ( | adc_ctrl_t * | p_api_ctrl | ) |
If the SDADC is configured for hardware triggers, enables hardware triggers. Otherwise, starts a scan. Implements adc_api_t::scanStart().
| SSP_SUCCESS | Scan started or hardware triggers enabled successfully. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
| SSP_ERR_IN_USE | A conversion or calibration is in progress. |
Conversion cannot be performed if conversion or calibration is already in progress.
If the unit is configured for software triggering, trigger a scan.
Otherwise, enable hardware triggers.
Return the error code
| ssp_err_t R_SDADC_ScanStop | ( | adc_ctrl_t * | p_api_ctrl | ) |
If the SDADC is configured for hardware triggers, disables hardware triggers. Otherwise, stops any in-progress scan started by software. Implements adc_api_t::scanStop().
| SSP_SUCCESS | Scan stopped or hardware triggers disabled successfully. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. |
If the unit is configured for software triggering, stop the scan.
Otherwise, disable hardware triggers.
Return the error code
| ssp_err_t R_SDADC_VersionGet | ( | ssp_version_t *const | p_version | ) |
Gets the API and code version. Implements adc_api_t::versionGet().
| SSP_SUCCESS | Version information available in p_version. |
| SSP_ERR_ASSERTION | The parameter p_version is NULL. |
Return the version number