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.

156 lines
4.8 KiB

3 years ago
  1. // #include "ozone_pwm_control.h"
  2. // #define TIMINT_TIM 1800000
  3. // #define INTERVAL_TIM 300000
  4. // #define CLCK 48
  5. // ozone_messages_t ozone_messages;
  6. // extern timing_message_t timing_message;
  7. // extern uint32_t g_duty[4]; // PWMd��ռ�ձ�
  8. // extern uint32_t g_frequency;
  9. // extern ozone_message_t ozone_message;
  10. // /**
  11. // * @brief ��ʱ����
  12. // * *
  13. // * @brief ���ü�Ъ����������
  14. // *
  15. // * @param ozone_interval_period
  16. // * @param ozone_interval_duty
  17. // */
  18. // void ozone_pwm_control_set_pwm2(uint32_t ozone_interval_period,uint32_t ozone_interval_duty){
  19. // }
  20. // /**
  21. // * @brief ���ó���PWM����ʱ����ģʽ��һֱ��������ʱ��������Ъ������������
  22. // *
  23. // * @param mode
  24. // */
  25. // void set_ozone_work_mode(OZONE_WOEK_MODE_T mode) {
  26. // if (mode == HAS_BEEN_WORKING) {
  27. // set_ozone_work_gears(ozone_messages.will_be_set_work_gears);
  28. // } else if (mode == TIMING_WORK) {
  29. // ozone_pwm_control_set_pwm_output_1(ozone_messages.ozone_timing_duty);
  30. // } else if (mode == TIMING_INTERVAL_WORK) {
  31. // ozone_pwm_control_set_pwm_output_2(ozone_messages.ozone_timing_duty,
  32. // ozone_messages.ozone_interval_duty);
  33. // } else if (mode == STOP_PWM_WORK) {
  34. // ozone_pwm_control_stop_pwm();
  35. // }
  36. // ozone_messages.now_ozone_woek_mode = mode;
  37. // }
  38. // /**
  39. // * @brief ���ó���PWM������λ
  40. // *
  41. // * @param mode
  42. // */
  43. // void set_ozone_work_gears(OZONE_WOEK_GEARS_T gears) {
  44. // if (gears == LOW_END) {
  45. // ozone_pwm_control_set_pwm_duty(ozone_messages.ozone_pwm_frequency,
  46. // ozone_messages.ozone_pwm_duty);
  47. // } else if (gears == MIDDLE_GRADE) {
  48. // ozone_pwm_control_set_pwm_duty(ozone_messages.ozone_pwm_frequency,
  49. // ozone_messages.ozone_pwm_duty);
  50. // } else if (gears == SLAP_UP) {
  51. // ozone_pwm_control_set_pwm_duty(ozone_messages.ozone_pwm_frequency,
  52. // ozone_messages.ozone_pwm_duty);
  53. // }
  54. // ozone_messages.now_ozone_woek_gears = gears;
  55. // }
  56. // //######################################################
  57. // double calculate_top(double target_frequency) {
  58. // int clck = 0;
  59. // int target_frequency_hz = 0;
  60. // int top = 0;
  61. // clck = CLCK * 1000 * 1000;
  62. // target_frequency_hz = (int)target_frequency * 1000;
  63. // // printf("target_frequency_hz%d\n", target_frequency_hz);
  64. // top = clck / target_frequency_hz;
  65. // // printf("top%d\t\n", top);
  66. // return top;
  67. // }
  68. // double calculate_MAT2(double top, double duty) {
  69. // double percentage_duty = 0;
  70. // double Mat2 = 0;
  71. // percentage_duty = duty / 100;
  72. // Mat2 = top * percentage_duty;
  73. // return Mat2;
  74. // }
  75. // void ozone_pwm_control_set_pwm_duty(uint32_t set_frequency, uint32_t set_duty) {
  76. // double top = 0;
  77. // double Mat2 = 0;
  78. // if (set_frequency > CLCK * 1000) {
  79. // printf("out of range\n");
  80. // return;
  81. // }
  82. // top = calculate_top(set_frequency); //������Ҫ��Ƶ�ʼ�����TOP���Զ���װ��ֵ��
  83. // if (top == 0) {
  84. // return;
  85. // }
  86. // Mat2 = calculate_MAT2(top, set_duty);
  87. // // printf("top:\t%2.lf\n", top);
  88. // // printf("MAT2:\t%2.lf\n", Mat2);
  89. // // printf("MAT3:\t%2.lf\n", top);
  90. // T16Nx_Disable(T16N0);
  91. // t16n0_1_init();
  92. // T16Nx_SetMAT2(T16N0, Mat2);
  93. // T16Nx_SetMAT3(T16N0, top);
  94. // T16Nx_SetTOP1(T16N0, top);
  95. // }
  96. // //######################################################
  97. // /**
  98. // * @brief �ж�ʱ���޼�Ъ
  99. // *
  100. // * @param pwm_timing_duty
  101. // */
  102. // void ozone_pwm_control_set_pwm_output_1(uint32_t pwm_timing_duty) {}
  103. // /**
  104. // * @brief �ж�ʱ���м�Ъ
  105. // *
  106. // * @param pwm_duty
  107. // * @param pwm_interval_duty
  108. // */
  109. // void ozone_pwm_control_set_pwm_output_2(uint32_t pwm_timing_duty,
  110. // uint32_t pwm_interval_duty) {}
  111. // /**
  112. // * @brief ֹͣpwm����
  113. // *
  114. // */
  115. // void ozone_pwm_control_stop_pwm(void) { stop_ozone_work(); }
  116. // /**
  117. // * @brief ��ʱʱ�䵽���Ժ��ػ�
  118. // *
  119. // */
  120. // void try_shutdown(void) {
  121. // if (port_haspassedms(ozone_message.count_down_begin_sys_time) >= TIMINT_TIM) {
  122. // ozone_message.count_down_begin_sys_time = get_sys_ticket();
  123. // if (ozone_message.timing_rank == 1) { //��ʱʱ�䵽
  124. // set_timing_light_mode(CLOSE_ALL_LED);
  125. // printf("time over\r\n");
  126. // } else { //��ʱʱ����30min,ÿ��30min�ر�һ��led
  127. // printf("time minus 30min\r\n");
  128. // set_timing_light_mode(timing_message.now_timing_mode - 1);
  129. // }
  130. // }
  131. // }
  132. // /**
  133. // * @brief �ر�pwm����
  134. // *
  135. // */
  136. // void stop_ozone_work(void) {
  137. // set_ozone_work_mode(STOP_PWM_WORK); //�ر�PWM����
  138. // port_fan_set(false); //���Ƚ�������
  139. // close_all_light(); //�ر�rgb���ر�led0~led3
  140. // }