MIDI Stop Controller V1.0 suitable for driving Hauptwerk digital organ software. Written for the KL25Z uses BusInOut and will drive up to 16 illuminated push buttons each switch uses a single I/O pin to both drive the LED and act as a switch input. Pressing a button will alternately send MIDI note on / off messages and turn the LED on or off. If corresponding MIDI note on/off messages are received these will be used to drive the LEDs in preference to the locally generated LED signals. The MIDI channel used to send can be selected by jumpers on 4 pins of the J2 header.

Dependencies:   mbed

Committer:
djbottrill
Date:
Sat Sep 14 21:32:06 2013 +0000
Revision:
0:aac55e1fc12f
V1.0 MIDI Stop Controller

Who changed what in which revision?

UserRevisionLine numberNew contents of line
djbottrill 0:aac55e1fc12f 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
djbottrill 0:aac55e1fc12f 2 *
djbottrill 0:aac55e1fc12f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
djbottrill 0:aac55e1fc12f 4 * and associated documentation files (the "Software"), to deal in the Software without
djbottrill 0:aac55e1fc12f 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
djbottrill 0:aac55e1fc12f 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
djbottrill 0:aac55e1fc12f 7 * Software is furnished to do so, subject to the following conditions:
djbottrill 0:aac55e1fc12f 8 *
djbottrill 0:aac55e1fc12f 9 * The above copyright notice and this permission notice shall be included in all copies or
djbottrill 0:aac55e1fc12f 10 * substantial portions of the Software.
djbottrill 0:aac55e1fc12f 11 *
djbottrill 0:aac55e1fc12f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
djbottrill 0:aac55e1fc12f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
djbottrill 0:aac55e1fc12f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
djbottrill 0:aac55e1fc12f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
djbottrill 0:aac55e1fc12f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
djbottrill 0:aac55e1fc12f 17 */
djbottrill 0:aac55e1fc12f 18
djbottrill 0:aac55e1fc12f 19 /* Standard descriptor types */
djbottrill 0:aac55e1fc12f 20 #define DEVICE_DESCRIPTOR (1)
djbottrill 0:aac55e1fc12f 21 #define CONFIGURATION_DESCRIPTOR (2)
djbottrill 0:aac55e1fc12f 22 #define STRING_DESCRIPTOR (3)
djbottrill 0:aac55e1fc12f 23 #define INTERFACE_DESCRIPTOR (4)
djbottrill 0:aac55e1fc12f 24 #define ENDPOINT_DESCRIPTOR (5)
djbottrill 0:aac55e1fc12f 25 #define QUALIFIER_DESCRIPTOR (6)
djbottrill 0:aac55e1fc12f 26
djbottrill 0:aac55e1fc12f 27 /* Standard descriptor lengths */
djbottrill 0:aac55e1fc12f 28 #define DEVICE_DESCRIPTOR_LENGTH (0x12)
djbottrill 0:aac55e1fc12f 29 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
djbottrill 0:aac55e1fc12f 30 #define INTERFACE_DESCRIPTOR_LENGTH (0x09)
djbottrill 0:aac55e1fc12f 31 #define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
djbottrill 0:aac55e1fc12f 32
djbottrill 0:aac55e1fc12f 33
djbottrill 0:aac55e1fc12f 34 /*string offset*/
djbottrill 0:aac55e1fc12f 35 #define STRING_OFFSET_LANGID (0)
djbottrill 0:aac55e1fc12f 36 #define STRING_OFFSET_IMANUFACTURER (1)
djbottrill 0:aac55e1fc12f 37 #define STRING_OFFSET_IPRODUCT (2)
djbottrill 0:aac55e1fc12f 38 #define STRING_OFFSET_ISERIAL (3)
djbottrill 0:aac55e1fc12f 39 #define STRING_OFFSET_ICONFIGURATION (4)
djbottrill 0:aac55e1fc12f 40 #define STRING_OFFSET_IINTERFACE (5)
djbottrill 0:aac55e1fc12f 41
djbottrill 0:aac55e1fc12f 42 /* USB Specification Release Number */
djbottrill 0:aac55e1fc12f 43 #define USB_VERSION_2_0 (0x0200)
djbottrill 0:aac55e1fc12f 44
djbottrill 0:aac55e1fc12f 45 /* Least/Most significant byte of short integer */
djbottrill 0:aac55e1fc12f 46 #define LSB(n) ((n)&0xff)
djbottrill 0:aac55e1fc12f 47 #define MSB(n) (((n)&0xff00)>>8)
djbottrill 0:aac55e1fc12f 48
djbottrill 0:aac55e1fc12f 49 /* Convert physical endpoint number to descriptor endpoint number */
djbottrill 0:aac55e1fc12f 50 #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
djbottrill 0:aac55e1fc12f 51
djbottrill 0:aac55e1fc12f 52 /* bmAttributes in configuration descriptor */
djbottrill 0:aac55e1fc12f 53 /* C_RESERVED must always be set */
djbottrill 0:aac55e1fc12f 54 #define C_RESERVED (1U<<7)
djbottrill 0:aac55e1fc12f 55 #define C_SELF_POWERED (1U<<6)
djbottrill 0:aac55e1fc12f 56 #define C_REMOTE_WAKEUP (1U<<5)
djbottrill 0:aac55e1fc12f 57
djbottrill 0:aac55e1fc12f 58 /* bMaxPower in configuration descriptor */
djbottrill 0:aac55e1fc12f 59 #define C_POWER(mA) ((mA)/2)
djbottrill 0:aac55e1fc12f 60
djbottrill 0:aac55e1fc12f 61 /* bmAttributes in endpoint descriptor */
djbottrill 0:aac55e1fc12f 62 #define E_CONTROL (0x00)
djbottrill 0:aac55e1fc12f 63 #define E_ISOCHRONOUS (0x01)
djbottrill 0:aac55e1fc12f 64 #define E_BULK (0x02)
djbottrill 0:aac55e1fc12f 65 #define E_INTERRUPT (0x03)
djbottrill 0:aac55e1fc12f 66
djbottrill 0:aac55e1fc12f 67 /* For isochronous endpoints only: */
djbottrill 0:aac55e1fc12f 68 #define E_NO_SYNCHRONIZATION (0x00)
djbottrill 0:aac55e1fc12f 69 #define E_ASYNCHRONOUS (0x04)
djbottrill 0:aac55e1fc12f 70 #define E_ADAPTIVE (0x08)
djbottrill 0:aac55e1fc12f 71 #define E_SYNCHRONOUS (0x0C)
djbottrill 0:aac55e1fc12f 72 #define E_DATA (0x00)
djbottrill 0:aac55e1fc12f 73 #define E_FEEDBACK (0x10)
djbottrill 0:aac55e1fc12f 74 #define E_IMPLICIT_FEEDBACK (0x20)