1 |
577 |
jeremybenn |
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
|
2 |
|
|
* File Name : 75x_adc.h
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 03/10/2006
|
5 |
|
|
* Description : This file contains all the functions prototypes for the
|
6 |
|
|
* ADC software library.
|
7 |
|
|
********************************************************************************
|
8 |
|
|
* History:
|
9 |
|
|
* 07/17/2006 : V1.0
|
10 |
|
|
* 03/10/2006 : V0.1
|
11 |
|
|
********************************************************************************
|
12 |
|
|
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
13 |
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
14 |
|
|
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
15 |
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
16 |
|
|
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
17 |
|
|
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
18 |
|
|
*******************************************************************************/
|
19 |
|
|
|
20 |
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
21 |
|
|
#ifndef __75x_ADC_H
|
22 |
|
|
#define __75x_ADC_H
|
23 |
|
|
|
24 |
|
|
/* Includes ------------------------------------------------------------------*/
|
25 |
|
|
#include "75x_map.h"
|
26 |
|
|
|
27 |
|
|
/* Exported types ------------------------------------------------------------*/
|
28 |
|
|
/* ADC Init structure definition */
|
29 |
|
|
typedef struct
|
30 |
|
|
{
|
31 |
|
|
u16 ADC_ConversionMode;
|
32 |
|
|
u16 ADC_ExtTrigger;
|
33 |
|
|
u16 ADC_AutoClockOff;
|
34 |
|
|
u8 ADC_SamplingPrescaler;
|
35 |
|
|
u8 ADC_ConversionPrescaler;
|
36 |
|
|
u8 ADC_FirstChannel;
|
37 |
|
|
u8 ADC_ChannelNumber;
|
38 |
|
|
}ADC_InitTypeDef;
|
39 |
|
|
|
40 |
|
|
/* Exported constants --------------------------------------------------------*/
|
41 |
|
|
/* ADC control status flags */
|
42 |
|
|
#define ADC_FLAG_ECH 0x0001
|
43 |
|
|
#define ADC_FLAG_EOC 0x0002
|
44 |
|
|
#define ADC_FLAG_JECH 0x0004
|
45 |
|
|
#define ADC_FLAG_JEOC 0x0008
|
46 |
|
|
#define ADC_FLAG_AnalogWatchdog0_LowThreshold 0x0010
|
47 |
|
|
#define ADC_FLAG_AnalogWatchdog0_HighThreshold 0x0020
|
48 |
|
|
#define ADC_FLAG_AnalogWatchdog1_LowThreshold 0x0040
|
49 |
|
|
#define ADC_FLAG_AnalogWatchdog1_HighThreshold 0x0080
|
50 |
|
|
#define ADC_FLAG_AnalogWatchdog2_LowThreshold 0x0100
|
51 |
|
|
#define ADC_FLAG_AnalogWatchdog2_HighThreshold 0x0200
|
52 |
|
|
#define ADC_FLAG_AnalogWatchdog3_LowThreshold 0x0400
|
53 |
|
|
#define ADC_FLAG_AnalogWatchdog3_HighThreshold 0x0800
|
54 |
|
|
|
55 |
|
|
/* ADC Interrupt sources */
|
56 |
|
|
#define ADC_IT_ECH 0x0001
|
57 |
|
|
#define ADC_IT_EOC 0x0002
|
58 |
|
|
#define ADC_IT_JECH 0x0004
|
59 |
|
|
#define ADC_IT_JEOC 0x0008
|
60 |
|
|
#define ADC_IT_AnalogWatchdog0_LowThreshold 0x0010
|
61 |
|
|
#define ADC_IT_AnalogWatchdog0_HighThreshold 0x0020
|
62 |
|
|
#define ADC_IT_AnalogWatchdog1_LowThreshold 0x0040
|
63 |
|
|
#define ADC_IT_AnalogWatchdog1_HighThreshold 0x0080
|
64 |
|
|
#define ADC_IT_AnalogWatchdog2_LowThreshold 0x0100
|
65 |
|
|
#define ADC_IT_AnalogWatchdog2_HighThreshold 0x0200
|
66 |
|
|
#define ADC_IT_AnalogWatchdog3_LowThreshold 0x0400
|
67 |
|
|
#define ADC_IT_AnalogWatchdog3_HighThreshold 0x0800
|
68 |
|
|
#define ADC_IT_ALL 0x0FFF
|
69 |
|
|
|
70 |
|
|
/* ADC Watchdogs Thresholds */
|
71 |
|
|
#define ADC_AnalogWatchdog0 0x0030
|
72 |
|
|
#define ADC_AnalogWatchdog1 0x00C0
|
73 |
|
|
#define ADC_AnalogWatchdog2 0x0300
|
74 |
|
|
#define ADC_AnalogWatchdog3 0x0C00
|
75 |
|
|
|
76 |
|
|
/* ADC Channels */
|
77 |
|
|
#define ADC_CHANNEL0 0x0
|
78 |
|
|
#define ADC_CHANNEL1 0x1
|
79 |
|
|
#define ADC_CHANNEL2 0x2
|
80 |
|
|
#define ADC_CHANNEL3 0x3
|
81 |
|
|
#define ADC_CHANNEL4 0x4
|
82 |
|
|
#define ADC_CHANNEL5 0x5
|
83 |
|
|
#define ADC_CHANNEL6 0x6
|
84 |
|
|
#define ADC_CHANNEL7 0x7
|
85 |
|
|
#define ADC_CHANNEL8 0x8
|
86 |
|
|
#define ADC_CHANNEL9 0x9
|
87 |
|
|
#define ADC_CHANNEL10 0xA
|
88 |
|
|
#define ADC_CHANNEL11 0xB
|
89 |
|
|
#define ADC_CHANNEL12 0xC
|
90 |
|
|
#define ADC_CHANNEL13 0xD
|
91 |
|
|
#define ADC_CHANNEL14 0xE
|
92 |
|
|
#define ADC_CHANNEL15 0xF
|
93 |
|
|
|
94 |
|
|
/* ADC DMA Channels */
|
95 |
|
|
#define ADC_DMA_CHANNEL0 0x0001
|
96 |
|
|
#define ADC_DMA_CHANNEL1 0x0002
|
97 |
|
|
#define ADC_DMA_CHANNEL2 0x0004
|
98 |
|
|
#define ADC_DMA_CHANNEL3 0x0008
|
99 |
|
|
#define ADC_DMA_CHANNEL4 0x0010
|
100 |
|
|
#define ADC_DMA_CHANNEL5 0x0020
|
101 |
|
|
#define ADC_DMA_CHANNEL6 0x0040
|
102 |
|
|
#define ADC_DMA_CHANNEL7 0x0080
|
103 |
|
|
#define ADC_DMA_CHANNEL8 0x0100
|
104 |
|
|
#define ADC_DMA_CHANNEL9 0x0200
|
105 |
|
|
#define ADC_DMA_CHANNEL10 0x0400
|
106 |
|
|
#define ADC_DMA_CHANNEL11 0x0800
|
107 |
|
|
#define ADC_DMA_CHANNEL12 0x1000
|
108 |
|
|
#define ADC_DMA_CHANNEL13 0x2000
|
109 |
|
|
#define ADC_DMA_CHANNEL14 0x4000
|
110 |
|
|
#define ADC_DMA_CHANNEL15 0x8000
|
111 |
|
|
|
112 |
|
|
/* Trigger conversion detection */
|
113 |
|
|
#define ADC_ExtTrigger_LowLevel 0x4FFF
|
114 |
|
|
#define ADC_ExtTrigger_HighLevel 0x5000
|
115 |
|
|
#define ADC_ExtTrigger_FallingEdge 0x6000
|
116 |
|
|
#define ADC_ExtTrigger_RisingEdge 0x7000
|
117 |
|
|
#define ADC_ExtTrigger_Disable 0x8FFF
|
118 |
|
|
|
119 |
|
|
/* DMA enable config */
|
120 |
|
|
#define ADC_DMA_ExtTrigger_HighLevel 0x6000
|
121 |
|
|
#define ADC_DMA_ExtTrigger_LowLevel 0x4FFF
|
122 |
|
|
#define ADC_DMA_Enable 0x8000
|
123 |
|
|
#define ADC_DMA_Disable 0x3FFF
|
124 |
|
|
|
125 |
|
|
/* Injected Trigger conversion detection */
|
126 |
|
|
#define ADC_Injec_ExtTrigger_RisingEdge 0x6000
|
127 |
|
|
#define ADC_Injec_ExtTrigger_FallingEdge 0xDFFF
|
128 |
|
|
#define ADC_Injec_ExtTrigger_Disable 0x3FFF
|
129 |
|
|
|
130 |
|
|
/* Start Conversion */
|
131 |
|
|
#define ADC_Conversion_Start 0x0001
|
132 |
|
|
#define ADC_Conversion_Stop 0xFFFE
|
133 |
|
|
|
134 |
|
|
/* ADC Conversion Modes */
|
135 |
|
|
#define ADC_ConversionMode_Scan 0x8000
|
136 |
|
|
#define ADC_ConversionMode_OneShot 0x7FFF
|
137 |
|
|
|
138 |
|
|
/* Auto Clock Off */
|
139 |
|
|
#define ADC_AutoClockOff_Enable 0x4000
|
140 |
|
|
#define ADC_AutoClockOff_Disable 0xBFFF
|
141 |
|
|
|
142 |
|
|
/* Calibration */
|
143 |
|
|
#define ADC_Calibration_ON 0x0002
|
144 |
|
|
#define ADC_CalibAverage_Disable 0x0020
|
145 |
|
|
#define ADC_CalibAverage_Enable 0xFFDF
|
146 |
|
|
|
147 |
|
|
/* Exported macro ------------------------------------------------------------*/
|
148 |
|
|
/* Exported functions --------------------------------------------------------*/
|
149 |
|
|
|
150 |
|
|
void ADC_DeInit(void);
|
151 |
|
|
void ADC_Init(ADC_InitTypeDef *ADC_InitStruct);
|
152 |
|
|
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct);
|
153 |
|
|
void ADC_Cmd(FunctionalState NewState);
|
154 |
|
|
void ADC_StartCalibration(u16 ADC_CalibAverage);
|
155 |
|
|
FlagStatus ADC_GetCalibrationStatus(void);
|
156 |
|
|
void ADC_ConversionCmd(u16 ADC_Conversion);
|
157 |
|
|
FlagStatus ADC_GetSTARTBitStatus(void);
|
158 |
|
|
void ADC_AutoClockOffConfig(FunctionalState NewState);
|
159 |
|
|
u16 ADC_GetConversionValue(u8 ADC_CHANNEL);
|
160 |
|
|
void ADC_ITConfig(u16 ADC_IT, FunctionalState NewState);
|
161 |
|
|
void ADC_AnalogWatchdogConfig(u16 ADC_AnalogWatchdog, u8 ADC_CHANNEL,
|
162 |
|
|
u16 LowThreshold, u16 HighThreshold);
|
163 |
|
|
void ADC_AnalogWatchdogCmd(u16 ADC_AnalogWatchdog, FunctionalState NewState);
|
164 |
|
|
u16 ADC_GetAnalogWatchdogResult(u16 ADC_AnalogWatchdog);
|
165 |
|
|
void ADC_StartInjectedConversion(void);
|
166 |
|
|
void ADC_InjectedConversionConfig(u16 ADC_Injec_ExtTrigger, u8 FirstChannel, u8 ChannelNumber);
|
167 |
|
|
void ADC_DMAConfig(u16 ADC_DMA_CHANNEL, FunctionalState NewState);
|
168 |
|
|
void ADC_DMACmd(u16 ADC_DMA);
|
169 |
|
|
u16 ADC_GetDMAFirstEnabledChannel(void);
|
170 |
|
|
FlagStatus ADC_GetFlagStatus(u16 ADC_FLAG);
|
171 |
|
|
void ADC_ClearFlag(u16 ADC_FLAG);
|
172 |
|
|
ITStatus ADC_GetITStatus(u16 ADC_IT);
|
173 |
|
|
void ADC_ClearITPendingBit(u16 ADC_IT);
|
174 |
|
|
|
175 |
|
|
#endif /*__75x_ADC_H */
|
176 |
|
|
|
177 |
|
|
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
|