hal_adc_sd24b.h
Go to the documentation of this file.
1 <EMDC_COPYRIGHT>
2 //#############################################################################
3 //
9 <EMDC_DEVICE_NAME>
12 //#############################################################################
13 
14 #ifndef HAL_ADC_H_
15 #define HAL_ADC_H_
16 
17 #include "sd24_b.h"
18 #include <stdint.h>
19 #include <stdbool.h>
20 
21 //*****************************************************************************
22 // defines
23 //*****************************************************************************
24 
26 #define HAL_ADC_CONV_INVALID_INDEX 0xFF
27 #define HAL_ADC_MAX_MOD_FREQ 2097152L
29 #define HAL_ADC_V_ARRAY_LENGTH 4
31 #define HAL_ADC_I_ARRAY_LENGTH 4
33 
34 //******************************************************************************
35 // DO NOT MODIFY THESE DEFINES
36 //******************************************************************************
38 #define HAL_ADC_V_MASK (HAL_ADC_V_ARRAY_LENGTH-1)
39 #define HAL_ADC_I_MASK (HAL_ADC_I_ARRAY_LENGTH-1)
41 
42 //*****************************************************************************
43 //
44 // The following are values are used as masks for the chReadStatus global
45 // variable to keep track of what channels have been read.
46 //
47 //*****************************************************************************
48 #define HAL_ADC_CH0_READ (BIT0)
49 #define HAL_ADC_CH1_READ (BIT1)
50 #define HAL_ADC_CH2_READ (BIT2)
51 #define HAL_ADC_CH3_READ (BIT3)
52 #define HAL_ADC_CH4_READ (BIT4)
53 #define HAL_ADC_CH5_READ (BIT5)
54 #define HAL_ADC_CH6_READ (BIT6)
55 #define HAL_ADC_CH7_READ (BIT7)
56 
57 //*****************************************************************************
58 //
59 // The following are values are used by HAL_ADC_setClockDividers() function
60 // to set the clockPreDivider and clockDivider. The formula
61 // SMCLK / (OSR * sampleFreq) should include one of the values below.
62 //
63 //*****************************************************************************
64 #define HAL_ADC_CLOCK_MULT_4 4
65 #define HAL_ADC_CLOCK_MULT_8 8
66 #define HAL_ADC_CLOCK_MULT_12 12
67 #define HAL_ADC_CLOCK_MULT_16 16
68 #define HAL_ADC_CLOCK_MULT_24 24
69 #define HAL_ADC_CLOCK_MULT_32 32
70 #define HAL_ADC_CLOCK_MULT_64 64
71 #define HAL_ADC_CLOCK_MULT_96 96
72 #define HAL_ADC_CLOCK_MULT_128 128
73 #define HAL_ADC_CLOCK_MULT_192 192
74 #define HAL_ADC_CLOCK_MULT_384 384
75 
76 //*****************************************************************************
77 //
78 // The following are values that can be passed to the clockPreDivider parameter
79 // for functions: SD24_B_init();
80 //
81 //*****************************************************************************
82 #define HAL_ADC_SD24PDIV_MULT_4 (SD24_B_PRECLOCKDIVIDER_4)
83 #define HAL_ADC_SD24PDIV_MULT_8 (SD24_B_PRECLOCKDIVIDER_4)
84 #define HAL_ADC_SD24PDIV_MULT_12 (SD24_B_PRECLOCKDIVIDER_4)
85 #define HAL_ADC_SD24PDIV_MULT_16 (SD24_B_PRECLOCKDIVIDER_4)
86 #define HAL_ADC_SD24PDIV_MULT_24 (SD24_B_PRECLOCKDIVIDER_4)
87 #define HAL_ADC_SD24PDIV_MULT_32 (SD24_B_PRECLOCKDIVIDER_4)
88 #define HAL_ADC_SD24PDIV_MULT_48 (SD24_B_PRECLOCKDIVIDER_4)
89 #define HAL_ADC_SD24PDIV_MULT_64 (SD24_B_PRECLOCKDIVIDER_4)
90 #define HAL_ADC_SD24PDIV_MULT_96 (SD24_B_PRECLOCKDIVIDER_4)
91 #define HAL_ADC_SD24PDIV_MULT_128 (SD24_B_PRECLOCKDIVIDER_4)
92 #define HAL_ADC_SD24PDIV_MULT_192 (SD24_B_PRECLOCKDIVIDER_8)
93 #define HAL_ADC_SD24PDIV_MULT_384 (SD24_B_PRECLOCKDIVIDER_128)
94 
95 //*****************************************************************************
96 //
97 // The following are values that can be passed to the clockDivider parameter
98 // for functions: SD24_B_init();
99 //
100 //*****************************************************************************
101 #define HAL_ADC_SD24DIV_MULT_4 (SD24_B_CLOCKDIVIDER_1)
102 #define HAL_ADC_SD24DIV_MULT_8 (SD24_B_CLOCKDIVIDER_2)
103 #define HAL_ADC_SD24DIV_MULT_12 (SD24_B_CLOCKDIVIDER_3)
104 #define HAL_ADC_SD24DIV_MULT_16 (SD24_B_CLOCKDIVIDER_4)
105 #define HAL_ADC_SD24DIV_MULT_24 (SD24_B_CLOCKDIVIDER_6)
106 #define HAL_ADC_SD24DIV_MULT_32 (SD24_B_CLOCKDIVIDER_8)
107 #define HAL_ADC_SD24DIV_MULT_48 (SD24_B_CLOCKDIVIDER_12)
108 #define HAL_ADC_SD24DIV_MULT_64 (SD24_B_CLOCKDIVIDER_16)
109 #define HAL_ADC_SD24DIV_MULT_96 (SD24_B_CLOCKDIVIDER_24)
110 #define HAL_ADC_SD24DIV_MULT_128 (SD24_B_CLOCKDIVIDER_32)
111 #define HAL_ADC_SD24DIV_MULT_192 (SD24_B_CLOCKDIVIDER_24)
112 #define HAL_ADC_SD24DIV_MULT_384 (SD24_B_CLOCKDIVIDER_3)
113 
114 //*****************************************************************************
115 //
116 // The following are values that can be passed to the sampleFreq parameter
117 // for functions: HAL_ADC_init()
118 //
119 //*****************************************************************************
120 #define HAL_ADC_FREQ_2048_HZ 2048
121 #define HAL_ADC_FREQ_4096_HZ 4096
122 #define HAL_ADC_FREQ_8192_HZ 8192
123 #define HAL_ADC_FREQ_16384_HZ 16384
124 
125 //*****************************************************************************
126 //
127 // The following are values are used as mask for the phaseDataReady global
128 // variable to trigger the foreground process.
129 //
130 //*****************************************************************************
131 #define HAL_ADC_PHASE_NO_DATA_READY 0x00
132 #define HAL_ADC_PHASE_A_DATA_READY 0x01
133 #define HAL_ADC_PHASE_B_DATA_READY 0x02
134 #define HAL_ADC_PHASE_C_DATA_READY 0x04
135 #define HAL_ADC_PHASE_D_DATA_READY 0x08
136 #define HAL_ADC_PHASE_E_DATA_READY 0x10
137 #define HAL_ADC_PHASE_F_DATA_READY 0x20
138 #define HAL_ADC_PHASE_NEUTRAL_DATA_READY 0x40
139 #define HAL_ADC_PHASE_TOTAL_DATA_READY 0x80
140 
141 //*****************************************************************************
142 // typedefs
143 //*****************************************************************************
144 
149 {
160 
164 {
165  uint8_t gain;
173  uint16_t preload;
175  uint8_t converter;
183  uint8_t alignment;
189 
193 {
194  uint32_t SMCLKFrequency;
196  uint16_t overSampleRatio;
204  uint16_t sampleFreq;
211  SD24_B_initParam *sd24Param;
220 
221 //*****************************************************************************
222 // the function prototypes
223 //*****************************************************************************
224 
225 //*****************************************************************************
226 //
229 //
230 //******************************************************************************
239 
247 
255 
263 
272 
279 extern void HAL_ADC_clearVariables(uint8_t phase);
280 
281 //*****************************************************************************
282 // globals
283 //*****************************************************************************
284 
285 extern volatile uint8_t phaseDataReady;
286 
288 
289 //******************************************************************************
290 //
291 // Close the Doxygen group.
293 //
294 //******************************************************************************
295 
296 #endif
uint16_t preload
Preload of the Sigma Delta 24 Channel.
Definition: hal_adc_sd24b.h:173
uint16_t overSampleRatio
Definition: hal_adc_sd24b.h:196
volatile uint8_t phaseDataReady
uint8_t alignment
Definition: hal_adc_sd24b.h:183
void HAL_ADC_enableInterrupts(HAL_ADC_SD24_B_Configuration *config)
The following API enables the interrupt for the master converter.
struct _HAL_ADC_SD24_B_Channel_ HAL_ADC_SD24_B_Channel
Contains the SD24 Channel Configuration.
struct _HAL_ADC_SD24_B_Configuration_ HAL_ADC_SD24_B_Configuration
Contains the SD24 Configuration.
enum _HAL_ADC_message_code_ HAL_ADC_message_code
The following enumeration contain all possible HAL_ADC driver return message codes.
Definition: hal_adc_sd24b.h:153
uint8_t converter
Definition: hal_adc_sd24b.h:175
uint32_t SMCLKFrequency
Sub-System Clock (SMCLK) Frequency in Hz.
Definition: hal_adc_sd24b.h:194
HAL_ADC_SD24_B_Channel * adcChannelPtr
The highest converter used to start / stop conversions.
Definition: hal_adc_sd24b.h:215
Definition: hal_adc_sd24b.h:150
uint16_t sampleFreq
Definition: hal_adc_sd24b.h:204
void HAL_ADC_clearVariables(uint8_t phase)
The following API clears all the global variables used in the ISR.)
HAL_ADC_SD24_B_Configuration halAdcConfig
uint8_t gain
Definition: hal_adc_sd24b.h:165
void HAL_ADC_startConversion(HAL_ADC_SD24_B_Configuration *config)
The following API starts the enabled converters.
Contains the SD24 Configuration.
Definition: hal_adc_sd24b.h:192
_HAL_ADC_message_code_
The following enumeration contain all possible HAL_ADC driver return message codes.
Definition: hal_adc_sd24.h:94
enum _HAL_ADC_message_code_ HAL_ADC_message_code
The following enumeration contain all possible HAL_ADC driver return message codes.
uint8_t adcChannelLength
Pointer to the location where the channel configuration is stored.
Definition: hal_adc_sd24b.h:217
uint8_t masterConverter
Pointer to struct for SD24_B initialization.
Definition: hal_adc_sd24b.h:213
void HAL_ADC_stopConversion(HAL_ADC_SD24_B_Configuration *config)
The following API stops the enabled converters.
SD24_B_initParam * sd24Param
Definition: hal_adc_sd24b.h:211
void HAL_ADC_disableInterrupts(HAL_ADC_SD24_B_Configuration *config)
The following API disables the interrupt for all the channels initialized in adcChannelArray (located...
HAL_ADC_message_code HAL_ADC_init(HAL_ADC_SD24_B_Configuration *config)
The following API configures SD24_B module based on user configuration files "emSwLib_userConfig.c" and "emSwLib_userConfig.h".
Contains the SD24 Channel Configuration.
Definition: hal_adc_sd24b.h:163
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale