From b908ae85935c8c679016bd3c3e01c4f91306f4de Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Fri, 15 Dec 2023 21:42:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E7=94=B5=E6=9C=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=E5=87=BD=E6=95=B0=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=8B=E9=92=AE=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_fan_control.c | 26 ++++++++++++++++++++ app/by_fan_control.h | 11 +++++++++ app/{by_peripheral_init.c => by_pt_button.c} | 9 ++++++- app/{by_peripheral_init.h => by_pt_button.h} | 6 ++--- app/isr.c | 2 +- app/main.c | 11 ++++----- 6 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 app/by_fan_control.c create mode 100644 app/by_fan_control.h rename app/{by_peripheral_init.c => by_pt_button.c} (69%) rename app/{by_peripheral_init.h => by_pt_button.h} (77%) diff --git a/app/by_fan_control.c b/app/by_fan_control.c new file mode 100644 index 0000000..ad7ccc5 --- /dev/null +++ b/app/by_fan_control.c @@ -0,0 +1,26 @@ +#include "by_fan_control.h" +#include "zf_common_headfile.h" + +void by_pwm_init(void) +{ + pwm_init(TIM4_PWM_MAP1_CH1_D12, 10000, 0); // 浮力风扇左 + pwm_init(TIM4_PWM_MAP1_CH2_D13, 10000, 0); // 浮力风扇右 + + pwm_init(TIM4_PWM_MAP1_CH3_D14, 10000, 0); // 动力风扇左 + pwm_init(TIM4_PWM_MAP1_CH4_D15, 10000, 0); // 动力风扇右 +} + +void by_pwm_update_duty(uint32_t update_pwm_duty) +{ + if (7000UL > update_pwm_duty) { + update_pwm_duty = 7000UL; + } + pwm_set_duty(TIM4_PWM_MAP1_CH1_D12, update_pwm_duty); + pwm_set_duty(TIM4_PWM_MAP1_CH2_D13, update_pwm_duty); +} + +void by_pwm_power_duty(uint32_t power_pwm_duty_l, uint32_t power_pwm_duty_r) +{ + pwm_set_duty(TIM4_PWM_MAP1_CH3_D14, power_pwm_duty_l); + pwm_set_duty(TIM4_PWM_MAP1_CH4_D15, power_pwm_duty_r); +} diff --git a/app/by_fan_control.h b/app/by_fan_control.h new file mode 100644 index 0000000..2ae6049 --- /dev/null +++ b/app/by_fan_control.h @@ -0,0 +1,11 @@ +#ifndef _BY_FAN_CONTROL_H_ +#define _BY_FAN_CONTROL_H_ + +#include "stdio.h" +#include "ch32v30x.h" + +extern void by_pwm_init(void); +extern void by_pwm_update_duty(uint32_t update_pwm_duty); +extern void by_pwm_power_duty(uint32_t power_pwm_duty_l, uint32_t power_pwm_duty_r); + +#endif \ No newline at end of file diff --git a/app/by_peripheral_init.c b/app/by_pt_button.c similarity index 69% rename from app/by_peripheral_init.c rename to app/by_pt_button.c index c44f301..fc0a5ce 100644 --- a/app/by_peripheral_init.c +++ b/app/by_pt_button.c @@ -1,4 +1,4 @@ -#include "by_peripheral_init.h" +#include "by_pt_button.h" #include "zf_common_headfile.h" uint8_t potate_button; void by_gpio_init(void) @@ -17,4 +17,11 @@ uint8_t by_get_pb_statu(void) uint8_t temp_s = potate_button; potate_button = 0; return temp_s; +} + +void by_ips_show(void) +{ + ips114_show_string(0, 0, "button statu:"); + ips114_show_uint(104, 0, by_get_pb_statu(), 1); + } \ No newline at end of file diff --git a/app/by_peripheral_init.h b/app/by_pt_button.h similarity index 77% rename from app/by_peripheral_init.h rename to app/by_pt_button.h index 7e19940..4e0ded1 100644 --- a/app/by_peripheral_init.h +++ b/app/by_pt_button.h @@ -1,5 +1,5 @@ -#ifndef _BY_PERIPHERAL_INIT_H__ -#define _BY_PERIPHERAL_INIT_H__ +#ifndef _BY_PT_BUTTON_H__ +#define _BY_PT_BUTTON_H__ #include "stdio.h" #include "ch32v30x.h" @@ -11,5 +11,5 @@ extern uint8_t potate_button; extern void by_exit_init(void); extern void by_gpio_init(void); extern uint8_t by_get_pb_statu(void); - +extern void by_ips_show(void); #endif \ No newline at end of file diff --git a/app/isr.c b/app/isr.c index af20fec..33f643e 100644 --- a/app/isr.c +++ b/app/isr.c @@ -34,7 +34,7 @@ ********************************************************************************************************************/ #include "zf_common_headfile.h" -#include "by_peripheral_init.h" +#include "by_pt_button.h" void NMI_Handler(void) __attribute__((interrupt())); void HardFault_Handler(void) __attribute__((interrupt())); diff --git a/app/main.c b/app/main.c index b620c6c..5822915 100644 --- a/app/main.c +++ b/app/main.c @@ -33,7 +33,8 @@ * 2022-09-15 W first version ********************************************************************************************************************/ #include "zf_common_headfile.h" -#include "by_peripheral_init.h" +#include "by_pt_button.h" +#include "by_fan_control.h" int main (void) @@ -45,17 +46,15 @@ int main (void) ips114_init(); by_gpio_init(); by_exit_init(); + by_pwm_init(); // mt9v03x_init(); // ˴дû ʼ while(1) { // ˴дҪѭִеĴ - // if(mt9v03x_finish_flag){ - // ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0); - // } - printf("%d\r\n",by_get_pb_statu()); - system_delay_ms(100); + + // ˴дҪѭִеĴ } }