aboutsummaryrefslogtreecommitdiff
path: root/quantum/audio/audio_chibios.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/audio/audio_chibios.c')
-rw-r--r--quantum/audio/audio_chibios.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/quantum/audio/audio_chibios.c b/quantum/audio/audio_chibios.c
index 1f147f2c9..dddb8f135 100644
--- a/quantum/audio/audio_chibios.c
+++ b/quantum/audio/audio_chibios.c
@@ -86,13 +86,21 @@ static void gpt_cb8(GPTDriver *gptp);
86 86
87#define START_CHANNEL_1() \ 87#define START_CHANNEL_1() \
88 gptStart(&GPTD6, &gpt6cfg1); \ 88 gptStart(&GPTD6, &gpt6cfg1); \
89 gptStartContinuous(&GPTD6, 2U) 89 gptStartContinuous(&GPTD6, 2U); \
90 palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG)
90#define START_CHANNEL_2() \ 91#define START_CHANNEL_2() \
91 gptStart(&GPTD7, &gpt7cfg1); \ 92 gptStart(&GPTD7, &gpt7cfg1); \
92 gptStartContinuous(&GPTD7, 2U) 93 gptStartContinuous(&GPTD7, 2U); \
93#define STOP_CHANNEL_1() gptStopTimer(&GPTD6) 94 palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG)
94#define STOP_CHANNEL_2() gptStopTimer(&GPTD7) 95#define STOP_CHANNEL_1() \
95#define RESTART_CHANNEL_1() \ 96 gptStopTimer(&GPTD6); \
97 palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL); \
98 palSetPad(GPIOA, 4)
99#define STOP_CHANNEL_2() \
100 gptStopTimer(&GPTD7); \
101 palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL); \
102 palSetPad(GPIOA, 5)
103 #define RESTART_CHANNEL_1() \
96 STOP_CHANNEL_1(); \ 104 STOP_CHANNEL_1(); \
97 START_CHANNEL_1() 105 START_CHANNEL_1()
98#define RESTART_CHANNEL_2() \ 106#define RESTART_CHANNEL_2() \
@@ -274,6 +282,12 @@ void audio_init() {
274 dacStart(&DACD2, &dac1cfg2); 282 dacStart(&DACD2, &dac1cfg2);
275 283
276 /* 284 /*
285 * Start the note timer
286 */
287 gptStart(&GPTD8, &gpt8cfg1);
288 gptStartContinuous(&GPTD8, 2U);
289
290 /*
277 * Starting GPT6/7 driver, it is used for triggering the DAC. 291 * Starting GPT6/7 driver, it is used for triggering the DAC.
278 */ 292 */
279 START_CHANNEL_1(); 293 START_CHANNEL_1();
@@ -287,10 +301,12 @@ void audio_init() {
287 301
288 audio_initialized = true; 302 audio_initialized = true;
289 303
304 stop_all_notes();
305}
306
307void audio_startup() {
290 if (audio_config.enable) { 308 if (audio_config.enable) {
291 PLAY_SONG(startup_song); 309 PLAY_SONG(startup_song);
292 } else {
293 stop_all_notes();
294 } 310 }
295} 311}
296 312
@@ -630,6 +646,9 @@ bool is_playing_notes(void) { return playing_notes; }
630bool is_audio_on(void) { return (audio_config.enable != 0); } 646bool is_audio_on(void) { return (audio_config.enable != 0); }
631 647
632void audio_toggle(void) { 648void audio_toggle(void) {
649 if (audio_config.enable) {
650 stop_all_notes();
651 }
633 audio_config.enable ^= 1; 652 audio_config.enable ^= 1;
634 eeconfig_update_audio(audio_config.raw); 653 eeconfig_update_audio(audio_config.raw);
635 if (audio_config.enable) { 654 if (audio_config.enable) {