Move new Class Driver powered demos to a new ClassDriver subdirectory, re-add old...
[pub/USBasp.git] / Demos / Device / LowLevel / MIDI / MIDI.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for AudioOutput.c.
34 */
35
36 #ifndef _AUDIO_OUTPUT_H_
37 #define _AUDIO_OUTPUT_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/power.h>
43 #include <stdbool.h>
44
45 #include "Descriptors.h"
46
47 #include <LUFA/Version.h> // Library Version Information
48 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
49 #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
50 #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
51 #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
52 #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
53
54 /* Macros: */
55 /** MIDI command for a note on (activation) event */
56 #define MIDI_COMMAND_NOTE_ON 0x90
57
58 /** MIDI command for a note off (deactivation) event */
59 #define MIDI_COMMAND_NOTE_OFF 0x80
60
61 /** Standard key press velocity value used for all note events, as no pressure sensor is mounted */
62 #define MIDI_STANDARD_VELOCITY 64
63
64 /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel
65 * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.
66 *
67 * \param channel MIDI channel number to address
68 */
69 #define MIDI_CHANNEL(channel) (channel - 1)
70
71 /* Enums: */
72 /** Enum for the possible status codes for passing to the UpdateStatus() function. */
73 enum MIDI_StatusCodes_t
74 {
75 Status_USBNotReady = 0, /**< USB is not ready (disconnected from a USB host) */
76 Status_USBEnumerating = 1, /**< USB interface is enumerating */
77 Status_USBReady = 2, /**< USB interface is connected and ready */
78 };
79
80 /* Task Definitions: */
81 TASK(USB_MIDI_Task);
82
83 /* Function Prototypes: */
84 void EVENT_USB_Connect(void);
85 void EVENT_USB_Disconnect(void);
86 void EVENT_USB_ConfigurationChanged(void);
87
88 void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff,
89 const uint8_t CableID, const uint8_t Channel);
90 void UpdateStatus(uint8_t CurrentStatus);
91
92 #endif