|
SmartSnippets DA1459x SDK
|
Go to the documentation of this file.
45 #if dg_configUSE_HW_GPADC
63 typedef void * HW_GPADC_ID;
81 #define HW_GPADC_RESULT_NOB (16U)
87 #define HW_GPADC_DEFAULT_ENOB (10U)
93 #define HW_GPADC_UNUSED_BITS (HW_GPADC_RESULT_NOB - HW_GPADC_DEFAULT_ENOB)
100 #define HW_GPADC_MID_SCALE_ADC (1 << (HW_GPADC_RESULT_NOB - 1))
107 #define HW_GPADC_OFFSET_RESET 0x200
115 #define HW_GPADC_DMA_SUPPORT dg_configGPADC_DMA_SUPPORT
144 #if HW_GPADC_DMA_SUPPORT
161 uint16 irq_nr_of_trans;
198 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_CONT, !!enabled);
209 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_CONT);
249 REG_SETF(GPADC, GP_ADC_CTRL2_REG, GP_ADC_CONV_NRS, n_samples);
262 return REG_GETF(GPADC, GP_ADC_CTRL2_REG, GP_ADC_CONV_NRS);
278 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_MUTE, !!enabled);
291 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_MUTE);
304 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_SIGN, !!enabled);
315 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_SIGN);
327 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_CHOP, !!enabled);
338 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_CHOP);
350 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_MINT, !!enabled);
361 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_MINT);
374 REG_SETF(GPADC, GP_ADC_CTRL2_REG, GP_ADC_I20U, !!enabled);
387 return REG_GETF(GPADC, GP_ADC_CTRL2_REG, GP_ADC_I20U);
402 REG_SETF(GPADC, GP_ADC_CTRL3_REG, GP_ADC_INTERVAL, mult);
415 return REG_GETF(GPADC, GP_ADC_CTRL3_REG, GP_ADC_INTERVAL);
426 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_DMA_EN, !!enabled);
437 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_DMA_EN);
471 GPADC->GP_ADC_OFFP_REG = offset &
REG_MSK(GPADC, GP_ADC_OFFP_REG, GP_ADC_OFFP);
484 return GPADC->GP_ADC_OFFP_REG &
REG_MSK(GPADC, GP_ADC_OFFP_REG, GP_ADC_OFFP);
502 GPADC->GP_ADC_OFFN_REG = offset &
REG_MSK(GPADC, GP_ADC_OFFN_REG, GP_ADC_OFFN);
516 return GPADC->GP_ADC_OFFN_REG &
REG_MSK(GPADC, GP_ADC_OFFN_REG, GP_ADC_OFFN);
564 return ((
high - low + ((uint16_t)(
high - low) >> 2 )) - UINT16_MAX);
580 return ((int16_t)((9 * low) -
high) >> 3);
596 return (((
high - low) + ((uint16_t)(
high - low) >> 2)) - UINT16_MAX);
612 return (low +
high) >> 1;
725 GPADC->GP_ADC_CLEAR_INT_REG = 1;
766 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_EN);
779 REG_SETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_START, 1);
790 return REG_GETF(GPADC, GP_ADC_CTRL_REG, GP_ADC_START);
804 return GPADC->GP_ADC_RESULT_REG;
uint16_t hw_gpadc_apply_correction(const hw_gpadc_config_t *cfg, uint16_t raw)
Apply a fine trimming algorithm to the conversion result.
Definition of API for the DMA Low Level Driver.
__STATIC_INLINE HW_GPADC_INPUT_MODE hw_gpadc_get_input_mode(void)
Get the current input mode.
Definition: hw_gpadc.h:228
__STATIC_INLINE void hw_gpadc_clear_interrupt(void)
Clear interrupt.
Definition: hw_gpadc.h:720
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
bool hw_gpadc_read(uint32_t nof_conv, uint16_t *out_buf, hw_gpadc_read_cb cb, void *user_data)
Generic read function Follows.
#define REG_CLR_BIT(base, reg, field)
Clear a bit of a register.
Definition: sdk_defs.h:781
Definition: hw_gpadc.h:121
Definition: hw_gpadc.h:138
__STATIC_INLINE bool hw_gpadc_get_continuous(void)
Get continuous mode state.
Definition: hw_gpadc.h:206
Definition: hw_gpadc.h:139
#define REG_SET_BIT(base, reg, field)
Set a bit of a register.
Definition: sdk_defs.h:766
__STATIC_INLINE uint8_t hw_gpadc_get_interval(void)
Get the current interval between conversions in continuous mode.
Definition: hw_gpadc.h:412
void hw_gpadc_configure(const hw_gpadc_config_t *cfg)
Configure ADC.
__STATIC_INLINE void hw_gpadc_set_ldo_constant_current(bool enabled)
Set state of constant 20uA load current on ADC LDO output.
Definition: hw_gpadc.h:371
Calibration Data - (Temperature, 16-bit ADC value) pair.
Definition: hw_gpadc.h:919
#define ASSERT_ERROR(a)
Assert as error macro.
Definition: sdk_defs.h:422
__STATIC_INLINE uint16_t hw_gpadc_get_offset_negative(void)
Get the current offset adjustment for negative ADC array.
Definition: hw_gpadc.h:512
__STATIC_INLINE void hw_gpadc_set_mute(bool enabled)
Set input mute state.
Definition: hw_gpadc.h:275
__STATIC_INLINE HW_GPADC_OVERSAMPLING hw_gpadc_get_oversampling(void)
Get the current oversampling.
Definition: hw_gpadc.h:259
__STATIC_INLINE int16_t hw_gpadc_calculate_single_ended_gain_error(int16_t low, int16_t high)
Calculate Single Ended ADC Gain Error from two points.
Definition: hw_gpadc.h:560
void hw_gpadc_store_se_gain_error(int16_t single)
Store Single Ended ADC Gain Error.
Central include header file with platform definitions.
__STATIC_INLINE void hw_gpadc_set_sign_change(bool enabled)
Set input and output sign change.
Definition: hw_gpadc.h:301
HW_GPADC_INPUT_MODE
ADC input mode.
Definition: hw_gpadc.h:120
__STATIC_INLINE uint16_t hw_gpadc_get_raw_value(void)
Get raw ADC value.
Definition: hw_gpadc.h:799
int16_t hw_gpadc_get_single_ended_gain_error(void)
Get single ended ADC Gain Error.
__STATIC_INLINE void hw_gpadc_start(void)
Start conversion.
Definition: hw_gpadc.h:774
Definition: hw_gpadc.h:135
void(* hw_gpadc_interrupt_cb)(void)
ADC interrupt handler.
Definition: hw_gpadc.h:68
void hw_gpadc_abort_read(void)
Stop conversions.
Definition of API for the GPADC Low Level Driver.
__STATIC_INLINE void hw_gpadc_set_offset_positive(uint16_t offset)
Set offset adjustment for positive ADC array. This register offers a coarse offset calibration,...
Definition: hw_gpadc.h:467
__STATIC_INLINE int16_t hw_gpadc_calculate_differential_gain_error(int16_t low, int16_t high)
Calculate Differential ADC Gain Error from two points.
Definition: hw_gpadc.h:592
__STATIC_INLINE void hw_gpadc_set_continuous(bool enabled)
Set continuous mode.
Definition: hw_gpadc.h:195
HW_DMA_CHANNEL
DMA channel number.
Definition: hw_dma.h:62
__STATIC_INLINE void hw_gpadc_adc_measure(void)
Start the ADC conversion engine, providing a measurement.
Definition: hw_gpadc.h:827
__STATIC_INLINE void hw_gpadc_set_interval(uint8_t mult)
Set interval between conversions in continuous mode.
Definition: hw_gpadc.h:399
__STATIC_INLINE int16_t hw_gpadc_calculate_differential_offset_error(int16_t low, int16_t high)
Calculate Differential ADC Offset Error from two points.
Definition: hw_gpadc.h:608
void hw_gpadc_unregister_interrupt_no_clear(void)
Unregister interrupt handler without clearing the ADC engine interrupt. Only the NVIC interrupt is di...
__STATIC_INLINE void hw_gpadc_set_input_mode(HW_GPADC_INPUT_MODE mode)
Set input mode.
Definition: hw_gpadc.h:217
Definition: hw_gpadc.h:137
__STATIC_INLINE uint16_t hw_gpadc_get_offset_positive(void)
Get the current offset adjustment for positive ADC array.
Definition: hw_gpadc.h:480
void hw_gpadc_offset_calibrate(void)
Perform coarse ADC offset calibration.
__STATIC_INLINE bool hw_gpadc_get_chopping(void)
Get the current chopping state.
Definition: hw_gpadc.h:335
__STATIC_INLINE void hw_gpadc_set_dma_functionality(bool enabled)
Set DMA functionality.
Definition: hw_gpadc.h:423
__STATIC_INLINE void hw_gpadc_enable(void)
Enable ADC.
Definition: hw_gpadc.h:734
HW_DMA_PRIO
Channel priority.
Definition: hw_dma.h:163
void(* hw_gpadc_read_cb)(void *user_data, uint32_t conv_to_go)
ADC callback for read function.
Definition: hw_gpadc.h:74
__STATIC_INLINE bool hw_gpadc_in_progress(void)
Check if conversion is in progress.
Definition: hw_gpadc.h:785
Definition: hw_gpadc.h:134
HW_GPADC_OVERSAMPLING
GPADC oversampling.
Definition: hw_gpadc.h:132
#define REG_MSK(base, reg, field)
Access register field mask.
Definition: sdk_defs.h:583
HW_GPIO_MODE mode
Definition: hw_gpio.h:211
void hw_gpadc_unregister_interrupt(void)
Unregister interrupt handler.
ADC configuration.
Definition: hw_gpadc_v2.h:159
uint16_t hw_gpadc_get_value(void)
Get conversion result value with gain compensation and over sampling.
__STATIC_INLINE bool hw_gpadc_get_ldo_constant_current(void)
Get the current state of constant 20uA load current on ADC LDO output.
Definition: hw_gpadc.h:384
void hw_gpadc_register_interrupt(hw_gpadc_interrupt_cb cb)
Register interrupt handler.
__STATIC_INLINE void hw_gpadc_set_mint(bool enabled)
Set masked interrupt.
Definition: hw_gpadc.h:347
__STATIC_INLINE bool hw_gpadc_get_dma_functionality(void)
Get current state of DMA functionality.
Definition: hw_gpadc.h:434
Definition: hw_gpadc.h:136
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
void hw_gpadc_init(const hw_gpadc_config_t *cfg, bool enable)
Initialize ADC.
__STATIC_INLINE void hw_gpadc_set_offset_negative(uint16_t offset)
Set offset adjustment for negative ADC array. This register offers a coarse offset calibration,...
Definition: hw_gpadc.h:498
__STATIC_INLINE void hw_gpadc_disable(void)
Disable ADC.
Definition: hw_gpadc.h:750
Definition: hw_gpadc.h:122
void hw_gpadc_store_diff_gain_error(int16_t diff)
Store Differential ADC Gain Error.
__STATIC_INLINE bool hw_gpadc_get_mint(void)
Get masked interrupt state.
Definition: hw_gpadc.h:358
__STATIC_INLINE bool hw_gpadc_is_enabled(void)
ADC enabled state.
Definition: hw_gpadc.h:761
int16_t hw_gpadc_convert_to_millivolt(const hw_gpadc_config_t *cfg, uint16_t raw)
Convert a GPADC raw measurement to voltage in mVolt. If no configuration is given,...
__STATIC_INLINE bool hw_gpadc_get_sign_change(void)
Get the current input and output sign change.
Definition: hw_gpadc.h:312
__STATIC_INLINE void hw_gpadc_set_oversampling(HW_GPADC_OVERSAMPLING n_samples)
Set oversampling.
Definition: hw_gpadc.h:246
void hw_gpadc_store_diff_offset_error(int16_t diff)
Store Differential ADC Offset Error.
void hw_gpadc_store_se_offset_error(int16_t single)
Store Single Ended ADC Offset Error.
Definition: hw_gpadc.h:140
bool high
Definition: hw_gpio.h:213
__STATIC_INLINE bool hw_gpadc_get_mute(void)
Get the current input mute state.
Definition: hw_gpadc.h:288
__STATIC_INLINE void hw_gpadc_set_chopping(bool enabled)
Set chopping state.
Definition: hw_gpadc.h:324
__STATIC_INLINE int16_t hw_gpadc_calculate_single_ended_offset_error(int16_t low, int16_t high)
Calculate Single Ended ADC Offset Error from two points.
Definition: hw_gpadc.h:576
Definition: hw_gpadc.h:133
bool hw_gpadc_pre_check_for_gain_error(void)
Check the availability of ADC Gain Error.