You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /*********************************************************
  2. *Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
  3. *: main.c
  4. * : AE Team
  5. * : V1.00
  6. * : 2021/05/13
  7. * : GPIO模块示例程序
  8. * GPIO_PA2的电平状态LED1LED1
  9. * :
  10. *使
  11. **********************************************************/
  12. #include "main.h"
  13. #include <stdbool.h> //定义布尔
  14. extern int ozone_work_state;
  15. extern uint32_t g_sys_sick;
  16. extern zkey_module_t key_module;
  17. /***********************************************************************************************************************
  18. * ===========================================================================================================
  19. **
  20. ***********************************************************************************************************************/
  21. void iwdt_init(void) {
  22. /**
  23. * @brief 0+1
  24. * 2
  25. * 4
  26. *
  27. */
  28. IWDT_InitStruType x;
  29. x.WDT_Tms = 4000;
  30. x.WDT_IE = Enable; /* IWDT中断使能 */
  31. x.WDT_Rst = Enable; /* IWDT复位使能 */
  32. x.WDT_Clock = IWDT_CLOCK_WDT; /* LRC */
  33. IWDT_Init(&x);
  34. /* 使能IWDT */
  35. IWDT_Enable();
  36. }
  37. void feed_iwdt(void) {
  38. //喂狗
  39. if (0x01 == IWDT_GetFlagStatus()) //产生中断
  40. IWDT_Clear();
  41. }
  42. extern uint32_t print_time;
  43. //############### 测试一下看门狗 ##############//
  44. void test_iwdt(void){
  45. if(print_time<=5000){
  46. feed_iwdt();
  47. }
  48. }
  49. /***********************************************************************************************************************
  50. * =============================================================================================================
  51. **
  52. ***********************************************************************************************************************/
  53. int main(void) {
  54. HRC_Config(Enable, SCU_HRC_48M, Enable); //时钟源SCU_CLK_HRC
  55. SystemInit();
  56. DeviceClockAllEnable(); //打开所有外设时钟
  57. User_SysTickInit(); //滴答定时器初始化为(配置为1ms中断)
  58. SysTick_Enable();
  59. uart0_init();
  60. gpio_init();
  61. zkey_init(&key_module);
  62. t16n0_1_init(); //配置PA4输出pwm
  63. iwdt_init();
  64. gears_led_on(0); //上电以后默认高档工作亮红灯
  65. port_fan_set(true); //上电风扇开始工作
  66. printf("Initialization completed\r\n");
  67. while (1) {
  68. port_do_debug_light_state();
  69. port_key_state();
  70. if (ozone_work_state == 2)
  71. is_ozone_work_time_over();
  72. if (print_time >= 1800000) {
  73. // if (print_time >= 1000) {
  74. print_time = 0;
  75. printf("g_sys_sick:%d\n",g_sys_sick);
  76. }
  77. //test_iwdt();
  78. feed_iwdt();//当产生中断的时候进行喂狗操作
  79. }
  80. }