RX Family
ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20
Page 53 of 74
Dec 01, 2016
3.2
R_ADC_Open()
This function applies power to the A/D peripheral, sets the operational mode, trigger sources, interrupt priority, and
configurations common to all channels and sensors. If interrupt priority is non-zero, the function takes a callback
function pointer for notifying the user at interrupt level whenever a scan has completed or comparator condition met.
The function initializes the S12AD FIT module. This function must be called before calling any other API functions.
Format
adc_err_t R_ADC_Open(uint8_t unit,
adc_mode_t const mode,
adc_cfg_t * const p_cfg,
void (* const p_callback)(void *p_args));
Parameters
unit
0 or 1. For MCUs with only one unit 0 should be passed (only the RX64M/RX71M/RX65x have 2 units).
mode
Operational mode. See type
adc_mode_t
in section 2.10 for the MCU being used.
The mode indicates the type of scan to be performed. For ADC_MODE_SS_MULTI_CH_
GROUPED_DBLTRIG_A, only one channel can be in Group A.
p_cfg
Pointer to configuration structure. See type
adc_cfg_t
in section 2.10 for the MCU being used.
The resolution field uses the
adc_res_t
enum. Lower resolution results in shorter conversion times (RX64M,
RX71M and RX65x).
The .alignment, .clearing, and .conversion fields use the
adc_align_t
,
adc_clear_t
, enums. If addition is
enabled, the .alignment field is ignored.
The .add_cnt field uses the
adc_add_t
enum. The number of samples added applies to all channels and sensors
(except for Temperature sensor on RX210). An individual channel may opt out of any addition using the Control()
function.
The .trigger and .trigger_groupb fields use the
adc_trig_t
enum for trigger sources.
The .priority and .groupb_priority fields use interrupt priority levels ranging from 1 (lowest) to 15 (highest). If the
priority is set to 0, the corresponding interrupt is disabled and the application must poll for the scan to complete
(use Control() function).
p_callback
Optional pointer to function called from interrupt when a scan completes
Return Values
ADC_SUCCESS:
Successful
ADC_ERR_AD_LOCKED:
Open() call is in progress elsewhere
ADC_ERR_AD_NOT_CLOSED: Peripheral is still running in another mode; Perform R_ADC_Close() first
ADC_ERR
_
INVALID_ARG:
mode or element of p_cfg structure has invalid value
ADC_ERR
_
ILLEGAL_ARG: an argument is illegal based upon mode
ADC_ERR_MISSING_PTR:
p_cfg pointer is FIT_NO_PTR/NULL
Properties
Prototyped in file “r_s12ad_rx_if.h”
Description
Applies power to the A/D peripheral, sets the operational mode, trigger sources, interrupt priority, and
configurations common to all channels and sensors. Setting the interrupt priority to 0 indicates that the
application will poll until scanning completes (see Control()). With a non-zero interrupt priority (interrupt