RTEMS 6.1-rc1
fsl_adc.h
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2020 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_ADC_H_
10#define _FSL_ADC_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
23#define FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
29{
30 kADC_ConversionActiveFlag = ADC_GS_ADACT_MASK,
31 kADC_CalibrationFailedFlag = ADC_GS_CALF_MASK,
33 ADC_GS_AWKST_MASK,
35
40{
43
48{
49 /* This group of enumeration is for internal use which is related to register setting. */
54 /* This group of enumeration is for a public user. */
55 /* For long sample mode. */
60 /* For short sample mode. */
66
71{
74#if !(defined(FSL_FEATURE_ADC_SUPPORT_ALTCLK_REMOVE) && FSL_FEATURE_ADC_SUPPORT_ALTCLK_REMOVE)
76#endif
79
84{
90
94typedef enum _adc_resolution
95{
100
105{
117
122{
129
133typedef struct _adc_config
134{
147
151typedef struct _adc_offest_config
152{
155 uint32_t offsetValue;
157
173{
176 uint16_t value1;
177 uint16_t value2;
179
184{
185 uint32_t channelNumber;
190/*******************************************************************************
191 * API
192 ******************************************************************************/
193#if defined(__cplusplus)
194extern "C" {
195#endif
196
208void ADC_Init(ADC_Type *base, const adc_config_t *config);
209
215void ADC_Deinit(ADC_Type *base);
216
237
265void ADC_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config);
266
275static inline uint32_t ADC_GetChannelConversionValue(ADC_Type *base, uint32_t channelGroup)
276{
277 assert(channelGroup < (uint32_t)FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
278
279 return base->R[channelGroup];
280}
281
299static inline uint32_t ADC_GetChannelStatusFlags(ADC_Type *base, uint32_t channelGroup)
300{
301 assert(channelGroup < (uint32_t)FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
302
303 /* If flag is set,return 1,otherwise, return 0. */
304 return (((base->HS) & (1UL << channelGroup)) >> channelGroup);
305}
306
321
329
336static inline void ADC_EnableDMA(ADC_Type *base, bool enable)
337{
338 if (enable)
339 {
340 base->GC |= ADC_GC_DMAEN_MASK;
341 }
342 else
343 {
344 base->GC &= ~ADC_GC_DMAEN_MASK;
345 }
346}
347
354#if !(defined(FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE) && FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE)
355static inline void ADC_EnableHardwareTrigger(ADC_Type *base, bool enable)
356{
357 if (enable)
358 {
359 base->CFG |= ADC_CFG_ADTRG_MASK;
360 }
361 else
362 {
363 base->CFG &= ~ADC_CFG_ADTRG_MASK;
364 }
365}
366#endif
367
382
394
402static inline uint32_t ADC_GetStatusFlags(ADC_Type *base)
403{
404 return base->GS;
405}
406
413void ADC_ClearStatusFlags(ADC_Type *base, uint32_t mask);
414
419#if defined(__cplusplus)
420}
421#endif
422
427#endif /* _FSL_ADC_H_ */
enum _adc_hardware_compare_mode adc_hardware_compare_mode_t
Converter hardware compare mode.
enum _adc_resolution adc_resolution_t
Converter's resolution.
void ADC_SetHardwareAverageConfig(ADC_Type *base, adc_hardware_average_mode_t mode)
Configures the hardware average mode.
Definition: fsl_adc.c:359
void ADC_SetOffsetConfig(ADC_Type *base, const adc_offest_config_t *config)
Set user defined offset.
Definition: fsl_adc.c:284
struct _adc_offest_config adc_offest_config_t
Converter Offset configuration.
enum _adc_clock_source adc_clock_source_t
Clock source.
_adc_status_flags
Converter's status flags.
Definition: fsl_adc.h:29
status_t ADC_DoAutoCalibration(ADC_Type *base)
Automates the hardware calibration.
Definition: fsl_adc.c:224
_adc_sample_period_mode
Sample time duration.
Definition: fsl_adc.h:48
enum _adc_reference_voltage_source adc_reference_voltage_source_t
Reference voltage source.
_adc_clock_source
Clock source.
Definition: fsl_adc.h:71
void ADC_GetDefaultConfig(adc_config_t *config)
Gets an available pre-defined settings for the converter's configuration.
Definition: fsl_adc.c:142
enum _adc_hardware_average_mode adc_hardware_average_mode_t
Converter hardware average mode.
struct _adc_hardware_compare_config adc_hardware_compare_config_t
ADC hardware compare configuration.
void ADC_ClearStatusFlags(ADC_Type *base, uint32_t mask)
Clears the converter's status falgs.
Definition: fsl_adc.c:382
struct _adc_channel_config adc_channel_config_t
ADC channel conversion configuration.
_adc_reference_voltage_source
Reference voltage source.
Definition: fsl_adc.h:40
void ADC_Deinit(ADC_Type *base)
De-initializes the ADC module.
Definition: fsl_adc.c:114
void ADC_Init(ADC_Type *base, const adc_config_t *config)
Initialize the ADC module.
Definition: fsl_adc.c:64
enum _adc_status_flags adc_status_flags_t
Converter's status flags.
_adc_hardware_compare_mode
Converter hardware compare mode.
Definition: fsl_adc.h:105
_adc_resolution
Converter's resolution.
Definition: fsl_adc.h:95
_adc_clock_drvier
Clock divider for the converter.
Definition: fsl_adc.h:84
void ADC_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config)
Configures the conversion channel.
Definition: fsl_adc.c:189
enum _adc_sample_period_mode adc_sample_period_mode_t
Sample time duration.
_adc_hardware_average_mode
Converter hardware average mode.
Definition: fsl_adc.h:122
enum _adc_clock_drvier adc_clock_driver_t
Clock divider for the converter.
struct _adc_config adc_config_t
Converter configuration.
void ADC_SetHardwareCompareConfig(ADC_Type *base, const adc_hardware_compare_config_t *config)
Configures the hardware compare mode.
Definition: fsl_adc.c:311
@ kADC_ConversionActiveFlag
Definition: fsl_adc.h:30
@ kADC_CalibrationFailedFlag
Definition: fsl_adc.h:31
@ kADC_AsynchronousWakeupInterruptFlag
Definition: fsl_adc.h:32
@ kADC_SamplePeriod8or24Clocks
Definition: fsl_adc.h:53
@ kADC_SamplePeriodShort4Clocks
Definition: fsl_adc.h:62
@ kADC_SamplePeriodLong20Clcoks
Definition: fsl_adc.h:58
@ kADC_SamplePeriodShort8Clocks
Definition: fsl_adc.h:64
@ kADC_SamplePeriod4or16Clocks
Definition: fsl_adc.h:51
@ kADC_SamplePeriodLong16Clcoks
Definition: fsl_adc.h:57
@ kADC_SamplePeriodLong12Clcoks
Definition: fsl_adc.h:56
@ kADC_SamplePeriodShort6Clocks
Definition: fsl_adc.h:63
@ kADC_SamplePeriodShort2Clocks
Definition: fsl_adc.h:61
@ kADC_SamplePeriod2or12Clocks
Definition: fsl_adc.h:50
@ kADC_SamplePeriodLong24Clcoks
Definition: fsl_adc.h:59
@ kADC_SamplePeriod6or20Clocks
Definition: fsl_adc.h:52
@ kADC_ClockSourceALT
Definition: fsl_adc.h:75
@ kADC_ClockSourceIPGDiv2
Definition: fsl_adc.h:73
@ kADC_ClockSourceIPG
Definition: fsl_adc.h:72
@ kADC_ClockSourceAD
Definition: fsl_adc.h:77
@ kADC_ReferenceVoltageSourceAlt0
Definition: fsl_adc.h:41
@ kADC_HardwareCompareMode0
Definition: fsl_adc.h:106
@ kADC_HardwareCompareMode2
Definition: fsl_adc.h:108
@ kADC_HardwareCompareMode1
Definition: fsl_adc.h:107
@ kADC_HardwareCompareMode3
Definition: fsl_adc.h:112
@ kADC_Resolution10Bit
Definition: fsl_adc.h:97
@ kADC_Resolution12Bit
Definition: fsl_adc.h:98
@ kADC_Resolution8Bit
Definition: fsl_adc.h:96
@ kADC_ClockDriver2
Definition: fsl_adc.h:86
@ kADC_ClockDriver1
Definition: fsl_adc.h:85
@ kADC_ClockDriver8
Definition: fsl_adc.h:88
@ kADC_ClockDriver4
Definition: fsl_adc.h:87
@ kADC_HardwareAverageDiasable
Definition: fsl_adc.h:127
@ kADC_HardwareAverageCount8
Definition: fsl_adc.h:124
@ kADC_HardwareAverageCount16
Definition: fsl_adc.h:125
@ kADC_HardwareAverageCount32
Definition: fsl_adc.h:126
@ kADC_HardwareAverageCount4
Definition: fsl_adc.h:123
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
Definition: MIMXRT1052.h:1298
ADC channel conversion configuration.
Definition: fsl_adc.h:184
uint32_t channelNumber
Definition: fsl_adc.h:185
bool enableInterruptOnConversionCompleted
Definition: fsl_adc.h:188
Converter configuration.
Definition: fsl_adc.h:134
bool enableOverWrite
Definition: fsl_adc.h:135
bool enableLowPower
Definition: fsl_adc.h:138
adc_sample_period_mode_t samplePeriodMode
Definition: fsl_adc.h:142
bool enableLongSample
Definition: fsl_adc.h:139
bool enableAsynchronousClockOutput
Definition: fsl_adc.h:140
adc_clock_driver_t clockDriver
Definition: fsl_adc.h:144
adc_resolution_t resolution
Definition: fsl_adc.h:145
adc_reference_voltage_source_t referenceVoltageSource
Definition: fsl_adc.h:141
bool enableHighSpeed
Definition: fsl_adc.h:137
bool enableContinuousConversion
Definition: fsl_adc.h:136
adc_clock_source_t clockSource
Definition: fsl_adc.h:143
ADC hardware compare configuration.
Definition: fsl_adc.h:173
adc_hardware_compare_mode_t hardwareCompareMode
Definition: fsl_adc.h:174
uint16_t value1
Definition: fsl_adc.h:176
uint16_t value2
Definition: fsl_adc.h:177
Converter Offset configuration.
Definition: fsl_adc.h:152
uint32_t offsetValue
Definition: fsl_adc.h:155
bool enableSigned
Definition: fsl_adc.h:153
Definition: deflate.c:114