├── .gitignore ├── .gitmodules ├── Bees-in-Trees-v3v.gv ├── Gemfile ├── README.md ├── __init__.py ├── braids ├── __init__.py ├── analog_oscillator.cc ├── analog_oscillator.h ├── bootloader │ ├── __init__.py │ ├── bootloader.cc │ ├── characters.cc │ ├── characters.h │ ├── makefile │ └── test │ │ ├── makefile │ │ └── qpsk_decoder_test.cc ├── braids.cc ├── data │ ├── map.bin │ └── waves.bin ├── digital_oscillator.cc ├── digital_oscillator.h ├── drivers │ ├── adc.cc │ ├── adc.h │ ├── dac.cc │ ├── dac.h │ ├── debug_pin.cc │ ├── debug_pin.h │ ├── display.cc │ ├── display.h │ ├── encoder.cc │ ├── encoder.h │ ├── gate_input.cc │ ├── gate_input.h │ ├── internal_adc.cc │ ├── internal_adc.h │ ├── system.cc │ ├── system.h │ ├── uart_logger.cc │ └── uart_logger.h ├── envelope.h ├── excitation.h ├── hardware_design │ ├── panel │ │ ├── braids.ai │ │ └── braids.dwg │ └── pcb │ │ ├── braids_v03.brd │ │ └── braids_v03.sch ├── macro_oscillator.cc ├── macro_oscillator.h ├── makefile ├── page_storage.h ├── parameter_interpolation.h ├── resources.cc ├── resources.h ├── resources │ ├── __init__.py │ ├── characters.py │ ├── lookup_tables.py │ ├── resources.py │ ├── waveforms.py │ └── waveshapers.py ├── settings.cc ├── settings.h ├── signature_waveshaper.h ├── svf.h ├── test │ ├── makefile │ └── oscillator_test.cc ├── ui.cc ├── ui.h └── vco_jitter_source.h ├── edges ├── __init__.py ├── adc_acquisition.cc ├── adc_acquisition.h ├── audio_buffer.cc ├── audio_buffer.h ├── bootloader │ ├── bootloader.cc │ └── makefile ├── digital_oscillator.cc ├── digital_oscillator.h ├── edges.cc ├── hardware_config.h ├── hardware_design │ ├── panel │ │ ├── edges.ai │ │ └── edges.dwg │ └── pcb │ │ ├── edges_expander_v01.brd │ │ ├── edges_expander_v01.sch │ │ ├── edges_v01.brd │ │ └── edges_v01.sch ├── makefile ├── midi.h ├── midi_handler.cc ├── midi_handler.h ├── note_stack.h ├── resources.cc ├── resources.h ├── resources │ ├── __init__.py │ ├── lookup_tables.py │ ├── resources.py │ └── waveforms.py ├── settings.cc ├── settings.h ├── storage.h ├── timer_oscillator.cc ├── timer_oscillator.h ├── ui.cc ├── ui.h ├── voice_allocator.cc └── voice_allocator.h ├── frames ├── __init__.py ├── bootloader │ ├── __init__.py │ ├── bootloader.cc │ └── makefile ├── drivers │ ├── adc.cc │ ├── adc.h │ ├── channel_leds.cc │ ├── channel_leds.h │ ├── dac.cc │ ├── dac.h │ ├── factory_testing_switch.h │ ├── keyframe_led.cc │ ├── keyframe_led.h │ ├── rgb_led.cc │ ├── rgb_led.h │ ├── switches.cc │ ├── switches.h │ ├── system.cc │ ├── system.h │ ├── trigger_output.cc │ ├── trigger_output.h │ ├── uart_logger.cc │ └── uart_logger.h ├── frames.cc ├── hardware_design │ ├── panel │ │ ├── frames.ai │ │ └── frames.dwg │ └── pcb │ │ ├── frames_v03.brd │ │ └── frames_v03.sch ├── keyframer.cc ├── keyframer.h ├── makefile ├── poly_lfo.cc ├── poly_lfo.h ├── resources.cc ├── resources.h ├── resources │ ├── __init__.py │ ├── lookup_tables.py │ ├── resources.py │ └── waveforms.py ├── ui.cc └── ui.h ├── grids ├── __init__.py ├── bootloader │ ├── bootloader.cc │ └── makefile ├── clock.cc ├── clock.h ├── grids.cc ├── hardware_config.h ├── hardware_design │ ├── panel │ │ ├── grids.ai │ │ └── grids.dwg │ └── pcb │ │ ├── grids_v01.brd │ │ └── grids_v01.sch ├── makefile ├── pattern_generator.cc ├── pattern_generator.h ├── resources.cc ├── resources.h └── resources │ ├── __init__.py │ ├── lookup_tables.py │ └── resources.py ├── links └── hardware_design │ ├── panel │ ├── links.ai │ └── links.dwg │ └── pcb │ ├── links_v01.brd │ └── links_v01.sch ├── peaks ├── __init__.py ├── bootloader │ ├── bootloader.cc │ └── makefile ├── calibration_data.cc ├── calibration_data.h ├── data │ └── digits.bin ├── drivers │ ├── adc.cc │ ├── adc.h │ ├── dac.cc │ ├── dac.h │ ├── debug_pin.h │ ├── gate_input.cc │ ├── gate_input.h │ ├── leds.cc │ ├── leds.h │ ├── switches.cc │ ├── switches.h │ ├── system.cc │ └── system.h ├── drums │ ├── bass_drum.cc │ ├── bass_drum.h │ ├── excitation.h │ ├── fm_drum.cc │ ├── fm_drum.h │ ├── high_hat.cc │ ├── high_hat.h │ ├── snare_drum.cc │ ├── snare_drum.h │ └── svf.h ├── gate_processor.h ├── hardware_design │ ├── panel │ │ ├── peaks.ai │ │ └── peaks.dwg │ └── pcb │ │ ├── peaks_v02.brd │ │ └── peaks_v02.sch ├── io_buffer.h ├── makefile ├── modulations │ ├── bouncing_ball.h │ ├── lfo.cc │ ├── lfo.h │ ├── mini_sequencer.h │ ├── multistage_envelope.cc │ ├── multistage_envelope.h │ └── turing_machine.h ├── number_station │ ├── bytebeats.cc │ ├── bytebeats.h │ ├── number_station.cc │ └── number_station.h ├── peaks.cc ├── processors.cc ├── processors.h ├── pulse_processor │ ├── pulse_randomizer.cc │ ├── pulse_randomizer.h │ ├── pulse_shaper.cc │ └── pulse_shaper.h ├── resources.cc ├── resources.h ├── resources │ ├── __init__.py │ ├── lookup_tables.py │ ├── resources.py │ └── waveforms.py ├── test │ ├── makefile │ └── peaks_test.cc ├── ui.cc └── ui.h ├── ripples └── hardware_design │ ├── panel │ ├── ripples.ai │ └── ripples.dwg │ └── pcb │ ├── ripples_v01.brd │ └── ripples_v01.sch ├── tides ├── __init__.py ├── bootloader │ ├── __init__.py │ ├── bootloader.cc │ └── makefile ├── cv_scaler.cc ├── cv_scaler.h ├── drivers │ ├── adc.cc │ ├── adc.h │ ├── dac.cc │ ├── dac.h │ ├── factory_testing_switch.h │ ├── gate_input.cc │ ├── gate_input.h │ ├── gate_output.cc │ ├── gate_output.h │ ├── leds.cc │ ├── leds.h │ ├── switches.cc │ ├── switches.h │ ├── system.cc │ ├── system.h │ ├── uart_logger.cc │ └── uart_logger.h ├── easter_egg │ └── plotter_program.h ├── generator.cc ├── generator.h ├── hardware_design │ ├── panel │ │ ├── tides.ai │ │ └── tides.dwg │ └── pcb │ │ ├── tides_v03.brd │ │ └── tides_v03.sch ├── makefile ├── plotter.cc ├── plotter.h ├── resources.cc ├── resources.h ├── resources │ ├── __init__.py │ ├── lookup_tables.py │ ├── resources.py │ ├── waveforms.py │ ├── waves.bin │ └── wavetables.py ├── test │ ├── generator_test.cc │ └── makefile ├── tides.cc ├── ui.cc └── ui.h ├── tools ├── __init__.py ├── hex2sysex │ ├── __init__.py │ └── hex2sysex.py ├── hexfile │ ├── __init__.py │ └── hexfile.py ├── learning │ ├── __init__.py │ └── som.py ├── midi │ ├── __init__.py │ └── midifile.py └── optimization │ ├── __init__.py │ └── munkres.py ├── volts └── hardware_design │ └── pcb │ ├── volts_v01.brd │ └── volts_v01.sch └── yarns ├── __init__.py ├── bootloader ├── bootloader.cc ├── characters.cc ├── characters.h └── makefile ├── drivers ├── channel_leds.cc ├── channel_leds.h ├── dac.cc ├── dac.h ├── display.cc ├── display.h ├── encoder.cc ├── encoder.h ├── gate_output.cc ├── gate_output.h ├── midi_io.cc ├── midi_io.h ├── switches.cc ├── switches.h ├── system.cc └── system.h ├── hardware_design ├── panel │ ├── yarns.ai │ └── yarns.dwg └── pcb │ ├── yarns_v03.brd │ └── yarns_v03.sch ├── internal_clock.h ├── just_intonation_processor.cc ├── just_intonation_processor.h ├── layout_configurator.cc ├── layout_configurator.h ├── makefile ├── midi_handler.cc ├── midi_handler.h ├── multi.cc ├── multi.h ├── part.cc ├── part.h ├── resources.cc ├── resources.h ├── resources ├── __init__.py ├── characters.py ├── lookup_tables.py ├── resources.py └── waveforms.py ├── scale_editor ├── README ├── __init__.py ├── app.yaml ├── index.yaml ├── main.py ├── music │ ├── __init__.py │ └── scala │ │ ├── __init__.py │ │ └── scala.py ├── static │ ├── bg_main.jpg │ ├── db_yarns.png │ ├── divider_big.jpg │ ├── favicon.ico │ ├── logo.jpg │ └── main.css └── templates │ ├── base.html │ └── index.html ├── settings.cc ├── settings.h ├── song └── song.h ├── storage_manager.cc ├── storage_manager.h ├── ui.cc ├── ui.h ├── voice.cc ├── voice.h └── yarns.cc /.gitignore: -------------------------------------------------------------------------------- 1 | # Precompiled python modules 2 | *.pyc 3 | 4 | # Eagle backups 5 | *.s#? 6 | *.b#? 7 | *.bak 8 | 9 | # Gerber files 10 | *.CUT 11 | *.GBL 12 | *.GBO 13 | *.GBS 14 | *.GML 15 | *.GTL 16 | *.GTO 17 | *.GTP 18 | *.GTS 19 | *.TXT 20 | *.dri 21 | *.gpi 22 | *.pro 23 | 24 | # Assembly files 25 | *assembly.zip 26 | *top.pdf 27 | *bottom.pdf 28 | *.csv 29 | *partlist.txt 30 | *.zip 31 | 32 | # LaTeX compiled file 33 | *.pdf 34 | *.log 35 | *.aux 36 | 37 | # OS X crap 38 | .DS_Stor? 39 | 40 | # Build directory 41 | build 42 | 43 | # Jekyll site staging directory 44 | _site 45 | 46 | # BETA Layout variants 47 | *_beta.sch 48 | *_BETA.sch 49 | *_beta.brd 50 | *_BETA.brd 51 | 52 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "avrlib"] 2 | path = avrlib 3 | url = https://github.com/pichenettes/avril.git 4 | [submodule "avrlibx"] 5 | path = avrlibx 6 | url = https://github.com/pichenettes/avrilx.git 7 | [submodule "stmlib"] 8 | path = stmlib 9 | url = https://github.com/pichenettes/stmlib.git 10 | [submodule "stm_audio_bootloader"] 11 | path = stm_audio_bootloader 12 | url = https://github.com/pichenettes/stm-audio-bootloader.git 13 | [submodule "avr_audio_bootloader"] 14 | path = avr_audio_bootloader 15 | url = git@github.com:pichenettes/avr-audio-bootloader.git 16 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'github-pages' 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mutated Mutables 2 | ================ 3 | 4 | Various enhancements, experiments and outright hacks of Mutable Instruments firmware code. 5 | 6 | This repository was originally a copy of the Mutable Instruments GitHub eurorack repository at https://github.com/pichenettes/eurorack 7 | 8 | Please see the [Mutated Mutables project page](http://timchurches.github.io/Mutated-Mutables/) for more information. -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/__init__.py -------------------------------------------------------------------------------- /braids/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/__init__.py -------------------------------------------------------------------------------- /braids/bootloader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/bootloader/__init__.py -------------------------------------------------------------------------------- /braids/bootloader/characters.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Resources definitions. 28 | // 29 | // Automatically generated with: 30 | // make resources 31 | 32 | 33 | #ifndef BRAIDS_BOOTLOADER_CHARACTERS_H_ 34 | #define BRAIDS_BOOTLOADER_CHARACTERS_H_ 35 | 36 | 37 | #include "stmlib/stmlib.h" 38 | 39 | namespace braids { 40 | 41 | extern const uint16_t chr_characters[]; 42 | 43 | } // namespace braids 44 | 45 | #endif // BRAIDS_BOOTLOADER_CHARACTERS_H_ 46 | -------------------------------------------------------------------------------- /braids/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | # Preferred upload command 35 | UPLOAD_COMMAND = upload_jtag 36 | 37 | # Packages to build 38 | TARGET = braids_bootloader 39 | PACKAGES = braids/bootloader braids/drivers stmlib/utils stmlib/system \ 40 | stm_audio_bootloader/qpsk 41 | RESOURCES = braids/resources 42 | 43 | include stmlib/makefile.inc 44 | -------------------------------------------------------------------------------- /braids/bootloader/test/makefile: -------------------------------------------------------------------------------- 1 | PACKAGES = braids/bootloader stm_audio_bootloader/qpsk braids/bootloader/test stmlib/utils 2 | VPATH = $(PACKAGES) 3 | 4 | TARGET = qpsk_decoder_test 5 | BUILD_ROOT = build/ 6 | BUILD_DIR = $(BUILD_ROOT)$(TARGET)/ 7 | CC_FILES = demodulator.cc \ 8 | packet_decoder.cc \ 9 | qpsk_decoder_test.cc 10 | OBJ_FILES = $(CC_FILES:.cc=.o) 11 | OBJS = $(patsubst %,$(BUILD_DIR)%,$(OBJ_FILES)) $(STARTUP_OBJ) 12 | DEPS = $(OBJS:.o=.d) 13 | DEP_FILE = $(BUILD_DIR)depends.mk 14 | 15 | all: qpsk_decoder_test 16 | 17 | $(BUILD_DIR): 18 | mkdir -p $(BUILD_DIR) 19 | 20 | $(BUILD_DIR)%.o: %.cc 21 | g++ -c -DTEST -g -Wall -Werror -I. $< -o $@ 22 | 23 | $(BUILD_DIR)%.d: %.cc 24 | g++ -MM -DTEST -I. $< -MF $@ -MT $(@:.d=.o) 25 | 26 | qpsk_decoder_test: $(OBJS) 27 | g++ -o $(TARGET) $(OBJS) 28 | 29 | depends: $(DEPS) 30 | cat $(DEPS) > $(DEP_FILE) 31 | 32 | $(DEP_FILE): $(BUILD_DIR) $(DEPS) 33 | cat $(DEPS) > $(DEP_FILE) 34 | 35 | include $(DEP_FILE) 36 | -------------------------------------------------------------------------------- /braids/data/map.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/data/map.bin -------------------------------------------------------------------------------- /braids/data/waves.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/data/waves.bin -------------------------------------------------------------------------------- /braids/drivers/dac.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for DAC. 28 | 29 | #include "braids/drivers/dac.h" 30 | 31 | #include 32 | 33 | namespace braids { 34 | 35 | void Dac::Init() { 36 | // Initialize SS pin. 37 | GPIO_InitTypeDef gpio_init; 38 | gpio_init.GPIO_Pin = GPIO_Pin_12; 39 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 40 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 41 | GPIO_Init(GPIOB, &gpio_init); 42 | 43 | // Initialize MOSI and SCK pins. 44 | gpio_init.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_15; 45 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 46 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 47 | GPIO_Init(GPIOB, &gpio_init); 48 | 49 | // Initialize SPI 50 | SPI_InitTypeDef spi_init; 51 | spi_init.SPI_Direction = SPI_Direction_2Lines_FullDuplex; 52 | spi_init.SPI_Mode = SPI_Mode_Master; 53 | spi_init.SPI_DataSize = SPI_DataSize_16b; 54 | spi_init.SPI_CPOL = SPI_CPOL_High; 55 | spi_init.SPI_CPHA = SPI_CPHA_1Edge; 56 | spi_init.SPI_NSS = SPI_NSS_Soft; 57 | spi_init.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; 58 | spi_init.SPI_FirstBit = SPI_FirstBit_MSB; 59 | spi_init.SPI_CRCPolynomial = 7; 60 | SPI_Init(SPI2, &spi_init); 61 | SPI_Cmd(SPI2, ENABLE); 62 | } 63 | 64 | } // namespace braids 65 | -------------------------------------------------------------------------------- /braids/drivers/dac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for DAC. 28 | 29 | #ifndef BRAIDS_DRIVERS_DAC_H_ 30 | #define BRAIDS_DRIVERS_DAC_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | class Dac { 38 | public: 39 | Dac() { } 40 | ~Dac() { } 41 | 42 | void Init(); 43 | inline void Write(uint16_t value) { 44 | GPIOB->BSRR = GPIO_Pin_12; 45 | GPIOB->BRR = GPIO_Pin_12; 46 | SPI2->DR = value >> 8; 47 | __asm__("nop"); 48 | __asm__("nop"); 49 | __asm__("nop"); 50 | __asm__("nop"); 51 | __asm__("nop"); 52 | __asm__("nop"); 53 | __asm__("nop"); 54 | __asm__("nop"); 55 | __asm__("nop"); 56 | __asm__("nop"); 57 | __asm__("nop"); 58 | __asm__("nop"); 59 | __asm__("nop"); 60 | __asm__("nop"); 61 | __asm__("nop"); 62 | __asm__("nop"); 63 | SPI2->DR = value << 8; 64 | } 65 | 66 | private: 67 | 68 | DISALLOW_COPY_AND_ASSIGN(Dac); 69 | }; 70 | 71 | } // namespace braids 72 | 73 | #endif // BRAIDS_DRIVERS_DAC_H_ 74 | -------------------------------------------------------------------------------- /braids/drivers/debug_pin.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the debug (timing) pin. 28 | 29 | #include "braids/drivers/debug_pin.h" 30 | 31 | #include 32 | 33 | namespace braids { 34 | 35 | void DebugPin::Init() { 36 | GPIO_InitTypeDef gpio_init; 37 | gpio_init.GPIO_Pin = GPIO_Pin_2; 38 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 39 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 40 | GPIO_Init(GPIOC, &gpio_init); 41 | 42 | GPIOC->BSRR = GPIO_Pin_2; 43 | } 44 | 45 | void DebugPin::High() { 46 | GPIOC->BSRR = GPIO_Pin_2; 47 | } 48 | 49 | void DebugPin::Low() { 50 | GPIOC->BRR = GPIO_Pin_2; 51 | } 52 | 53 | } // namespace braids 54 | -------------------------------------------------------------------------------- /braids/drivers/debug_pin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the debug (timing) pin. 28 | 29 | #ifndef BRAIDS_DRIVERS_DEBUG_PIN_H_ 30 | #define BRAIDS_DRIVERS_DEBUG_PIN_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | class DebugPin { 38 | public: 39 | DebugPin() { } 40 | ~DebugPin() { } 41 | 42 | void Init(); 43 | void High(); 44 | void Low(); 45 | 46 | private: 47 | 48 | DISALLOW_COPY_AND_ASSIGN(DebugPin); 49 | }; 50 | 51 | } // namespace braids 52 | 53 | #endif // BRAIDS_DRIVERS_DEBUG_PIN_H_ 54 | -------------------------------------------------------------------------------- /braids/drivers/display.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for 4x14-segments display. 28 | 29 | #ifndef BRAIDS_DRIVERS_DISPLAY_H_ 30 | #define BRAIDS_DRIVERS_DISPLAY_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | const uint8_t kDisplayWidth = 4; 38 | const uint8_t kBrightnessLevels = 4; 39 | 40 | class Display { 41 | public: 42 | Display() { } 43 | ~Display() { } 44 | 45 | void Init(); 46 | void Refresh(); 47 | void Print(const char* s); 48 | 49 | char* mutable_buffer() { return buffer_; } 50 | void set_brightness(uint16_t brightness) { brightness_ = brightness; } 51 | 52 | private: 53 | void Shift14SegmentsWord(uint16_t data); 54 | 55 | char buffer_[kDisplayWidth]; 56 | uint8_t char_index_; 57 | uint16_t active_position_; 58 | uint16_t brightness_pwm_cycle_; 59 | uint16_t brightness_; 60 | 61 | DISALLOW_COPY_AND_ASSIGN(Display); 62 | }; 63 | 64 | } // namespace braids 65 | 66 | #endif // BRAIDS_DRIVERS_DISPLAY_H_ 67 | -------------------------------------------------------------------------------- /braids/drivers/encoder.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for rotary encoder. 28 | 29 | #include "braids/drivers/encoder.h" 30 | 31 | namespace braids { 32 | 33 | void Encoder::Init() { 34 | GPIO_InitTypeDef gpio_init; 35 | 36 | gpio_init.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; 37 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 38 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 39 | GPIO_Init(GPIOC, &gpio_init); 40 | 41 | switch_state_ = 0xff; 42 | quadrature_decoding_state_[0] = quadrature_decoding_state_[1] = 0xff; 43 | } 44 | 45 | void Encoder::Debounce() { 46 | switch_state_ = (switch_state_ << 1) | \ 47 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13); 48 | quadrature_decoding_state_[0] = (quadrature_decoding_state_[0] << 1) | \ 49 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_14); 50 | quadrature_decoding_state_[1] = (quadrature_decoding_state_[1] << 1) | \ 51 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_15); 52 | } 53 | 54 | } // namespace braids 55 | -------------------------------------------------------------------------------- /braids/drivers/gate_input.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for gate input. 28 | 29 | #include "braids/drivers/gate_input.h" 30 | 31 | namespace braids { 32 | 33 | void GateInput::Init() { 34 | GPIO_InitTypeDef gpio_init; 35 | gpio_init.GPIO_Pin = GPIO_Pin_4; 36 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 37 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 38 | GPIO_Init(GPIOA, &gpio_init); 39 | previous_state_ = true; 40 | } 41 | 42 | } // namespace braids 43 | -------------------------------------------------------------------------------- /braids/drivers/gate_input.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for gate input. 28 | 29 | #ifndef BRAIDS_DRIVERS_GATE_INPUT_H_ 30 | #define BRAIDS_DRIVERS_GATE_INPUT_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | class GateInput { 38 | public: 39 | GateInput() { } 40 | ~GateInput() { } 41 | 42 | void Init(); 43 | 44 | inline bool Read() { 45 | return !(GPIOA->IDR & GPIO_Pin_4); 46 | } 47 | 48 | inline bool raised() { 49 | bool new_state = Read(); 50 | bool rising_edge = (!previous_state_ && new_state); 51 | previous_state_ = new_state; 52 | return rising_edge; 53 | } 54 | 55 | inline bool lowered() { 56 | bool new_state = Read(); 57 | bool falling_edge = (previous_state_ && !new_state); 58 | previous_state_ = new_state; 59 | return falling_edge; 60 | } 61 | 62 | inline bool state() { return previous_state_; } 63 | 64 | private: 65 | bool previous_state_; 66 | 67 | DISALLOW_COPY_AND_ASSIGN(GateInput); 68 | }; 69 | 70 | } // namespace braids 71 | 72 | #endif // BRAIDS_DRIVERS_GATE_INPUT_H_ 73 | -------------------------------------------------------------------------------- /braids/drivers/internal_adc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for ADC. 28 | 29 | #ifndef BRAIDS_DRIVERS_INTERNAL_ADC_H_ 30 | #define BRAIDS_DRIVERS_INTERNAL_ADC_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace braids { 35 | 36 | class InternalAdc { 37 | public: 38 | InternalAdc() { } 39 | ~InternalAdc() { } 40 | 41 | void Init(); 42 | 43 | inline int32_t value() { 44 | if (disabled_) { 45 | return 0; 46 | } else { 47 | int32_t v = (static_cast(value_) - 32768) << 8; 48 | int32_t delta = v - state_; 49 | state_ += (delta >> 8); 50 | return state_ >> 8; 51 | } 52 | } 53 | 54 | private: 55 | bool disabled_; 56 | uint16_t value_; 57 | int32_t state_; 58 | 59 | DISALLOW_COPY_AND_ASSIGN(InternalAdc); 60 | }; 61 | 62 | } // namespace braids 63 | 64 | #endif // BRAIDS_DRIVERS_INTERNAL_ADC_H_ 65 | -------------------------------------------------------------------------------- /braids/drivers/system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // System-level initialization. 28 | 29 | #ifndef BRAIDS_DRIVERS_SYSTEM_H_ 30 | #define BRAIDS_DRIVERS_SYSTEM_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | class System { 38 | public: 39 | System() { } 40 | ~System() { } 41 | 42 | void Init(uint32_t timer_period, bool application); 43 | void StartTimers(); 44 | 45 | private: 46 | DISALLOW_COPY_AND_ASSIGN(System); 47 | }; 48 | 49 | } // namespace braids 50 | 51 | #endif // BRAIDS_DRIVERS_SYSTEM_H_ 52 | -------------------------------------------------------------------------------- /braids/drivers/uart_logger.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #include "braids/drivers/uart_logger.h" 30 | 31 | #include 32 | 33 | namespace braids { 34 | 35 | void UartLogger::Init(uint32_t baud_rate) { 36 | // Initialize TX pin. 37 | GPIO_InitTypeDef gpio_init; 38 | gpio_init.GPIO_Pin = GPIO_Pin_9; 39 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 40 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 41 | GPIO_Init(GPIOA, &gpio_init); 42 | 43 | // Initialize USART. 44 | USART_InitTypeDef usart_init; 45 | usart_init.USART_BaudRate = baud_rate; 46 | usart_init.USART_WordLength = USART_WordLength_8b; 47 | usart_init.USART_StopBits = USART_StopBits_1; 48 | usart_init.USART_Parity = USART_Parity_No; 49 | usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 50 | usart_init.USART_Mode = USART_Mode_Tx; 51 | 52 | USART_Init(USART1, &usart_init); 53 | USART_Cmd(USART1, ENABLE); 54 | 55 | } 56 | 57 | void UartLogger::Trace(uint8_t byte) { 58 | while (!(USART1->SR & USART_FLAG_TXE)); 59 | USART1->DR = byte; 60 | } 61 | 62 | } // namespace braids 63 | -------------------------------------------------------------------------------- /braids/drivers/uart_logger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #ifndef BRAIDS_DRIVERS_UART_LOGGER_H_ 30 | #define BRAIDS_DRIVERS_UART_LOGGER_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace braids { 36 | 37 | class UartLogger { 38 | public: 39 | UartLogger() { } 40 | ~UartLogger() { } 41 | 42 | void Init(uint32_t baud_rate); 43 | void Trace(uint8_t byte); 44 | 45 | private: 46 | DISALLOW_COPY_AND_ASSIGN(UartLogger); 47 | }; 48 | 49 | } // namespace braids 50 | 51 | #endif // BRAIDS_DRIVERS_UART_LOGGER_H_ 52 | -------------------------------------------------------------------------------- /braids/hardware_design/panel/braids.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/hardware_design/panel/braids.ai -------------------------------------------------------------------------------- /braids/hardware_design/panel/braids.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/hardware_design/panel/braids.dwg -------------------------------------------------------------------------------- /braids/hardware_design/pcb/braids_v03.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/hardware_design/pcb/braids_v03.brd -------------------------------------------------------------------------------- /braids/hardware_design/pcb/braids_v03.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/hardware_design/pcb/braids_v03.sch -------------------------------------------------------------------------------- /braids/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | APPLICATION = TRUE 35 | BOOTLOADER = braids_bootloader 36 | 37 | # Preferred upload command 38 | UPLOAD_COMMAND = upload_combo_jtag 39 | 40 | # Packages to build 41 | TARGET = braids 42 | PACKAGES = braids braids/drivers stmlib/utils stmlib/system 43 | RESOURCES = braids/resources 44 | 45 | include stmlib/makefile.inc 46 | 47 | # Rule for building the firmware update file 48 | wav: $(TARGET_BIN) 49 | python stm_audio_bootloader/qpsk/encoder.py \ 50 | -s 48000 -b 12000 -c 6000 -p 256 \ 51 | $(TARGET_BIN) 52 | -------------------------------------------------------------------------------- /braids/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/braids/resources/__init__.py -------------------------------------------------------------------------------- /braids/resources/waveshapers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2.5 2 | # 3 | # Copyright 2012 Olivier Gillet. 4 | # 5 | # Author: Olivier Gillet (ol.gillet@gmail.com) 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | # ----------------------------------------------------------------------------- 19 | # 20 | # Waveshaper lookup tables. 21 | 22 | import numpy 23 | 24 | waveshapers = [] 25 | 26 | def scale(x, min=-32766, max=32766, center=True): 27 | if center: 28 | x -= x.mean() 29 | mx = numpy.abs(x).max() 30 | x = (x + mx) / (2 * mx) 31 | x = x * (max - min) + min 32 | x = numpy.round(x) 33 | return x.astype(int) 34 | 35 | 36 | x = ((numpy.arange(0, 257) / 128.0 - 1.0)) 37 | x[-1] = x[-2] 38 | violent_overdrive = numpy.tanh(8.0 * x) 39 | overdrive = numpy.tanh(5.0 * x) 40 | moderate_overdrive = numpy.tanh(2.0 * x) 41 | 42 | # Wavefolder curves from the first version 43 | # tri_fold = numpy.abs(4.0 * x - numpy.round(4.0 * x)) * numpy.sign(x) 44 | # sine_fold = numpy.sin(5 * numpy.pi * x) 45 | 46 | tri_fold = numpy.sin(numpy.pi * (3 * x + (2 * x) ** 3)) 47 | 48 | # In v1.4 RC 49 | window = numpy.exp(-x * x * 4) ** 1.5 50 | sine = numpy.sin(8 * numpy.pi * x) 51 | sine_fold = sine * window + numpy.arctan(3 * x) * (1 - window) 52 | sine_fold /= numpy.abs(sine_fold).max() 53 | 54 | # Another curve for the sine wavefolder inspired by the uFold response 55 | # frequency = 4 / (1 + (1.5 * x) ** 2) ** 2 56 | # window = numpy.exp(-24 * numpy.maximum(numpy.abs(x) - 0.25, 0) ** 2) 57 | # sine = numpy.sin(2 * numpy.pi * frequency * x) * window 58 | # cubic = (x ** 3 + 0.5 * x ** 2 + 0.5 * x) / 3 59 | # knee = numpy.minimum(x + 0.7, 0.0) 60 | # sine_fold = sine + cubic + knee 61 | 62 | waveshapers.append(('moderate_overdrive', scale(moderate_overdrive))) 63 | waveshapers.append(('violent_overdrive', scale(violent_overdrive))) 64 | waveshapers.append(('sine_fold', scale(sine_fold, center=False))) 65 | waveshapers.append(('tri_fold', scale(tri_fold))) 66 | -------------------------------------------------------------------------------- /braids/test/makefile: -------------------------------------------------------------------------------- 1 | PACKAGES = braids/test stmlib/utils braids 2 | 3 | VPATH = $(PACKAGES) 4 | 5 | TARGET = oscillator_test 6 | BUILD_ROOT = build/ 7 | BUILD_DIR = $(BUILD_ROOT)$(TARGET)/ 8 | CC_FILES = analog_oscillator.cc \ 9 | digital_oscillator.cc \ 10 | resources.cc \ 11 | macro_oscillator.cc \ 12 | oscillator_test.cc \ 13 | random.cc 14 | OBJ_FILES = $(CC_FILES:.cc=.o) 15 | OBJS = $(patsubst %,$(BUILD_DIR)%,$(OBJ_FILES)) $(STARTUP_OBJ) 16 | DEPS = $(OBJS:.o=.d) 17 | DEP_FILE = $(BUILD_DIR)depends.mk 18 | 19 | all: oscillator_test 20 | 21 | $(BUILD_DIR): 22 | mkdir -p $(BUILD_DIR) 23 | 24 | $(BUILD_DIR)%.o: %.cc 25 | g++ -c -DTEST -g -Wall -Werror -Wno-unused-variable -I. $< -o $@ 26 | 27 | $(BUILD_DIR)%.d: %.cc 28 | g++ -MM -DTEST -I. $< -MF $@ -MT $(@:.d=.o) 29 | 30 | oscillator_test: $(OBJS) 31 | g++ -o $(TARGET) $(OBJS) 32 | 33 | depends: $(DEPS) 34 | cat $(DEPS) > $(DEP_FILE) 35 | 36 | $(DEP_FILE): $(BUILD_DIR) $(DEPS) 37 | cat $(DEPS) > $(DEP_FILE) 38 | 39 | include $(DEP_FILE) 40 | -------------------------------------------------------------------------------- /edges/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/__init__.py -------------------------------------------------------------------------------- /edges/adc_acquisition.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Staged SPI communication with the ADC. Prevents the 128 cycles lock. 19 | 20 | #include "edges/adc_acquisition.h" 21 | 22 | namespace edges { 23 | 24 | /* static */ 25 | ADCInterface ADCAcquisition::adc_; 26 | 27 | /* static */ 28 | Word ADCAcquisition::rx_; 29 | 30 | /* static */ 31 | uint8_t ADCAcquisition::active_channel_; 32 | 33 | /* static */ 34 | uint8_t ADCAcquisition::acquisition_stage_; 35 | 36 | /* static */ 37 | uint16_t ADCAcquisition::channels_[kNumAdcChannels]; 38 | 39 | /* extern */ 40 | ADCAcquisition adc_acquisition; 41 | 42 | } // namespace edges 43 | -------------------------------------------------------------------------------- /edges/audio_buffer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Instance of the audio out buffer. 19 | 20 | #include "edges/audio_buffer.h" 21 | 22 | namespace edges { 23 | 24 | /* extern */ 25 | avrlibx::RingBuffer audio_buffer; 26 | 27 | } // namespace edges 28 | -------------------------------------------------------------------------------- /edges/audio_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Instance of the audio buffer class. 19 | 20 | #ifndef EDGES_AUDIO_BUFFER_H_ 21 | #define EDGES_AUDIO_BUFFER_H_ 22 | 23 | #include "avrlibx/io/ring_buffer.h" 24 | 25 | namespace edges { 26 | 27 | struct AudioBufferSpecs { 28 | typedef uint16_t Value; 29 | enum { 30 | buffer_size = 128, 31 | data_size = 16, 32 | }; 33 | }; 34 | 35 | static const uint8_t kAudioBlockSize = 16; 36 | 37 | extern avrlibx::RingBuffer audio_buffer; 38 | 39 | } // namespace edges 40 | 41 | #endif // EDGES_AUDIO_BUFFER_H_ 42 | -------------------------------------------------------------------------------- /edges/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Olivier Gillet. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | 14 | VERSION = 0.1 15 | F_CPU = 32000000 16 | MCU_NAME = 32a4 17 | TARGET = edges_bootloader 18 | PACKAGES = avrlibx \ 19 | avrlibx/io \ 20 | avrlibx/system \ 21 | avrlibx/utils \ 22 | avrlibx/third_party/sp_driver \ 23 | edges/bootloader 24 | EXTRA_LD_FLAGS = ,--section-start=.text=0x8000,--relax 25 | 26 | FUSE0 = 00 27 | FUSE1 = 00 28 | # bf enables the bootloader 29 | FUSE2 = bf 30 | FUSE4 = fe 31 | FUSE5 = f7 32 | LOCK = 3f 33 | 34 | include avrlibx/makefile.mk 35 | 36 | include $(DEP_FILE) 37 | -------------------------------------------------------------------------------- /edges/digital_oscillator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Sampled oscillator. 19 | 20 | #ifndef EDGES_DIGITAL_OSCILLATOR_H_ 21 | #define EDGES_DIGITAL_OSCILLATOR_H_ 22 | 23 | #include "avrlibx/avrlibx.h" 24 | 25 | namespace edges { 26 | 27 | using namespace avrlibx; 28 | 29 | enum OscillatorShape { 30 | OSC_TRIANGLE, 31 | OSC_NES_TRIANGLE, 32 | OSC_PITCHED_NOISE, 33 | OSC_NES_NOISE_LONG, 34 | OSC_NES_NOISE_SHORT, 35 | OSC_SINE, 36 | }; 37 | 38 | class DigitalOscillator { 39 | public: 40 | typedef void (DigitalOscillator::*RenderFn)(); 41 | 42 | DigitalOscillator() { } 43 | ~DigitalOscillator() { } 44 | 45 | void Init() { 46 | UpdatePitch(60 << 7, OSC_TRIANGLE); 47 | Gate(true); 48 | rng_state_ = 1; 49 | } 50 | 51 | void UpdatePitch(int16_t pitch, OscillatorShape shape) { 52 | pitch_ = pitch; 53 | shape_ = shape; 54 | } 55 | 56 | void Gate(bool gate) { 57 | gate_ = gate; 58 | } 59 | 60 | void Render(); 61 | 62 | inline void set_cv_pw(uint8_t pw) { 63 | cv_pw_ = pw; 64 | } 65 | 66 | private: 67 | void ComputePhaseIncrement(); 68 | 69 | void RenderSilence(); 70 | void RenderSine(); 71 | void RenderBandlimitedTriangle(); 72 | void RenderNoiseNES(); 73 | void RenderNoise(); 74 | 75 | OscillatorShape shape_; 76 | int16_t pitch_; 77 | bool gate_; 78 | 79 | uint8_t note_; 80 | uint24_t phase_; 81 | uint24_t phase_increment_; 82 | uint16_t sample_; 83 | uint16_t rng_state_; 84 | uint16_t aux_phase_; 85 | uint8_t cv_pw_; 86 | 87 | static const RenderFn fn_table_[]; 88 | 89 | DISALLOW_COPY_AND_ASSIGN(DigitalOscillator); 90 | }; 91 | 92 | } // namespace edges 93 | 94 | 95 | #endif // EDGES_DIGITAL_OSCILLATOR_H_ 96 | -------------------------------------------------------------------------------- /edges/hardware_design/panel/edges.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/panel/edges.ai -------------------------------------------------------------------------------- /edges/hardware_design/panel/edges.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/panel/edges.dwg -------------------------------------------------------------------------------- /edges/hardware_design/pcb/edges_expander_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/pcb/edges_expander_v01.brd -------------------------------------------------------------------------------- /edges/hardware_design/pcb/edges_expander_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/pcb/edges_expander_v01.sch -------------------------------------------------------------------------------- /edges/hardware_design/pcb/edges_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/pcb/edges_v01.brd -------------------------------------------------------------------------------- /edges/hardware_design/pcb/edges_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/hardware_design/pcb/edges_v01.sch -------------------------------------------------------------------------------- /edges/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Olivier Gillet. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | 14 | VERSION = 0.1 15 | F_CPU = 32000000 16 | MCU_NAME = 32a4 17 | TARGET = edges 18 | PACKAGES = avrlibx \ 19 | avrlibx/io \ 20 | avrlibx/system \ 21 | avrlibx/utils \ 22 | avrlibx/third_party/eeprom_driver \ 23 | edges 24 | RESOURCES = edges/resources 25 | SYSEX_FLAGS = --page_size=128 --device_id=10 26 | # EXTRA_DEFINES =-DOCTAL_ADC 27 | 28 | FUSE0 = 00 29 | FUSE1 = 00 30 | # bf enables the bootloader 31 | FUSE2 = bf 32 | FUSE4 = fe 33 | FUSE5 = f7 34 | LOCK = 3f 35 | 36 | include avrlibx/makefile.mk 37 | 38 | include $(DEP_FILE) 39 | -------------------------------------------------------------------------------- /edges/midi_handler.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Instance of the midi out filter class. 19 | 20 | #include "edges/midi_handler.h" 21 | 22 | namespace edges { 23 | 24 | /* static */ 25 | bool MidiHandler::gate_[kNumChannels]; 26 | 27 | /* static */ 28 | int16_t MidiHandler::pitch_[kNumChannels]; 29 | 30 | /* static */ 31 | int16_t MidiHandler::pitch_bend_[kNumChannels] = { 0, 0, 0, 0 }; 32 | 33 | /* static */ 34 | NoteStack<10> MidiHandler::stack_[kNumChannels]; 35 | 36 | /* static */ 37 | VoiceAllocator MidiHandler::allocator_; 38 | 39 | /* static */ 40 | bool MidiHandler::learning_; 41 | 42 | /* extern */ 43 | MidiHandler midi_handler; 44 | 45 | } // namespace anu -------------------------------------------------------------------------------- /edges/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/edges/resources/__init__.py -------------------------------------------------------------------------------- /edges/resources/lookup_tables.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2.5 2 | # 3 | # Copyright 2012 Olivier Gillet. 4 | # 5 | # Author: Olivier Gillet (olivier@mutable-instruments.net) 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | # ----------------------------------------------------------------------------- 19 | # 20 | # Lookup table definitions. 21 | 22 | import numpy 23 | 24 | lookup_tables = [] 25 | lookup_tables_32 = [] 26 | 27 | """---------------------------------------------------------------------------- 28 | Timer oscillator pitch table. 29 | ----------------------------------------------------------------------------""" 30 | 31 | notes = numpy.arange(0, 12 * 128 + 16, 16) / 128.0 + 24 32 | frequencies = 2 ** ((notes - 69) / 12) * 440.0 33 | values = 32000000.0 / (2 * 8 * frequencies) 34 | lookup_tables.append( 35 | ('timer_count', numpy.round(values)) 36 | ) 37 | 38 | """---------------------------------------------------------------------------- 39 | Digital oscillator pitch table. 40 | ----------------------------------------------------------------------------""" 41 | 42 | sample_rate = 32000000 / 666.0 43 | a4_midi = 69 44 | a4_pitch = 440.0 45 | excursion = 65536.0 46 | notes = numpy.arange(116 * 128.0, 128 * 128.0 + 16, 16) 47 | pitches = 2 * a4_pitch * 2 ** ((notes - a4_midi * 128) / (128 * 12)) 48 | increments = excursion / sample_rate * pitches 49 | 50 | lookup_tables.append( 51 | ('oscillator_increments', increments.astype(int)) 52 | ) 53 | 54 | """---------------------------------------------------------------------------- 55 | Bitcrusher pitch table. 56 | ----------------------------------------------------------------------------""" 57 | ratios = [1] * 128 58 | ratios = ratios + list(numpy.linspace(1.0, 64.0, 128)) 59 | increments = 65536 / numpy.array(ratios) 60 | lookup_tables.append( 61 | ('bitcrusher_increments', increments.astype(int)) 62 | ) 63 | -------------------------------------------------------------------------------- /edges/settings.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // Settings written to eeprom 17 | 18 | #include "edges/settings.h" 19 | 20 | #include "edges/storage.h" 21 | 22 | namespace edges { 23 | 24 | /* static */ 25 | SettingsData Settings::data_; 26 | 27 | /* static */ 28 | int16_t Settings::previous_code_[kNumChannels]; 29 | 30 | /* static */ 31 | int16_t Settings::previous_pitch_[kNumChannels]; 32 | 33 | /* extern */ 34 | Settings settings; 35 | 36 | typedef SettingsData PROGMEM prog_SettingsData; 37 | 38 | const prog_SettingsData init_settings PROGMEM = { 39 | { { 0, false, false, 3, 0, 40 | { 512, 1536, 0, 0, 0, 0, 0 }, 1536, 15360, -7680 41 | }, 42 | 43 | { 0, false, false, 3, 0, 44 | { 512, 896, 0, 0, 0, 0, 0 }, 1536, 15360, -7680 45 | }, 46 | 47 | { 0, false, false, 4, 0, 48 | { 512, 896, 1536, 0, 0, 0, 0 }, 1536, 15360, -7680 49 | }, 50 | 51 | { 0, false, false, 5, 0, 52 | { 512, 896, 1536, 3072, 0, 0, 0 }, 1536, 15360, -7680 53 | } }, 54 | 0, 55 | 0 56 | }; 57 | 58 | template<> 59 | struct StorageLayout { 60 | static uint16_t eeprom_address() { 61 | return 0; 62 | } 63 | static const prog_char* init_data() { 64 | return (prog_char*)&init_settings; 65 | } 66 | }; 67 | 68 | /* static */ 69 | void Settings::Init(bool reset_to_factory_defaults) { 70 | if (reset_to_factory_defaults) { 71 | storage.ResetToFactoryDefaults(&data_); 72 | } else { 73 | storage.Load(&data_); 74 | } 75 | } 76 | 77 | /* static */ 78 | void Settings::Save() { 79 | storage.Save(data_); 80 | } 81 | 82 | } // namespace edges 83 | -------------------------------------------------------------------------------- /edges/timer_oscillator.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Square oscillator generated from a timer. 19 | 20 | #include 21 | 22 | #include "avrlibx/utils/op.h" 23 | 24 | #include "edges/resources.h" 25 | #include "edges/timer_oscillator.h" 26 | 27 | namespace edges { 28 | 29 | using namespace avrlibx; 30 | 31 | static const int16_t kOctave = 12 << 7; 32 | static const int16_t kFirstNoteNormalMode = 24 << 7; 33 | static const int16_t kFirstNoteLFOMode = -(12 << 7); 34 | 35 | const uint8_t pulse_widths[] = { 36 | 128, 85, 64, 32, 13, 10 37 | }; 38 | 39 | void TimerOscillator::UpdateTimerParameters( 40 | int16_t pitch, 41 | PulseWidth pulse_width) { 42 | int8_t shifts = 0; 43 | 44 | // Lowest note: E0. 45 | pitch -= prescaler_ == TIMER_PRESCALER_CLK_64 \ 46 | ? kFirstNoteLFOMode 47 | : kFirstNoteNormalMode; 48 | 49 | // Transpose the lowest octave up. 50 | while (pitch < 0) { 51 | pitch += kOctave; 52 | } 53 | while (pitch >= kOctave) { 54 | pitch -= kOctave; 55 | ++shifts; 56 | } 57 | uint16_t index_integral = U16ShiftRight4(pitch); 58 | uint16_t index_fractional = U8U8Mul(pitch & 0xf, 16); 59 | uint16_t count = pgm_read_word(lut_res_timer_count + index_integral); 60 | uint16_t next = pgm_read_word(lut_res_timer_count + index_integral + 1); 61 | count -= U16U8MulShift8(count - next, index_fractional); 62 | 63 | period_ = count >> shifts; 64 | uint8_t pw = pulse_width == PULSE_WIDTH_CV_CONTROLLED 65 | ? cv_pw_ 66 | : pulse_widths[pulse_width]; 67 | value_ = U16U8MulShift8(period_, pw); 68 | } 69 | 70 | } // namespace edges 71 | -------------------------------------------------------------------------------- /edges/voice_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Polyphonic voice allocator. 19 | 20 | #ifndef EDGES_VOICE_ALLOCATOR_H_ 21 | #define EDGES_VOICE_ALLOCATOR_H_ 22 | 23 | #include "avrlibx/avrlibx.h" 24 | 25 | static const uint8_t kMaxPolyphony = 4; 26 | 27 | namespace edges { 28 | 29 | class VoiceAllocator { 30 | public: 31 | VoiceAllocator() { } 32 | void Init() { size_ = 0; Clear(); } 33 | void set_size(uint8_t size) { 34 | size_ = size; 35 | } 36 | uint8_t NoteOn(uint8_t note); 37 | uint8_t NoteOff(uint8_t note); 38 | uint8_t Find(uint8_t note) const; 39 | void Clear(); 40 | void ClearNotes(); 41 | uint8_t size() const { return size_; } 42 | 43 | private: 44 | void Touch(uint8_t voice); 45 | 46 | uint8_t pool_[kMaxPolyphony]; 47 | // Holds the indices of the voices sorted by most recent usage. 48 | uint8_t lru_[kMaxPolyphony]; 49 | uint8_t size_; 50 | 51 | DISALLOW_COPY_AND_ASSIGN(VoiceAllocator); 52 | }; 53 | 54 | } // namespace edges 55 | 56 | #endif // EDGES_VOICE_ALLOCATOR_H_ 57 | -------------------------------------------------------------------------------- /frames/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/__init__.py -------------------------------------------------------------------------------- /frames/bootloader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/bootloader/__init__.py -------------------------------------------------------------------------------- /frames/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | # Preferred upload command 35 | UPLOAD_COMMAND = upload_jtag 36 | 37 | # Packages to build 38 | TARGET = frames_bootloader 39 | PACKAGES = frames/bootloader frames/drivers stmlib/utils stmlib/system \ 40 | stm_audio_bootloader/qpsk 41 | 42 | include stmlib/makefile.inc 43 | -------------------------------------------------------------------------------- /frames/drivers/adc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for ADC. 28 | 29 | #ifndef FRAMES_DRIVERS_ADC_H_ 30 | #define FRAMES_DRIVERS_ADC_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | const uint8_t kNumAdcChannels = 6; 37 | const uint8_t kFrameAdcChannel = 4; 38 | const uint8_t kFrameModulationAdcChannel = 5; 39 | 40 | class Adc { 41 | public: 42 | Adc() { } 43 | ~Adc() { } 44 | 45 | void Init(bool single_channel); 46 | void DeInit(); 47 | inline uint16_t value(uint8_t channel) const { return values_[channel]; } 48 | 49 | private: 50 | uint16_t values_[kNumAdcChannels]; 51 | 52 | DISALLOW_COPY_AND_ASSIGN(Adc); 53 | }; 54 | 55 | } // namespace frames 56 | 57 | #endif // FRAMES_DRIVERS_ADC_H_ 58 | -------------------------------------------------------------------------------- /frames/drivers/channel_leds.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the 4 channels LEDs. 28 | 29 | #ifndef FRAMES_DRIVERS_CHANNEL_LEDS_H_ 30 | #define FRAMES_DRIVERS_CHANNEL_LEDS_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include "frames/keyframer.h" 35 | 36 | namespace frames { 37 | 38 | class ChannelLeds { 39 | public: 40 | ChannelLeds() { } 41 | ~ChannelLeds() { } 42 | 43 | void Init(); 44 | void set_channel(uint8_t channel, uint8_t brightness) { 45 | levels_[channel] = brightness; 46 | } 47 | 48 | void Write(); 49 | 50 | private: 51 | uint8_t levels_[kNumChannels]; 52 | 53 | DISALLOW_COPY_AND_ASSIGN(ChannelLeds); 54 | }; 55 | 56 | } // namespace frames 57 | 58 | #endif // FRAMES_DRIVERS_CHANNEL_LEDS_H_ 59 | -------------------------------------------------------------------------------- /frames/drivers/dac.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for DAC. 28 | 29 | #include "frames/drivers/dac.h" 30 | 31 | namespace frames { 32 | 33 | void Dac::Init() { 34 | // Initialize SS pin. 35 | GPIO_InitTypeDef gpio_init; 36 | gpio_init.GPIO_Pin = kPinSS; 37 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 38 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 39 | GPIO_Init(GPIOB, &gpio_init); 40 | 41 | // Initialize MOSI and SCK pins. 42 | gpio_init.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_15; 43 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 44 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 45 | GPIO_Init(GPIOB, &gpio_init); 46 | 47 | // Initialize SPI 48 | SPI_InitTypeDef spi_init; 49 | spi_init.SPI_Direction = SPI_Direction_2Lines_FullDuplex; 50 | spi_init.SPI_Mode = SPI_Mode_Master; 51 | spi_init.SPI_DataSize = SPI_DataSize_16b; 52 | spi_init.SPI_CPOL = SPI_CPOL_High; 53 | spi_init.SPI_CPHA = SPI_CPHA_1Edge; 54 | spi_init.SPI_NSS = SPI_NSS_Soft; 55 | spi_init.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; 56 | spi_init.SPI_FirstBit = SPI_FirstBit_MSB; 57 | spi_init.SPI_CRCPolynomial = 7; 58 | SPI_Init(SPI2, &spi_init); 59 | SPI_Cmd(SPI2, ENABLE); 60 | 61 | active_channel_ = 0; 62 | } 63 | 64 | } // namespace frames 65 | -------------------------------------------------------------------------------- /frames/drivers/dac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for DAC. 28 | 29 | #ifndef FRAMES_DRIVERS_DAC_H_ 30 | #define FRAMES_DRIVERS_DAC_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | #include "frames/keyframer.h" 37 | 38 | namespace frames { 39 | 40 | const uint16_t kPinSS = GPIO_Pin_12; 41 | 42 | class Dac { 43 | public: 44 | Dac() { } 45 | ~Dac() { } 46 | 47 | void Init(); 48 | void Write(uint8_t channel, uint16_t data) { 49 | data_[channel] = data & 0x0fff; 50 | } 51 | void Update() { 52 | GPIOB->BSRR = kPinSS; 53 | GPIOB->BRR = kPinSS; 54 | uint16_t command_nibble = (active_channel_ << 2) | 1; 55 | SPI2->DR = (command_nibble << 12) | data_[active_channel_]; 56 | active_channel_ = (active_channel_ + 1) % 4; 57 | } 58 | bool ready() { return active_channel_ == 0; } 59 | 60 | private: 61 | uint8_t active_channel_; 62 | uint16_t data_[kNumChannels]; 63 | 64 | DISALLOW_COPY_AND_ASSIGN(Dac); 65 | }; 66 | 67 | } // namespace frames 68 | 69 | #endif // FRAMES_DRIVERS_DAC_H_ 70 | -------------------------------------------------------------------------------- /frames/drivers/factory_testing_switch.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the factory testing switch. 28 | 29 | #ifndef FRAMES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 30 | #define FRAMES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace frames { 37 | 38 | class FactoryTestingSwitch { 39 | public: 40 | FactoryTestingSwitch() { } 41 | ~FactoryTestingSwitch() { } 42 | 43 | void Init() { 44 | GPIO_InitTypeDef gpio_init; 45 | gpio_init.GPIO_Pin = GPIO_Pin_10; 46 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 47 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 48 | GPIO_Init(GPIOA, &gpio_init); 49 | } 50 | 51 | inline bool Read() { 52 | return GPIOA->IDR & GPIO_Pin_10; 53 | } 54 | 55 | private: 56 | DISALLOW_COPY_AND_ASSIGN(FactoryTestingSwitch); 57 | }; 58 | 59 | } // namespace frames 60 | 61 | #endif // FRAMES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 62 | -------------------------------------------------------------------------------- /frames/drivers/keyframe_led.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the trigger output pin. 28 | 29 | #include "frames/drivers/keyframe_led.h" 30 | 31 | #include 32 | 33 | namespace frames { 34 | 35 | const uint16_t kKeyframeIndicatorPin = GPIO_Pin_5; 36 | 37 | void KeyframeLed::Init() { 38 | GPIO_InitTypeDef gpio_init; 39 | gpio_init.GPIO_Pin = kKeyframeIndicatorPin; 40 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 41 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 42 | GPIO_Init(GPIOB, &gpio_init); 43 | } 44 | 45 | void KeyframeLed::Low() { 46 | GPIOB->BRR = kKeyframeIndicatorPin; 47 | } 48 | 49 | void KeyframeLed::High() { 50 | GPIOB->BSRR = kKeyframeIndicatorPin; 51 | } 52 | 53 | } // namespace frames 54 | -------------------------------------------------------------------------------- /frames/drivers/keyframe_led.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the keyframe indicator LED. 28 | 29 | #ifndef FRAMES_DRIVERS_KEYFRAME_LED_H_ 30 | #define FRAMES_DRIVERS_KEYFRAME_LED_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | class KeyframeLed { 37 | public: 38 | KeyframeLed() { } 39 | ~KeyframeLed() { } 40 | 41 | void Init(); 42 | void High(); 43 | void Low(); 44 | 45 | private: 46 | DISALLOW_COPY_AND_ASSIGN(KeyframeLed); 47 | }; 48 | 49 | } // namespace frames 50 | 51 | #endif // FRAMES_DRIVERS_KEYFRAME_LED_H_ 52 | -------------------------------------------------------------------------------- /frames/drivers/rgb_led.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the main RGB LED. 28 | 29 | #ifndef FRAMES_DRIVERS_RGB_LED_H_ 30 | #define FRAMES_DRIVERS_RGB_LED_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | class RgbLed { 37 | public: 38 | RgbLed() { } 39 | ~RgbLed() { } 40 | 41 | void Init(); 42 | 43 | inline void set_color(uint8_t r, uint8_t g, uint8_t b) { 44 | rgb_[0] = r; 45 | rgb_[1] = g; 46 | rgb_[2] = b; 47 | } 48 | 49 | inline void set_color(const uint8_t* rgb) { 50 | rgb_[0] = rgb[0]; 51 | rgb_[1] = rgb[1]; 52 | rgb_[2] = rgb[2]; 53 | } 54 | 55 | inline void Dim(uint16_t brightness) { 56 | rgb_[0] = rgb_[0] * brightness >> 16; 57 | rgb_[1] = rgb_[1] * brightness >> 16; 58 | rgb_[2] = rgb_[2] * brightness >> 16; 59 | } 60 | 61 | 62 | void Write(); 63 | 64 | private: 65 | uint8_t rgb_[3]; 66 | 67 | DISALLOW_COPY_AND_ASSIGN(RgbLed); 68 | }; 69 | 70 | } // namespace frames 71 | 72 | #endif // FRAMES_DRIVERS_RGB_LED_H_ 73 | -------------------------------------------------------------------------------- /frames/drivers/switches.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the ADD/DEL switches. 28 | 29 | #include "frames/drivers/switches.h" 30 | 31 | #include 32 | 33 | namespace frames { 34 | 35 | void Switches::Init() { 36 | memset(&switch_state_, 0xff, sizeof(switch_state_)); 37 | 38 | GPIO_InitTypeDef gpio_init; 39 | 40 | gpio_init.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; 41 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 42 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 43 | GPIO_Init(GPIOB, &gpio_init); 44 | } 45 | 46 | void Switches::Debounce() { 47 | switch_state_[0] = (switch_state_[0] << 1) | \ 48 | GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_10); 49 | switch_state_[1] = (switch_state_[1] << 1) | \ 50 | GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11); 51 | } 52 | 53 | } // namespace frames 54 | -------------------------------------------------------------------------------- /frames/drivers/switches.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the ADD/DEL switches. 28 | 29 | #ifndef FRAMES_DRIVERS_SWITCHES_H_ 30 | #define FRAMES_DRIVERS_SWITCHES_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace frames { 36 | 37 | const uint8_t kNumSwitches = 2; 38 | 39 | class Switches { 40 | public: 41 | Switches() { } 42 | ~Switches() { } 43 | 44 | void Init(); 45 | void Debounce(); 46 | 47 | inline bool released(uint8_t index) const { 48 | return switch_state_[index] == 0x7f; 49 | } 50 | 51 | inline bool just_pressed(uint8_t index) const { 52 | return switch_state_[index] == 0x80; 53 | } 54 | 55 | inline bool pressed(uint8_t index) const { 56 | return switch_state_[index] == 0x00; 57 | } 58 | 59 | inline bool pressed_immediate(uint8_t index) const { 60 | return !GPIO_ReadInputDataBit(GPIOB, index ? GPIO_Pin_11 : GPIO_Pin_10); 61 | } 62 | 63 | private: 64 | uint8_t switch_state_[kNumSwitches]; 65 | 66 | DISALLOW_COPY_AND_ASSIGN(Switches); 67 | }; 68 | 69 | } // namespace frames 70 | 71 | #endif // FRAMES_DRIVERS_SWITCHES_H_ 72 | -------------------------------------------------------------------------------- /frames/drivers/system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // System-level initialization. 28 | 29 | #ifndef FRAMES_DRIVERS_SYSTEM_H_ 30 | #define FRAMES_DRIVERS_SYSTEM_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | class System { 37 | public: 38 | System() { } 39 | ~System() { } 40 | 41 | void Init(uint32_t timer_period, bool application); 42 | void StartTimers(); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(System); 46 | }; 47 | 48 | } // namespace frames 49 | 50 | #endif // FRAMES_DRIVERS_SYSTEM_H_ 51 | -------------------------------------------------------------------------------- /frames/drivers/trigger_output.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the trigger output pin. 28 | 29 | #include "frames/drivers/trigger_output.h" 30 | 31 | #include 32 | 33 | namespace frames { 34 | 35 | const uint16_t kFrameChangePin = GPIO_Pin_6; 36 | 37 | void TriggerOutput::Init() { 38 | GPIO_InitTypeDef gpio_init; 39 | gpio_init.GPIO_Pin = kFrameChangePin; 40 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 41 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 42 | GPIO_Init(GPIOA, &gpio_init); 43 | 44 | GPIOA->BRR = kFrameChangePin; 45 | } 46 | 47 | void TriggerOutput::Low() { 48 | GPIOA->BSRR = kFrameChangePin; 49 | } 50 | 51 | void TriggerOutput::High() { 52 | GPIOA->BRR = kFrameChangePin; 53 | } 54 | 55 | } // namespace frames 56 | -------------------------------------------------------------------------------- /frames/drivers/trigger_output.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the trigger output pin. 28 | 29 | #ifndef FRAMES_DRIVERS_TRIGGER_OUTPUT_H_ 30 | #define FRAMES_DRIVERS_TRIGGER_OUTPUT_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | class TriggerOutput { 37 | public: 38 | TriggerOutput() { } 39 | ~TriggerOutput() { } 40 | 41 | void Init(); 42 | void High(); 43 | void Low(); 44 | 45 | private: 46 | 47 | DISALLOW_COPY_AND_ASSIGN(TriggerOutput); 48 | }; 49 | 50 | } // namespace frames 51 | 52 | #endif // FRAMES_DRIVERS_TRIGGER_OUTPUT_H_ 53 | -------------------------------------------------------------------------------- /frames/drivers/uart_logger.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #include "frames/drivers/uart_logger.h" 30 | 31 | #include 32 | 33 | namespace frames { 34 | 35 | void UartLogger::Init(uint32_t baud_rate) { 36 | // Initialize TX pin. 37 | GPIO_InitTypeDef gpio_init; 38 | gpio_init.GPIO_Pin = GPIO_Pin_9; 39 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 40 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 41 | GPIO_Init(GPIOA, &gpio_init); 42 | 43 | // Initialize USART. 44 | USART_InitTypeDef usart_init; 45 | usart_init.USART_BaudRate = baud_rate; 46 | usart_init.USART_WordLength = USART_WordLength_8b; 47 | usart_init.USART_StopBits = USART_StopBits_1; 48 | usart_init.USART_Parity = USART_Parity_No; 49 | usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 50 | usart_init.USART_Mode = USART_Mode_Tx; 51 | 52 | USART_Init(USART1, &usart_init); 53 | USART_Cmd(USART1, ENABLE); 54 | 55 | } 56 | 57 | void UartLogger::Trace(uint8_t byte) { 58 | while (!(USART1->SR & USART_FLAG_TXE)); 59 | USART1->DR = byte; 60 | } 61 | 62 | } // namespace frames 63 | -------------------------------------------------------------------------------- /frames/drivers/uart_logger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #ifndef FRAMES_DRIVERS_UART_LOGGER_H_ 30 | #define FRAMES_DRIVERS_UART_LOGGER_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace frames { 35 | 36 | class UartLogger { 37 | public: 38 | UartLogger() { } 39 | ~UartLogger() { } 40 | 41 | void Init(uint32_t baud_rate); 42 | void Trace(uint8_t byte); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(UartLogger); 46 | }; 47 | 48 | } // namespace frames 49 | 50 | #endif // FRAMES_DRIVERS_UART_LOGGER_H_ 51 | -------------------------------------------------------------------------------- /frames/hardware_design/panel/frames.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/hardware_design/panel/frames.ai -------------------------------------------------------------------------------- /frames/hardware_design/panel/frames.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/hardware_design/panel/frames.dwg -------------------------------------------------------------------------------- /frames/hardware_design/pcb/frames_v03.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/hardware_design/pcb/frames_v03.brd -------------------------------------------------------------------------------- /frames/hardware_design/pcb/frames_v03.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/hardware_design/pcb/frames_v03.sch -------------------------------------------------------------------------------- /frames/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | APPLICATION = TRUE 35 | BOOTLOADER = frames_bootloader 36 | 37 | # Preferred upload command 38 | UPLOAD_COMMAND = upload_combo_jtag 39 | 40 | # Packages to build 41 | TARGET = frames 42 | PACKAGES = frames frames/drivers stmlib/utils stmlib/system 43 | RESOURCES = frames/resources 44 | 45 | include stmlib/makefile.inc 46 | 47 | # Rule for building the firmware update file 48 | wav: $(TARGET_BIN) 49 | python stm_audio_bootloader/qpsk/encoder.py \ 50 | -s 48000 -b 12000 -c 6000 -p 256 \ 51 | $(TARGET_BIN) 52 | 53 | -------------------------------------------------------------------------------- /frames/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/frames/resources/__init__.py -------------------------------------------------------------------------------- /grids/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/__init__.py -------------------------------------------------------------------------------- /grids/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Olivier Gillet. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | 14 | VERSION = 0.1 15 | MCU_NAME = 328 16 | TARGET = grids_bootloader 17 | PACKAGES = avrlib grids/bootloader avr_audio_bootloader/fsk 18 | EXTRA_DEFINES = -funsigned-char -fno-inline-small-functions -DDISABLE_DEFAULT_UART_RX_ISR 19 | EXTRA_LD_FLAGS = ,--section-start=.text=0x7000,--relax 20 | 21 | LFUSE = ff 22 | HFUSE = d8 23 | EFUSE = 05 24 | LOCK = 2f 25 | 26 | include avrlib/makefile.mk 27 | 28 | include $(DEP_FILE) 29 | -------------------------------------------------------------------------------- /grids/clock.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | // 16 | // ----------------------------------------------------------------------------- 17 | // 18 | // Global clock. 19 | 20 | #include "grids/clock.h" 21 | 22 | #include "grids/resources.h" 23 | 24 | namespace grids { 25 | 26 | Clock clock; 27 | 28 | /* static */ 29 | bool Clock::locked_; 30 | 31 | /* static */ 32 | uint16_t Clock::bpm_; 33 | 34 | /* static */ 35 | uint32_t Clock::phase_; 36 | 37 | /* static */ 38 | uint32_t Clock::phase_increment_; 39 | 40 | /* static */ 41 | uint8_t Clock::falling_edge_; 42 | 43 | /* static */ 44 | void Clock::Update(uint16_t bpm, ClockResolution resolution) { 45 | bpm_ = bpm; 46 | phase_increment_ = pgm_read_dword(lut_res_tempo_phase_increment + bpm); 47 | if (resolution == CLOCK_RESOLUTION_4_PPQN) { 48 | phase_increment_ >>= 1; 49 | } else if (resolution == CLOCK_RESOLUTION_24_PPQN) { 50 | phase_increment_ = (phase_increment_ << 1) + phase_increment_; 51 | } 52 | } 53 | 54 | } // namespace grids 55 | -------------------------------------------------------------------------------- /grids/hardware_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #ifndef GRIDS_HARDWARE_CONFIG_H_ 17 | #define GRIDS_HARDWARE_CONFIG_H_ 18 | 19 | #include "avrlib/base.h" 20 | #include "avrlib/gpio.h" 21 | #include "avrlib/parallel_io.h" 22 | #include "avrlib/serial.h" 23 | #include "avrlib/spi.h" 24 | 25 | namespace grids { 26 | 27 | enum AdcChannel { 28 | ADC_CHANNEL_X_CV, 29 | ADC_CHANNEL_Y_CV, 30 | ADC_CHANNEL_RANDOMNESS_CV, 31 | ADC_CHANNEL_BD_DENSITY_CV, 32 | ADC_CHANNEL_SD_DENSITY_CV, 33 | ADC_CHANNEL_HH_DENSITY_CV, 34 | ADC_CHANNEL_TEMPO, 35 | ADC_CHANNEL_LAST 36 | }; 37 | 38 | enum LedBits { 39 | LED_CLOCK = 1, 40 | LED_BD = 8, 41 | LED_SD = 4, 42 | LED_HH = 2, 43 | LED_ALL = LED_CLOCK | LED_BD | LED_SD | LED_HH 44 | }; 45 | 46 | enum InputBits { 47 | INPUT_CLOCK = 2, 48 | INPUT_RESET = 4, 49 | INPUT_SW_RESET = 8 50 | }; 51 | 52 | using avrlib::Gpio; 53 | using avrlib::ParallelPort; 54 | using avrlib::PortB; 55 | using avrlib::PortD; 56 | using avrlib::Serial; 57 | using avrlib::SerialPort0; 58 | using avrlib::SpiMaster; 59 | 60 | typedef ParallelPort Leds; 61 | typedef ParallelPort Inputs; 62 | typedef SpiMaster, avrlib::MSB_FIRST, 2> ShiftRegister; 63 | typedef Serial MidiInput; 64 | } // namespace grids 65 | 66 | #endif // GRIDS_HARDWARE_CONFIG_H_ 67 | -------------------------------------------------------------------------------- /grids/hardware_design/panel/grids.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/hardware_design/panel/grids.ai -------------------------------------------------------------------------------- /grids/hardware_design/panel/grids.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/hardware_design/panel/grids.dwg -------------------------------------------------------------------------------- /grids/hardware_design/pcb/grids_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/hardware_design/pcb/grids_v01.brd -------------------------------------------------------------------------------- /grids/hardware_design/pcb/grids_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/hardware_design/pcb/grids_v01.sch -------------------------------------------------------------------------------- /grids/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Olivier Gillet. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | 14 | VERSION = 0.1 15 | MCU_NAME = 328 16 | TARGET = grids 17 | PACKAGES = avrlib avrlib/devices grids 18 | RESOURCES = grids/resources 19 | SYSEX_FLAGS = --page_size=64 --device_id=9 20 | EXTRA_DEFINES = -DDISABLE_DEFAULT_UART_RX_ISR 21 | 22 | LFUSE = ff 23 | HFUSE = dc 24 | EFUSE = 05 25 | LOCK = 2f 26 | 27 | include avrlib/makefile.mk 28 | 29 | include $(DEP_FILE) 30 | -------------------------------------------------------------------------------- /grids/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/grids/resources/__init__.py -------------------------------------------------------------------------------- /grids/resources/resources.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2.5 2 | # 3 | # Copyright 2012 Olivier Gillet. 4 | # 5 | # Author: Olivier Gillet (olivier@mutable-instruments.net) 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | # ----------------------------------------------------------------------------- 19 | # 20 | # Master resources file. 21 | 22 | header = """// Copyright 2012 Olivier Gillet. 23 | // 24 | // Author: Olivier Gillet (olivier@mutable-instruments.net) 25 | // 26 | // This program is free software: you can redistribute it and/or modify 27 | // it under the terms of the GNU General Public License as published by 28 | // the Free Software Foundation, either version 3 of the License, or 29 | // (at your option) any later version. 30 | // This program is distributed in the hope that it will be useful, 31 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | // GNU General Public License for more details. 34 | // You should have received a copy of the GNU General Public License 35 | // along with this program. If not, see . 36 | // 37 | // ----------------------------------------------------------------------------- 38 | // 39 | // Resources definitions. 40 | // 41 | // Automatically generated with: 42 | // make resources 43 | """ 44 | 45 | namespace = 'grids' 46 | target = 'grids' 47 | modifier = 'PROGMEM' 48 | types = ['uint8_t', 'uint16_t'] 49 | includes = """ 50 | #include "avrlib/base.h" 51 | 52 | #include 53 | """ 54 | 55 | import lookup_tables 56 | 57 | create_specialized_manager = True 58 | 59 | resources = [ 60 | ('dummy', 'string', 'STR_RES', 'prog_char', str, True), 61 | (lookup_tables.lookup_tables, 62 | 'lookup_table', 'LUT_RES', 'prog_uint16_t', int, True), 63 | (lookup_tables.lookup_tables32, 64 | 'lookup_table32', 'LUT_RES', 'prog_uint32_t', int, True), 65 | (lookup_tables.drum_map_nodes, 66 | 'node', 'NODE', 'prog_uint8_t', int, True), 67 | ] 68 | -------------------------------------------------------------------------------- /links/hardware_design/panel/links.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/links/hardware_design/panel/links.ai -------------------------------------------------------------------------------- /links/hardware_design/panel/links.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/links/hardware_design/panel/links.dwg -------------------------------------------------------------------------------- /links/hardware_design/pcb/links_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/links/hardware_design/pcb/links_v01.brd -------------------------------------------------------------------------------- /links/hardware_design/pcb/links_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/links/hardware_design/pcb/links_v01.sch -------------------------------------------------------------------------------- /peaks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/__init__.py -------------------------------------------------------------------------------- /peaks/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | # Preferred upload command 35 | UPLOAD_COMMAND = upload_jtag 36 | 37 | # Packages to build 38 | TARGET = peaks_bootloader 39 | PACKAGES = peaks/bootloader peaks/drivers stmlib/utils stmlib/system \ 40 | stm_audio_bootloader/fsk 41 | 42 | include stmlib/makefile.inc 43 | -------------------------------------------------------------------------------- /peaks/calibration_data.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Calibration settings. 28 | 29 | #include "peaks/calibration_data.h" 30 | 31 | #include "stmlib/system/storage.h" 32 | 33 | namespace peaks { 34 | 35 | using namespace stmlib; 36 | 37 | Storage<0x801c000, 1> calibration_storage; 38 | 39 | void CalibrationData::Init() { 40 | if (!calibration_storage.Load(&calibration_settings_)) { 41 | calibration_settings_.dac_offset[0] = 0; 42 | calibration_settings_.dac_offset[1] = 0; 43 | } 44 | } 45 | 46 | void CalibrationData::Save() { 47 | calibration_storage.Save(calibration_settings_); 48 | } 49 | 50 | } // namespace peaks 51 | -------------------------------------------------------------------------------- /peaks/calibration_data.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Calibration settings. 28 | 29 | #ifndef PEAKS_CALIBRATION_DATA_H_ 30 | #define PEAKS_CALIBRATION_DATA_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace peaks { 35 | 36 | struct CalibrationSettings { 37 | int16_t dac_offset[2]; 38 | }; 39 | 40 | class CalibrationData { 41 | public: 42 | CalibrationData() { } 43 | ~CalibrationData() { } 44 | 45 | void Init(); 46 | 47 | inline uint16_t DacCode(uint8_t channel, int16_t value) const { 48 | int32_t shifted_value = 32767 - static_cast(value); 49 | shifted_value += static_cast( 50 | calibration_settings_.dac_offset[channel]); 51 | CONSTRAIN(shifted_value, 0, 65535); 52 | return static_cast(shifted_value); 53 | } 54 | 55 | inline void set_dac_offset(uint8_t channel, int16_t offset) { 56 | calibration_settings_.dac_offset[channel] = offset; 57 | } 58 | 59 | void Save(); 60 | 61 | private: 62 | CalibrationSettings calibration_settings_; 63 | 64 | DISALLOW_COPY_AND_ASSIGN(CalibrationData); 65 | }; 66 | 67 | } // namespace peaks 68 | 69 | #endif // PEAKS_CALIBRATION_DATA_H_ 70 | -------------------------------------------------------------------------------- /peaks/data/digits.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/data/digits.bin -------------------------------------------------------------------------------- /peaks/drivers/adc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for ADC. 28 | 29 | #ifndef PEAKS_DRIVERS_ADC_H_ 30 | #define PEAKS_DRIVERS_ADC_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace peaks { 35 | 36 | const uint8_t kNumAdcChannels = 4; 37 | 38 | class Adc { 39 | public: 40 | Adc() { } 41 | ~Adc() { } 42 | 43 | void Init(); 44 | 45 | inline uint16_t value(uint8_t channel) const { return values_[channel]; } 46 | 47 | private: 48 | uint16_t values_[kNumAdcChannels]; 49 | 50 | DISALLOW_COPY_AND_ASSIGN(Adc); 51 | }; 52 | 53 | } // namespace peaks 54 | 55 | #endif // PEAKS_DRIVERS_ADC_H_ 56 | -------------------------------------------------------------------------------- /peaks/drivers/debug_pin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the debug (timing) pin. 28 | 29 | #ifndef PEAKS_DRIVERS_DEBUG_PIN_H_ 30 | #define PEAKS_DRIVERS_DEBUG_PIN_H_ 31 | 32 | #include 33 | #include "stmlib/stmlib.h" 34 | 35 | namespace peaks { 36 | 37 | class DebugPin { 38 | public: 39 | DebugPin() { } 40 | ~DebugPin() { } 41 | 42 | static void Init() { 43 | GPIO_InitTypeDef gpio_init; 44 | gpio_init.GPIO_Pin = GPIO_Pin_10; 45 | gpio_init.GPIO_Speed = GPIO_Speed_2MHz; 46 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 47 | GPIO_Init(GPIOA, &gpio_init); 48 | GPIOA->BSRR = GPIO_Pin_10; 49 | } 50 | 51 | static void High() { 52 | GPIOA->BSRR = GPIO_Pin_10; 53 | } 54 | 55 | static void Low() { 56 | GPIOA->BRR = GPIO_Pin_10; 57 | } 58 | 59 | private: 60 | DISALLOW_COPY_AND_ASSIGN(DebugPin); 61 | }; 62 | 63 | } // namespace peaks 64 | 65 | #endif // PEAKS_DRIVERS_DEBUG_PIN_H_ 66 | -------------------------------------------------------------------------------- /peaks/drivers/gate_input.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the 2 gate inputs. 28 | 29 | #include "peaks/drivers/gate_input.h" 30 | 31 | namespace peaks { 32 | 33 | void GateInput::Init() { 34 | GPIO_InitTypeDef gpio_init; 35 | gpio_init.GPIO_Pin = GPIO_Pin_12; 36 | gpio_init.GPIO_Speed = GPIO_Speed_2MHz; 37 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 38 | GPIO_Init(GPIOA, &gpio_init); 39 | 40 | gpio_init.GPIO_Pin = GPIO_Pin_11; 41 | gpio_init.GPIO_Speed = GPIO_Speed_2MHz; 42 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 43 | GPIO_Init(GPIOB, &gpio_init); 44 | } 45 | 46 | } // namespace peaks 47 | -------------------------------------------------------------------------------- /peaks/drivers/gate_input.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the 2 gate inputs. 28 | 29 | #ifndef PEAKS_DRIVERS_GATE_INPUT_H_ 30 | #define PEAKS_DRIVERS_GATE_INPUT_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace peaks { 37 | 38 | enum GateInputState { 39 | INPUT_1_GATE = 0x01, 40 | INPUT_1_RAISING = 0x02, 41 | INPUT_1_FALLING = 0x04, 42 | INPUT_2_GATE = 0x10, 43 | INPUT_2_RAISING = 0x20, 44 | INPUT_2_FALLING = 0x40, 45 | }; 46 | 47 | class GateInput { 48 | public: 49 | GateInput() { } 50 | ~GateInput() { } 51 | 52 | void Init(); 53 | 54 | uint32_t Read() { 55 | uint32_t result = 0; 56 | result |= GPIOB->IDR & GPIO_Pin_11 ? 0 : 1; 57 | result |= GPIOA->IDR & GPIO_Pin_12 ? 0 : 2; 58 | return result; 59 | } 60 | 61 | inline bool ReadInput1() { 62 | return GPIOB->IDR & GPIO_Pin_11; 63 | } 64 | 65 | private: 66 | uint8_t ReadBits(); 67 | 68 | DISALLOW_COPY_AND_ASSIGN(GateInput); 69 | }; 70 | 71 | } // namespace peaks 72 | 73 | #endif // PEAKS_DRIVERS_GATE_INPUT_H_ 74 | -------------------------------------------------------------------------------- /peaks/drivers/leds.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the status LEDs. 28 | 29 | #ifndef PEAKS_DRIVERS_LEDS_H_ 30 | #define PEAKS_DRIVERS_LEDS_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace peaks { 35 | 36 | class Leds { 37 | public: 38 | Leds() { } 39 | ~Leds() { } 40 | 41 | void Init(); 42 | 43 | void set_function(uint8_t function) { 44 | function_ = 1 << function; 45 | } 46 | void set_pattern(uint8_t pattern) { 47 | function_ = pattern; 48 | } 49 | void set_twin_mode(bool twin_mode) { 50 | twin_mode_ = twin_mode; 51 | } 52 | void set_levels(uint8_t level_1, uint8_t level_2) { 53 | levels_[0] = level_1; 54 | levels_[1] = level_2; 55 | } 56 | void fade_levels(uint8_t level_1, uint8_t level_2) { 57 | levels_[0] = (255 * levels_[0] + level_1) >> 8; 58 | levels_[1] = (255 * levels_[1] + level_2) >> 8; 59 | } 60 | void Write(); 61 | 62 | private: 63 | uint8_t function_; 64 | bool twin_mode_; 65 | uint8_t levels_[2]; 66 | 67 | DISALLOW_COPY_AND_ASSIGN(Leds); 68 | }; 69 | 70 | } // namespace peaks 71 | 72 | #endif // PEAKS_DRIVERS_LEDS_H_ 73 | -------------------------------------------------------------------------------- /peaks/drivers/system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // System-level initialization. 28 | 29 | #ifndef PEAKS_DRIVERS_SYSTEM_H_ 30 | #define PEAKS_DRIVERS_SYSTEM_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace peaks { 35 | 36 | class System { 37 | public: 38 | System() { } 39 | ~System() { } 40 | 41 | void Init(uint32_t timer_period, bool application); 42 | void StartTimers(); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(System); 46 | }; 47 | 48 | } // namespace peaks 49 | 50 | #endif // PEAKS_DRIVERS_SYSTEM_H_ 51 | -------------------------------------------------------------------------------- /peaks/gate_processor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // General declarations used by all trigger/gate processors. 28 | 29 | #ifndef PEAKS_GATE_PROCESSOR_H_ 30 | #define PEAKS_GATE_PROCESSOR_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include "stmlib/utils/ring_buffer.h" 35 | 36 | namespace peaks { 37 | 38 | enum ControlMode { 39 | CONTROL_MODE_FULL, 40 | CONTROL_MODE_HALF 41 | }; 42 | 43 | enum GateFlagsBits { 44 | GATE_FLAG_LOW = 0, 45 | GATE_FLAG_HIGH = 1, 46 | GATE_FLAG_RISING = 2, 47 | GATE_FLAG_FALLING = 4, 48 | GATE_FLAG_FROM_BUTTON = 8, 49 | 50 | GATE_FLAG_AUXILIARY_LOW = 0, 51 | GATE_FLAG_AUXILIARY_HIGH = 16, 52 | GATE_FLAG_AUXILIARY_RISING = 32, 53 | GATE_FLAG_AUXILIARY_FALLING = 64, 54 | }; 55 | 56 | typedef uint8_t GateFlags; 57 | 58 | inline GateFlags ExtractGateFlags(GateFlags previous, bool current) { 59 | previous &= GATE_FLAG_HIGH; 60 | if (current) { 61 | return previous ? GATE_FLAG_HIGH : (GATE_FLAG_RISING | GATE_FLAG_HIGH); 62 | } else { 63 | return previous ? GATE_FLAG_FALLING : GATE_FLAG_LOW; 64 | } 65 | } 66 | 67 | } // namespace peaks 68 | 69 | #endif // PEAKS_GATE_PROCESSOR_H_ 70 | -------------------------------------------------------------------------------- /peaks/hardware_design/panel/peaks.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/hardware_design/panel/peaks.ai -------------------------------------------------------------------------------- /peaks/hardware_design/panel/peaks.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/hardware_design/panel/peaks.dwg -------------------------------------------------------------------------------- /peaks/hardware_design/pcb/peaks_v02.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/hardware_design/pcb/peaks_v02.brd -------------------------------------------------------------------------------- /peaks/hardware_design/pcb/peaks_v02.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/hardware_design/pcb/peaks_v02.sch -------------------------------------------------------------------------------- /peaks/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | APPLICATION = TRUE 35 | BOOTLOADER = peaks_bootloader 36 | 37 | # Preferred upload command 38 | UPLOAD_COMMAND = upload_combo_jtag 39 | 40 | # Packages to build 41 | TARGET = peaks 42 | PACKAGES = peaks \ 43 | peaks/drivers \ 44 | peaks/drums \ 45 | peaks/modulations \ 46 | peaks/number_station \ 47 | peaks/pulse_processor \ 48 | stmlib/utils \ 49 | stmlib/system 50 | RESOURCES = peaks/resources 51 | 52 | TOOLCHAIN_PATH ?= /usr/local/arm-4.8.3/ 53 | 54 | include stmlib/makefile.inc 55 | 56 | # Rule for building the firmware update file 57 | wav: $(TARGET_BIN) 58 | python stm_audio_bootloader/fsk/encoder.py \ 59 | -s 48000 -b 16 -n 8 -z 4 -p 256 \ 60 | $(TARGET_BIN) 61 | -------------------------------------------------------------------------------- /peaks/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/peaks/resources/__init__.py -------------------------------------------------------------------------------- /peaks/test/makefile: -------------------------------------------------------------------------------- 1 | PACKAGES = peaks/test stmlib/utils peaks peaks/drums peaks/pulse_processor peaks/modulations peaks/number_station 2 | 3 | VPATH = $(PACKAGES) 4 | 5 | TARGET = peaks_test 6 | BUILD_ROOT = build/ 7 | BUILD_DIR = $(BUILD_ROOT)$(TARGET)/ 8 | CC_FILES = bass_drum.cc \ 9 | fm_drum.cc \ 10 | high_hat.cc \ 11 | lfo.cc \ 12 | multistage_envelope.cc \ 13 | number_station.cc \ 14 | peaks_test.cc \ 15 | processors.cc \ 16 | pulse_shaper.cc \ 17 | pulse_randomizer.cc \ 18 | random.cc \ 19 | resources.cc \ 20 | snare_drum.cc \ 21 | svf.cc 22 | OBJ_FILES = $(CC_FILES:.cc=.o) 23 | OBJS = $(patsubst %,$(BUILD_DIR)%,$(OBJ_FILES)) $(STARTUP_OBJ) 24 | DEPS = $(OBJS:.o=.d) 25 | DEP_FILE = $(BUILD_DIR)depends.mk 26 | 27 | all: peaks_test 28 | 29 | $(BUILD_DIR): 30 | mkdir -p $(BUILD_DIR) 31 | 32 | $(BUILD_DIR)%.o: %.cc 33 | g++ -c -DTEST -g -Wall -Werror -I. $< -o $@ 34 | 35 | $(BUILD_DIR)%.d: %.cc 36 | g++ -MM -DTEST -I. $< -MF $@ -MT $(@:.d=.o) 37 | 38 | peaks_test: $(OBJS) 39 | g++ -o $(TARGET) $(OBJS) 40 | 41 | depends: $(DEPS) 42 | cat $(DEPS) > $(DEP_FILE) 43 | 44 | $(DEP_FILE): $(BUILD_DIR) $(DEPS) 45 | cat $(DEPS) > $(DEP_FILE) 46 | 47 | include $(DEP_FILE) 48 | -------------------------------------------------------------------------------- /ripples/hardware_design/panel/ripples.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/ripples/hardware_design/panel/ripples.ai -------------------------------------------------------------------------------- /ripples/hardware_design/panel/ripples.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/ripples/hardware_design/panel/ripples.dwg -------------------------------------------------------------------------------- /ripples/hardware_design/pcb/ripples_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/ripples/hardware_design/pcb/ripples_v01.brd -------------------------------------------------------------------------------- /ripples/hardware_design/pcb/ripples_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/ripples/hardware_design/pcb/ripples_v01.sch -------------------------------------------------------------------------------- /tides/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/__init__.py -------------------------------------------------------------------------------- /tides/bootloader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/bootloader/__init__.py -------------------------------------------------------------------------------- /tides/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | # Preferred upload command 35 | UPLOAD_COMMAND = upload_serial 36 | 37 | # Packages to build 38 | TARGET = tides_bootloader 39 | PACKAGES = tides/bootloader tides/drivers stmlib/utils stmlib/system \ 40 | stm_audio_bootloader/qpsk 41 | 42 | include stmlib/makefile.inc 43 | -------------------------------------------------------------------------------- /tides/drivers/adc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for ADC. 28 | 29 | #ifndef TIDES_DRIVERS_ADC_H_ 30 | #define TIDES_DRIVERS_ADC_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include "tides/cv_scaler.h" 35 | 36 | namespace tides { 37 | 38 | class Adc { 39 | public: 40 | Adc() { } 41 | ~Adc() { } 42 | 43 | void Init(bool single_channel); 44 | void DeInit(); 45 | inline uint16_t value(uint8_t channel) const { return values_[channel]; } 46 | inline const uint16_t* values() { return &values_[0]; } 47 | 48 | private: 49 | uint16_t values_[ADC_CHANNEL_LAST]; 50 | 51 | DISALLOW_COPY_AND_ASSIGN(Adc); 52 | }; 53 | 54 | } // namespace tides 55 | 56 | #endif // TIDES_DRIVERS_ADC_H_ 57 | -------------------------------------------------------------------------------- /tides/drivers/factory_testing_switch.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the factory testing switch. 28 | 29 | #ifndef TIDES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 30 | #define TIDES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace tides { 37 | 38 | class FactoryTestingSwitch { 39 | public: 40 | FactoryTestingSwitch() { } 41 | ~FactoryTestingSwitch() { } 42 | 43 | void Init() { 44 | GPIO_InitTypeDef gpio_init; 45 | gpio_init.GPIO_Pin = GPIO_Pin_10; 46 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 47 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 48 | GPIO_Init(GPIOA, &gpio_init); 49 | } 50 | 51 | inline bool Read() { 52 | return GPIOA->IDR & GPIO_Pin_10; 53 | } 54 | 55 | private: 56 | DISALLOW_COPY_AND_ASSIGN(FactoryTestingSwitch); 57 | }; 58 | 59 | } // namespace tides 60 | 61 | #endif // TIDES_DRIVERS_FACTORY_TESTING_SWITCH_H_ 62 | -------------------------------------------------------------------------------- /tides/drivers/gate_input.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the end of cycles output pins. 28 | 29 | #include "tides/drivers/gate_input.h" 30 | 31 | #include 32 | 33 | namespace tides { 34 | 35 | void GateInput::Init() { 36 | GPIO_InitTypeDef gpio_init; 37 | gpio_init.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_10 | GPIO_Pin_11; 38 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 39 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 40 | GPIO_Init(GPIOB, &gpio_init); 41 | previous_state_ = 0; 42 | } 43 | 44 | } // namespace tides 45 | -------------------------------------------------------------------------------- /tides/drivers/gate_output.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the end of cycles output pins. 28 | 29 | #include "tides/drivers/gate_output.h" 30 | 31 | #include 32 | 33 | namespace tides { 34 | 35 | void GateOutput::Init() { 36 | GPIO_InitTypeDef gpio_init; 37 | gpio_init.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12; 38 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 39 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 40 | GPIO_Init(GPIOA, &gpio_init); 41 | } 42 | 43 | } // namespace tides 44 | -------------------------------------------------------------------------------- /tides/drivers/gate_output.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the end of cycles output pins. 28 | 29 | #ifndef TIDES_DRIVERS_GATE_OUTPUT_H_ 30 | #define TIDES_DRIVERS_GATE_OUTPUT_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace tides { 37 | 38 | class GateOutput { 39 | public: 40 | GateOutput() { } 41 | ~GateOutput() { } 42 | 43 | void Init(); 44 | 45 | inline void Write(bool end_of_attack, bool end_of_release) { 46 | if (end_of_attack) { 47 | GPIOA->BRR = GPIO_Pin_12; 48 | } else { 49 | GPIOA->BSRR = GPIO_Pin_12; 50 | } 51 | 52 | if (end_of_release) { 53 | GPIOA->BRR = GPIO_Pin_11; 54 | } else { 55 | GPIOA->BSRR = GPIO_Pin_11; 56 | } 57 | } 58 | 59 | private: 60 | DISALLOW_COPY_AND_ASSIGN(GateOutput); 61 | }; 62 | 63 | } // namespace tides 64 | 65 | #endif // TIDES_DRIVERS_GATE_OUTPUT_H_ 66 | -------------------------------------------------------------------------------- /tides/drivers/leds.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the 4 channels LEDs. 28 | 29 | #ifndef TIDES_DRIVERS_LEDS_H_ 30 | #define TIDES_DRIVERS_LEDS_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace tides { 35 | 36 | class Leds { 37 | public: 38 | Leds() { } 39 | ~Leds() { } 40 | 41 | void Init(); 42 | 43 | void set_mode(bool y) { 44 | mode_r_ = mode_g_ = y; 45 | } 46 | 47 | void set_mode(bool r, bool g) { 48 | mode_r_ = r; 49 | mode_g_ = g; 50 | } 51 | 52 | void set_rate(uint16_t y) { 53 | rate_r_ = rate_g_ = y; 54 | } 55 | 56 | void set_rate(uint16_t r, uint16_t g) { 57 | rate_r_ = r; 58 | rate_g_ = g; 59 | } 60 | 61 | void set_value(uint16_t r, uint16_t g) { 62 | value_r_ = r; 63 | value_g_ = g; 64 | } 65 | 66 | void set_value(uint16_t y) { 67 | value_r_ = value_g_ = y; 68 | } 69 | 70 | void Write(); 71 | 72 | private: 73 | bool mode_r_; 74 | bool mode_g_; 75 | uint16_t rate_r_; 76 | uint16_t rate_g_; 77 | uint16_t value_r_; 78 | uint16_t value_g_; 79 | 80 | DISALLOW_COPY_AND_ASSIGN(Leds); 81 | }; 82 | 83 | } // namespace tides 84 | 85 | #endif // TIDES_DRIVERS_LEDS_H_ 86 | -------------------------------------------------------------------------------- /tides/drivers/switches.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the Mode and Range switches. 28 | 29 | #include "tides/drivers/switches.h" 30 | 31 | #include 32 | 33 | namespace tides { 34 | 35 | void Switches::Init() { 36 | memset(&switch_state_, 0xff, sizeof(switch_state_)); 37 | 38 | GPIO_InitTypeDef gpio_init; 39 | 40 | gpio_init.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; 41 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 42 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 43 | GPIO_Init(GPIOA, &gpio_init); 44 | } 45 | 46 | void Switches::Debounce() { 47 | switch_state_[0] = (switch_state_[0] << 1) | \ 48 | GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0); 49 | switch_state_[1] = (switch_state_[1] << 1) | \ 50 | GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1); 51 | } 52 | 53 | } // namespace tides 54 | -------------------------------------------------------------------------------- /tides/drivers/switches.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the Mode and Range switches. 28 | 29 | #ifndef TIDES_DRIVERS_SWITCHES_H_ 30 | #define TIDES_DRIVERS_SWITCHES_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace tides { 37 | 38 | const uint8_t kNumSwitches = 2; 39 | 40 | class Switches { 41 | public: 42 | Switches() { } 43 | ~Switches() { } 44 | 45 | void Init(); 46 | void Debounce(); 47 | 48 | inline bool released(uint8_t index) const { 49 | return switch_state_[index] == 0x7f; 50 | } 51 | 52 | inline bool just_pressed(uint8_t index) const { 53 | return switch_state_[index] == 0x80; 54 | } 55 | 56 | inline bool pressed(uint8_t index) const { 57 | return switch_state_[index] == 0x00; 58 | } 59 | 60 | inline bool pressed_immediate(uint8_t index) const { 61 | return !GPIO_ReadInputDataBit(GPIOA, index ? GPIO_Pin_1 : GPIO_Pin_0); 62 | } 63 | 64 | private: 65 | uint8_t switch_state_[kNumSwitches]; 66 | 67 | DISALLOW_COPY_AND_ASSIGN(Switches); 68 | }; 69 | 70 | } // namespace tides 71 | 72 | #endif // TIDES_DRIVERS_SWITCHES_H_ 73 | -------------------------------------------------------------------------------- /tides/drivers/system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // System-level initialization. 28 | 29 | #ifndef TIDES_DRIVERS_SYSTEM_H_ 30 | #define TIDES_DRIVERS_SYSTEM_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace tides { 35 | 36 | class System { 37 | public: 38 | System() { } 39 | ~System() { } 40 | 41 | void Init(uint32_t timer_period, bool application); 42 | void StartTimers(); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(System); 46 | }; 47 | 48 | } // namespace tides 49 | 50 | #endif // TIDES_DRIVERS_SYSTEM_H_ 51 | -------------------------------------------------------------------------------- /tides/drivers/uart_logger.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #include "tides/drivers/uart_logger.h" 30 | 31 | #include 32 | 33 | namespace tides { 34 | 35 | void UartLogger::Init(uint32_t baud_rate) { 36 | // Initialize TX pin. 37 | GPIO_InitTypeDef gpio_init; 38 | gpio_init.GPIO_Pin = GPIO_Pin_9; 39 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 40 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 41 | GPIO_Init(GPIOA, &gpio_init); 42 | 43 | // Initialize USART. 44 | USART_InitTypeDef usart_init; 45 | usart_init.USART_BaudRate = baud_rate; 46 | usart_init.USART_WordLength = USART_WordLength_8b; 47 | usart_init.USART_StopBits = USART_StopBits_1; 48 | usart_init.USART_Parity = USART_Parity_No; 49 | usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 50 | usart_init.USART_Mode = USART_Mode_Tx; 51 | 52 | USART_Init(USART1, &usart_init); 53 | USART_Cmd(USART1, ENABLE); 54 | 55 | } 56 | 57 | void UartLogger::Trace(uint8_t byte) { 58 | while (!(USART1->SR & USART_FLAG_TXE)); 59 | USART1->DR = byte; 60 | } 61 | 62 | } // namespace tides 63 | -------------------------------------------------------------------------------- /tides/drivers/uart_logger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #ifndef TIDES_DRIVERS_UART_LOGGER_H_ 30 | #define TIDES_DRIVERS_UART_LOGGER_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace tides { 35 | 36 | class UartLogger { 37 | public: 38 | UartLogger() { } 39 | ~UartLogger() { } 40 | 41 | void Init(uint32_t baud_rate); 42 | void Trace(uint8_t byte); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(UartLogger); 46 | }; 47 | 48 | } // namespace tides 49 | 50 | #endif // TIDES_DRIVERS_UART_LOGGER_H_ 51 | -------------------------------------------------------------------------------- /tides/hardware_design/panel/tides.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/hardware_design/panel/tides.ai -------------------------------------------------------------------------------- /tides/hardware_design/panel/tides.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/hardware_design/panel/tides.dwg -------------------------------------------------------------------------------- /tides/hardware_design/pcb/tides_v03.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/hardware_design/pcb/tides_v03.brd -------------------------------------------------------------------------------- /tides/hardware_design/pcb/tides_v03.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/hardware_design/pcb/tides_v03.sch -------------------------------------------------------------------------------- /tides/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | APPLICATION = TRUE 35 | BOOTLOADER = tides_bootloader 36 | 37 | # Preferred upload command 38 | UPLOAD_COMMAND = upload_combo_jtag 39 | 40 | # Packages to build 41 | TARGET = tides 42 | PACKAGES = tides tides/drivers stmlib/utils stmlib/system 43 | RESOURCES = tides/resources 44 | 45 | include stmlib/makefile.inc 46 | 47 | # Rule for building the firmware update file 48 | wav: $(TARGET_BIN) 49 | python stm_audio_bootloader/qpsk/encoder.py \ 50 | -s 48000 -b 12000 -c 6000 -p 256 \ 51 | $(TARGET_BIN) 52 | -------------------------------------------------------------------------------- /tides/plotter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Plotter. 28 | 29 | #include "tides/plotter.h" 30 | 31 | #include "stmlib/utils/dsp.h" 32 | 33 | #include "tides/resources.h" 34 | 35 | namespace tides { 36 | 37 | using namespace stmlib; 38 | 39 | void Plotter::Run() { 40 | const PlotInstruction& instruction = program_[pc_]; 41 | if (instruction.command == PLOT_MOVE_TO) { 42 | x_ = instruction.x; 43 | y_ = instruction.y; 44 | NextInstruction(); 45 | } else { 46 | x_ = start_x_ + ((instruction.x - start_x_) * counter_) / instruction.steps; 47 | y_ = start_y_ + ((instruction.y - start_y_) * counter_) / instruction.steps; 48 | ++counter_; 49 | if (counter_ > instruction.steps) { 50 | x_ = instruction.x; 51 | y_ = instruction.y; 52 | NextInstruction(); 53 | } 54 | } 55 | } 56 | 57 | void Plotter::NextInstruction() { 58 | counter_ = 0; 59 | start_x_ = x_; 60 | start_y_ = y_; 61 | pc_++; 62 | if (pc_ >= program_size_) { 63 | pc_ = 0; 64 | } 65 | } 66 | 67 | } // namespace tides 68 | -------------------------------------------------------------------------------- /tides/plotter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Plotter. 28 | 29 | #ifndef TIDES_PLOTTER_H_ 30 | #define TIDES_PLOTTER_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace tides { 35 | 36 | enum PlotCommand { 37 | PLOT_MOVE_TO, 38 | PLOT_LINE_TO 39 | }; 40 | 41 | struct PlotInstruction { 42 | PlotCommand command; 43 | uint8_t steps; 44 | uint16_t x; 45 | uint16_t y; 46 | }; 47 | 48 | class Plotter { 49 | public: 50 | Plotter() { } 51 | ~Plotter() { } 52 | 53 | void Init(const PlotInstruction* program, size_t program_size) { 54 | program_ = program; 55 | program_size_ = program_size; 56 | pc_ = 0; 57 | counter_ = 0; 58 | } 59 | 60 | void Run(); 61 | 62 | inline int32_t x() const { return x_; } 63 | inline int32_t y() const { return y_; } 64 | 65 | private: 66 | void NextInstruction(); 67 | void Move(); 68 | 69 | const PlotInstruction* program_; 70 | size_t program_size_; 71 | size_t pc_; 72 | 73 | int32_t start_x_; 74 | int32_t start_y_; 75 | int32_t x_; 76 | int32_t y_; 77 | int32_t counter_; 78 | 79 | DISALLOW_COPY_AND_ASSIGN(Plotter); 80 | }; 81 | 82 | } // namespace tides 83 | 84 | #endif // TIDES_PLOTTER_H_ 85 | -------------------------------------------------------------------------------- /tides/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/resources/__init__.py -------------------------------------------------------------------------------- /tides/resources/waves.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tides/resources/waves.bin -------------------------------------------------------------------------------- /tides/test/makefile: -------------------------------------------------------------------------------- 1 | PACKAGES = tides/test stmlib/utils tides 2 | 3 | VPATH = $(PACKAGES) 4 | 5 | TARGET = generator_test 6 | BUILD_ROOT = build/ 7 | BUILD_DIR = $(BUILD_ROOT)$(TARGET)/ 8 | CC_FILES = generator.cc \ 9 | resources.cc \ 10 | generator_test.cc 11 | OBJ_FILES = $(CC_FILES:.cc=.o) 12 | OBJS = $(patsubst %,$(BUILD_DIR)%,$(OBJ_FILES)) $(STARTUP_OBJ) 13 | DEPS = $(OBJS:.o=.d) 14 | DEP_FILE = $(BUILD_DIR)depends.mk 15 | 16 | all: generator_test 17 | 18 | $(BUILD_DIR): 19 | mkdir -p $(BUILD_DIR) 20 | 21 | $(BUILD_DIR)%.o: %.cc 22 | g++ -c -DTEST -g -Wall -Werror -I. $< -o $@ 23 | 24 | $(BUILD_DIR)%.d: %.cc 25 | g++ -MM -DTEST -I. $< -MF $@ -MT $(@:.d=.o) 26 | 27 | generator_test: $(OBJS) 28 | g++ -o $(TARGET) $(OBJS) 29 | 30 | depends: $(DEPS) 31 | cat $(DEPS) > $(DEP_FILE) 32 | 33 | $(DEP_FILE): $(BUILD_DIR) $(DEPS) 34 | cat $(DEPS) > $(DEP_FILE) 35 | 36 | include $(DEP_FILE) 37 | -------------------------------------------------------------------------------- /tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/__init__.py -------------------------------------------------------------------------------- /tools/hex2sysex/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/hex2sysex/__init__.py -------------------------------------------------------------------------------- /tools/hexfile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/hexfile/__init__.py -------------------------------------------------------------------------------- /tools/learning/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/learning/__init__.py -------------------------------------------------------------------------------- /tools/midi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/midi/__init__.py -------------------------------------------------------------------------------- /tools/optimization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/tools/optimization/__init__.py -------------------------------------------------------------------------------- /volts/hardware_design/pcb/volts_v01.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/volts/hardware_design/pcb/volts_v01.brd -------------------------------------------------------------------------------- /volts/hardware_design/pcb/volts_v01.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/volts/hardware_design/pcb/volts_v01.sch -------------------------------------------------------------------------------- /yarns/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/__init__.py -------------------------------------------------------------------------------- /yarns/bootloader/characters.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Resources definitions. 28 | // 29 | // Automatically generated with: 30 | // make resources 31 | 32 | 33 | #ifndef YARNS_BOOTLOADER_CHARACTERS_H_ 34 | #define YARNS_BOOTLOADER_CHARACTERS_H_ 35 | 36 | 37 | #include "stmlib/stmlib.h" 38 | 39 | namespace yarns { 40 | 41 | extern const uint16_t chr_characters[]; 42 | 43 | } // namespace yarns 44 | 45 | #endif // YARNS_BOOTLOADER_CHARACTERS_H_ 46 | -------------------------------------------------------------------------------- /yarns/bootloader/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 24000000L 28 | SYSCLOCK = SYSCLK_FREQ_24MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | 33 | # USB = enabled 34 | 35 | # Preferred upload command 36 | UPLOAD_COMMAND = upload_jtag 37 | 38 | # Packages to build 39 | TARGET = yarns_bootloader 40 | PACKAGES = yarns/bootloader yarns/drivers stmlib/utils stmlib/system 41 | RESOURCES = yarns/resources 42 | 43 | include stmlib/makefile.inc 44 | -------------------------------------------------------------------------------- /yarns/drivers/channel_leds.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the 4 channels LEDs. 28 | 29 | #ifndef YARNS_DRIVERS_CHANNEL_LEDS_H_ 30 | #define YARNS_DRIVERS_CHANNEL_LEDS_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace yarns { 37 | 38 | class ChannelLeds { 39 | public: 40 | ChannelLeds() { } 41 | ~ChannelLeds() { } 42 | 43 | void Init(); 44 | 45 | void set_channel(uint8_t channel, uint8_t brightness) { 46 | brightness_[channel] = brightness; 47 | } 48 | 49 | void Write(const uint8_t* brightness) { 50 | std::copy(&brightness[0], &brightness[4], &brightness_[0]); 51 | } 52 | 53 | void Write(); 54 | 55 | private: 56 | uint8_t pwm_counter_; 57 | uint8_t brightness_[4]; 58 | 59 | DISALLOW_COPY_AND_ASSIGN(ChannelLeds); 60 | }; 61 | 62 | } // namespace yarns 63 | 64 | #endif // YARNS_DRIVERS_CHANNEL_LEDS_H_ 65 | -------------------------------------------------------------------------------- /yarns/drivers/encoder.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for rotary encoder. 28 | 29 | #include "yarns/drivers/encoder.h" 30 | 31 | namespace yarns { 32 | 33 | void Encoder::Init() { 34 | GPIO_InitTypeDef gpio_init; 35 | 36 | gpio_init.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; 37 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 38 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 39 | GPIO_Init(GPIOC, &gpio_init); 40 | 41 | switch_state_ = 0xff; 42 | quadrature_decoding_state_[0] = quadrature_decoding_state_[1] = 0xff; 43 | } 44 | 45 | void Encoder::Debounce() { 46 | switch_state_ = (switch_state_ << 1) | \ 47 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_15); 48 | quadrature_decoding_state_[0] = (quadrature_decoding_state_[0] << 1) | \ 49 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13); 50 | quadrature_decoding_state_[1] = (quadrature_decoding_state_[1] << 1) | \ 51 | GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_14); 52 | } 53 | 54 | } // namespace yarns 55 | -------------------------------------------------------------------------------- /yarns/drivers/gate_output.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the Gate/Trigger outputs. 28 | 29 | #include "yarns/drivers/gate_output.h" 30 | 31 | #include 32 | 33 | namespace yarns { 34 | 35 | void GateOutput::Init() { 36 | GPIO_InitTypeDef gpio_init; 37 | gpio_init.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_10 | GPIO_Pin_11; 38 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 39 | gpio_init.GPIO_Mode = GPIO_Mode_Out_PP; 40 | GPIO_Init(GPIOB, &gpio_init); 41 | } 42 | 43 | void GateOutput::Write(const bool* gate) { 44 | GPIO_WriteBit(GPIOB, GPIO_Pin_10, static_cast(gate[0])); 45 | GPIO_WriteBit(GPIOB, GPIO_Pin_11, static_cast(gate[1])); 46 | GPIO_WriteBit(GPIOB, GPIO_Pin_0, static_cast(gate[2])); 47 | GPIO_WriteBit(GPIOB, GPIO_Pin_1, static_cast(gate[3])); 48 | } 49 | 50 | } // namespace yarns 51 | -------------------------------------------------------------------------------- /yarns/drivers/gate_output.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the Gate/Trigger outputs. 28 | 29 | #ifndef YARNS_DRIVERS_GATE_OUTPUT_H_ 30 | #define YARNS_DRIVERS_GATE_OUTPUT_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace yarns { 35 | 36 | class GateOutput { 37 | public: 38 | GateOutput() { } 39 | ~GateOutput() { } 40 | 41 | void Init(); 42 | void Write(const bool* channel); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(GateOutput); 46 | }; 47 | 48 | } // namespace yarns 49 | 50 | #endif // YARNS_DRIVERS_GATE_OUTPUT_H_ 51 | -------------------------------------------------------------------------------- /yarns/drivers/midi_io.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #include "yarns/drivers/midi_io.h" 30 | 31 | #include 32 | 33 | namespace yarns { 34 | 35 | void MidiIO::Init() { 36 | // Initialize TX pin. 37 | GPIO_InitTypeDef gpio_init; 38 | gpio_init.GPIO_Pin = GPIO_Pin_9; 39 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 40 | gpio_init.GPIO_Mode = GPIO_Mode_AF_PP; 41 | GPIO_Init(GPIOA, &gpio_init); 42 | 43 | // Initialize RX pin. 44 | gpio_init.GPIO_Pin = GPIO_Pin_10; 45 | gpio_init.GPIO_Speed = GPIO_Speed_50MHz; 46 | gpio_init.GPIO_Mode = GPIO_Mode_IN_FLOATING; 47 | GPIO_Init(GPIOA, &gpio_init); 48 | 49 | // Initialize USART. 50 | USART_InitTypeDef usart_init; 51 | usart_init.USART_BaudRate = 31250; 52 | usart_init.USART_WordLength = USART_WordLength_8b; 53 | usart_init.USART_StopBits = USART_StopBits_1; 54 | usart_init.USART_Parity = USART_Parity_No; 55 | usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 56 | usart_init.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; 57 | 58 | USART_Init(USART1, &usart_init); 59 | USART_Cmd(USART1, ENABLE); 60 | } 61 | 62 | } // namespace yarns 63 | -------------------------------------------------------------------------------- /yarns/drivers/midi_io.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for dumping log messages to the UART (TX pin). 28 | 29 | #ifndef YARNS_DRIVERS_MIDI_IO_H_ 30 | #define YARNS_DRIVERS_MIDI_IO_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | #include 35 | 36 | namespace yarns { 37 | 38 | class MidiIO { 39 | public: 40 | 41 | MidiIO() { } 42 | ~MidiIO() { } 43 | 44 | void Init(); 45 | 46 | bool writable() { 47 | return USART1->SR & USART_FLAG_TXE; 48 | } 49 | 50 | bool readable() { 51 | return USART1->SR & USART_FLAG_RXNE; 52 | } 53 | 54 | void Overwrite(uint8_t byte) { 55 | USART1->DR = byte; 56 | } 57 | 58 | uint8_t ImmediateRead() { 59 | return USART1->DR; 60 | } 61 | 62 | private: 63 | DISALLOW_COPY_AND_ASSIGN(MidiIO); 64 | }; 65 | 66 | } // namespace yarns 67 | 68 | #endif // YARNS_DRIVERS_MIDI_IO_H_ 69 | -------------------------------------------------------------------------------- /yarns/drivers/switches.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the ADD/DEL switches. 28 | 29 | #include "yarns/drivers/switches.h" 30 | 31 | #include 32 | #include 33 | 34 | namespace yarns { 35 | 36 | void Switches::Init() { 37 | memset(&switch_state_, 0xff, sizeof(switch_state_)); 38 | 39 | GPIO_InitTypeDef gpio_init; 40 | 41 | gpio_init.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6; 42 | gpio_init.GPIO_Speed = GPIO_Speed_10MHz; 43 | gpio_init.GPIO_Mode = GPIO_Mode_IPU; 44 | GPIO_Init(GPIOA, &gpio_init); 45 | } 46 | 47 | void Switches::Debounce() { 48 | switch_state_[0] = (switch_state_[0] << 1) | \ 49 | GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5); 50 | switch_state_[1] = (switch_state_[1] << 1) | \ 51 | GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6); 52 | switch_state_[2] = (switch_state_[2] << 1) | \ 53 | GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4); 54 | } 55 | 56 | } // namespace yarns 57 | -------------------------------------------------------------------------------- /yarns/drivers/switches.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Driver for the ADD/DEL switches. 28 | 29 | #ifndef YARNS_DRIVERS_SWITCHES_H_ 30 | #define YARNS_DRIVERS_SWITCHES_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace yarns { 35 | 36 | const uint8_t kNumSwitches = 3; 37 | 38 | class Switches { 39 | public: 40 | Switches() { } 41 | ~Switches() { } 42 | 43 | void Init(); 44 | void Debounce(); 45 | 46 | inline bool released(uint8_t index) const { 47 | return switch_state_[index] == 0x7f; 48 | } 49 | 50 | inline bool just_pressed(uint8_t index) const { 51 | return switch_state_[index] == 0x80; 52 | } 53 | 54 | inline bool pressed(uint8_t index) const { 55 | return switch_state_[index] == 0x00; 56 | } 57 | 58 | private: 59 | uint8_t switch_state_[kNumSwitches]; 60 | 61 | DISALLOW_COPY_AND_ASSIGN(Switches); 62 | }; 63 | 64 | } // namespace yarns 65 | 66 | #endif // YARNS_DRIVERS_SWITCHES_H_ 67 | -------------------------------------------------------------------------------- /yarns/drivers/system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // System-level initialization. 28 | 29 | #ifndef YARNS_DRIVERS_SYSTEM_H_ 30 | #define YARNS_DRIVERS_SYSTEM_H_ 31 | 32 | #include "stmlib/stmlib.h" 33 | 34 | namespace yarns { 35 | 36 | class System { 37 | public: 38 | System() { } 39 | ~System() { } 40 | 41 | void Init(); 42 | void StartTimers(); 43 | 44 | private: 45 | DISALLOW_COPY_AND_ASSIGN(System); 46 | }; 47 | 48 | } // namespace yarns 49 | 50 | #endif // YARNS_DRIVERS_SYSTEM_H_ 51 | -------------------------------------------------------------------------------- /yarns/hardware_design/panel/yarns.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/hardware_design/panel/yarns.ai -------------------------------------------------------------------------------- /yarns/hardware_design/panel/yarns.dwg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/hardware_design/panel/yarns.dwg -------------------------------------------------------------------------------- /yarns/hardware_design/pcb/yarns_v03.brd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/hardware_design/pcb/yarns_v03.brd -------------------------------------------------------------------------------- /yarns/hardware_design/pcb/yarns_v03.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/hardware_design/pcb/yarns_v03.sch -------------------------------------------------------------------------------- /yarns/makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Olivier Gillet. 2 | # 3 | # Author: Olivier Gillet (ol.gillet@gmail.com) 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | # 23 | # See http://creativecommons.org/licenses/MIT/ for more information. 24 | 25 | # System specifications 26 | F_CRYSTAL = 8000000L 27 | F_CPU = 72000000L 28 | SYSCLOCK = SYSCLK_FREQ_72MHz 29 | FAMILY = f10x 30 | DENSITY = md 31 | MEMORY_MODE = flash 32 | # USB = enabled 33 | 34 | BOOTLOADER = yarns_bootloader 35 | 36 | APPLICATION_SMALL = TRUE 37 | 38 | # Preferred upload command 39 | UPLOAD_COMMAND = upload_combo_jtag 40 | 41 | # Packages to build 42 | TARGET = yarns 43 | PACKAGES = yarns yarns/drivers stmlib/utils stmlib/system 44 | RESOURCES = yarns/resources 45 | 46 | include stmlib/makefile.inc 47 | 48 | 49 | # Rules for building the SysEx update file. 50 | SYSEX_FLAGS = --page_size=512 --device_id=11 51 | 52 | HEX2SYSEX = python tools/hex2sysex/hex2sysex.py 53 | 54 | $(BUILD_DIR)%.syx: $(BUILD_DIR)%.bin 55 | $(HEX2SYSEX) $(SYSEX_FLAGS) --syx -o $@ $< 56 | 57 | syx: $(BUILD_DIR)$(TARGET).syx -------------------------------------------------------------------------------- /yarns/resources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/resources/__init__.py -------------------------------------------------------------------------------- /yarns/scale_editor/README: -------------------------------------------------------------------------------- 1 | AppEngine web app for converting a scala .scl file into a tuning .syx recognized by Yarns. -------------------------------------------------------------------------------- /yarns/scale_editor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/__init__.py -------------------------------------------------------------------------------- /yarns/scale_editor/app.yaml: -------------------------------------------------------------------------------- 1 | application: scale-editor 2 | version: 1 3 | runtime: python27 4 | api_version: 1 5 | threadsafe: true 6 | 7 | handlers: 8 | - url: /static 9 | static_dir: static 10 | 11 | - url: /favicon.ico 12 | static_files: static/favicon.ico 13 | upload: static/favicon.ico 14 | 15 | - url: .* 16 | script: main.application 17 | 18 | - url: /syx 19 | script: main.application 20 | -------------------------------------------------------------------------------- /yarns/scale_editor/index.yaml: -------------------------------------------------------------------------------- 1 | indexes: 2 | 3 | # AUTOGENERATED 4 | 5 | # This index.yaml is automatically updated whenever the dev_appserver 6 | # detects that a new type of query is run. If you want to manage the 7 | # index.yaml file manually, remove the above marker line (the line 8 | # saying "# AUTOGENERATED"). If you want to manage some indexes 9 | # manually, move them above the marker line. The index.yaml file is 10 | # automatically uploaded to the admin console when you next deploy 11 | # your application using appcfg.py. 12 | -------------------------------------------------------------------------------- /yarns/scale_editor/music/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/music/__init__.py -------------------------------------------------------------------------------- /yarns/scale_editor/music/scala/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/music/scala/__init__.py -------------------------------------------------------------------------------- /yarns/scale_editor/static/bg_main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/static/bg_main.jpg -------------------------------------------------------------------------------- /yarns/scale_editor/static/db_yarns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/static/db_yarns.png -------------------------------------------------------------------------------- /yarns/scale_editor/static/divider_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/static/divider_big.jpg -------------------------------------------------------------------------------- /yarns/scale_editor/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/static/favicon.ico -------------------------------------------------------------------------------- /yarns/scale_editor/static/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timchurches/Mutated-Mutables/b9b222e26b1f75ffc48111ea06c8d8eb71c884f5/yarns/scale_editor/static/logo.jpg -------------------------------------------------------------------------------- /yarns/scale_editor/static/main.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, font, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td { background: transparent; border: 0; margin: 0; padding: 0; vertical-align: baseline; } 10 | 11 | body { 12 | font-family: Helvetica, Arial, sans-serif; 13 | font-size: 0.9em; 14 | background: url("bg_main.jpg") top left; 15 | margin: 0; 16 | } 17 | 18 | h1, h2, h3, h4, h5, h6 { clear: both; font-weight: normal; } 19 | h1 { margin: 10px 90px 20px 90px; padding-left: 50px; font-size: 36px; font-weight: 100; background: url("db_yarns.png") left 0 no-repeat; } 20 | h2 { margin: 20px 90px 20px 90px; font-size: 24px; color: #b31748; font-weight: 100; } 21 | h3 { margin: 20px 90px 10px 90px; font-size: 18px; font-weight: 100; } 22 | #content p, #content ul, #content ol, #content pre { margin: 0 90px 10px 90px; line-height: 150%; } 23 | 24 | a { color: #1a7877; font-weight: bold; } 25 | a:hover { color: #b31748; } 26 | 27 | 28 | #wrapper { 29 | width: 100%; 30 | margin-left: 20px; 31 | padding: 0; 32 | width: 960px; 33 | } 34 | 35 | #content { 36 | width: 720px; 37 | box-shadow: 0 0 20px #706c64; 38 | background-color: #fff; 39 | float: right; 40 | margin: 0; 41 | min-height:100%; 42 | } 43 | 44 | #sidebar { width: 240px; padding: 0; float: left; margin: 0; } 45 | #sidebar #logo { background: url("logo.jpg") no-repeat center; display:block; width:100%; height:177px; overflow:hidden; text-indent:-420em; padding:11px 0 30px; } 46 | #credits { margin: 10px 10px; color: #998f85; font-style: oblique; } 47 | .divider_big{ width: 100%; height: 60px; background: url("divider_big.jpg") repeat-x center; } 48 | 49 | ul.mappings li { 50 | padding: 8px; 51 | border: 1px; 52 | background-color: #b31748; 53 | border-color: #b31748; 54 | border-style: solid; 55 | color: #fff; 56 | line-height: 2; 57 | } 58 | 59 | ul.notes li { 60 | padding: 4px; 61 | border: 1px; 62 | background-color: #1a7877; 63 | border-color: #1a7877; 64 | border-style: solid; 65 | color: #fff; 66 | display: inline; 67 | line-height: 2.2; 68 | } 69 | 70 | p.error { 71 | padding: 8px; 72 | background-color: #b31748; 73 | color: #fff; 74 | font-weight: bold; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /yarns/scale_editor/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ title }} 4 | 5 | 6 | 7 |
8 |
9 | {% block content %} 10 | {% endblock %} 11 | 12 |
13 |
14 |

Mutable Instruments, 2014. Source code.

15 |
16 | 17 |
18 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /yarns/scale_editor/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |

Scala to SysEx conversion

5 | 6 |

Scale editor

7 | 8 |

Upload an existing Scala file:

9 | 10 |
11 |

12 |
13 | 14 |

Or input a scale using Scala's syntax (reference here):

15 | 16 |
17 |

18 |

19 |
20 | 21 | {% if error_message %} 22 | 23 |

Parse error!

24 | 25 |

{{ error_message }}

26 | 27 | {% endif %} 28 | 29 | {% if notes %} 30 | 31 |

Result

32 | 33 |

Download .syx file

34 | 35 |

The scale contains the following notes (in cents):

36 | 37 |
    38 | 39 | {% for note in notes %} 40 | 41 |
  • {{ note|floatformat:2 }}
  • 42 | 43 | {% endfor %} 44 | 45 |
46 | 47 |

The note mapping (for a root note of C) is as follows:

48 | 49 |
    50 | 51 | {% for mapping in mappings %} 52 | 53 |
  • {{ mapping }}
  • 54 | 55 | {% endfor %} 56 | 57 |
58 | 59 | {% endif %} 60 | 61 | 62 | {% endblock %} 63 | -------------------------------------------------------------------------------- /yarns/storage_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Olivier Gillet. 2 | // 3 | // Author: Olivier Gillet (ol.gillet@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // See http://creativecommons.org/licenses/MIT/ for more information. 24 | // 25 | // ----------------------------------------------------------------------------- 26 | // 27 | // Responsible for flash memory storage. 28 | 29 | #ifndef YARNS_STORAGE_MANAGER_H_ 30 | #define YARNS_STORAGE_MANAGER_H_ 31 | 32 | #include 33 | 34 | #include "stmlib/stmlib.h" 35 | 36 | #include "stmlib/utils/stream_buffer.h" 37 | #include "stmlib/system/storage.h" 38 | 39 | namespace yarns { 40 | 41 | class StorageManager { 42 | public: 43 | StorageManager() { } 44 | ~StorageManager() { } 45 | 46 | void SaveMulti(uint8_t slot); 47 | bool LoadMulti(uint8_t slot); 48 | void SaveCalibration(); 49 | bool LoadCalibration(); 50 | void SysExSendMulti(); 51 | 52 | void AppendData(const uint8_t* data, size_t size, bool rewind) { 53 | if (rewind) { 54 | stream_buffer_.Rewind(); 55 | } 56 | stream_buffer_.Write(data, size); 57 | } 58 | 59 | void DeserializeMulti(); 60 | 61 | private: 62 | stmlib::StreamBuffer<1024> stream_buffer_; 63 | stmlib::Storage<0x8020000, 9> storage_; 64 | 65 | DISALLOW_COPY_AND_ASSIGN(StorageManager); 66 | }; 67 | 68 | extern StorageManager storage_manager; 69 | 70 | } // namespace yarns 71 | 72 | #endif // YARNS_STORAGE_MANAGER_H_ 73 | --------------------------------------------------------------------------------