]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_STM32L152_Discovery_IAR/ST_Code/Libraries/STMTouch_Driver/inc/tsl_acq_stm32f0xx.h
Add STM32L Discovery board project as a starting point to adapt to an RTOS demo.
[freertos] / FreeRTOS / Demo / CORTEX_STM32L152_Discovery_IAR / ST_Code / Libraries / STMTouch_Driver / inc / tsl_acq_stm32f0xx.h
1 /**\r
2   ******************************************************************************\r
3   * @file    tsl_acq_stm32f0xx.h\r
4   * @author  MCD Application Team\r
5   * @version V1.3.2\r
6   * @date    22-January-2013\r
7   * @brief   This file contains all functions prototypes that manage the TSC\r
8   *          acquisition on STM32F0x products.\r
9   ******************************************************************************\r
10   * @attention\r
11   *\r
12   * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>\r
13   *\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
17   *\r
18   *        http://www.st.com/software_license_agreement_liberty_v2\r
19   *\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
25   *\r
26   ******************************************************************************\r
27   */\r
28 \r
29 /* Define to prevent recursive inclusion -------------------------------------*/\r
30 #ifndef __TSL_ACQ_STM32F0XX_H\r
31 #define __TSL_ACQ_STM32F0XX_H\r
32 \r
33 /* Includes ------------------------------------------------------------------*/\r
34 #include "stm32f0xx.h"\r
35 #include "tsl_conf_stm32f0xx.h"\r
36 #include "tsl_types.h"\r
37 \r
38 /* Defines -------------------------------------------------------------------*/\r
39 \r
40 #ifndef CONST\r
41 #define CONST const\r
42 #endif\r
43 \r
44 // SysTick enable/disable interrupt macros\r
45 #define enableInterrupts()  {SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;}\r
46 #define disableInterrupts() {SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;}\r
47 \r
48 #define TSL_NB_GROUPS (6) // Only 6 groups on STM32F0xx\r
49 \r
50 #define TSL_GROUP1 (0x01)\r
51 #define TSL_GROUP2 (0x02)\r
52 #define TSL_GROUP3 (0x04)\r
53 #define TSL_GROUP4 (0x08)\r
54 #define TSL_GROUP5 (0x10)\r
55 #define TSL_GROUP6 (0x20)\r
56 \r
57 // GxIOy masks\r
58 #define TSL_GROUP1_IO1 (0x00000001)\r
59 #define TSL_GROUP1_IO2 (0x00000002)\r
60 #define TSL_GROUP1_IO3 (0x00000004)\r
61 #define TSL_GROUP1_IO4 (0x00000008)\r
62 #define TSL_GROUP2_IO1 (0x00000010)\r
63 #define TSL_GROUP2_IO2 (0x00000020)\r
64 #define TSL_GROUP2_IO3 (0x00000040)\r
65 #define TSL_GROUP2_IO4 (0x00000080)\r
66 #define TSL_GROUP3_IO1 (0x00000100)\r
67 #define TSL_GROUP3_IO2 (0x00000200)\r
68 #define TSL_GROUP3_IO3 (0x00000400)\r
69 #define TSL_GROUP3_IO4 (0x00000800)\r
70 #define TSL_GROUP4_IO1 (0x00001000)\r
71 #define TSL_GROUP4_IO2 (0x00002000)\r
72 #define TSL_GROUP4_IO3 (0x00004000)\r
73 #define TSL_GROUP4_IO4 (0x00008000)\r
74 #define TSL_GROUP5_IO1 (0x00010000)\r
75 #define TSL_GROUP5_IO2 (0x00020000)\r
76 #define TSL_GROUP5_IO3 (0x00040000)\r
77 #define TSL_GROUP5_IO4 (0x00080000)\r
78 #define TSL_GROUP6_IO1 (0x00100000)\r
79 #define TSL_GROUP6_IO2 (0x00200000)\r
80 #define TSL_GROUP6_IO3 (0x00400000)\r
81 #define TSL_GROUP6_IO4 (0x00800000)\r
82 \r
83 /* Exported types ------------------------------------------------------------*/\r
84 \r
85 // For all devices/acquisitions\r
86 \r
87 typedef uint16_t  TSL_tMeas_T; /**< Measurement */\r
88 typedef uint16_t  TSL_tRef_T; /**< Reference */\r
89 typedef int16_t   TSL_tDelta_T; /**< Delta */\r
90 \r
91 typedef uint8_t   TSL_tIndexSrc_T; /**< Channel source index */\r
92 typedef uint16_t  TSL_tIndexDest_T; /**< Channel destination index */\r
93 \r
94 typedef uint8_t   TSL_tRefRest_T; /**< Reference Rest (ECS) */\r
95 typedef uint16_t  TSL_tKCoeff_T; /**< K coefficient (ECS) */\r
96 \r
97 typedef uint8_t   TSL_tIndex_T; /**< Generic index */\r
98 typedef uint16_t  TSL_tNb_T; /**< Generic number */\r
99 typedef uint8_t   TSL_tCounter_T; /**< Generic counter used for debounce */\r
100 \r
101 typedef uint8_t   TSL_tThreshold_T; /**< Delta threshold */\r
102 \r
103 typedef int16_t   TSL_tsignPosition_T; /**< Linear and Rotary sensors position */\r
104 typedef uint8_t   TSL_tPosition_T; /**< Linear and Rotary sensors position */\r
105 \r
106 typedef uint16_t  TSL_tTick_ms_T; /**< Time in ms */\r
107 typedef uint8_t   TSL_tTick_sec_T; /**< Time in sec */\r
108 \r
109 //------------------------------------------------------------------------------\r
110 // Channel\r
111 //------------------------------------------------------------------------------\r
112 \r
113 /** Channel destination index\r
114   */\r
115 typedef struct\r
116 {\r
117   TSL_tIndexDest_T  IdxDest; /**< Index in the Channel data array */\r
118 } TSL_ChannelDest_T;\r
119 \r
120 /** Channel Source and Configuration\r
121   */\r
122 typedef struct\r
123 {\r
124   TSL_tIndexSrc_T  IdxSrc; /**< Index of TSC->IOGXCR[] registers */\r
125   // For stm32f0x TSC acquisition only\r
126   uint32_t         msk_IOCCR_channel; /**< Mask of the Channel IO (electrodes ONLY) */\r
127   uint32_t         msk_IOGCSR_group;  /**< Mask of the Group used (electrodes ONLY) */\r
128 } TSL_ChannelSrc_T;\r
129 \r
130 /** Channel flags\r
131   */\r
132 typedef struct\r
133 {\r
134   unsigned int DataReady : 1; /**< To identify a new measurement (TSL_DataReady_enum_T) */\r
135   unsigned int AcqStatus : 2; /**< Acquisition status (TSL_AcqStatus_enum_T) */\r
136   unsigned int ObjStatus : 2; /**< Object status (TSL_ObjStatus_enum_T) */\r
137 } TSL_ChannelFlags_T;\r
138 \r
139 /** Channel Data\r
140   */\r
141 typedef struct\r
142 {\r
143   TSL_ChannelFlags_T   Flags;   /**< Flags */\r
144   TSL_tRef_T           Ref;     /**< Reference */\r
145   TSL_tRefRest_T       RefRest; /**< Reference rest for ECS */\r
146   TSL_tDelta_T         Delta;   /**< Delta */\r
147 #if TSLPRM_USE_MEAS > 0\r
148   TSL_tMeas_T          Meas;    /**< Hold the last acquisition measure */\r
149 #endif\r
150 } TSL_ChannelData_T;\r
151 \r
152 //------------------------------------------------------------------------------\r
153 // Bank\r
154 //------------------------------------------------------------------------------\r
155 \r
156 /** Bank\r
157   */\r
158 typedef struct\r
159 {\r
160   // Common to all acquisitions\r
161   CONST TSL_ChannelSrc_T  *p_chSrc;     /**< Pointer to the Channel Source and Configuration */\r
162   CONST TSL_ChannelDest_T *p_chDest;    /**< Pointer to the Channel Destination */\r
163   TSL_ChannelData_T       *p_chData;    /**< Pointer to the Channel Data */\r
164   TSL_tNb_T               NbChannels;   /**< Number of channels in the bank */\r
165   // For STM32F0x TSC acquisition only\r
166   uint32_t                msk_IOCCR_channels; /**< Mask of all channel IOs (electrodes AND shields) */\r
167   uint32_t                msk_IOGCSR_groups;  /**< Mask of all groups used (electrodes ONLY) */\r
168 } TSL_Bank_T;\r
169 \r
170 /* Exported variables --------------------------------------------------------*/\r
171 /* Exported macros -----------------------------------------------------------*/\r
172 /* Exported functions ------------------------------------------------------- */\r
173 \r
174 TSL_Status_enum_T TSL_acq_Init(void);\r
175 void TSL_acq_InitGPIOs(void);\r
176 TSL_Status_enum_T TSL_acq_BankConfig(TSL_tIndex_T idx_bk);\r
177 TSL_Bool_enum_T TSL_acq_UseFilter(TSL_ChannelData_T *pCh);\r
178 TSL_Bool_enum_T TSL_acq_TestReferenceOutOfRange(TSL_ChannelData_T *pCh);\r
179 TSL_Bool_enum_T TSL_acq_TestFirstReferenceIsValid(TSL_ChannelData_T *pCh, TSL_tMeas_T new_meas);\r
180 void TSL_acq_BankStartAcq(void);\r
181 TSL_Status_enum_T TSL_acq_BankWaitEOC(void);\r
182 TSL_AcqStatus_enum_T TSL_acq_CheckNoise(void);\r
183 TSL_tMeas_T TSL_acq_GetMeas(TSL_tIndexSrc_T index);\r
184 TSL_tDelta_T TSL_acq_ComputeDelta(TSL_tRef_T ref, TSL_tMeas_T meas);\r
185 TSL_tMeas_T TSL_acq_ComputeMeas(TSL_tRef_T ref, TSL_tDelta_T delta);\r
186 \r
187 #endif /* __TSL_ACQ_STM32F0XX_H */\r
188 \r
189 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r