ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
watchdog_clear_n_reset.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/***
16 * Demo: Watchdog Clear And Reset
17 */
18
19#include "fw_hal.h"
20
21static uint8_t c0 = 0, c1 = 0;
22
23INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
24{
25 c0++;
26 if (c0 == 100)
27 {
28 c0 = 0;
29 c1++;
30 if (c1 < 5)
31 {
32 UART1_TxString("Round ");
34 UART1_TxString(", reset watchdog counter\r\n");
36 }
37 else
38 {
39 UART1_TxString("Round ");
41 UART1_TxString(", no operation\r\n");
42 }
43 }
44}
45
46int main(void)
47{
48 uint8_t count = 9;
51 UART1_TxString("Watchdog test restarted\r\n");
52 // Timer0: 12T mode, frequency 100Hz
58 UART1_TxString("Timer 0 started\r\n");
64 while(1);
65}
#define EXTI_Timer0_SetIntPriority(__PRIORITY__)
Definition: fw_exti.h:214
@ EXTI_IntPriority_High
Definition: fw_exti.h:25
#define EXTI_Timer0_SetIntState(__STATE__)
Definition: fw_exti.h:116
#define EXTI_Global_SetIntState(__STATE__)
Definition: fw_exti.h:115
#define EXTI_VectTimer0
Definition: fw_exti.h:38
void SYS_SetClock(void)
Definition: fw_sys.c:40
@ TIM_TimerMode_16BitAuto
Definition: fw_tim.h:24
void TIM_Timer0_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency)
Definition: fw_tim.c:38
#define TIM_Timer0_SetRunState(__STATE__)
Definition: fw_tim.h:35
@ HAL_State_OFF
Definition: fw_types.h:70
@ HAL_State_ON
Definition: fw_types.h:71
unsigned char uint8_t
Definition: fw_types.h:18
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
@ UART1_BaudSource_Timer2
Definition: fw_uart.h:34
void UART1_TxHex(uint8_t hex)
Definition: fw_uart.c:79
void UART1_Config8bitUart(UART1_BaudSource_t baudSource, HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:56
#define WDT_StartWatchDog()
Definition: fw_wdt.h:33
#define WDT_SetCounterPrescaler(__PRE_SCALER__)
Definition: fw_wdt.h:47
#define WDT_ResetCounter()
Definition: fw_wdt.h:37
static uint8_t c0
static uint8_t c1
INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
int main(void)