RX Family
ADC Module Using Firmware Integration Technology
R01AN1666EJ0220 Rev. 2.20
Page 32 of 74
Dec 01, 2016
ADC_TRIG_SYNC_TRGAN_OR_UDF4N = 3, // MTUx TRGA or MTU4 underflow
//(complementary PWM mode)
ADC_TRIG_SYNC_TRG0EN = 4, // MTU0 TRGE
ADC_TRIG_SYNC_TRG0FN = 5, // MTU0 TRGF
ADC_TRIG_SYNC_TRG4AN = 6, // MTU4 TADCORA
ADC_TRIG_SYNC_TRG4BN = 7, // MTU4 TADCORB
ADC_TRIG_SYNC_TRG4AN_AND_TRG4BN = 8, // MTU4 TADCORA and MTU4 TADCORB
ADC_TRIG_SYNC_ELC = 9, // ELC
ADC_TRIG_SYNC_TPUTRGAN = 13, // TPUx TRGA
ADC_TRIG_SYNC_TPUTRG0AN = 14, // TPU0 TRGA
ADC_TRIG_SOFTWARE = 15, // software trigger; not for Group modes
// nor double trigger modes
// This is not set to TRSA or TRSB
ADC_TRIG_NONE = 0x3F
}
adc_trig_t;
typedef enum
e_adc_speed
{
ADC_CONVERT_SPEED_DEFAULT = 0,
ADC_CONVERT_SPEED_HIGH = 0,
ADC_CONVERT_CURRENT_LOW = 1
} adc_speed_t;
typedef
struct
st_adc_cfg
{
adc_speed_t conv_speed; // ADCSR.ADHSC, Two conversion speeds
adc_align_t alignment; // ADCER.ADRFMT, L or R align
adc_add_t add_cnt; // ADADC.ADC, Addition/average cnt select.
adc_clear_t clearing; // ADCER.ACE, Auto clearing enable/disable
adc_trig_t trigger; // ADSTRGR.TRSA, default & Grp A trig src
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/async 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,