Skip to content

Commit

Permalink
added everything
Browse files Browse the repository at this point in the history
  • Loading branch information
kurt ak committed Dec 8, 2013
1 parent 2c7afea commit beae55d
Show file tree
Hide file tree
Showing 163 changed files with 20,050 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .cproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1082250715">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1082250715" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="0.1082250715" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1082250715." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.25613297" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.25613297.564421632" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1052957540" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1910309972" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.133038649" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.91481071" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.667309214" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.519851299" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.382096792" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1837451386" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="midipal-mod (makefile).null.1182078173" name="midipal-mod (makefile)"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.lib.release.1150804460;cdt.managedbuild.config.gnu.cross.lib.release.1150804460.;cdt.managedbuild.tool.gnu.cross.c.compiler.1436809524;cdt.managedbuild.tool.gnu.c.compiler.input.1027197012">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.lib.debug.158310937;cdt.managedbuild.config.gnu.cross.lib.debug.158310937.;cdt.managedbuild.tool.gnu.cross.c.compiler.2089064608;cdt.managedbuild.tool.gnu.c.compiler.input.1964240726">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.1082250715">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "avrlib"]
path = avrlib
url = git://github.com/pichenettes/avril.git
[submodule "tools"]
path = tools
url = git://github.com/pichenettes/avril-firmware_tools.git
27 changes: 27 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>midipal_mods</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>
24 changes: 24 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Midipal, the MIDI swiss army knife.

A midi in, a midi out, a small display, an encoder ; 20 awesome features:

* MIDI monitor
* BPM counter
* Keyboard splitter
* Note dispatcher / voice stealing / polyphonic driver
* Channels merger
* Channel filter
* Clock divider
* Clock source, with swing
* CC and NRPN knob
* 8 pots/sensors voltage reader/controller
* Drum pattern generator (including Euclidian patterns)
* Note, velocity and CC randomizer
* Chord memory
* Arpeggiator
* Sequencer
* CC lfo
* Tempo-synchronized note delay (with transposition and decay velocity)
* Slave start/stop synchronizer (à la Mungo Sync)
* Scale processor / harmonizer
* Ear training game
1 change: 1 addition & 0 deletions avrlib
Submodule avrlib added at f58119
202 changes: 202 additions & 0 deletions bootloader/bootloader.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// Copyright 2011 Olivier Gillet.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------------------
//
// Bootloader supporting MIDI SysEx update.
//
// Caveat: assumes the firmware flashing is always done from first to last
// block, in increasing order. Random access flashing is not supported!

#include <avr/boot.h>
#include <avr/pgmspace.h>
#include <avr/delay.h>

#include "avrlib/devices/shift_register.h"
#include "avrlib/gpio.h"
#include "avrlib/devices/led.h"
#include "avrlib/serial.h"
#include "avrlib/watchdog_timer.h"

#include "midipal/hardware_config.h"

using namespace avrlib;
using namespace midipal;

Serial<SerialPort0, 31250, POLLED, DISABLED> midi;
DigitalInput<EncoderClickLine> encoder_click;
Led<LedOut, LED_SOURCE_CURRENT> green_led;
Led<LedIn, LED_SOURCE_CURRENT> red_led;

uint16_t page = 0;
uint8_t rx_buffer[2 * (SPM_PAGESIZE + 1)];

void (*main_entry_point)(void) = 0x0000;

inline void Init() {
cli();
encoder_click.Init();
encoder_click.EnablePullUpResistor();
green_led.Init();
red_led.Init();
}

void WriteBufferToFlash() {
uint16_t i;
const uint8_t* p = rx_buffer;
eeprom_busy_wait();

boot_page_erase(page);
boot_spm_busy_wait();

for (i = 0; i < SPM_PAGESIZE; i += 2) {
uint16_t w = *p++;
w |= (*p++) << 8;
boot_page_fill(page + i, w);
}

boot_page_write(page);
boot_spm_busy_wait();
boot_rww_enable();
}

void FlashLedsOk() {
for (uint8_t i = 0; i < 3; ++i) {
_delay_ms(100);
green_led.On();
red_led.Off();
_delay_ms(100);
green_led.Off();
red_led.On();
}
}

void FlashLedsError() {
for (uint8_t i = 0; i < 5; ++i) {
_delay_ms(50);
green_led.On();
red_led.On();
_delay_ms(50);
green_led.Off();
red_led.Off();
}
}

static const uint8_t sysex_header[] = {
0xf0, // <SysEx>
0x00, 0x21, 0x02, // Mutable instruments manufacturer id.
0x00, 0x03, // Product ID for MIDIpal.
};

enum SysExReceptionState {
MATCHING_HEADER = 0,
READING_COMMAND = 1,
READING_DATA = 2,
};

inline void MidiLoop() {
uint8_t byte;
uint16_t bytes_read = 0;
uint16_t rx_buffer_index;
uint8_t state = MATCHING_HEADER;
uint8_t checksum;
uint8_t sysex_commands[2];
uint8_t status = 0;

midi.Init();
page = 0;

while (1) {
byte = midi.Read();
// In case we see a realtime message in the stream, safely ignore it.
if (byte > 0xf0 && byte != 0xf7) {
continue;
}
switch (state) {
case MATCHING_HEADER:
if (byte == sysex_header[bytes_read]) {
++bytes_read;
if (bytes_read == sizeof(sysex_header)) {
bytes_read = 0;
state = READING_COMMAND;
}
} else {
bytes_read = 0;
}
break;

case READING_COMMAND:
if (byte < 0x80) {
sysex_commands[bytes_read++] = byte;
if (bytes_read == 2) {
bytes_read = 0;
rx_buffer_index = 0;
checksum = 0;
state = READING_DATA;
}
} else {
state = MATCHING_HEADER;
status = 0;
bytes_read = 0;
}
break;

case READING_DATA:
if (byte < 0x80) {
if (bytes_read & 1) {
rx_buffer[rx_buffer_index] |= byte & 0xf;
if (rx_buffer_index < SPM_PAGESIZE) {
checksum += rx_buffer[rx_buffer_index];
}
++rx_buffer_index;
} else {
rx_buffer[rx_buffer_index] = (byte << 4);
}
++bytes_read;
} else if (byte == 0xf7) {
if (sysex_commands[0] == 0x7f &&
sysex_commands[1] == 0x00 &&
bytes_read == 0) {
// Reset.
return;
} else if (rx_buffer_index == SPM_PAGESIZE + 1 &&
sysex_commands[0] == 0x7e &&
sysex_commands[1] == 0x00 &&
rx_buffer[rx_buffer_index - 1] == checksum) {
// Block write.
red_led.On();
WriteBufferToFlash();
page += SPM_PAGESIZE;
} else {
FlashLedsError();
}
state = MATCHING_HEADER;
bytes_read = 0;
}
break;
}
green_led.Off();
red_led.Off();
}
}

int main(void) {
ResetWatchdog();
Init();
if (encoder_click.Read() == 0) {
FlashLedsOk();
MidiLoop();
FlashLedsOk();
}
main_entry_point();
}
28 changes: 28 additions & 0 deletions bootloader/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2011 Olivier Gillet.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

VERSION = 0.1
MCU_NAME = 328
TARGET = muboot
PACKAGES = avrlib bootloader
EXTRA_DEFINES = -funsigned-char -fno-inline-small-functions -DDISABLE_DEFAULT_UART_RX_ISR
EXTRA_LD_FLAGS = ,--section-start=.text=0x7c00,--relax

LFUSE = ff
HFUSE = d4
EFUSE = fd
LOCK = 2f

include avrlib/makefile.mk

include $(DEP_FILE)
Empty file added eclipse/.metadata/.lock
Empty file.
Binary file added eclipse/.metadata/.mylyn/repositories.xml.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#GitProjectData
#Thu Sep 05 23:49:39 CEST 2013
.gitdir=../../.git
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
spelling_locale_initialized=true
useAnnotationsPrefPage=true
useQuickDiffPrefPage=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GitRepositoriesView.GitDirectories=C\:\\Projects\\midipal-mod\\.git;
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
mylyn.attention.migrated=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
org.eclipse.mylyn.tasks.ui.filters.nonmatching=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
org.eclipse.rse.systemtype.local.systemType.defaultUserId=not sure
useridperkey=notsure-PC.Local\=not sure;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.rse.preferences.order.connections=notsure-PC.Local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
pref_first_startup=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.team.ui.first_time=false
Loading

0 comments on commit beae55d

Please sign in to comment.