hal_adc_sd24.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.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 
53 //*****************************************************************************
54 //
55 // The following are values that can be passed to the sampleFreq parameter
56 // for functions: HAL_ADC_init()
57 //
58 //*****************************************************************************
59 #define HAL_ADC_FREQ_4000_HZ (4000)
60 #define HAL_ADC_FREQ_8000_HZ (8000)
61 #define HAL_ADC_FREQ_16000_HZ (16000)
62 
63 //*****************************************************************************
64 //
65 // The following are values are used as mask for the phaseDataReady global
66 // variable to trigger the foreground process.
67 //
68 //*****************************************************************************
69 #define HAL_ADC_PHASE_NO_DATA_READY 0x00
70 #define HAL_ADC_PHASE_A_DATA_READY 0x01
71 #define HAL_ADC_PHASE_B_DATA_READY 0x02
72 #define HAL_ADC_PHASE_C_DATA_READY 0x04
73 #define HAL_ADC_PHASE_NEUTRAL_DATA_READY 0x40
74 #define HAL_ADC_PHASE_TOTAL_DATA_READY 0x80
75 
76 //*****************************************************************************
77 //
78 // The following are values are oversample values used to calculate the
79 // preload initial value.
80 //
81 //*****************************************************************************
82 #define HAL_ADC_OSR_32 (32-1)
83 #define HAL_ADC_OSR_64 (64-1)
84 #define HAL_ADC_OSR_128 (128-1)
85 #define HAL_ADC_OSR_256 (256-1)
86 
87 //*****************************************************************************
88 // typedefs
89 //*****************************************************************************
90 
95 {
102 
106 {
107  uint8_t gain;
115  uint8_t preload;
117  int32_t *samplePtr;
119  uint8_t converter;
128 
132 {
133  uint16_t overSampleRatio;
140  uint16_t sampleFreq;
158 
159 //*****************************************************************************
160 // the function prototypes
161 //*****************************************************************************
162 
163 //*****************************************************************************
164 //
167 //
168 //******************************************************************************
177 
185 
193 
201 
209 
217 
224 extern void HAL_ADC_clearVariables(uint8_t phase);
225 
226 //*****************************************************************************
227 // globals
228 //*****************************************************************************
229 
230 extern volatile uint8_t phaseDataReady;
231 
233 
234 //******************************************************************************
235 //
236 // Close the Doxygen group.
238 //
239 //******************************************************************************
240 
241 #endif
uint8_t preload
Preload of the Sigma Delta 24 Channel- Valid 0x00 to SD24_MAX_PRELOAD.
Definition: hal_adc_sd24.h:115
HAL_ADC_SD24_Channel * adcChannelPtr
The highest converter used to start / stop conversions.
Definition: hal_adc_sd24.h:153
void HAL_ADC_clearVariables(uint8_t phase)
The following API clears all the global variables used in the ISR.)
uint8_t masterConverter
Definition: hal_adc_sd24.h:151
void HAL_ADC_printResult(HAL_ADC_SD24_Configuration *config)
The following API sends the stored results to the GUI.
int32_t * samplePtr
Channel enabled used to initialize the SD24 channel.
Definition: hal_adc_sd24.h:117
uint16_t overSampleRatio
Definition: hal_adc_sd24.h:133
This message code is returned when the input frequency is not supported.
Definition: hal_adc_sd24.h:99
uint8_t converter
Definition: hal_adc_sd24.h:119
void HAL_ADC_enableInterrupt(HAL_ADC_SD24_Configuration *config)
The following API enables the interrupt for the master converter.
Definition: hal_adc_sd24.h:96
uint8_t adcChannelLength
Pointer to the location where the channel configuration is stored.
Definition: hal_adc_sd24.h:155
HAL_ADC_message_code HAL_ADC_init(HAL_ADC_SD24_Configuration *config)
The following API configures SD24 module based on user configuration files "emSwLib_userConfig.c" and "emSwLib_userConfig.h".
struct _HAL_ADC_SD24_Channel_ HAL_ADC_SD24_Channel
Contains the SD24 Channel Configuration.
Contains the SD24 Configuration.
Definition: hal_adc_sd24.h:131
void HAL_ADC_startConversion(HAL_ADC_SD24_Configuration *config)
The following API starts the enabled converters.
uint8_t gain
Definition: hal_adc_sd24.h:107
uint8_t referenceSelect
Definition: hal_adc_sd24.h:146
volatile uint8_t phaseDataReady
uint16_t sampleFreq
Definition: hal_adc_sd24.h:140
_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.
void HAL_ADC_disableInterrupt(HAL_ADC_SD24_Configuration *config)
The following API disables the interrupt for the master converter.
void HAL_ADC_stopConversion(HAL_ADC_SD24_Configuration *config)
The following API stops the enabled converters.
Contains the SD24 Channel Configuration.
Definition: hal_adc_sd24.h:105
struct _HAL_ADC_SD24_Configuration_ HAL_ADC_SD24_Configuration
Contains the SD24 Configuration.
HAL_ADC_SD24_Configuration halAdcConfig
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale