summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common_features.mk21
-rw-r--r--docs/_summary.md1
-rw-r--r--docs/audio_driver.md221
-rw-r--r--docs/config_options.md12
-rw-r--r--docs/feature_audio.md143
-rw-r--r--keyboards/1upkeyboards/sweet16/v2/proton_c/config.h4
-rw-r--r--keyboards/atomic/keymaps/pvc/config.h2
-rw-r--r--keyboards/boston_meetup/2019/config.h5
-rw-r--r--keyboards/c39/keymaps/kuchosauronad0/config.h9
-rw-r--r--keyboards/ckeys/obelus/config.h2
-rwxr-xr-xkeyboards/ckeys/thedora/config.h3
-rw-r--r--keyboards/clueboard/2x1800/2018/config.h4
-rw-r--r--keyboards/clueboard/2x1800/2019/config.h4
-rw-r--r--keyboards/clueboard/66/rev4/config.h4
-rw-r--r--keyboards/clueboard/66_hotswap/gen1/config.h4
-rw-r--r--keyboards/clueboard/66_hotswap/prototype/config.h2
-rw-r--r--keyboards/clueboard/california/config.h4
-rw-r--r--keyboards/clueboard/card/config.h2
-rw-r--r--keyboards/crkbd/keymaps/gotham/config.h2
-rw-r--r--keyboards/ergodash/mini/config.h2
-rw-r--r--keyboards/ergodash/rev1/config.h2
-rw-r--r--keyboards/evyd13/plain60/keymaps/audio/config.h2
-rw-r--r--keyboards/flehrad/bigswitch/keymaps/wanleg/config.h2
-rw-r--r--keyboards/hadron/ver3/config.h6
-rw-r--r--keyboards/handwired/aranck/config.h2
-rw-r--r--keyboards/handwired/dactyl_manuform/5x6_right_trackball/config.h2
-rw-r--r--keyboards/handwired/heisenberg/config.h2
-rw-r--r--keyboards/handwired/ibm122m/config.h6
-rw-r--r--keyboards/handwired/xealous/config.h3
-rw-r--r--keyboards/helix/pico/config.h2
-rw-r--r--keyboards/hp69/config.h5
-rw-r--r--keyboards/jones/v03/config.h4
-rw-r--r--keyboards/jones/v03_1/config.h4
-rw-r--r--keyboards/keebio/iris/keymaps/blucky/config.h4
-rw-r--r--keyboards/keebio/iris/keymaps/broswen/config.h2
-rw-r--r--keyboards/keebio/iris/keymaps/drashna/config.h2
-rw-r--r--keyboards/keebio/iris/keymaps/mtdjr/config.h2
-rw-r--r--keyboards/keebio/iris/keymaps/pvinis/config.h2
-rw-r--r--keyboards/keebio/levinson/keymaps/issmirnov/config.h2
-rw-r--r--keyboards/keebio/quefrency/keymaps/drashna_ms/config.h2
-rw-r--r--keyboards/keebio/viterbi/keymaps/drashna/config.h2
-rwxr-xr-xkeyboards/keysofkings/twokey/config.h30
-rw-r--r--keyboards/knops/mini/keymaps/mverteuil/config.h4
-rw-r--r--keyboards/launchpad/keymaps/drashna/config.h2
-rw-r--r--keyboards/lets_split/sockets/config.h2
-rw-r--r--keyboards/lfkeyboards/lfk78/config.h2
-rw-r--r--keyboards/lfkeyboards/lfk87/config.h2
-rw-r--r--keyboards/lfkeyboards/mini1800/config.h2
-rw-r--r--keyboards/lfkeyboards/smk65/revb/config.h3
-rw-r--r--keyboards/meira/featherble/config.h2
-rw-r--r--keyboards/meira/keymaps/grahampheath/config.h2
-rw-r--r--keyboards/mitosis/keymaps/datagrok/config.h2
-rw-r--r--keyboards/mitosis/keymaps/mjt/config.h2
-rw-r--r--keyboards/moonlander/config.h4
-rw-r--r--keyboards/mschwingen/modelm/config.h2
-rw-r--r--keyboards/nack/config.h14
-rw-r--r--keyboards/nightly_boards/n40_o/config.h4
-rw-r--r--keyboards/nightly_boards/n87/config.h2
-rw-r--r--keyboards/nightly_boards/octopad/config.h2
-rw-r--r--keyboards/orthodox/keymaps/drashna/config.h2
-rw-r--r--keyboards/planck/config.h2
-rw-r--r--keyboards/planck/ez/config.h5
-rw-r--r--keyboards/planck/keymaps/dodger/config.h2
-rw-r--r--keyboards/planck/keymaps/synth_sample/config.h56
-rw-r--r--keyboards/planck/keymaps/synth_sample/keymap.c296
-rw-r--r--keyboards/planck/keymaps/synth_sample/rules.mk2
-rw-r--r--keyboards/planck/keymaps/synth_sample/sample.h3797
-rw-r--r--keyboards/planck/keymaps/synth_wavetable/config.h56
-rw-r--r--keyboards/planck/keymaps/synth_wavetable/keymap.c320
-rw-r--r--keyboards/planck/keymaps/synth_wavetable/rules.mk2
-rw-r--r--keyboards/planck/keymaps/synth_wavetable/wavetable.h2197
-rw-r--r--keyboards/planck/light/config.h4
-rw-r--r--keyboards/planck/rev6/config.h6
-rw-r--r--keyboards/preonic/config.h2
-rw-r--r--keyboards/preonic/rev3/config.h6
-rw-r--r--keyboards/scarletbandana/config.h2
-rw-r--r--keyboards/silverbullet44/config.h2
-rw-r--r--keyboards/splitkb/zima/config.h2
-rw-r--r--keyboards/subatomic/config.h2
-rwxr-xr-xkeyboards/tetris/config.h2
-rw-r--r--keyboards/vitamins_included/rev1/config.h2
-rw-r--r--keyboards/vitamins_included/rev2/config.h2
-rw-r--r--keyboards/wilba_tech/wt60_xt/config.h2
-rw-r--r--keyboards/yoichiro/lunakey_mini/config.h2
-rw-r--r--layouts/community/numpad_5x6/bjohnson/config.h2
-rw-r--r--layouts/community/numpad_5x6/drashna/config.h1
-rw-r--r--layouts/community/ortho_4x12/bakingpy/config.h2
-rw-r--r--layouts/community/ortho_5x12/drashna/config.h2
-rw-r--r--layouts/community/ortho_5x14/yet-another-developer/config.h2
-rw-r--r--layouts/community/split_3x6_3/drashna/config.h2
-rw-r--r--quantum/audio/audio.c539
-rw-r--r--quantum/audio/audio.h281
-rw-r--r--quantum/audio/audio_avr.c812
-rw-r--r--quantum/audio/audio_chibios.c721
-rw-r--r--quantum/audio/audio_pwm.c606
-rw-r--r--quantum/audio/driver_avr_pwm.h17
-rw-r--r--quantum/audio/driver_avr_pwm_hardware.c322
-rw-r--r--quantum/audio/driver_chibios_dac.h126
-rw-r--r--quantum/audio/driver_chibios_dac_additive.c335
-rw-r--r--quantum/audio/driver_chibios_dac_basic.c245
-rw-r--r--quantum/audio/driver_chibios_pwm.h40
-rw-r--r--quantum/audio/driver_chibios_pwm_hardware.c144
-rw-r--r--quantum/audio/driver_chibios_pwm_software.c164
-rw-r--r--quantum/audio/musical_notes.h77
-rw-r--r--quantum/audio/voices.c170
-rw-r--r--quantum/audio/voices.h21
-rw-r--r--quantum/audio/wave.h36
-rw-r--r--quantum/backlight/backlight_avr.c4
-rw-r--r--requirements-dev.txt1
-rw-r--r--users/yanfali/config.h2
-rwxr-xr-xutil/audio_generate_dac_lut.py67
-rwxr-xr-xutil/sample_parser.py39
-rwxr-xr-xutil/wavetable_parser.py40
113 files changed, 9731 insertions, 2456 deletions
diff --git a/common_features.mk b/common_features.mk
index 8338ce4080..6463efb8ba 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -42,12 +42,31 @@ ifeq ($(strip $(COMMAND_ENABLE)), yes)
OPT_DEFS += -DCOMMAND_ENABLE
endif
+AUDIO_ENABLE ?= no
ifeq ($(strip $(AUDIO_ENABLE)), yes)
+ ifeq ($(PLATFORM),CHIBIOS)
+ AUDIO_DRIVER ?= dac_basic
+ ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
+ else
+ # fallback for all other platforms is pwm
+ AUDIO_DRIVER ?= pwm_hardware
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
OPT_DEFS += -DAUDIO_ENABLE
MUSIC_ENABLE = yes
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
- SRC += $(QUANTUM_DIR)/audio/audio_$(PLATFORM_KEY).c
+ SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
+ SRC += $(QUANTUM_DIR)/audio/driver_$(PLATFORM_KEY)_$(strip $(AUDIO_DRIVER)).c
SRC += $(QUANTUM_DIR)/audio/voices.c
SRC += $(QUANTUM_DIR)/audio/luts.c
endif
diff --git a/docs/_summary.md b/docs/_summary.md
index 526caf926f..acbfcfaeda 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -133,6 +133,7 @@
* [Compatible Microcontrollers](compatible_microcontrollers.md)
* [Drivers](hardware_drivers.md)
* [ADC Driver](adc_driver.md)
+ * [Audio Driver](audio_driver.md)
* [I2C Driver](i2c_driver.md)
* [SPI Driver](spi_driver.md)
* [WS2812 Driver](ws2812_driver.md)
diff --git a/docs/audio_driver.md b/docs/audio_driver.md
new file mode 100644
index 0000000000..7cd5a98d9f
--- /dev/null
+++ b/docs/audio_driver.md
@@ -0,0 +1,221 @@
+# Audio Driver :id=audio-driver
+
+The [Audio feature](feature_audio.md) breaks the hardware specifics out into separate, exchangeable driver units, with a common interface to the audio-"core" - which itself handles playing songs and notes while tracking their progress in an internal state, initializing/starting/stopping the driver as needed.
+
+Not all MCUs support every available driver, either the platform-support is not there (yet?) or the MCU simply does not have the required hardware peripheral.
+
+
+## AVR :id=avr
+
+Boards built around an Atmega32U4 can use two sets of PWM capable pins, each driving a separate speaker.
+The possible configurations are:
+
+| | Timer3 | Timer1 |
+|--------------|-------------|--------------|
+| one speaker | C4,C5 or C6 | |
+| one speaker | | B4, B5 or B7 |
+| two speakers | C4,C5 or C6 | B4, B5 or B7 |
+
+Currently there is only one/default driver for AVR based boards, which is automatically configured to:
+
+```make
+AUDIO_DRIVER = pwm_hardware
+```
+
+
+## ARM :id=arm
+
+For Arm based boards, QMK depends on ChibiOS - hence any MCU supported by the later is likely usable, as long as certain hardware peripherals are available.
+
+Supported wiring configurations, with their ChibiOS/MCU peripheral requirement are listed below;
+piezo speakers are marked with :one: for the first/primary and :two: for the secondary.
+
+ | driver | GPTD6<br>Tim6 | GPTD7<br>Tim7 | GPTD8<br>Tim8 | PWMD1<sup>1</sup><br>Tim1_Ch1 |
+ |--------------|------------------------------------------|------------------------|---------------|-------------------------------|
+ | dac_basic | A4+DACD1 = :one: | A5+DACD2 = :one: | state | |
+ | | A4+DACD1 = :one: + Gnd | A5+DACD2 = :two: + Gnd | state | |
+ | | A4+DACD1 = :two: + Gnd | A5+DACD2 = :one: + Gnd | state | |
+ | | A4+DACD1 = :one: + Gnd | | state | |
+ | | | A5+DACD2 = :one: + Gnd | state | |
+ | dac_additive | A4+DACD1 = :one: + Gnd | | | |
+ | | A5+DACD2 = :one: + Gnd | | | |
+ | | A4+DACD1 + A5+DACD2 = :one: <sup>2</sup> | | | |
+ | pwm_software | state-update | | | any = :one: |
+ | pwm hardware | state-update | | | A8 = :one: <sup>3</sup> |
+
+
+<sup>1</sup>: the routing and alternate functions for PWM differ sometimes between STM32 MCUs, if in doubt consult the data-sheet
+<sup>2</sup>: one piezo connected to A4 and A5, with AUDIO_PIN_ALT_AS_NEGATIVE set
+<sup>3</sup>: TIM1_CH1 = A8 on STM32F103C8, other combinations are possible, see Data-sheet. configured with: AUDIO_PWM_DRIVER and AUDIO_PWM_CHANNEL
+
+
+
+### DAC basic :id=dac-basic
+
+The default driver for ARM boards, in absence of an overriding configuration.
+This driver needs one Timer per enabled/used DAC channel, to trigger conversion; and a third timer to trigger state updates with the audio-core.
+
+Additionally, in the board config, you'll want to make changes to enable the DACs, GPT for Timers 6, 7 and 8:
+
+``` c
+//halconf.h:
+#define HAL_USE_DAC TRUE
+#define HAL_USE_GPT TRUE
+#include_next <halconf.h>
+```
+
+``` c
+// mcuconf.h:
+#include_next <mcuconf.h>
+#undef STM32_DAC_USE_DAC1_CH1
+#define STM32_DAC_USE_DAC1_CH1 TRUE
+#undef STM32_DAC_USE_DAC1_CH2
+#define STM32_DAC_USE_DAC1_CH2 TRUE
+#undef STM32_GPT_USE_TIM6
+#define STM32_GPT_USE_TIM6 TRUE
+#undef STM32_GPT_USE_TIM7
+#define STM32_GPT_USE_TIM7 TRUE
+#undef STM32_GPT_USE_TIM8
+#define STM32_GPT_USE_TIM8 TRUE
+```
+
+?> Note: DAC1 (A4) uses TIM6, DAC2 (A5) uses TIM7, and the audio state timer uses TIM8 (configurable).
+
+You can also change the timer used for the overall audio state by defining the driver. For instance:
+
+```c
+#define AUDIO_STATE_TIMER GPTD9
+```
+
+### DAC additive :id=dac-additive
+
+only needs one timer (GPTD6, Tim6) to trigger the DAC unit to do a conversion; the audio state updates are in turn triggered during the DAC callback.
+
+Additionally, in the board config, you'll want to make changes to enable the DACs, GPT for Timer 6:
+
+``` c
+//halconf.h:
+#define HAL_USE_DAC TRUE
+#define HAL_USE_GPT TRUE
+#include_next <halconf.h>
+```
+
+``` c
+// mcuconf.h:
+#include_next <mcuconf.h>
+#undef STM32_DAC_USE_DAC1_CH1
+#define STM32_DAC_USE_DAC1_CH1 TRUE
+#undef STM32_DAC_USE_DAC1_CH2
+#define STM32_DAC_USE_DAC1_CH2 TRUE
+#undef STM32_GPT_USE_TIM6
+#define STM32_GPT_USE_TIM6 TRUE
+```
+
+### DAC Config
+
+| Define | Defaults | Description --------------------------------------------------------------------------------------------- |
+| `AUDIO_DAC_SAMPLE_MAX` | `4095U` | Highest value allowed. Lower v