void buzzer_play (uint16_t frequency, uint16_t duration) { buzzer_pwm_set_frequency(frequency); buzzer_pwm_start(); StartSlowTimer (&buzzerTimer, duration, buzzerTimerCallback); }
void buzzer_play_sync (uint16_t frequency, uint32_t duration) { buzzer_pwm_set_frequency(frequency); buzzer_pwm_start(); while (duration--) delay_us (1000); buzzer_pwm_stop(); }
static void buzzer_pwm_set(struct buzzer_t * buzzer, int frequency) { struct buzzer_pwm_pdata_t * pdat = (struct buzzer_pwm_pdata_t *)buzzer->priv; if(pdat->frequency != frequency) { buzzer_pwm_set_frequency(pdat, frequency); pdat->frequency = frequency; } }
static void buzzer_pwm_resume(struct device_t * dev) { struct buzzer_t * buzzer = (struct buzzer_t *)dev->priv; struct buzzer_pwm_pdata_t * pdat = (struct buzzer_pwm_pdata_t *)buzzer->priv; buzzer_pwm_set_frequency(pdat, pdat->frequency); }
static void buzzer_pwm_suspend(struct device_t * dev) { struct buzzer_t * buzzer = (struct buzzer_t *)dev->priv; struct buzzer_pwm_pdata_t * pdat = (struct buzzer_pwm_pdata_t *)buzzer->priv; buzzer_pwm_set_frequency(pdat, 0); }