|
@ -1,5 +1,6 @@ |
|
|
#include "board_beep_ctrl.h" |
|
|
#include "board_beep_ctrl.h" |
|
|
#define BEEP_TIMER_INTERVAL (150) |
|
|
#define BEEP_TIMER_INTERVAL (150) |
|
|
|
|
|
#if 1 |
|
|
|
|
|
|
|
|
APP_TIMER_DEF(m_beep_tmr); // |
|
|
APP_TIMER_DEF(m_beep_tmr); // |
|
|
static nrf_drv_pwm_t m_beep_pwm0 = NRF_DRV_PWM_INSTANCE(BEEP_PWM_INSTANCE); |
|
|
static nrf_drv_pwm_t m_beep_pwm0 = NRF_DRV_PWM_INSTANCE(BEEP_PWM_INSTANCE); |
|
@ -70,17 +71,20 @@ static void beep_tmr_handler(void *context) { |
|
|
m_beep_cnt++; |
|
|
m_beep_cnt++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void BoardBeepCtrl_init(void) { app_timer_create(&m_beep_tmr, APP_TIMER_MODE_REPEATED, beep_tmr_handler); } |
|
|
|
|
|
void BoardBeepCtrl_load() { APP_ERROR_CHECK(nrfx_pwm_init(&m_beep_pwm0, &m_beep_pwm0_config0, NULL)); } |
|
|
|
|
|
|
|
|
void BoardBeepCtrl_init(void) { |
|
|
|
|
|
APP_ERROR_CHECK(nrfx_pwm_init(&m_beep_pwm0, &m_beep_pwm0_config0, NULL)); |
|
|
|
|
|
app_timer_create(&m_beep_tmr, APP_TIMER_MODE_REPEATED, beep_tmr_handler); |
|
|
|
|
|
} |
|
|
|
|
|
void BoardBeepCtrl_load() {} |
|
|
|
|
|
|
|
|
void BoardBeepCtrl_unload() { |
|
|
void BoardBeepCtrl_unload() { |
|
|
BoardBeepCtrl_set(0); |
|
|
BoardBeepCtrl_set(0); |
|
|
nrfx_pwm_uninit(&m_beep_pwm0); |
|
|
|
|
|
|
|
|
// nrfx_pwm_uninit(&m_beep_pwm0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void BoardBeepCtrl_set(uint8_t state) { |
|
|
void BoardBeepCtrl_set(uint8_t state) { |
|
|
if (state) { |
|
|
if (state) { |
|
|
m_beep_pwm0_seq_values.channel_0 = m_beep_pwm0_config0.top_value / 2; // 设置占空比,数值最大不超过 top_value |
|
|
|
|
|
|
|
|
m_beep_pwm0_seq_values.channel_0 = m_beep_pwm0_config0.top_value / 4; // 设置占空比,数值最大不超过 top_value |
|
|
nrfx_pwm_simple_playback(&m_beep_pwm0, &m_beep_pwm0_seq, 1, NRF_DRV_PWM_FLAG_LOOP); |
|
|
nrfx_pwm_simple_playback(&m_beep_pwm0, &m_beep_pwm0_seq, 1, NRF_DRV_PWM_FLAG_LOOP); |
|
|
} else { |
|
|
} else { |
|
|
nrfx_pwm_stop(&m_beep_pwm0, true); |
|
|
nrfx_pwm_stop(&m_beep_pwm0, true); |
|
@ -100,3 +104,15 @@ void BoardBeepCtrl_setEffect(BoardBeepEffect_t effect) { |
|
|
app_timer_start(m_beep_tmr, APP_TIMER_TICKS(BEEP_TIMER_INTERVAL), NULL); |
|
|
app_timer_start(m_beep_tmr, APP_TIMER_TICKS(BEEP_TIMER_INTERVAL), NULL); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
void BoardBeepCtrl_init(void) {} |
|
|
|
|
|
void BoardBeepCtrl_load() {} |
|
|
|
|
|
|
|
|
|
|
|
void BoardBeepCtrl_unload() {} |
|
|
|
|
|
|
|
|
|
|
|
void BoardBeepCtrl_set(uint8_t state) {} |
|
|
|
|
|
|
|
|
|
|
|
void BoardBeepCtrl_setEffect(BoardBeepEffect_t effect) {} |
|
|
|
|
|
#endif |