2 ******************************************************************************
\r
3 * @file tsl_acq_stm32l1xx_sw.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_sw.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_SW_H
\r
30 #define __TSL_ACQ_STM32L1XX_SW_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
73 High significant nibble for the IO port (GPIOA:0,...,GPIOG:6)
\r
74 Low significant nibble for the IO number (pin0:0,...,pin15:F)
\r
78 PA0 = 0x00, /**< TSL_GROUP1_IO1 */
\r
82 PA6 = 0x06, /**< TSL_GROUP2_IO1 */
\r
87 PA13 = 0x0D, /**< TSL_GROUP5_IO1 */
\r
90 PB0 = 0x10, /**< TSL_GROUP3_IO1 */
\r
93 PB4 = 0x14, /**< TSL_GROUP6_IO1 */
\r
97 PB12 = 0x1C, /**< TSL_GROUP7_IO1 */
\r
101 PC0 = 0x20, /**< TSL_GROUP8_IO1 */
\r
111 PF6 = 0x56, /**< TSL_GROUP11_IO1 */
\r
121 PG0 = 0x60, /**< TSL_GROUP2_IO4 */
\r
129 - High significant nibble for the IO port (GPIOA:0,...,GPIOG:6)
\r
130 - Low significant nibble for the IO number (pin0:0,...,pin15:F)
\r
134 TSL_GROUP1_IO1 = 0x00, /**< PA0 */
\r
135 TSL_GROUP1_IO2 = 0x01,
\r
136 TSL_GROUP1_IO3 = 0x02,
\r
137 TSL_GROUP1_IO4 = 0x03,
\r
138 TSL_GROUP2_IO1 = 0x06, /**< PA6 */
\r
139 TSL_GROUP2_IO2 = 0x07,
\r
140 TSL_GROUP4_IO1 = 0x08,
\r
141 TSL_GROUP4_IO2 = 0x09,
\r
142 TSL_GROUP4_IO3 = 0x0A,
\r
143 TSL_GROUP5_IO1 = 0x0D, /**< PA13 */
\r
144 TSL_GROUP5_IO2 = 0x0E,
\r
145 TSL_GROUP5_IO3 = 0x0F,
\r
146 TSL_GROUP3_IO1 = 0x10, /**< PB0 */
\r
147 TSL_GROUP3_IO2 = 0x11,
\r
148 TSL_GROUP3_IO3 = 0x12,
\r
149 TSL_GROUP6_IO1 = 0x14, /**< PB4 */
\r
150 TSL_GROUP6_IO2 = 0x15,
\r
151 TSL_GROUP6_IO3 = 0x16,
\r
152 TSL_GROUP6_IO4 = 0x17,
\r
153 TSL_GROUP7_IO1 = 0x1C, /**< PB12 */
\r
154 TSL_GROUP7_IO2 = 0x1D,
\r
155 TSL_GROUP7_IO3 = 0x1E,
\r
156 TSL_GROUP7_IO4 = 0x1F,
\r
157 TSL_GROUP8_IO1 = 0x20, /**< PC0 */
\r
158 TSL_GROUP8_IO2 = 0x21,
\r
159 TSL_GROUP8_IO3 = 0x22,
\r
160 TSL_GROUP8_IO4 = 0x23,
\r
161 TSL_GROUP9_IO1 = 0x24,
\r
162 TSL_GROUP9_IO2 = 0x25,
\r
163 TSL_GROUP10_IO1 = 0x26,
\r
164 TSL_GROUP10_IO2 = 0x27,
\r
165 TSL_GROUP10_IO3 = 0x28,
\r
166 TSL_GROUP10_IO4 = 0x29,
\r
167 TSL_GROUP11_IO1 = 0x56, /**< PF6 */
\r
168 TSL_GROUP11_IO2 = 0x57,
\r
169 TSL_GROUP11_IO3 = 0x58,
\r
170 TSL_GROUP11_IO4 = 0x59,
\r
171 TSL_GROUP11_IO5 = 0x5A,
\r
172 TSL_GROUP3_IO4 = 0x5B,
\r
173 TSL_GROUP3_IO5 = 0x5C,
\r
174 TSL_GROUP9_IO3 = 0x5D,
\r
175 TSL_GROUP9_IO4 = 0x5E,
\r
176 TSL_GROUP2_IO3 = 0x5F,
\r
177 TSL_GROUP2_IO4 = 0x60, /**< PG0 */
\r
178 TSL_GROUP2_IO5 = 0x61,
\r
179 TSL_GROUP7_IO5 = 0x62,
\r
180 TSL_GROUP7_IO6 = 0x63,
\r
181 TSL_GROUP7_IO7 = 0x64
\r
184 /* Exported types ------------------------------------------------------------*/
\r
186 // For all devices/acquisitions
\r
188 typedef uint16_t TSL_tMeas_T; /**< Measurement */
\r
189 typedef uint16_t TSL_tRef_T; /**< Reference */
\r
190 typedef int16_t TSL_tDelta_T; /**< Delta */
\r
192 typedef uint8_t TSL_tIndexSrc_T; /**< Channel source index */
\r
193 typedef uint16_t TSL_tIndexDest_T; /**< Channel destination index */
\r
195 typedef uint8_t TSL_tRefRest_T; /**< Reference Rest (ECS) */
\r
196 typedef uint16_t TSL_tKCoeff_T; /**< K coefficient (ECS) */
\r
198 typedef uint8_t TSL_tIndex_T; /**< Generic index */
\r
199 typedef uint16_t TSL_tNb_T; /**< Generic number */
\r
200 typedef uint8_t TSL_tCounter_T; /**< Generic counter used for debounce */
\r
202 typedef uint8_t TSL_tThreshold_T; /**< Delta threshold */
\r
204 typedef int16_t TSL_tsignPosition_T; /**< Linear and Rotary sensors position */
\r
205 typedef uint8_t TSL_tPosition_T; /**< Linear and Rotary sensors position */
\r
207 typedef uint16_t TSL_tTick_ms_T; /**< Time in ms */
\r
208 typedef uint8_t TSL_tTick_sec_T; /**< Time in sec */
\r
210 //------------------------------------------------------------------------------
\r
212 //------------------------------------------------------------------------------
\r
214 typedef uint8_t TSL_Conf_t;
\r
216 /** Channel destination index
\r
220 TSL_tIndex_T IdxDest; /**< Index in the Channel data array */
\r
221 } TSL_ChannelDest_T;
\r
223 /** Channel Source and Configuration
\r
227 TSL_tIndex_T IdxSrc; /**< Index of source value */
\r
228 // For stm32l1x acquisition only
\r
229 TSL_Conf_t t_sample; /**< Indicates which GPIO.n is used for the sample */
\r
230 TSL_Conf_t t_channel; /**< Indicates which GPIO.n is used for the channel */
\r
231 } TSL_ChannelSrc_T;
\r
237 unsigned int DataReady : 1; /**< To identify a new measurement (TSL_DataReady_enum_T) */
\r
238 unsigned int AcqStatus : 2; /**< Acquisition status (TSL_AcqStatus_enum_T) */
\r
239 unsigned int ObjStatus : 2; /**< Object status (TSL_ObjStatus_enum_T) */
\r
240 } TSL_ChannelFlags_T;
\r
246 TSL_ChannelFlags_T Flags; /**< Flags */
\r
247 TSL_tRef_T Ref; /**< Reference */
\r
248 TSL_tRefRest_T RefRest; /**< Reference rest for ECS */
\r
249 TSL_tDelta_T Delta; /**< Delta */
\r
250 #if TSLPRM_USE_MEAS > 0
\r
251 TSL_tMeas_T Meas; /**< Hold the last acquisition measure */
\r
253 } TSL_ChannelData_T;
\r
255 //------------------------------------------------------------------------------
\r
257 //------------------------------------------------------------------------------
\r
263 // Common to all acquisitions
\r
264 CONST TSL_ChannelSrc_T *p_chSrc; /**< Pointer to the Channel Source and Configuration */
\r
265 CONST TSL_ChannelDest_T *p_chDest; /**< Pointer to the Channel Destination */
\r
266 TSL_ChannelData_T *p_chData; /**< Pointer to the Channel Data */
\r
267 TSL_tNb_T NbChannels; /**< Number of channels in the bank */
\r
268 // For stm32l1x acquisition only
\r
269 TSL_Conf_t shield_sample; /**< Indicates which GPIO.n is used for the shield sample */
\r
270 TSL_Conf_t shield_channel; /**< Indicates which GPIO.n is used for the shield channel */
\r
273 /* Exported variables --------------------------------------------------------*/
\r
275 /* Exported macros -----------------------------------------------------------*/
\r
276 /* Exported functions ------------------------------------------------------- */
\r
277 TSL_Status_enum_T TSL_acq_Init(void);
\r
278 TSL_Status_enum_T TSL_acq_BankConfig(TSL_tIndex_T idx_bk);
\r
279 void TSL_acq_BankStartAcq(void);
\r
280 TSL_Status_enum_T TSL_acq_BankWaitEOC(void);
\r
281 void TSL_acq_ProcessIT(void);
\r
282 TSL_tMeas_T TSL_acq_GetMeas(TSL_tIndex_T index);
\r
283 TSL_AcqStatus_enum_T TSL_acq_CheckNoise(void);
\r
285 TSL_Bool_enum_T TSL_acq_UseFilter(TSL_ChannelData_T *pCh);
\r
286 TSL_tDelta_T TSL_acq_ComputeDelta(TSL_tRef_T ref, TSL_tMeas_T meas);
\r
287 TSL_tMeas_T TSL_acq_ComputeMeas(TSL_tRef_T ref, TSL_tDelta_T delta);
\r
288 TSL_Bool_enum_T TSL_acq_TestReferenceOutOfRange(TSL_ChannelData_T *pCh);
\r
289 TSL_Bool_enum_T TSL_acq_TestFirstReferenceIsValid(TSL_ChannelData_T *pCh, TSL_tMeas_T new_meas);
\r
291 #endif /* __TSL_ACQ_STM32L1XX_SW_H */
\r
293 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r