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.

101 lines
4.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
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 uint32_t g_count_down_begin_sys_time;
  17. extern uint32_t g_count_interval_down_begin_sys_time;
  18. extern zkey_module_t key_module;
  19. extern bool g_ozone_interva_stat;
  20. /***********************************************************************************************************************
  21. * ===========================================================================================================
  22. **
  23. ***********************************************************************************************************************/
  24. void iwdt_init(void) {
  25. /**
  26. * @brief 0+1
  27. * 2
  28. * 4
  29. *
  30. */
  31. IWDT_InitStruType x;
  32. x.WDT_Tms = 4000;
  33. x.WDT_IE = Enable; /* IWDT中断使能 */
  34. x.WDT_Rst = Enable; /* IWDT复位使能 */
  35. x.WDT_Clock = IWDT_CLOCK_WDT; /* LRC */
  36. IWDT_Init(&x);
  37. /* 使能IWDT */
  38. IWDT_Enable();
  39. }
  40. void feed_iwdt(void) {
  41. //喂狗
  42. if (0x01 == IWDT_GetFlagStatus()) //产生中断
  43. IWDT_Clear();
  44. }
  45. extern uint32_t print_time;
  46. //############### 测试一下看门狗 ##############//
  47. void test_iwdt(void) {
  48. if (print_time <= 5000) {
  49. feed_iwdt();
  50. }
  51. }
  52. /***********************************************************************************************************************
  53. * =============================================================================================================
  54. **
  55. ***********************************************************************************************************************/
  56. int main(void) {
  57. HRC_Config(Enable, SCU_HRC_48M, Enable); //时钟源SCU_CLK_HRC
  58. SystemInit();
  59. DeviceClockAllEnable(); //打开所有外设时钟
  60. User_SysTickInit(); //滴答定时器初始化为(配置为1ms中断)
  61. SysTick_Enable();
  62. uart0_init();
  63. gpio_init();
  64. zkey_init(&key_module);
  65. t16n0_1_init(); //配置PA4输出pwm
  66. iwdt_init();
  67. power_on_ozone_work_state(); //上电工作情况
  68. printf("Initialization completed\r\n");
  69. while (1) {
  70. // port_do_debug_light_state();
  71. port_key_state();
  72. if (get_ozone_starting_up_state() == true) { //开机中
  73. if (ozone_work_state == 2)
  74. is_ozone_work_time_over();
  75. if (g_ozone_interva_stat == true)
  76. is_ozone_interva_time_over();
  77. // if (print_time >= 300000) {
  78. // if (print_time >= 1800000) {
  79. if (print_time >= 10000) {
  80. print_time = 0;
  81. // // printf("mian port_haspassedms(g_count_down_begin_sys_time):%d\n",
  82. // // port_haspassedms(g_count_down_begin_sys_time));
  83. // // printf("mian g_sys_sick:%d\n", g_sys_sick);
  84. // printf("mian ozone_work_state:%d\n", ozone_work_state);
  85. // // printf("mian g_ozone_interva_stat:%d\n", g_ozone_interva_stat);
  86. printf("mian port_haspassedms(g_count_down_begin_sys_time):%d\r\n",
  87. port_haspassedms(g_count_down_begin_sys_time));
  88. printf("mian ozone_work_state:%d\r\n", ozone_work_state);
  89. printf(
  90. "mian port_haspassedms(g_count_interval_down_begin_sys_time):%d\r\n",
  91. port_haspassedms(g_count_interval_down_begin_sys_time));
  92. printf("mian g_ozone_interva_stat:%d\r\n", g_ozone_interva_stat);
  93. }
  94. }
  95. // test_iwdt();
  96. feed_iwdt(); //当产生中断的时候进行喂狗操作
  97. }
  98. }