| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

MFT_Mode_4_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : MFT_Mode_4_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the MFT Mode 4 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
158 /* Includes ------------------------------------------------------------------*/
159 #include "BlueNRG1.h"
160 #include "BlueNRG1_conf.h"
161 #include "SDK_EVAL_Config.h"
162
163
177 /* Private typedef -----------------------------------------------------------*/
178 /* Private define ------------------------------------------------------------*/
179 #define IO_CAPTURE_PIN_MFT1_TIMERA 3 /* IO3 */
180
181 /* Private macro -------------------------------------------------------------*/
182 /* Private variables ---------------------------------------------------------*/
183 /* Private function prototypes -----------------------------------------------*/
184 void GPIO_Configuration(void);
185 void MFT_Configuration(void);
186
187 /* Private functions ---------------------------------------------------------*/
188
189
195 int main(void)
196 {
197 /* System initialization function */
198 SystemInit();
199
200 /* Identify BlueNRG1 platform */
201 SdkEvalIdentification();
202
203 /* GPIO configuration */
204 GPIO_Configuration();
205
206 /* MFT configuration */
207 MFT_Configuration();
208
209 /* IO3 for TnCRB */
210 MFT_SelectCapturePin(MFT1_TIMERB, IO_CAPTURE_PIN_MFT1_TIMERA);
211
212 /* Timer input sensitive to the rising edge */
213 MFT_TnEDGES(MFT1, MFT_RISING, MFT_RISING);
214
215 /* Connect PWM output from timer to TnA pin */
216 MFT_TnXEN(MFT1, MFT_TnA, ENABLE);
217
218 /* Enable preset for CNT1 TnB event */
219 MFT_TnXEN(MFT1, MFT_TnB, ENABLE);
220
221 /* Enable MFT interrupts */
222 MFT_EnableIT(MFT1, MFT_IT_TNA | MFT_IT_TNB | MFT_IT_TND, ENABLE);
223
224 /* Start MFT1 timer */
225 MFT_Cmd(MFT1, ENABLE);
226
227 /* Infinite loop */
228 while (1)
229 {
230 }
231 }
232
233
240 void GPIO_Configuration(void)
241 {
242 GPIO_InitType GPIO_InitStructure;
243
244 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_GPIO, ENABLE);
245
246 /* Configure PWM pin */
247 GPIO_InitStructure.GPIO_Pin = MFT_PWM0_PIN;
248 GPIO_InitStructure.GPIO_Mode = Serial1_Mode;
249 GPIO_InitStructure.GPIO_Pull = DISABLE;
250 GPIO_InitStructure.GPIO_HighPwr = DISABLE;
251 GPIO_Init(&GPIO_InitStructure);
252 }
253
260 void MFT_Configuration()
261 {
262 MFT_InitType timer_init;
263 NVIC_InitType NVIC_InitStructure;
264
265 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_MTFX1, ENABLE);
266
267 /* Init MFT1 in mode 4 */
268 timer_init.MFT_Mode = MFT_MODE_4;
269 timer_init.MFT_Clock1 = MFT_PRESCALED_CLK;
270 timer_init.MFT_Clock2 = MFT_PRESCALED_CLK;
271 timer_init.MFT_CRA = 50000-1;
272 timer_init.MFT_CRB = 0xFFFF;
273 timer_init.MFT_Prescaler = 16 - 1;
274 MFT_Init(MFT1, &timer_init);
275 MFT_SetCounter(MFT1, 50000-1, 0xFFFF);
276
277 /* Enable MFT Interrupts */
278 NVIC_InitStructure.NVIC_IRQChannel = MFT1A_IRQn;
279 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
280 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
281 NVIC_Init(&NVIC_InitStructure);
282
283 NVIC_InitStructure.NVIC_IRQChannel = MFT1B_IRQn;
284 NVIC_Init(&NVIC_InitStructure);
285 }
286
287 #ifdef USE_FULL_ASSERT
288
295 void assert_failed(uint8_t* file, uint32_t line)
296 {
297 /* User can add his own implementation to report the file name and line number,
298 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
299
300 /* Infinite loop */
301 while (1)
302 {
303 }
304 }
305
306 #endif
307
320 /******************* (C) COPYRIGHT 2014 STMicroelectronics *****END OF FILE****/
IO_CAPTURE_PIN_MFT1_TIMERA
#define IO_CAPTURE_PIN_MFT1_TIMERA
Definition: MFT_Mode_4_main.c:179
main
int main(void)
Main program code.
Definition: MFT_Mode_4_main.c:195
GPIO_Configuration
void GPIO_Configuration(void)
GPIO Configuration. Configure outputs GPIO pins.
Definition: MFT_Mode_4_main.c:240
MFT_Configuration
void MFT_Configuration(void)
MFT_Configuration. Configure MFT.
Definition: MFT_Mode_4_main.c:260