2 ******************************************************************************
\r
3 * @file tsl_acq_stm8tl5x.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 STM8TL5x 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_STM8TL5X_H
\r
31 #define __TSL_ACQ_STM8TL5X_H
\r
33 /* Includes ------------------------------------------------------------------*/
\r
34 #include "stm8tl5x.h"
\r
35 #include "tsl_conf_stm8tl5x.h"
\r
36 #include "tsl_types.h"
\r
38 /*==============================================================================
\r
40 *** RECEIVERS AND TRANSMITTERS DESCRIPTION ***
\r
42 ProxSense receiver and transmitter description for STM8TL5x
\r
43 For more details please refer to the Proxsense
\r
44 section in the reference manual
\r
48 Group Ai Rx0a __/____ |
\r
59 Group Bi Rx0b __/____ |
\r
70 ==============================================================================*/
\r
72 /* Defines -------------------------------------------------------------------*/
\r
75 #define RX0 (0+0x8000)
\r
76 #define RX1 (1+0x8000)
\r
77 #define RX2 (2+0x8000)
\r
78 #define RX3 (3+0x8000)
\r
79 #define RX4 (4+0x8000)
\r
80 #define RX5 (5+0x8000)
\r
81 #define RX6 (6+0x8000)
\r
82 #define RX7 (7+0x8000)
\r
83 #define RX8 (8+0x8000)
\r
84 #define RX9 (9+0x8000)
\r
103 #define BIT_MASK_RX(N) ((uint16_t)1<<(uint8_t)(N & 0xFF))
\r
104 #define BIT_MASK_TX(N) ((uint16_t)1<< N)
\r
106 // Acquisition Bank
\r
138 /* Exported types ------------------------------------------------------------*/
\r
140 // For all devices/acquisitions
\r
142 typedef uint16_t TSL_tMeas_T; /**< Measurement */
\r
143 typedef uint16_t TSL_tRef_T; /**< Reference */
\r
144 typedef int16_t TSL_tDelta_T; /**< Delta */
\r
146 typedef uint8_t TSL_tIndexSrc_T; /**< Channel source index */
\r
147 typedef uint16_t TSL_tIndexDest_T; /**< Channel destination index */
\r
149 typedef uint8_t TSL_tRefRest_T; /**< Reference Rest (ECS) */
\r
150 typedef uint16_t TSL_tKCoeff_T; /**< K coefficient (ECS) */
\r
152 typedef uint8_t TSL_tIndex_T; /**< Generic index */
\r
153 typedef uint16_t TSL_tNb_T; /**< Generic number */
\r
154 typedef uint8_t TSL_tCounter_T; /**< Generic counter used for debounce */
\r
156 typedef uint8_t TSL_tThreshold_T; /**< Delta threshold */
\r
158 typedef int16_t TSL_tsignPosition_T; /**< Linear and Rotary sensors position */
\r
159 typedef uint8_t TSL_tPosition_T; /**< Linear and Rotary sensors position */
\r
161 typedef uint16_t TSL_tTick_ms_T; /**< Time in ms */
\r
162 typedef uint8_t TSL_tTick_sec_T; /**< Time in sec */
\r
164 // For STM8TL5X only
\r
166 typedef uint16_t TSL_tMaskRX; /**< Receiver mask */
\r
167 typedef uint16_t TSL_tMaskTX; /**< Transmitter mask */
\r
169 //------------------------------------------------------------------------------
\r
171 //------------------------------------------------------------------------------
\r
173 /** Channel destination index
\r
177 TSL_tIndexDest_T IdxDest; /**< Index in the Channel data array */
\r
178 } TSL_ChannelDest_T;
\r
180 /** Channel Source and Configuration
\r
184 TSL_tIndexSrc_T IdxSrc; /**< Index of the receivers (between 0 and 9) */
\r
185 } TSL_ChannelSrc_T;
\r
187 #define TSL_EPCC_CHANGE_MASK (0x04) /**< EPCC change mask */
\r
193 TSL_EPCC_STATUS_UNLOCKED = 0, /**< EPCC is unlocked */
\r
194 TSL_EPCC_STATUS_LOCKED = 1, /**< EPCC is locked */
\r
195 TSL_EPCC_STATUS_DECREASE = 4, /**< EPCC must decreased */
\r
196 TSL_EPCC_STATUS_INCREASE = 6 /**< EPCC must be increased */
\r
197 } TSL_EPCCStatus_enum_T;
\r
203 unsigned int DataReady : 1; /**< To identify a new measurement (TSL_DataReady_enum_T) */
\r
204 unsigned int AcqStatus : 2; /**< Acquisition status (TSL_AcqStatus_enum_T) */
\r
205 unsigned int EPCCStatus : 3; /**< Acquisition status (TSL_EPCCStatus_enum_T) */
\r
206 unsigned int ObjStatus : 2; /**< Object status (TSL_ObjStatus_enum_T) */
\r
207 } TSL_ChannelFlags_T;
\r
213 TSL_ChannelFlags_T Flags; /**< Flags */
\r
214 TSL_tRef_T Ref; /**< Reference */
\r
215 TSL_tRefRest_T RefRest; /**< Reference rest for ECS */
\r
216 TSL_tDelta_T Delta; /**< Delta */
\r
217 #if TSLPRM_USE_MEAS > 0
\r
218 TSL_tMeas_T Meas; /**< Hold the last acquisition measure */
\r
220 } TSL_ChannelData_T;
\r
222 //------------------------------------------------------------------------------
\r
224 //------------------------------------------------------------------------------
\r
230 // Common to all acquisitions
\r
231 CONST TSL_ChannelSrc_T *p_chSrc; /**< Pointer to the Channel Source and Configuration */
\r
232 CONST TSL_ChannelDest_T *p_chDest; /**< Pointer to the Channel Destination */
\r
233 TSL_ChannelData_T *p_chData; /**< Pointer to the Channel Data */
\r
234 TSL_tNb_T NbChannels; /**< Number of channels in the bank */
\r
235 // For stm8tl5x PXS acquisition only
\r
236 TSL_tMaskRX msk_channels; /**< Mask of all receivers */
\r
237 TSL_tMaskTX msk_TX; /**< Mask of Tx */
\r
238 uint8_t msk_group; /**< Mask of group used (RX_GROUPA or RX_GROUPB) */
\r
239 TSL_tMaskRX msk_RXEN; /**< Mask of all RX (receivers and transmitters) */
\r
242 /** Bank Configuration
\r
246 uint8_t CSSEL[TSLPRM_HIGH_CHANNEL_NB+1]; /**< Array of CS values */
\r
247 uint8_t EPCCSEL[TSLPRM_HIGH_CHANNEL_NB+1]; /**< Array of EPCC values */
\r
248 } TSL_BankConfig_T;
\r
250 /* Exported variables --------------------------------------------------------*/
\r
252 /* Exported macros -----------------------------------------------------------*/
\r
253 #define TSL_acq_ComputeDelta(Reference,Measure) (TSL_tDelta_T)(Measure - Reference) /**< Calculate the Delta */
\r
254 #define TSL_acq_ComputeMeas(Reference,Delta) (TSL_tMeas_T)(Delta + Reference) /**< Calculate the Measure */
\r
256 /* Exported functions ------------------------------------------------------- */
\r
257 TSL_Status_enum_T TSL_acq_Init(void);
\r
258 TSL_Status_enum_T TSL_acq_BankConfig(TSL_tIndex_T idx_bk);
\r
259 TSL_Bool_enum_T TSL_acq_UseFilter(TSL_ChannelData_T *pCh);
\r
260 TSL_Bool_enum_T TSL_acq_TestFirstReferenceIsValid(TSL_ChannelData_T *pCh, TSL_tMeas_T new_meas);
\r
261 TSL_Bool_enum_T TSL_acq_TestReferenceOutOfRange(TSL_ChannelData_T *pCh);
\r
262 void TSL_acq_BankStartAcq(void);
\r
263 TSL_Status_enum_T TSL_acq_BankWaitEOC(void);
\r
264 TSL_AcqStatus_enum_T TSL_acq_CheckNoise(void);
\r
265 TSL_tMeas_T TSL_acq_GetMeas(TSL_tIndexSrc_T index);
\r
266 void TSL_acq_UpdateCS(uint8_t *pCSSEL, TSL_EPCCStatus_enum_T change);
\r
268 #endif /* __TSL_ACQ_STM8TL5X_H */
\r
270 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r