]> git.earman.xyz Git - sensor-watch.git/commitdiff
fixes 161: sets both CCBUF and PERFBUF for correct buzzer tone (#162)
authorgugray <gugray@users.noreply.github.com>
Tue, 10 Jan 2023 21:33:29 +0000 (22:33 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Jan 2023 21:33:29 +0000 (16:33 -0500)
watch-library/hardware/watch/watch_buzzer.c

index 7a5f17043f3aa58a09aa62ebd0273c298408e0ff..073034828c4d3d2b51d8e71a8fa2d907a217a479 100644 (file)
@@ -32,6 +32,7 @@
 }
 inline void watch_set_buzzer_period(uint32_t period) {
     hri_tcc_write_PERBUF_reg(TCC0, period);
+    hri_tcc_write_CCBUF_reg(TCC0, WATCH_BUZZER_TCC_CHANNEL, period / 2);
 }
 
 void watch_disable_buzzer(void) {
@@ -53,8 +54,7 @@ void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms) {
     if (note == BUZZER_NOTE_REST) {
         watch_set_buzzer_off();
     } else {
-        hri_tcc_write_PERBUF_reg(TCC0, NotePeriods[note]);
-        hri_tcc_write_CCBUF_reg(TCC0, WATCH_BUZZER_TCC_CHANNEL, NotePeriods[note] / 2);
+        watch_set_buzzer_period(NotePeriods[note]);
         watch_set_buzzer_on();
     }
     delay_ms(duration_ms);