![]() |
Synergy Software Package User's Manual
|
Driver for the 14-Bit A/D Converter (ADC14) and 12-bit A/D Converter (ADC12). More...
Data Structures | |
| struct | adc_instance_ctrl_t |
Macros | |
| #define | ADC_CODE_VERSION_MAJOR (2U) |
| #define | ADC_SAMPLE_STATE_COUNT_MIN (7U) |
| #define | ADC_SAMPLE_STATE_HOLD_COUNT_MIN (4U) |
| #define | ADC_SAMPLE_STATE_HOLD_COUNT_DEFAULT (24U) |
| #define | ADC_MASK_CHANNEL_0 (1U<<0U) |
| #define | ADC_SAMPLE_HOLD_CHANNELS (0x07U) |
Functions | |
| ssp_err_t | R_ADC_Open (adc_ctrl_t *p_api_ctrl, adc_cfg_t const *const p_cfg) |
| The Open function applies power to the A/D peripheral, sets the operational mode, trigger sources, interrupt priority, and configurations for the peripheral as a whole. If interrupt priority is non-zero in BSP_IRQ_Cfg.h, the function takes a callback function pointer for notifying the user at interrupt level whenever a scan has completed. On MCUs where calibration is possible, this function will only return after calibration is completed if enabled in the user configuration. The calibration times vary depending on PCLKB and ADCLK. More... | |
| ssp_err_t | R_ADC_SetSampleStateCount (adc_ctrl_t *p_api_ctrl, adc_sample_state_t *p_sample) |
| Set the sample state count for individual channels. This only needs to be set for special use cases. Normally, use the default values out of Reset. More... | |
| ssp_err_t | R_ADC_ScanConfigure (adc_ctrl_t *p_api_ctrl, adc_channel_cfg_t const *const p_channel_cfg) |
| Configure the ADC scan parameters. Channel specific settings are set in this function. More... | |
| ssp_err_t | R_ADC_InfoGet (adc_ctrl_t *p_api_ctrl, adc_info_t *p_adc_info) |
| This function returns the address of the lowest number configured channel and the total number of bytes to be read in order to read the results of the configured channels and return the ELC Event name. If no channels are configured, then a length of 0 is returned. This function retrieves the temperature sensor slope. It also returns the calibration data for the sensor if available on this MCU otherwise an invalid calibration data of 0xFFFFFFFF will be returned. More... | |
| ssp_err_t | R_ADC_ScanStart (adc_ctrl_t *p_api_ctrl) |
| This function starts a software scan or enables the hardware trigger for a scan depending on how the triggers were configured in the Open() call. If the Unit was configured for hardware triggering, then this function simply allows the trigger signal (hardware or software) to get to the ADC Unit. The function is not able to control the generation of the trigger itself. If the Unit was configured for software triggering, then this function starts the software triggered scan. More... | |
| ssp_err_t | R_ADC_ScanStop (adc_ctrl_t *p_api_ctrl) |
| This function stops the software scan or disables the Unit from being triggered by the hardware trigger (internal or external) based on what type of trigger the unit was configured for in the Open() function. Stopping a hardware triggered scan via this function does not abort an ongoing scan, but prevents the next scan from occurring. Stopping a software triggered scan aborts an ongoing scan. More... | |
| ssp_err_t | R_ADC_CheckScanDone (adc_ctrl_t *p_api_ctrl) |
| This function returns the status of any scan process that was started. On supported MCUs, the status of the ADC calibration is returned. More... | |
| ssp_err_t | R_ADC_Read (adc_ctrl_t *p_api_ctrl, adc_register_t const reg_id, adc_data_size_t *const p_data) |
| This function reads conversion results from a single channel or sensor register. More... | |
| ssp_err_t | R_ADC_Read32 (adc_ctrl_t *p_api_ctrl, adc_register_t const reg_id, uint32_t *const p_data) |
| This function reads conversion results from a single channel or sensor register into a 32-bit result. More... | |
| ssp_err_t | R_ADC_Close (adc_ctrl_t *p_api_ctrl) |
| This function ends any scan in progress, disables interrupts, and removes power to the A/D peripheral. More... | |
| ssp_err_t | R_ADC_VersionGet (ssp_version_t *const p_version) |
| Retrieve the API version number. More... | |
| ssp_err_t | R_ADC_Calibrate (adc_ctrl_t *const p_api_ctrl, void *const p_extend) |
| This function initiates calibration of the ADC on supported MCUs. Calibration will take a minimum of 24 milliseconds at 32 MHz PCLKB and ADCLK. If ADC interrupts are enabled, a notification is provided via callback when calibration is complete. Otherwise, if the ADC interrupts are disabled then no notification will be provided and the application must check calibration status using infoGet() to determine if the calibration is complete before using the ADC API.Interrupts are enabled in adc_api_t::scanStatusGet(). More... | |
| ssp_err_t | R_ADC_OffsetSet (adc_ctrl_t *const p_api_ctrl, adc_register_t const reg_id, int32_t offset) |
Driver for the 14-Bit A/D Converter (ADC14) and 12-bit A/D Converter (ADC12).
This module supports the ADC14 and ADC12 peripherals. It implements the following interfaces:
| #define ADC_CODE_VERSION_MAJOR (2U) |
Version of code that implements the API defined in this file
| #define ADC_MASK_CHANNEL_0 (1U<<0U) |
For ADC Scan configuration adc_channel_cfg_t::scan_mask, scan_mask_group_b, add_mask and sample_hold_mask Use bitwise OR to combine these masks for desired channels and sensors.
| #define ADC_SAMPLE_HOLD_CHANNELS (0x07U) |
Sample and hold Channel mask. Sample and hold is only available for channel 0,1,2
| #define ADC_SAMPLE_STATE_COUNT_MIN (7U) |
Typical values that can be used to modify the sample states. The minimum sample state count value is either 6 or 7 depending on the clock ratios. It is fixed to 7 based on the fact that at the lowest ADC conversion clock supported (1 MHz) this extra state will lead to at worst a "1 microsecond" increase in conversion time. At 60 MHz the extra sample state will add 16.7 ns to the conversion time.
| #define ADC_SAMPLE_STATE_HOLD_COUNT_DEFAULT (24U) |
Default sample and hold states
| #define ADC_SAMPLE_STATE_HOLD_COUNT_MIN (4U) |
Typical values that can be used for the sample and hold counts for the channels 0-2 Minimum sample and hold states
| ssp_err_t R_ADC_Calibrate | ( | adc_ctrl_t *const | p_api_ctrl, |
| void *const | p_extend | ||
| ) |
This function initiates calibration of the ADC on supported MCUs. Calibration will take a minimum of 24 milliseconds at 32 MHz PCLKB and ADCLK. If ADC interrupts are enabled, a notification is provided via callback when calibration is complete. Otherwise, if the ADC interrupts are disabled then no notification will be provided and the application must check calibration status using infoGet() to determine if the calibration is complete before using the ADC API.Interrupts are enabled in adc_api_t::scanStatusGet().
| [in] | p_api_ctrl | Pointer to control handle structure |
| [in] | p_extend | Unused argument. Pass NULL. |
| SSP_SUCCESS | Calibration successfully initiated. |
| SSP_ERR_INVALID_HW_CONDITION | Hardware is in invalid state to perform calibration due to ongoing scan or scan trigger is enabled. |
| SSP_ERR_UNSUPPORTED | Calibration not supported on this MCU. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
Perform parameter checking
ADC Calibration can only happen if there is no ongoing scan and if the scan trigger is disabled
Set the normal mode interrupt request to occur when calibration is complete
Initiate calibration
Return the unsupported error.
| ssp_err_t R_ADC_CheckScanDone | ( | adc_ctrl_t * | p_api_ctrl | ) |
This function returns the status of any scan process that was started. On supported MCUs, the status of the ADC calibration is returned.
| SSP_SUCCESS | Successful; the scan is complete. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_IN_USE | Running scan or calibration is still in progress. |
Perform parameter checking
Ensure ADC Unit is already open
Read status of ADC calibration and return busy status if calibration is ongoing
Read the status of the ADST bit
Return the error code
| ssp_err_t R_ADC_Close | ( | adc_ctrl_t * | p_api_ctrl | ) |
This function ends any scan in progress, disables interrupts, and removes power to the A/D peripheral.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
Perform parameter checking
Verify that the ADC is already open
Mark driver as closed
Perform hardware stop for the specific unit
Release the lock
Return the error code
| ssp_err_t R_ADC_InfoGet | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_info_t * | p_adc_info | ||
| ) |
This function returns the address of the lowest number configured channel and the total number of bytes to be read in order to read the results of the configured channels and return the ELC Event name. If no channels are configured, then a length of 0 is returned. This function retrieves the temperature sensor slope. It also returns the calibration data for the sensor if available on this MCU otherwise an invalid calibration data of 0xFFFFFFFF will be returned.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
Verify the parameters are valid
Return an error if the parameter check failed
Get a pointer to the base register for the current unit
Retrieve the scan mask of active channels from the control structure
If at least one channel is configured, determine the highest and lowest configured channels
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.
If no channels are configured, set the return length 0
Specify the peripheral name in the ELC list
Verify the return value from fmi event information
Set Temp Sensor calibration data to invalid value
If calibration register is available, retrieve it from the MCU
Provide the previously retrieved slope information
| ssp_err_t R_ADC_OffsetSet | ( | adc_ctrl_t *const | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| int32_t | offset | ||
| ) |
adc_api_t::offsetSet is not supported on the ADC.
Return the unsupported error.
| ssp_err_t R_ADC_Open | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_cfg_t const *const | p_cfg | ||
| ) |
The Open function applies power to the A/D peripheral, sets the operational mode, trigger sources, interrupt priority, and configurations for the peripheral as a whole. If interrupt priority is non-zero in BSP_IRQ_Cfg.h, the function takes a callback function pointer for notifying the user at interrupt level whenever a scan has completed. On MCUs where calibration is possible, this function will only return after calibration is completed if enabled in the user configuration. The calibration times vary depending on PCLKB and ADCLK.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl or p_cfg is NULL. |
| SSP_ERR_INVALID_ARGUMENT | Mode or element of p_cfg structure has invalid value or is illegal based on mode. |
| SSP_ERR_IN_USE | Calibration timed out. |
Perform parameter checking
Verify this unit has not already been initialized
Set all p_ctrl fields prior to using it in any functions
Save callback function pointer
Store the Unit number into the control structure
Store the user context into the control structure
Store the mode into the control structure
Store the alignment into the control structure
Save the regular mode/Group A trigger in the internal control block
Save the context
Store the voltage reference into the control structure
Store the over_current into the control structure
pga0 setting
pga1 setting
pga2 setting
Confirm the requested unit exists on this MCU and record available channels.
Lock specified ADC channel
Retrieve temperature sensor information into control block
Set ADC and Temperature sensors to a stop state
Initialize the hardware based on the configuration
Set ADC and Temperature sensors to a stop state
Configure PGA for the supported MCU's
Invalid scan mask (initialized for later).
Mark driver as opened by initializing it to "RADC" in its ASCII equivalent for this unit.
Return the error code
| ssp_err_t R_ADC_Read | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| adc_data_size_t *const | p_data | ||
| ) |
This function reads conversion results from a single channel or sensor register.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_INVALID_POINTER | The parameter p_data is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
Perform parameter checking
Verify that the ADC is already open
Get pointer to appropriate base address. This is repeated here in case parameter checking is disabled.
Read the data from the requested ADC conversion register and return it
Return the error code
| ssp_err_t R_ADC_Read32 | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_register_t const | reg_id, | ||
| uint32_t *const | p_data | ||
| ) |
This function reads conversion results from a single channel or sensor register into a 32-bit result.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_INVALID_POINTER | The parameter p_data is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
Read the 16-bit result.
Left shift the result into the upper 16 bits if the unit is configured for left alignment.
| ssp_err_t R_ADC_ScanConfigure | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_channel_cfg_t const *const | p_channel_cfg | ||
| ) |
Configure the ADC scan parameters. Channel specific settings are set in this function.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl or p_channel_cfg is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
Perform parameter checking
Ensure ADC Unit is already open
Configure the hardware based on the configuration
Save the scan mask locally; this is required for the infoGet function
Return the error code
| ssp_err_t R_ADC_ScanStart | ( | adc_ctrl_t * | p_api_ctrl | ) |
This function starts a software scan or enables the hardware trigger for a scan depending on how the triggers were configured in the Open() call. If the Unit was configured for hardware triggering, then this function simply allows the trigger signal (hardware or software) to get to the ADC Unit. The function is not able to control the generation of the trigger itself. If the Unit was configured for software triggering, then this function starts the software triggered scan.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_IN_USE | Running scan is still in progress |
Perform parameter checking
Ensure ADC Unit is already open
If the the normal/GroupA trigger is not set to software, then that the Unit is configured for hardware triggering
Otherwise, enable software triggering
Check to see if there is an ongoing scan else start the scan
Return the error code
| ssp_err_t R_ADC_ScanStop | ( | adc_ctrl_t * | p_api_ctrl | ) |
This function stops the software scan or disables the Unit from being triggered by the hardware trigger (internal or external) based on what type of trigger the unit was configured for in the Open() function. Stopping a hardware triggered scan via this function does not abort an ongoing scan, but prevents the next scan from occurring. Stopping a software triggered scan aborts an ongoing scan.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
Perform parameter checking
Ensure ADC Unit is already open
If the trigger is not software scan, then disallow hardware triggering
Otherwise, disable software triggering
Return the error code
| ssp_err_t R_ADC_SetSampleStateCount | ( | adc_ctrl_t * | p_api_ctrl, |
| adc_sample_state_t * | p_sample | ||
| ) |
Set the sample state count for individual channels. This only needs to be set for special use cases. Normally, use the default values out of Reset.
| SSP_SUCCESS | Call successful. |
| SSP_ERR_ASSERTION | The parameter p_api_ctrl or p_sample is NULL. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
Perform parameter checking
Ensure ADC Unit is already open
Set the sample state count for the specified register
Return the error code
| ssp_err_t R_ADC_VersionGet | ( | ssp_version_t *const | p_version | ) |
Retrieve the API version number.
| SSP_SUCCESS | Successful return. |
| SSP_ERR_ASSERTION | The parameter p_version is NULL. |
Return the version number