diff options
author | zvecr <git@zvecr.com> | 2022-02-25 23:45:40 +0000 |
---|---|---|
committer | zvecr <git@zvecr.com> | 2022-02-25 23:45:40 +0000 |
commit | e7931289918221081cbe2a7ea5df27a5d86324db (patch) | |
tree | 0b06145520f8aaf5ff5cb928aa5176fc2dd23619 /platforms/chibios/drivers/audio_pwm_software.c | |
parent | c0ee3d2c79388187883b1b1b1d1a0b6842acf741 (diff) | |
parent | cf31355f08dca311a013168eb3eb995e2fc6a3d1 (diff) |
Merge remote-tracking branch 'origin/develop'
Diffstat (limited to 'platforms/chibios/drivers/audio_pwm_software.c')
-rw-r--r-- | platforms/chibios/drivers/audio_pwm_software.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/platforms/chibios/drivers/audio_pwm_software.c b/platforms/chibios/drivers/audio_pwm_software.c index 15c3e98b6a..e01f86ea52 100644 --- a/platforms/chibios/drivers/audio_pwm_software.c +++ b/platforms/chibios/drivers/audio_pwm_software.c @@ -57,7 +57,7 @@ static float channel_1_frequency = 0.0f; void channel_1_set_frequency(float freq) { channel_1_frequency = freq; - if (freq <= 0.0) // a pause/rest has freq=0 + if (freq <= 0.0) // a pause/rest has freq=0 return; pwmcnt_t period = (pwmCFG.frequency / freq); @@ -68,7 +68,9 @@ void channel_1_set_frequency(float freq) { PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100)); } -float channel_1_get_frequency(void) { return channel_1_frequency; } +float channel_1_get_frequency(void) { + return channel_1_frequency; +} void channel_1_start(void) { pwmStop(&AUDIO_PWM_DRIVER); @@ -81,10 +83,10 @@ void channel_1_start(void) { void channel_1_stop(void) { pwmStop(&AUDIO_PWM_DRIVER); - palClearLine(AUDIO_PIN); // leave the line low, after last note was played + palClearLine(AUDIO_PIN); // leave the line low, after last note was played #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) - palClearLine(AUDIO_PIN_ALT); // leave the line low, after last note was played + palClearLine(AUDIO_PIN_ALT); // leave the line low, after last note was played #endif } @@ -100,7 +102,7 @@ static void pwm_audio_period_callback(PWMDriver *pwmp) { static void pwm_audio_channel_interrupt_callback(PWMDriver *pwmp) { (void)pwmp; if (channel_1_frequency > 0) { - palSetLine(AUDIO_PIN); // generate a PWM signal on any pin, not necessarily the one connected to the timer + palSetLine(AUDIO_PIN); // generate a PWM signal on any pin, not necessarily the one connected to the timer #if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE) palClearLine(AUDIO_PIN_ALT); #endif @@ -131,7 +133,7 @@ void audio_driver_initialize(void) { palClearLine(AUDIO_PIN_ALT); #endif - pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER); // enable pwm callbacks + pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER); // enable pwm callbacks pwmEnableChannelNotification(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1); gptStart(&AUDIO_STATE_TIMER, &gptCFG); @@ -155,10 +157,10 @@ void audio_driver_stop(void) { * and updates the pwm to output that frequency */ static void gpt_callback(GPTDriver *gptp) { - float freq; // TODO: freq_alt + float freq; // TODO: freq_alt if (audio_update_state()) { - freq = audio_get_processed_frequency(0); // freq_alt would be index=1 + freq = audio_get_processed_frequency(0); // freq_alt would be index=1 channel_1_set_frequency(freq); } } |