RX Family
ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20
Page 27 of 74
Dec 01, 2016
typedef
struct
st_adc_cfg
{
adc_speed_t conv_speed;
// ADCSR.ADHSC, rx230 has two
// conversion speeds
adc_align_t alignment;
// ADCER.ADRFMT, Left or Right
// alignment,ignored if addition used
adc_add_t add_cnt;
// ADADC.ADC, Addition/average
// count select.
adc_clear_t clearing;
// ADCER.ACE, Automatic clearing
// enable/disable after read
adc_trig_t trigger;
// ADSTRGR.TRSA, default and Group A
// trigger source
adc_trig_t trigger_groupb;
// valid only for group modes
uint8_t priority;
// for S12ADIO int; 1=lo 15=hi 0=off/polled
uint8_t priority_groupb;
// S12GBADI interrupt priority; 0-15
} adc_cfg_t;
/***** ADC_CONTROL() ARGUMENT DEFINITIONS *****/
typedef
enum
e_adc_cmd
{
// Commands for special hardware configurations
ADC_CMD_USE_VREFL0,
// Low reference. Default is to use AVSS0.
ADC_CMD_USE_VREFH0,
// High reference. Default is to use AVCC0.
ADC_CMD_SET_DDA_STATE_CNT,
// For Disconnect Detection Assist
ADC_CMD_SET_SAMPLE_STATE_CNT,
// Set the conversion time
// Command to configure channels, sensors, and comparator
ADC_CMD_ENABLE_CHANS,
// Configure channels to scan
ADC_CMD_ENABLE_TEMP_SENSOR,
// "configure" temperature sensor
ADC_CMD_ENABLE_VOLT_SENSOR,
// "configure" internal ref voltage sensor
ADC_CMD_EN_COMPARATOR_LEVEL,
// Enable comparator for threshold compare
ADC_CMD_EN_COMPARATOR_WINDOW,
// Enable comparator for range compare
// Commands to enable hardware triggers or cause software trigger
ADC_CMD_ENABLE_TRIG,
// ADCSR.TRGE=1 for sync/asynchronous
// triggers
ADC_CMD_SCAN_NOW,
// Software trigger start scan
// Commands to poll for scan completion and comparator results
ADC_CMD_CHECK_SCAN_DONE,
// For Normal or GroupA scan
ADC_CMD_CHECK_SCAN_DONE_GROUPA,
ADC_CMD_CHECK_SCAN_DONE_GROUPB,
ADC_CMD_CHECK_CONDITION_MET,
// comparator condition
// Advanced control commands
ADC_CMD_DISABLE_TRIG,
// ADCSR.TRGE=0 for sync/async trigs
ADC_CMD_DISABLE_INT,
// interrupt disable; ADCSR.ADIE=0
ADC_CMD_ENABLE_INT,
// interrupt enable; ADCSR.ADIE=1
ADC_CMD_DISABLE_INT_GROUPB,
// interrupt disable; ADCSR.GBADIE=0
ADC_CMD_ENABLE_INT_GROUPB,
// interrupt enable; ADCSR.GBADIE=1
} adc_cmd_t;
/* for ADC_CMD_SET_DDA_STATE_CNT */
typedef
enum
e_adc_charge
// Disconnection Detection Assist (DDA)
{
ADC_DDA_DISCHARGE = 0x00,