RX Family
ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20
Page 56 of 74
Dec 01, 2016
3.3
R_ADC_Control()
This function provides commands for enabling channels and sensors and for runtime operations. These include
enabling/disabling trigger sources and interrupts, initiating a software trigger, and checking for scan completion.
Format
adc_err_t R_ADC_Control(uint8_t unit,
adc_cmd_t const cmd,
void * const p_cfg);
Parameters
unit
0 or 1. For MCUs with only one unit 0 should be passed (only the RX64M/RX71M/RX65x have 2 units).
cmd
Command to run. See type
adc_cmd_t
in section 2.10 for the MCU being used.
Some commands require arguments. All other commands should use FIT_NO_PTR/NULL for the
p_cfg
argument.
p_cfg
Pointer to optional configuration structure. FIT_NO_PTR/NULL for most commands. See type
adc_ch_cfg_t
in section 2.10 for the MCU being used.
Return Values
ADC_SUCCESS:
Successful
ADC_ERR_MISSING_PTR:
p_cfg pointer is FIT_NO_PTR/NULL when required as an argument
ADC_ERR
_
INVALID_ARG:
cmd or element of p_cfg structure has invalid value.
ADC_ERR_ILLEGAL_ARG:
cmd is illegal based upon mode
ADC_ERR_SCAN_NOT_DONE:
The requested scan has not completed
ADC_ERR_TRIG_ENABLED:
Cannot configure comparator because scan still running
ADC_ERR_CONDITION_NOT_MET: No channels/sensors met the comparison condition
Properties
Prototyped in file “r_s12ad_rx_if.h”
Description
Provides commands for enabling channels and sensors and for runtime operations. These include enabling/disabling
trigger sources and interrupts, initiating a software trigger, and checking for scan completion.
After an Open() call, the following sequence of Control() commands should be issued (MCU dependent):
1)
Optionally issue commands for special hardware configuration (ADC_CMD_SET_DDA_STATE_CNT and/or
ADC_CMD_SET_SAMPLE_STATE_CNT, ADC_CMD_USE_VREFL0, ADC_CMD_USE_VREFH0).
2)
Issue a command to configure channels, sensors, and comparator
(ADC_CMD_ENABLE_CHANS, ADC_CMD_EN_COMPARATOR_LEVEL, and/or
ADC_CMD_EN_COMPARATOR_WINDOW, ADC_CMD_ENABLE_TEMP_SENSOR,
ADC_CMD_ENABLE_VOLT_SENSOR).
3)
Issue a command to enable hardware triggers or cause a software trigger (ADC_CMD_TRIG_ENABLE or
ADC_CMD_SCAN_NOW).
4)
If polling instead of using interrupts, check for completion of scan or comparator match
(ADC_CMD_CHECK_SCAN_DONE, ADC_CMD_CHECK_SCAN_DONE_GROUPA or
ADC_CMD_CHECK_SCAN_DONE_GROUPB, ADC_CMD_CHECK_CONDITION_MET).
5)
When the scan completes, the converted data is accessed using the Read() function at the application or
interrupt level.
To set values of parameters used in this function, first clear all members of parameters to 0, and then set values.