新增了电机相关功能函数 修改旋钮的接口
This commit is contained in:
26
app/by_fan_control.c
Normal file
26
app/by_fan_control.c
Normal file
@@ -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);
|
||||||
|
}
|
||||||
11
app/by_fan_control.h
Normal file
11
app/by_fan_control.h
Normal file
@@ -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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "by_peripheral_init.h"
|
#include "by_pt_button.h"
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
uint8_t potate_button;
|
uint8_t potate_button;
|
||||||
void by_gpio_init(void)
|
void by_gpio_init(void)
|
||||||
@@ -18,3 +18,10 @@ uint8_t by_get_pb_statu(void)
|
|||||||
potate_button = 0;
|
potate_button = 0;
|
||||||
return temp_s;
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _BY_PERIPHERAL_INIT_H__
|
#ifndef _BY_PT_BUTTON_H__
|
||||||
#define _BY_PERIPHERAL_INIT_H__
|
#define _BY_PT_BUTTON_H__
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "ch32v30x.h"
|
#include "ch32v30x.h"
|
||||||
@@ -11,5 +11,5 @@ extern uint8_t potate_button;
|
|||||||
extern void by_exit_init(void);
|
extern void by_exit_init(void);
|
||||||
extern void by_gpio_init(void);
|
extern void by_gpio_init(void);
|
||||||
extern uint8_t by_get_pb_statu(void);
|
extern uint8_t by_get_pb_statu(void);
|
||||||
|
extern void by_ips_show(void);
|
||||||
#endif
|
#endif
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
********************************************************************************************************************/
|
********************************************************************************************************************/
|
||||||
|
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
#include "by_peripheral_init.h"
|
#include "by_pt_button.h"
|
||||||
|
|
||||||
void NMI_Handler(void) __attribute__((interrupt()));
|
void NMI_Handler(void) __attribute__((interrupt()));
|
||||||
void HardFault_Handler(void) __attribute__((interrupt()));
|
void HardFault_Handler(void) __attribute__((interrupt()));
|
||||||
|
|||||||
11
app/main.c
11
app/main.c
@@ -33,7 +33,8 @@
|
|||||||
* 2022-09-15 <20><>W first version
|
* 2022-09-15 <20><>W first version
|
||||||
********************************************************************************************************************/
|
********************************************************************************************************************/
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
#include "by_peripheral_init.h"
|
#include "by_pt_button.h"
|
||||||
|
#include "by_fan_control.h"
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
@@ -45,17 +46,15 @@ int main (void)
|
|||||||
ips114_init();
|
ips114_init();
|
||||||
by_gpio_init();
|
by_gpio_init();
|
||||||
by_exit_init();
|
by_exit_init();
|
||||||
|
by_pwm_init();
|
||||||
// mt9v03x_init();
|
// mt9v03x_init();
|
||||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
||||||
// 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);
|
|
||||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user