27#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_ADC_H_
28#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_ADC_H_
47#define MAX_ADC_SLOT_NUM 16
48#define MAX_ADC_FIFO_LEN 16
49#define MAX_ADC_RES_DIV_CH 12
211typedef void (*mxc_adc_complete_cb_t)(
void *req,
int error);
325 void (*callback)(
int,
int));
Registers, Bit Masks and Bit Positions for the ADC Peripheral Module.
#define MXC_S_ADC_CTRL1_AVG_AVG8
Definition: adc_regs.h:189
#define MXC_S_ADC_CTRL1_AVG_AVG32
Definition: adc_regs.h:193
#define MXC_S_ADC_CTRL1_AVG_AVG4
Definition: adc_regs.h:187
#define MXC_S_ADC_CTRL1_AVG_AVG1
Definition: adc_regs.h:183
#define MXC_S_ADC_CTRL1_AVG_AVG16
Definition: adc_regs.h:191
#define MXC_S_ADC_CTRL1_AVG_AVG2
Definition: adc_regs.h:185
#define MXC_V_MCR_ADC_CFG2_CH0_DIV2_50K
Definition: mcr_regs.h:310
#define MXC_V_MCR_ADC_CFG2_CH0_DIV1
Definition: mcr_regs.h:306
#define MXC_V_MCR_ADC_CFG2_CH0_DIV2_5K
Definition: mcr_regs.h:308
mxc_adc_div_lpmode_t lpmode_divder
Divide by 2 control in lpmode.
Definition: adc.h:244
mxc_adc_trig_sel_t hwTrig
HW Trigger Source.
Definition: adc.h:240
uint8_t fifo_threshold
FIFO Threshold Configuration.
Definition: adc.h:242
mxc_adc_chsel_t channel
channel select
Definition: adc.h:229
mxc_adc_divsel_t div
Analog input divider.
Definition: adc.h:230
uint32_t trackCount
Sample Clock High time.
Definition: adc.h:221
mxc_adc_clock_t clock
clock to use
Definition: adc.h:217
mxc_adc_avg_t avg_number
no of samples to average
Definition: adc.h:243
mxc_adc_trig_mode_t trig
trigger mode
Definition: adc.h:239
mxc_adc_dynamic_pullup_t pullup_dyn
Dynamic Pullup.
Definition: adc.h:231
uint32_t idleCount
Sample Clock Low time.
Definition: adc.h:222
mxc_adc_refsel_t ref
ADC reference voltage.
Definition: adc.h:220
mxc_adc_calibration_t cal
skip calibration
Definition: adc.h:219
mxc_adc_clkdiv_t clkdiv
clock divider
Definition: adc.h:218
int8_t dma_channel
The channel to use for DMA-enabled transactions.
Definition: adc.h:246
mxc_adc_conversion_mode_t mode
conversion mode
Definition: adc.h:238
mxc_adc_fifodataformat_t fifo_format
FIFO Data Format.
Definition: adc.h:241
uint8_t num_slots
num of slots in the sequence
Definition: adc.h:245
int MXC_ADC_Configuration(mxc_adc_conversion_req_t *req)
Configures the ADC.
int MXC_ADC_DynamicModeEn(mxc_adc_chsel_t ch)
Enables the ADC Dynamic Power-Up Mode.
mxc_adc_avg_t
Enumeration type for the number of samples to average.
Definition: adc.h:82
mxc_adc_calibration_t
Calibration settings.
Definition: adc.h:127
int MXC_ADC_StartConversion(void)
Initiate configured ADC conversion.
void MXC_ADC_ClearFlags(uint32_t flags)
Clear adc interrupt flags.
int MXC_ADC_InputDividerSelect(mxc_adc_chsel_t ch, mxc_adc_divsel_t div, mxc_adc_dynamic_pullup_t lpEn)
Selects the analog input divider.
mxc_adc_dynamic_pullup_t
Dynamic Divider pullup control.
Definition: adc.h:205
mxc_adc_trig_sel_t
Hardware trigger select options.
Definition: adc.h:143
int MXC_ADC_DisableComparator(mxc_adc_comp_t comp)
Disable the Comparators.
int MXC_ConvertTemperature_ToK(uint16_t tempSensor_Readout, mxc_adc_refsel_t ref, float ext_ref, float *temp_k)
Calculates temperature (in K) from ADC readout.
int MXC_ADC_FIFO_Threshold_Config(uint32_t fifo_threshold)
Configures the ADC FIFO threshold register.
mxc_adc_trig_mode_t
trigger mode settings
Definition: adc.h:135
int MXC_ADC_ComparatorHysteresisDis(mxc_adc_comp_t comp)
Disable comparator hysteresis.
int MXC_ADC_AverageConfig(mxc_adc_avg_t avg_number)
Configures number of sample average in the sequence for each channel.
int MXC_ADC_GetData(int *outdata)
Gets the ADC readout after the ADC conversion.
void MXC_ADC_Clear_ChannelSelect(void)
Clear all channel select registers.
mxc_adc_clkdiv_t
Enumeration type for ADC clock divider.
Definition: adc.h:106
int MXC_ADC_DynamicModeDis(mxc_adc_chsel_t ch)
Disables the ADC Dynamic Power-Up Mode.
void MXC_ADC_EnableConversion(void)
Enables the ADC converter.
int MXC_ConvertTemperature_ToC(uint16_t tempSensor_Readout, mxc_adc_refsel_t ref, float ext_ref, float *temp)
Calculates temperature (in C) from ADC readout.
int MXC_ADC_ReferenceSelect(mxc_adc_refsel_t ref)
Selects the desired reference voltage for the ADC.
int MXC_ADC_EnableComparator(mxc_adc_comp_t comp, mxc_adc_chsel_t negCh, mxc_adc_chsel_t posCh)
Enable the Comparator.
void MAX_ADC_Flush_FIFO(void)
Flushes the ADC FIFO.
void MXC_ADC_SetConversionDelay(int delay)
Set Sample Delay before Continuous Mode Conversion Restart.
int MXC_ADC_SlotConfiguration(mxc_adc_slot_req_t *req, uint32_t slot_length)
Configures ADC slot and channel registers.
int MXC_ADC_StartConversionAsync(mxc_adc_complete_cb_t callback)
Perform a conversion on a specific channel.
mxc_adc_chsel_t
Enumeration type for the ADC Input Channels.
Definition: adc.h:59
int MXC_ADC_Init(mxc_adc_req_t *req)
Performs the ADC startup procedure.
mxc_adc_div_lpmode_t
Divide by 2 control in low power mode.
Definition: adc.h:186
void MXC_ADC_EnableInt(uint32_t flags)
Enable specific ADC interrupts.
uint16_t MXC_ADC_FIFO_Level(void)
Provides the ADC FIFO level.
mxc_adc_conversion_mode_t
trigger mode settings
Definition: adc.h:157
mxc_adc_refsel_t
Reference voltage select type.
Definition: adc.h:176
mxc_adc_comp_t
Definition: adc.h:94
int MXC_ADC_SlotsConfig(mxc_adc_conversion_req_t *req)
Configures number of slots for ADC sequence.
void MXC_ADC_TS_SelectEnable(void)
Enables the temperature sensor.
int MXC_ADC_GetFlags(void)
Get adc interrupt flags.
int MXC_ADC_StartConversionDMA(mxc_adc_conversion_req_t *req, int *data, void(*callback)(int, int))
Perform a conversion on a specific channel using a DMA transfer. DMA channel must be acquired using M...
void MXC_ADC_TS_SelectDisable(void)
Disables the temperature sensor.
mxc_adc_divsel_t
Analog input divider select.
Definition: adc.h:165
void MXC_ADC_TriggerConfig(mxc_adc_conversion_req_t *req)
Configures ADC Trigger to initiate ADC conversion.
int MXC_ConvertTemperature_ToF(uint16_t tempSensor_Readout, mxc_adc_refsel_t ref, float ext_ref, float *temp)
Calculates temperature (in F) from ADC readout.
int MXC_ADC_ComparatorHysteresisEn(mxc_adc_comp_t comp)
Enable comparator hysteresis.
void MXC_ADC_DisableConversion(void)
Disables the ADC converter.
mxc_adc_clock_t
Clock settings.
Definition: adc.h:117
int MXC_ADC_LowPowerModeDividerSelect(mxc_adc_div_lpmode_t div_lpmode)
Configures Divider (0-12 channel) in the low power mode.
int MXC_ADC_Handler(void)
Call this function from the ADC ISR when using Async API functions.
void MXC_ADC_DisableInt(uint32_t flags)
Disable specific ADC interrupts.
int MXC_ADC_Shutdown(void)
Shuts down the ADC.
mxc_adc_fifodataformat_t
Data FIFO data format.
Definition: adc.h:196
void MXC_ADC_ConversionModeConfig(mxc_adc_conversion_req_t *req)
Configures ADC Conversion Mode: Single vs Continuous Conversion.
@ MXC_ADC_AVG_32
Select Channel 5.
Definition: adc.h:88
@ MXC_ADC_AVG_1
Select Channel 0.
Definition: adc.h:83
@ MXC_ADC_AVG_8
Select Channel 3.
Definition: adc.h:86
@ MXC_ADC_AVG_16
Select Channel 4.
Definition: adc.h:87
@ MXC_ADC_AVG_2
Select Channel 1.
Definition: adc.h:84
@ MXC_ADC_AVG_4
Select Channel 2.
Definition: adc.h:85
@ MXC_ADC_SKIP_CAL
Skip calibration on power-up.
Definition: adc.h:128
@ MXC_ADC_EN_CAL
Calibrate on power-up.
Definition: adc.h:129
@ MXC_ADC_PY_DN_DISABLE
Disable Dynamic Divider Pullup.
Definition: adc.h:206
@ MXC_ADC_PY_DN_ENABLE
Enable Dynamic Divider Pullup.
Definition: adc.h:207
@ MXC_ADC_TRIG_SEL_P0_22
GPIO Port 0, Pin 22.
Definition: adc.h:149
@ MXC_ADC_TRIG_SEL_TMR2
Timer 2 Out Rising Edge.
Definition: adc.h:146
@ MXC_ADC_TRIG_SEL_P0_29
GPIO Port 0, Pin 29.
Definition: adc.h:148
@ MXC_ADC_TRIG_SEL_TEMP_SENS
Temperature Sensor Ready.
Definition: adc.h:151
@ MXC_ADC_TRIG_SEL_TMR1
Timer 1 Out Rising Edge.
Definition: adc.h:145
@ MXC_ADC_TRIG_SEL_P1_4
GPIO Port 1, Pin 4.
Definition: adc.h:150
@ MXC_ADC_TRIG_SEL_TMR3
Timer 3 Out Rising Edge.
Definition: adc.h:147
@ MXC_ADC_TRIG_SEL_TMR0
Timer 0 Out Rising edge.
Definition: adc.h:144
@ MXC_ADC_TRIG_SOFTWARE
Software Trigger.
Definition: adc.h:136
@ MXC_ADC_TRIG_HARDWARE
Hardware Trigger.
Definition: adc.h:137
@ MXC_ADC_CLKDIV_16
ADC Scale by 1/16.
Definition: adc.h:110
@ MXC_ADC_CLKDIV_8
ADC Scale by 1/8.
Definition: adc.h:109
@ MXC_ADC_CLKDIV_4
ADC Scale by 1/4.
Definition: adc.h:108
@ MXC_ADC_CLKDIV_2
ADC Scale by 1/2.
Definition: adc.h:107
@ MXC_ADC_CLKDIV_1
ADC Scale by 1x (no scaling)
Definition: adc.h:111
@ MXC_ADC_CH_6
Select Channel 6.
Definition: adc.h:66
@ MXC_ADC_CH_3
Select Channel 3.
Definition: adc.h:63
@ MXC_ADC_CH_0
Select Channel 0.
Definition: adc.h:60
@ MXC_ADC_CH_13
Select Channel 13.
Definition: adc.h:73
@ MXC_ADC_CH_15
Select Channel 15.
Definition: adc.h:75
@ MXC_ADC_CH_1
Select Channel 1.
Definition: adc.h:61
@ MXC_ADC_CH_14
Select Channel 14.
Definition: adc.h:74
@ MXC_ADC_CH_7
Select Channel 7.
Definition: adc.h:67
@ MXC_ADC_CH_5
Select Channel 5.
Definition: adc.h:65
@ MXC_ADC_CH_2
Select Channel 2.
Definition: adc.h:62
@ MXC_ADC_CH_9
Select Channel 9.
Definition: adc.h:69
@ MXC_ADC_CH_10
Select Channel 10.
Definition: adc.h:70
@ MXC_ADC_CH_11
Select Channel 11.
Definition: adc.h:71
@ MXC_ADC_CH_12
Select Channel 12.
Definition: adc.h:72
@ MXC_ADC_CH_4
Select Channel 4.
Definition: adc.h:64
@ MXC_ADC_CH_8
Select Channel 8.
Definition: adc.h:68
@ MXC_ADC_DIV_2_5K_50K_ENABLE
2.5K and 50K divide by 2 enable in lpmode
Definition: adc.h:187
@ MXC_ADC_DIV_2_5K_50K_DISABLE
2.5K and 50K divide by 2 disable in lpmode
Definition: adc.h:190
@ MXC_ADC_DIV_2_5K_DISABLE
2.5K disable and 50K divide by 2 enable in lpmode
Definition: adc.h:188
@ MXC_ADC_DIV_50K_DISABLE
2.5K enable and 50K divide by 2 disable in lpmode
Definition: adc.h:189
@ MXC_ADC_CONTINUOUS_CONV
Hardware Trigger.
Definition: adc.h:159
@ MXC_ADC_ATOMIC_CONV
Software Trigger.
Definition: adc.h:158
@ MXC_ADC_REF_EXT
Use external reference voltage source.
Definition: adc.h:177
@ MXC_ADC_REF_INT_1V25
Use internal 1.25V source.
Definition: adc.h:178
@ MXC_ADC_REF_INT_2V048
Use internal 2.048V souce.
Definition: adc.h:179
@ MXC_ADC_DIV1
No input divider.
Definition: adc.h:166
@ MXC_ADC_DIV2_5K
Divide analog input by two with 5K resistor.
Definition: adc.h:167
@ MXC_ADC_DIV2_50K
Divide analog input by two with 50K resistor.
Definition: adc.h:169
@ MXC_ADC_CLK_HCLK
HCLK CLock.
Definition: adc.h:118
@ MXC_ADC_CLK_IBRO
IBRO Clock.
Definition: adc.h:120
@ MXC_ADC_CLK_EXT
External Clock.
Definition: adc.h:119
@ MXC_ADC_CLK_ERFO
ERFO Clock.
Definition: adc.h:121
@ MXC_ADC_DATA_STATUS
Data(12-bit) plus Status.
Definition: adc.h:197
@ MXC_ADC_DATA
Data(12-bit) only.
Definition: adc.h:198
@ MXC_ADC_RAW_DATA
18-bit raw data
Definition: adc.h:199
ADC Conversion Settings.
Definition: adc.h:237
ADC Settings.
Definition: adc.h:216
ADC Slot Settings.
Definition: adc.h:228
Registers, Bit Masks and Bit Positions for the MCR Peripheral Module.