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.

125 lines
4.6 KiB

3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
  1. #if 0
  2. /*********************************************************
  3. *Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
  4. *: main.c
  5. * : AE Team
  6. * : V1.00
  7. * : 2021/05/13
  8. * : GPIO模块示例程序
  9. * GPIO_PA2的电平状态LED1LED1
  10. * :
  11. *使
  12. **********************************************************/
  13. #include "main.h"
  14. #include <stdbool.h> //定义布尔
  15. // extern ozone_message_t ozone_message;
  16. extern zkey_module_t key_module;
  17. bool rgb_flicker_state = false;
  18. extern rgb_message_t rgb_message;
  19. /***********************************************************************************************************************
  20. * ===========================================================================================================
  21. **
  22. ***********************************************************************************************************************/
  23. void iwdt_init(void) {
  24. /**
  25. * @brief 0+1
  26. * 2
  27. * 4
  28. *
  29. */
  30. IWDT_InitStruType x;
  31. x.WDT_Tms = 4000;
  32. x.WDT_IE = Enable; /* IWDT中断使能 */
  33. x.WDT_Rst = Enable; /* IWDT复位使能 */
  34. x.WDT_Clock = IWDT_CLOCK_WDT; /* LRC */
  35. IWDT_Init(&x);
  36. /* 使能IWDT */
  37. IWDT_Enable();
  38. }
  39. void feed_iwdt(void) {
  40. //喂狗
  41. if (0x01 == IWDT_GetFlagStatus()) //产生中断
  42. {
  43. IWDT_Clear();
  44. // printf("喂狗\r\n");
  45. }
  46. }
  47. //############### 测试一下看门狗 ##############//
  48. /**
  49. * @brief ,
  50. *
  51. */
  52. void power_on_ozone_working_status(void) {
  53. // PWM频率1Khz,占空比0,占空比低有效,设置占空比为100,pwm一直输出低电平
  54. HOOK_pwm_module_set_pwm_duty(1, 100);
  55. light_module_set_timing_light_mode(CLOSE_ALL_LED);
  56. light_module_set_rgb_mode(RGB_COLOR_RED);
  57. port_fan_set(false); //打开你风扇
  58. }
  59. /***********************************************************************************************************************
  60. * =============================================================================================================
  61. **
  62. ***********************************************************************************************************************/
  63. int main(void) {
  64. HRC_Config(Enable, SCU_HRC_48M, Enable); //时钟源SCU_CLK_HRC
  65. SystemInit();
  66. DeviceClockAllEnable(); //打开所有外设时钟
  67. User_SysTickInit(); //滴答定时器初始化为(配置为1ms中断)
  68. SysTick_Enable();
  69. uart0_init();
  70. gpio_init();
  71. zkey_init(&key_module);
  72. t16n0_1_init(); //配置PA4输出pwm
  73. // iwdt_init();
  74. power_on_ozone_working_status();
  75. // power_on_ozone_work_state(); //上电工作情况
  76. // ADCInit("A",4);
  77. // printf("Initialization completed\r\n");
  78. while (1) {
  79. // port_do_debug_light_state();
  80. port_key_state();
  81. // if (get_ozone_starting_up_state() == true) { //开机中
  82. // // if (ozone_message.ozone_work_state == 2)
  83. // // is_ozone_work_time_over();
  84. // // if (ozone_message.ozone_interva_state == true) {
  85. // // set_rgb_flicker(); //间歇状态下rgb亮3灭1
  86. // // is_ozone_interva_time_over();
  87. // // }
  88. // pwm_module_loop();
  89. // if (rgb_message.rgb_flicker_mode == true) {
  90. // process_rgb_flicker_mode();
  91. // rgb_message.already_set_rgb_mode = false;
  92. // } else if (rgb_message.rgb_flicker_mode == false) {
  93. // if (rgb_message.already_set_rgb_mode == false)
  94. // light_module_set_rgb_mode(rgb_message.turn_off_the_mode_before_rgb);
  95. // rgb_message.already_set_rgb_mode = true;
  96. // }
  97. // // adc_loop_gather();
  98. // } else if (get_ozone_starting_up_state() == false) { //关机
  99. // }
  100. // test_iwdt();
  101. // feed_iwdt(); //当产生中断的时候进行喂狗操作
  102. }
  103. }
  104. #endif
  105. #include <stdbool.h> //定义布尔
  106. #include "main.h"
  107. extern zkey_module_t key_module;
  108. int main(void) {
  109. HRC_Config(Enable, SCU_HRC_48M, Enable); //时钟源SCU_CLK_HRC
  110. SystemInit();
  111. DeviceClockAllEnable(); //打开所有外设时钟
  112. User_SysTickInit(); //滴答定时器初始化为(配置为1ms中断)
  113. SysTick_Enable();
  114. uart0_init();
  115. gpio_init();
  116. // zkey_init(&key_module);
  117. }