gpt audio implementation started, not working

clueboard_arm
Jack Humbert 7 years ago committed by skullY
parent 5e15803cd6
commit 8ef6b58caa

@ -34,7 +34,11 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes)
OPT_DEFS += -DAUDIO_ENABLE
MUSIC_ENABLE := 1
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
ifeq ($(PLATFORM),AVR)
SRC += $(QUANTUM_DIR)/audio/audio.c
else
SRC += $(QUANTUM_DIR)/audio/audio_arm.c
endif
SRC += $(QUANTUM_DIR)/audio/voices.c
SRC += $(QUANTUM_DIR)/audio/luts.c
endif

@ -14,118 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clueboard60.h"
#include "ch.h"
#include "hal.h"
/*
* DAC streaming callback.
*/
size_t nx = 0, ny = 0, nz = 0;
static void gpt_cb6(GPTDriver *gptp);
static void gpt_cb7(GPTDriver *gptp);
static void gpt_cb8(GPTDriver *gptp);
float frequency[2] = { 440.00, 523.25 };
/*
* GPT6 configuration.
*/
GPTConfig gpt6cfg1 = {
.frequency = 440.00,
// .frequency = 1000000,
.callback = gpt_cb6,
// .callback = NULL,
.cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
.dier = 0U
};
GPTConfig gpt7cfg1 = {
.frequency = 523.25,
.callback = gpt_cb7,
// .callback = NULL,
.cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
.dier = 0U
};
GPTConfig gpt8cfg1 = {
.frequency = 44100,
.callback = gpt_cb8,
.cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
.dier = 0U
};
static void gpt_cb6(GPTDriver *gptp) {
palTogglePad(GPIOA, 4);
// nz++;
// if ((nz % 1000) == 0) {
// palTogglePad(GPIOB, 7);
// nz = 0;
// gpt6cfg1.frequency *= 1.05946;
// gptStopTimer(&GPTD6);
// gptStart(&GPTD6, &gpt6cfg1);
// gptStartContinuous(&GPTD6, 2U);
// gpt7cfg1.frequency *= 1.05946;
// gptStopTimer(&GPTD7);
// gptStart(&GPTD7, &gpt7cfg1);
// gptStartContinuous(&GPTD7, 2U);
// }
}
static void gpt_cb7(GPTDriver *gptp) {
palTogglePad(GPIOA, 5);
// ny++;
// if ((ny % 1000) == 0) {
// palTogglePad(GPIOB, 7);
// ny = 0;
// }
}
static void gpt_cb8(GPTDriver *gptp) {
nz++;
if (nz == 5000) {
palTogglePad(GPIOB, 7);
nz = 0;
frequency[0] *= 1.05946;
frequency[1] *= 1.05946;
gpt6cfg1.frequency = frequency[0];
gptStopTimer(&GPTD6);
gptStart(&GPTD6, &gpt6cfg1);
gptStartContinuous(&GPTD6, 2U);
gpt7cfg1.frequency = frequency[1];
gptStopTimer(&GPTD7);
gptStart(&GPTD7, &gpt7cfg1);
gptStartContinuous(&GPTD7, 2U);
}
}
void matrix_init_kb(void) {
palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL);
gptStart(&GPTD6, &gpt6cfg1);
gptStart(&GPTD7, &gpt7cfg1);
gptStart(&GPTD8, &gpt8cfg1);
gptStartContinuous(&GPTD6, 2U);
gptStartContinuous(&GPTD7, 2U);
gptStartContinuous(&GPTD8, 2U);
}
void matrix_scan_kb(void) {

@ -48,5 +48,5 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = yes # Custom matrix file
# AUDIO_ENABLE = yes
AUDIO_ENABLE = yes
# SERIAL_LINK_ENABLE = yes

@ -18,12 +18,15 @@
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#if defined(__AVR__)
#include <avr/io.h>
#endif
#include "wait.h"
#include "musical_notes.h"
#include "song_list.h"
#include "voices.h"
#include "quantum.h"
#include <math.h>
// Largely untested PWM audio mode (doesn't sound as good)
// #define PWM_AUDIO

@ -14,9 +14,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "luts.h"
const float vibrato_lut[VIBRATO_LUT_LENGTH] =

@ -14,9 +14,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#if defined(__AVR__)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#else
#include "ch.h"
#include "hal.h"
#endif
#ifndef LUTS_H
#define LUTS_H

@ -15,8 +15,10 @@
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#if defined(__AVR__)
#include <avr/io.h>
#endif
#include "wait.h"
#include "luts.h"
#ifndef VOICES_H

Loading…
Cancel
Save