2 ******************************************************************************
\r
3 * @file tsl_acq_stm32l1xx_hw.h
\r
4 * @author MCD Application Team
\r
6 * @date 22-January-2013
\r
7 * @brief This file contains external declarations of the tsl_acq_stm32l1xx_hw.c file.
\r
8 ******************************************************************************
\r
11 * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
\r
13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
14 * You may not use this file except in compliance with the License.
\r
15 * You may obtain a copy of the License at:
\r
17 * http://www.st.com/software_license_agreement_liberty_v2
\r
19 * Unless required by applicable law or agreed to in writing, software
\r
20 * distributed under the License is distributed on an "AS IS" BASIS,
\r
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
22 * See the License for the specific language governing permissions and
\r
23 * limitations under the License.
\r
25 ******************************************************************************
\r
28 /* Define to prevent recursive inclusion -------------------------------------*/
\r
29 #ifndef __TSL_ACQ_STM32L1XX_HW_H
\r
30 #define __TSL_ACQ_STM32L1XX_HW_H
\r
32 /* Includes ------------------------------------------------------------------*/
\r
33 #include "stm32l1xx.h"
\r
34 #include "tsl_conf_stm32l1xx.h"
\r
35 #include "tsl_types.h"
\r
37 /* Defines -------------------------------------------------------------------*/
\r
43 // SysTick enable/disable interrupt macros
\r
44 #define enableInterrupts() {SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;}
\r
45 #define disableInterrupts() {SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;}
\r
65 High significant nibble for the IO port (GPIOA:0,...,GPIOG:6)
\r
66 Low significant nibble for the IO number (pin0:0,...,pin15:F)
\r
70 PA0 = 0x00, /**< TSL_GROUP1_IO1 */
\r
74 PA6 = 0x06, /**< TSL_GROUP2_IO1 */
\r
79 PA13 = 0x0D, /**< TSL_GROUP5_IO1 */
\r
82 PB0 = 0x10, /**< TSL_GROUP3_IO1 */
\r
85 PB4 = 0x14, /**< TSL_GROUP6_IO1 */
\r
89 PB12 = 0x1C, /**< TSL_GROUP7_IO1 */
\r
93 PC0 = 0x20, /**< TSL_GROUP8_IO1 */
\r
103 PF6 = 0x56, /**< TSL_GROUP11_IO1 */
\r
113 PG0 = 0x60, /**< TSL_GROUP2_IO4 */
\r
121 High significant nibble for the IO port (GPIOA:0,...,GPIOG:6)
\r
122 Low significant nibble for the IO number (pin0:0,...,pin15:F)
\r
126 TSL_GROUP1_IO1 = 0x00, /**< PA0 */
\r
127 TSL_GROUP1_IO2 = 0x01,
\r
128 TSL_GROUP1_IO3 = 0x02,
\r
129 TSL_GROUP1_IO4 = 0x03,
\r
130 TSL_GROUP2_IO1 = 0x06, /**< PA6 */
\r
131 TSL_GROUP2_IO2 = 0x07,
\r
132 TSL_GROUP4_IO1 = 0x08,
\r
133 TSL_GROUP4_IO2 = 0x09,
\r
134 TSL_GROUP4_IO3 = 0x0A,
\r
135 TSL_GROUP5_IO1 = 0x0D, /**< PA13 */
\r
136 TSL_GROUP5_IO2 = 0x0E,
\r
137 TSL_GROUP5_IO3 = 0x0F,
\r
138 TSL_GROUP3_IO1 = 0x10, /**< PB0 */
\r
139 TSL_GROUP3_IO2 = 0x11,
\r
140 TSL_GROUP3_IO3 = 0x12,
\r
141 TSL_GROUP6_IO1 = 0x14, /**< PB4 */
\r
142 TSL_GROUP6_IO2 = 0x15,
\r
143 TSL_GROUP6_IO3 = 0x16,
\r
144 TSL_GROUP6_IO4 = 0x17,
\r
145 TSL_GROUP7_IO1 = 0x1C, /**< PB12 */
\r
146 TSL_GROUP7_IO2 = 0x1D,
\r
147 TSL_GROUP7_IO3 = 0x1E,
\r
148 TSL_GROUP7_IO4 = 0x1F,
\r
149 TSL_GROUP8_IO1 = 0x20, /**< PC0 */
\r
150 TSL_GROUP8_IO2 = 0x21,
\r
151 TSL_GROUP8_IO3 = 0x22,
\r
152 TSL_GROUP8_IO4 = 0x23,
\r
153 TSL_GROUP9_IO1 = 0x24,
\r
154 TSL_GROUP9_IO2 = 0x25,
\r
155 TSL_GROUP10_IO1 = 0x26,
\r
156 TSL_GROUP10_IO2 = 0x27,
\r
157 TSL_GROUP10_IO3 = 0x28,
\r
158 TSL_GROUP10_IO4 = 0x29,
\r
159 TSL_GROUP11_IO1 = 0x56, /**< PF6 */
\r
160 TSL_GROUP11_IO2 = 0x57,
\r
161 TSL_GROUP11_IO3 = 0x58,
\r
162 TSL_GROUP11_IO4 = 0x59,
\r
163 TSL_GROUP11_IO5 = 0x5A,
\r
164 TSL_GROUP3_IO4 = 0x5B,
\r
165 TSL_GROUP3_IO5 = 0x5C,
\r
166 TSL_GROUP9_IO3 = 0x5D,
\r
167 TSL_GROUP9_IO4 = 0x5E,
\r
168 TSL_GROUP2_IO3 = 0x5F,
\r
169 TSL_GROUP2_IO4 = 0x60, /**< PG0 */
\r
170 TSL_GROUP2_IO5 = 0x61,
\r
171 TSL_GROUP7_IO5 = 0x62,
\r
172 TSL_GROUP7_IO6 = 0x63,
\r
173 TSL_GROUP7_IO7 = 0x64
\r
176 /* Exported types ------------------------------------------------------------*/
\r
182 __IO uint32_t ASCR1;
\r
183 __IO uint32_t ASCR2;
\r
184 __IO uint32_t HYSCR1;
\r
185 __IO uint32_t HYSCR2;
\r
186 __IO uint32_t HYSCR3;
\r
187 __IO uint32_t HYSCR4;
\r
189 __IO uint32_t ASMR1;
\r
190 __IO uint32_t CMR1;
\r
191 __IO uint32_t CICR1;
\r
192 __IO uint32_t ASMR2;
\r
193 __IO uint32_t CMR2;
\r
194 __IO uint32_t CICR2;
\r
195 __IO uint32_t ASMR3;
\r
196 __IO uint32_t CMR3;
\r
197 __IO uint32_t CICR3;
\r
198 __IO uint32_t ASMR4;
\r
199 __IO uint32_t CMR4;
\r
200 __IO uint32_t CICR4;
\r
201 __IO uint32_t ASMR5;
\r
202 __IO uint32_t CMR5;
\r
203 __IO uint32_t CICR5;
\r
206 // For all devices/acquisitions
\r
208 typedef uint16_t TSL_tMeas_T; /**< Measurement */
\r
209 typedef uint16_t TSL_tRef_T; /**< Reference */
\r
210 typedef int16_t TSL_tDelta_T; /**< Delta */
\r
212 typedef uint8_t TSL_tIndexSrc_T; /**< Channel source index */
\r
213 typedef uint16_t TSL_tIndexDest_T; /**< Channel destination index */
\r
215 typedef uint8_t TSL_tRefRest_T; /**< Reference Rest (ECS) */
\r
216 typedef uint16_t TSL_tKCoeff_T; /**< K coefficient (ECS) */
\r
218 typedef uint8_t TSL_tIndex_T; /**< Generic index */
\r
219 typedef uint16_t TSL_tNb_T; /**< Generic number */
\r
220 typedef uint8_t TSL_tCounter_T; /**< Generic counter used for debounce */
\r
222 typedef uint8_t TSL_tThreshold_T; /**< Delta threshold */
\r
224 typedef int16_t TSL_tsignPosition_T; /**< Linear and Rotary sensors position */
\r
225 typedef uint8_t TSL_tPosition_T; /**< Linear and Rotary sensors position */
\r
227 typedef uint16_t TSL_tTick_ms_T; /**< Time in ms */
\r
228 typedef uint8_t TSL_tTick_sec_T; /**< Time in sec */
\r
230 //------------------------------------------------------------------------------
\r
232 //------------------------------------------------------------------------------
\r
234 typedef uint8_t TSL_Conf_t;
\r
236 /** Channel destination index
\r
240 TSL_tIndex_T IdxDest; /**< Index in the Channel data array */
\r
241 } TSL_ChannelDest_T;
\r
243 /** Channel Source and Configuration
\r
247 TSL_tIndex_T IdxSrc; /**< Index of source value */
\r
248 // For stm32l1x acquisition only
\r
249 TSL_Conf_t t_sample; /**< Indicates which GPIO.n is used for the sample */
\r
250 TSL_Conf_t t_channel; /**< Indicates which GPIO.n is used for the channel */
\r
251 } TSL_ChannelSrc_T;
\r
257 unsigned int DataReady : 1; /**< To identify a new measurement (TSL_DataReady_enum_T) */
\r
258 unsigned int AcqStatus : 2; /**< Acquisition status (TSL_AcqStatus_enum_T) */
\r
259 unsigned int ObjStatus : 2; /**< Object status (TSL_ObjStatus_enum_T) */
\r
260 } TSL_ChannelFlags_T;
\r
266 TSL_ChannelFlags_T Flags; /**< Flags */
\r
267 TSL_tRef_T Ref; /**< Reference */
\r
268 TSL_tRefRest_T RefRest; /**< Reference rest for ECS */
\r
269 TSL_tDelta_T Delta; /**< Delta */
\r
270 #if TSLPRM_USE_MEAS > 0
\r
271 TSL_tMeas_T Meas; /**< Hold the last acquisition measure */
\r
273 } TSL_ChannelData_T;
\r
275 //------------------------------------------------------------------------------
\r
277 //------------------------------------------------------------------------------
\r
283 // Common to all acquisitions
\r
284 CONST TSL_ChannelSrc_T *p_chSrc; /**< Pointer to the Channel Source and Configuration */
\r
285 CONST TSL_ChannelDest_T *p_chDest; /**< Pointer to the Channel Destination */
\r
286 TSL_ChannelData_T *p_chData; /**< Pointer to the Channel Data */
\r
287 TSL_tNb_T NbChannels; /**< Number of channels in the bank */
\r
288 // For stm32l1x acquisition only
\r
289 TSL_Conf_t shield_sample; /**< Indicates which GPIO.n is used for the shield sample */
\r
290 TSL_Conf_t shield_channel; /**< Indicates which GPIO.n is used for the shield channel */
\r
293 /* Exported variables --------------------------------------------------------*/
\r
295 /* Exported macros -----------------------------------------------------------*/
\r
297 #define CPRI_BASE (APB1PERIPH_BASE + 0x7C04)
\r
298 #define CPRI ((CPRI_TypeDef *) CPRI_BASE)
\r
300 /* Exported functions ------------------------------------------------------- */
\r
302 TSL_Status_enum_T TSL_acq_Init(void);
\r
303 TSL_Status_enum_T TSL_acq_BankConfig(TSL_tIndex_T idx_bk);
\r
304 void TSL_acq_BankStartAcq(void);
\r
305 TSL_Status_enum_T TSL_acq_BankWaitEOC(void);
\r
306 void TSL_acq_ProcessIT(void);
\r
307 TSL_tMeas_T TSL_acq_GetMeas(TSL_tIndex_T index);
\r
308 TSL_AcqStatus_enum_T TSL_acq_CheckNoise(void);
\r
309 TSL_Bool_enum_T TSL_acq_UseFilter(TSL_ChannelData_T *pCh);
\r
310 TSL_tDelta_T TSL_acq_ComputeDelta(TSL_tRef_T ref, TSL_tMeas_T meas);
\r
311 TSL_tMeas_T TSL_acq_ComputeMeas(TSL_tRef_T ref, TSL_tDelta_T delta);
\r
312 TSL_Bool_enum_T TSL_acq_TestReferenceOutOfRange(TSL_ChannelData_T *pCh);
\r
313 TSL_Bool_enum_T TSL_acq_TestFirstReferenceIsValid(TSL_ChannelData_T *pCh, TSL_tMeas_T new_meas);
\r
315 #endif // __TSL_ACQ_STM32L1XX_HW_H
\r
317 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r