2 ******************************************************************************
\r
3 * @file tsl_acq_stm32f3xx.h
\r
4 * @author MCD Application Team
\r
6 * @date 22-January-2013
\r
7 * @brief This file contains all functions prototypes that manage the TSC
\r
8 * acquisition on STM32F3xx products.
\r
9 ******************************************************************************
\r
12 * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
\r
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
15 * You may not use this file except in compliance with the License.
\r
16 * You may obtain a copy of the License at:
\r
18 * http://www.st.com/software_license_agreement_liberty_v2
\r
20 * Unless required by applicable law or agreed to in writing, software
\r
21 * distributed under the License is distributed on an "AS IS" BASIS,
\r
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
23 * See the License for the specific language governing permissions and
\r
24 * limitations under the License.
\r
26 ******************************************************************************
\r
29 /* Define to prevent recursive inclusion -------------------------------------*/
\r
30 #ifndef __TSL_ACQ_STM32F3XX_H
\r
31 #define __TSL_ACQ_STM32F3XX_H
\r
33 /* Includes ------------------------------------------------------------------*/
\r
34 #if defined(STM32F30X)
\r
35 #include "stm32f30x.h"
\r
37 #if defined(STM32F37X)
\r
38 #include "stm32f37x.h"
\r
40 #include "tsl_conf_stm32f3xx.h"
\r
41 #include "tsl_types.h"
\r
43 /* Defines -------------------------------------------------------------------*/
\r
49 // SysTick enable/disable interrupt macros
\r
50 #define enableInterrupts() {SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;}
\r
51 #define disableInterrupts() {SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;}
\r
53 #define TSL_NB_GROUPS (8) // Number of groups available on STM32F3xx devices
\r
55 #define TSL_GROUP1 (0x01)
\r
56 #define TSL_GROUP2 (0x02)
\r
57 #define TSL_GROUP3 (0x04)
\r
58 #define TSL_GROUP4 (0x08)
\r
59 #define TSL_GROUP5 (0x10)
\r
60 #define TSL_GROUP6 (0x20)
\r
61 #define TSL_GROUP7 (0x40)
\r
62 #define TSL_GROUP8 (0x80)
\r
65 #define TSL_GROUP1_IO1 (0x00000001)
\r
66 #define TSL_GROUP1_IO2 (0x00000002)
\r
67 #define TSL_GROUP1_IO3 (0x00000004)
\r
68 #define TSL_GROUP1_IO4 (0x00000008)
\r
69 #define TSL_GROUP2_IO1 (0x00000010)
\r
70 #define TSL_GROUP2_IO2 (0x00000020)
\r
71 #define TSL_GROUP2_IO3 (0x00000040)
\r
72 #define TSL_GROUP2_IO4 (0x00000080)
\r
73 #define TSL_GROUP3_IO1 (0x00000100)
\r
74 #define TSL_GROUP3_IO2 (0x00000200)
\r
75 #define TSL_GROUP3_IO3 (0x00000400)
\r
76 #define TSL_GROUP3_IO4 (0x00000800)
\r
77 #define TSL_GROUP4_IO1 (0x00001000)
\r
78 #define TSL_GROUP4_IO2 (0x00002000)
\r
79 #define TSL_GROUP4_IO3 (0x00004000)
\r
80 #define TSL_GROUP4_IO4 (0x00008000)
\r
81 #define TSL_GROUP5_IO1 (0x00010000)
\r
82 #define TSL_GROUP5_IO2 (0x00020000)
\r
83 #define TSL_GROUP5_IO3 (0x00040000)
\r
84 #define TSL_GROUP5_IO4 (0x00080000)
\r
85 #define TSL_GROUP6_IO1 (0x00100000)
\r
86 #define TSL_GROUP6_IO2 (0x00200000)
\r
87 #define TSL_GROUP6_IO3 (0x00400000)
\r
88 #define TSL_GROUP6_IO4 (0x00800000)
\r
89 #define TSL_GROUP7_IO1 (0x01000000)
\r
90 #define TSL_GROUP7_IO2 (0x02000000)
\r
91 #define TSL_GROUP7_IO3 (0x04000000)
\r
92 #define TSL_GROUP7_IO4 (0x08000000)
\r
93 #define TSL_GROUP8_IO1 (0x10000000)
\r
94 #define TSL_GROUP8_IO2 (0x20000000)
\r
95 #define TSL_GROUP8_IO3 (0x40000000)
\r
96 #define TSL_GROUP8_IO4 (0x80000000)
\r
98 /* Exported types ------------------------------------------------------------*/
\r
100 // For all devices/acquisitions
\r
102 typedef uint16_t TSL_tMeas_T; /**< Measurement */
\r
103 typedef uint16_t TSL_tRef_T; /**< Reference */
\r
104 typedef int16_t TSL_tDelta_T; /**< Delta */
\r
106 typedef uint8_t TSL_tIndexSrc_T; /**< Channel source index */
\r
107 typedef uint16_t TSL_tIndexDest_T; /**< Channel destination index */
\r
109 typedef uint8_t TSL_tRefRest_T; /**< Reference Rest (ECS) */
\r
110 typedef uint16_t TSL_tKCoeff_T; /**< K coefficient (ECS) */
\r
112 typedef uint8_t TSL_tIndex_T; /**< Generic index */
\r
113 typedef uint16_t TSL_tNb_T; /**< Generic number */
\r
114 typedef uint8_t TSL_tCounter_T; /**< Generic counter used for debounce */
\r
116 typedef uint8_t TSL_tThreshold_T; /**< Delta threshold */
\r
118 typedef int16_t TSL_tsignPosition_T; /**< Linear and Rotary sensors position */
\r
119 typedef uint8_t TSL_tPosition_T; /**< Linear and Rotary sensors position */
\r
121 typedef uint16_t TSL_tTick_ms_T; /**< Time in ms */
\r
122 typedef uint8_t TSL_tTick_sec_T; /**< Time in sec */
\r
124 //------------------------------------------------------------------------------
\r
126 //------------------------------------------------------------------------------
\r
128 /** Channel destination index
\r
132 TSL_tIndexDest_T IdxDest; /**< Index in the Channel data array */
\r
133 } TSL_ChannelDest_T;
\r
135 /** Channel Source and Configuration
\r
139 TSL_tIndexSrc_T IdxSrc; /**< Index of TSC->IOGXCR[] registers */
\r
140 // For STM32F3xx TSC acquisition only
\r
141 uint32_t msk_IOCCR_channel; /**< Mask of the Channel IO (electrodes ONLY) */
\r
142 uint32_t msk_IOGCSR_group; /**< Mask of the Group used (electrodes ONLY) */
\r
143 } TSL_ChannelSrc_T;
\r
149 unsigned int DataReady : 1; /**< To identify a new measurement (TSL_DataReady_enum_T) */
\r
150 unsigned int AcqStatus : 2; /**< Acquisition status (TSL_AcqStatus_enum_T) */
\r
151 unsigned int ObjStatus : 2; /**< Object status (TSL_ObjStatus_enum_T) */
\r
152 } TSL_ChannelFlags_T;
\r
158 TSL_ChannelFlags_T Flags; /**< Flags */
\r
159 TSL_tRef_T Ref; /**< Reference */
\r
160 TSL_tRefRest_T RefRest; /**< Reference rest for ECS */
\r
161 TSL_tDelta_T Delta; /**< Delta */
\r
162 #if TSLPRM_USE_MEAS > 0
\r
163 TSL_tMeas_T Meas; /**< Hold the last acquisition measure */
\r
165 } TSL_ChannelData_T;
\r
167 //------------------------------------------------------------------------------
\r
169 //------------------------------------------------------------------------------
\r
175 // Common to all acquisitions
\r
176 CONST TSL_ChannelSrc_T *p_chSrc; /**< Pointer to the Channel Source and Configuration */
\r
177 CONST TSL_ChannelDest_T *p_chDest; /**< Pointer to the Channel Destination */
\r
178 TSL_ChannelData_T *p_chData; /**< Pointer to the Channel Data */
\r
179 TSL_tNb_T NbChannels; /**< Number of channels in the bank */
\r
180 // For STM32F3xx TSC acquisition only
\r
181 uint32_t msk_IOCCR_channels; /**< Mask of all channel IOs (electrodes AND shields) */
\r
182 uint32_t msk_IOGCSR_groups; /**< Mask of all groups used (electrodes ONLY) */
\r
185 /* Exported variables --------------------------------------------------------*/
\r
186 /* Exported macros -----------------------------------------------------------*/
\r
187 /* Exported functions ------------------------------------------------------- */
\r
189 TSL_Status_enum_T TSL_acq_Init(void);
\r
190 void TSL_acq_InitGPIOs(void);
\r
191 TSL_Status_enum_T TSL_acq_BankConfig(TSL_tIndex_T idx_bk);
\r
192 TSL_Bool_enum_T TSL_acq_UseFilter(TSL_ChannelData_T *pCh);
\r
193 TSL_Bool_enum_T TSL_acq_TestReferenceOutOfRange(TSL_ChannelData_T *pCh);
\r
194 TSL_Bool_enum_T TSL_acq_TestFirstReferenceIsValid(TSL_ChannelData_T *pCh, TSL_tMeas_T new_meas);
\r
195 void TSL_acq_BankStartAcq(void);
\r
196 TSL_Status_enum_T TSL_acq_BankWaitEOC(void);
\r
197 TSL_AcqStatus_enum_T TSL_acq_CheckNoise(void);
\r
198 TSL_tMeas_T TSL_acq_GetMeas(TSL_tIndexSrc_T index);
\r
199 TSL_tDelta_T TSL_acq_ComputeDelta(TSL_tRef_T ref, TSL_tMeas_T meas);
\r
200 TSL_tMeas_T TSL_acq_ComputeMeas(TSL_tRef_T ref, TSL_tDelta_T delta);
\r
202 #endif /* __TSL_ACQ_STM32F3XX_H */
\r
204 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r