| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

MFT_Timers_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : MFT_Timers_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2016
7 * Description : Code demostrating the timers functionality
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
148 /* Includes ------------------------------------------------------------------*/
149 #include "BlueNRG1.h"
150 #include "BlueNRG1_conf.h"
151 #include "SDK_EVAL_Config.h"
152
166 /* Private typedef -----------------------------------------------------------*/
167 /* Private define ------------------------------------------------------------*/
168 /* Private macro -------------------------------------------------------------*/
169 /* Private variables ---------------------------------------------------------*/
170 /* Private function prototypes -----------------------------------------------*/
171 void MFT_Configuration(void);
172
173 /* Private functions ---------------------------------------------------------*/
174
175
181 int main(void)
182 {
183 /* System initialization function */
184 SystemInit();
185
186 /* Identify BlueNRG1 platform */
187 SdkEvalIdentification();
188
189 /* LEDs initialization */
190 SdkEvalLedInit(LED1);
191 SdkEvalLedInit(LED2);
192 SdkEvalLedInit(LED3);
193
194 /* MFT configuration */
195 MFT_Configuration();
196
197 /* Configure SysTick to generate interrupt with 1 second period */
198 SysTick_Config(16000000);
199
200 /* Start MFT timers */
201 MFT_Cmd(MFT1, ENABLE);
202 MFT_Cmd(MFT2, ENABLE);
203
204 /* Infinite loop */
205 while(1);
206 }
207
208
209
215 void MFT_Configuration(void)
216 {
217 NVIC_InitType NVIC_InitStructure;
218 MFT_InitType timer_init;
219
220 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_MTFX1 | CLOCK_PERIPH_MTFX2, ENABLE);
221
222 MFT_StructInit(&timer_init);
223
224 timer_init.MFT_Mode = MFT_MODE_1;
225 timer_init.MFT_Prescaler = 160-1; /* 10 us clock */
226
227 /* MFT1 configuration */
228 timer_init.MFT_Clock2 = MFT_PRESCALED_CLK;
229 MFT_Init(MFT1, &timer_init);
230 /* Set the counter at 500 ms */
231 MFT_SetCounter2(MFT1, 50000);
232
233 /* MFT2 configuration */
234 timer_init.MFT_Clock2 = MFT_PRESCALED_CLK;
235 MFT_Init(MFT2, &timer_init);
236 /* Set the counter at 250 ms */
237 MFT_SetCounter2(MFT2, 25000);
238
239 /* Enable MFT2 Interrupt 1 */
240 NVIC_InitStructure.NVIC_IRQChannel = MFT1B_IRQn;
241 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
242 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
243 NVIC_Init(&NVIC_InitStructure);
244
245 /* Enable MFT2 Interrupt 2 */
246 NVIC_InitStructure.NVIC_IRQChannel = MFT2B_IRQn;
247 NVIC_Init(&NVIC_InitStructure);
248
250 MFT_EnableIT(MFT1, MFT_IT_TND, ENABLE);
251 MFT_EnableIT(MFT2, MFT_IT_TND, ENABLE);
252 }
253
254 #ifdef USE_FULL_ASSERT
255
262 void assert_failed(uint8_t* file, uint32_t line)
263 {
264 /* User can add his own implementation to report the file name and line number,
265 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
266
267 /* Infinite loop */
268 while (1)
269 {
270 }
271 }
272
273 #endif
274
286 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
MFT_Configuration
void MFT_Configuration(void)
MFT_Configuration.
Definition: MFT_Timers_main.c:215
main
int main(void)
Main program code.
Definition: MFT_Timers_main.c:181