| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

WDG_Reset_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : WDG_Reset_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the watchdog reset 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
162 /* Includes ------------------------------------------------------------------*/
163 #include "BlueNRG1.h"
164 #include "BlueNRG1_it.h"
165 #include "BlueNRG1_conf.h"
166 #include "SDK_EVAL_Config.h"
167
180 /* Private typedef -----------------------------------------------------------*/
181 /* Private define ------------------------------------------------------------*/
182 /* Private macro -------------------------------------------------------------*/
183 /* Private variables ---------------------------------------------------------*/
184 /* Private function prototypes -----------------------------------------------*/
185 void WDG_Configuration(void);
186 void MFT_Configuration(void);
187
188 /* Private functions ---------------------------------------------------------*/
189
195 #include <stdio.h>
196 int main(void)
197 {
198 /* System initialization function */
199 SystemInit();
200
201 /* Identify BlueNRG1 platform */
202 SdkEvalIdentification();
203
204 /* LEDs initialization function */
205 SdkEvalLedInit(LED1);
206 SdkEvalLedInit(LED2);
207 SdkEvalLedInit(LED3);
208
209 /* Push1 button initialization function */
210 SdkEvalPushButtonInit(BUTTON_1);
211 SdkEvalPushButtonIrq(BUTTON_1, IRQ_ON_RISING_EDGE);
212
213 /* MFT configuration */
214 MFT_Configuration();
215
216 /* WDG configuration */
217 WDG_Configuration();
218
219 /* Watchdog enable */
220 WDG_Enable();
221
222 /* MFT1 enable */
223 MFT_Cmd(MFT1, ENABLE);
224
225 /* Infinite loop */
226 while (1);
227 }
228
229
235 void WDG_Configuration(void)
236 {
237 NVIC_InitType NVIC_InitStructure;
238
239 /* Enable watchdog clocks */
240 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_WDG, ENABLE);
241
242 /* Set watchdog reload period at 15 seconds */
243 WDG_SetReload(RELOAD_TIME(WDG_TIME));
244
245 /* Enable the watchdog interrupt */
246 NVIC_InitStructure.NVIC_IRQChannel = WDG_IRQn;
247 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
248 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
249 NVIC_Init(&NVIC_InitStructure);
250 }
251
252
258 void MFT_Configuration(void)
259 {
260 NVIC_InitType NVIC_InitStructure;
261 MFT_InitType timer_init;
262
263 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_MTFX1, ENABLE);
264
265 MFT_StructInit(&timer_init);
266
267 timer_init.MFT_Mode = MFT_MODE_1;
268
269 /* Clock period at 10 us */
270 timer_init.MFT_Prescaler = 160-1;
271
272 /* MFT1 in mode 1 on Low speed clock (TIMER_8MHZ) generate 10kHz signal */
273 timer_init.MFT_Clock1 = MFT_PRESCALED_CLK;
274 timer_init.MFT_Clock2 = MFT_NO_CLK;
275 timer_init.MFT_CRA = 50000 - 1;
276 timer_init.MFT_CRB = 50000 - 1;
277 MFT_Init(MFT1, &timer_init);
278
279 /* Enable MFT2 Interrupt 1 */
280 NVIC_InitStructure.NVIC_IRQChannel = MFT1A_IRQn;
281 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
282 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
283 NVIC_Init(&NVIC_InitStructure);
284
285 MFT_EnableIT(MFT1, MFT_IT_TNA, ENABLE);
286 }
287
288
289 #ifdef USE_FULL_ASSERT
290
297 void assert_failed(uint8_t* file, uint32_t line)
298 {
299 /* User can add his own implementation to report the file name and line number,
300 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
301
302 /* Infinite loop */
303 while (1)
304 {
305 }
306 }
307
308 #endif
309
322 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
MFT_Configuration
void MFT_Configuration(void)
MFT configuration routine.
Definition: WDG_Reset_main.c:258
WDG_Configuration
void WDG_Configuration(void)
WDG configuration routine.
Definition: WDG_Reset_main.c:235
main
int main(void)
Main program code.
Definition: WDG_Reset_main.c:196
RELOAD_TIME
#define RELOAD_TIME(sec)
Definition: WDG_Wakeup_main.c:181