pref: 修改蜂鸣器为非阻塞形式
This commit is contained in:
@@ -3,8 +3,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
#define BUZZER_QUEUE_LENGTH 40
|
#define BUZZER_TIME (100) // 蜂鸣器音节长度
|
||||||
|
#define BUZZER_QUEUE_LENGTH (40)
|
||||||
|
|
||||||
|
uint32_t time_out = 0;
|
||||||
uint16_t queue_long = 0;
|
uint16_t queue_long = 0;
|
||||||
uint32_t a[40] = {0};
|
uint32_t a[40] = {0};
|
||||||
|
|
||||||
@@ -59,9 +61,15 @@ void by_buzzer_add(uint16_t tone)
|
|||||||
void by_buzzer_run(void)
|
void by_buzzer_run(void)
|
||||||
{
|
{
|
||||||
if (queue_long != 0) {
|
if (queue_long != 0) {
|
||||||
pwm_init(BUZZER_PIN, a[0], 5000);
|
|
||||||
queue_pop_element();
|
if (0 == time_out) {
|
||||||
system_delay_ms(100);
|
pwm_init(BUZZER_PIN, a[0], 5000);
|
||||||
|
queue_pop_element();
|
||||||
|
time_out = BUZZER_TIME;
|
||||||
|
} else {
|
||||||
|
time_out--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
pwm_set_duty(BUZZER_PIN, 0);
|
pwm_set_duty(BUZZER_PIN, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ void TIM1_UP_IRQHandler(void)
|
|||||||
{
|
{
|
||||||
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
|
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
|
||||||
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
|
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
|
||||||
|
by_buzzer_run();
|
||||||
sport_motion();
|
sport_motion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,14 +65,13 @@ int main(void)
|
|||||||
// printf("pwm:%lu,%lu,%lu,%lu\r\n", pwm_duty_ls_g, pwm_duty_rs_g, pwm_duty_lb_g, pwm_duty_rb_g);
|
// printf("pwm:%lu,%lu,%lu,%lu\r\n", pwm_duty_ls_g, pwm_duty_rs_g, pwm_duty_lb_g, pwm_duty_rb_g);
|
||||||
Page_Run();
|
Page_Run();
|
||||||
by_frame_parse(&test_data[0].u32);
|
by_frame_parse(&test_data[0].u32);
|
||||||
by_buzzer_run();
|
|
||||||
jj_bt_run();
|
jj_bt_run();
|
||||||
in_pos = test_data[1].f32;
|
in_pos = test_data[1].f32;
|
||||||
in_angle = test_data[0].f32;
|
in_angle = test_data[0].f32;
|
||||||
in_state = test_data[2].u8[0];
|
in_state = test_data[2].u8[0];
|
||||||
in_stop = test_data[2].u8[1];
|
in_stop = test_data[2].u8[1];
|
||||||
if (last_state != in_state) {
|
if (last_state != in_state) {
|
||||||
bt_printf("changing to%u\r\n",in_state);
|
bt_printf("changing to%u\r\n", in_state);
|
||||||
}
|
}
|
||||||
last_state = in_state;
|
last_state = in_state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
//====================================================软件 IIC 驱动====================================================
|
//====================================================软件 IIC 驱动====================================================
|
||||||
#define K24C02_SOFT_IIC_DELAY (500) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
|
#define K24C02_SOFT_IIC_DELAY (500) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
|
||||||
#define K24C02_SCL_PIN (E3) // 软件 IIC SCL 引脚 连接 K24C02 的 SCL 引脚
|
#define K24C02_SCL_PIN (E3) // 软件 IIC SCL 引脚 连接 K24C02 的 SCL 引脚
|
||||||
#define K24C02_SDA_PIN (E2 ) // 软件 IIC SDA 引脚 连接 K24C02 的 SDA 引脚
|
#define K24C02_SDA_PIN (E2) // 软件 IIC SDA 引脚 连接 K24C02 的 SDA 引脚
|
||||||
//====================================================软件 IIC 驱动====================================================
|
//====================================================软件 IIC 驱动====================================================
|
||||||
#else
|
#else
|
||||||
//====================================================硬件 IIC 驱动====================================================
|
//====================================================硬件 IIC 驱动====================================================
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
#define K24C02_TIMEOUT_COUNT (0x00FF) // K24C02 超时计数
|
#define K24C02_TIMEOUT_COUNT (0x00FF) // K24C02 超时计数
|
||||||
|
|
||||||
//================================================定义 K24C02 内部地址================================================
|
//================================================定义 K24C02 内部地址================================================
|
||||||
#define K24C02_DEV_ADDR (0xA0 >> 1) // IIC写入时的地址字节数据 +1为读取
|
#define K24C02_DEV_ADDR (0xA0 >> 1) // IIC 写入时的地址字节数据 +1 为读取
|
||||||
//================================================定义 K24C02 内部地址================================================
|
//================================================定义 K24C02 内部地址================================================
|
||||||
|
|
||||||
#define K24C02_SIZE (256) // 256 byte
|
#define K24C02_SIZE (256) // 256 byte
|
||||||
|
|||||||
Reference in New Issue
Block a user