]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/lufa/lufa.h
Merge branch 'master' of github.com:jackhumbert/qmk_firmware into wu5y7
[qmk_firmware.git] / tmk_core / protocol / lufa / lufa.h
1 /* 
2  * Copyright 2012 Jun Wako <wakojun@gmail.com>
3  * This file is based on:
4  *     LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
5  *     LUFA-120219/Demos/Device/Lowlevel/GenericHID
6  */
7
8 /*
9              LUFA Library
10      Copyright (C) Dean Camera, 2012.
11
12   dean [at] fourwalledcubicle [dot] com
13            www.lufa-lib.org
14 */
15
16 /*
17   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
18   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)
19
20   Permission to use, copy, modify, distribute, and sell this
21   software and its documentation for any purpose is hereby granted
22   without fee, provided that the above copyright notice appear in
23   all copies and that both that the copyright notice and this
24   permission notice and warranty disclaimer appear in supporting
25   documentation, and that the name of the author not be used in
26   advertising or publicity pertaining to distribution of the
27   software without specific, written prior permission.
28
29   The author disclaim all warranties with regard to this
30   software, including all implied warranties of merchantability
31   and fitness.  In no event shall the author be liable for any
32   special, indirect or consequential damages or any damages
33   whatsoever resulting from loss of use, data or profits, whether
34   in an action of contract, negligence or other tortious action,
35   arising out of or in connection with the use or performance of
36   this software.
37 */
38
39 #ifndef _LUFA_H_
40 #define _LUFA_H_
41
42 #include <avr/io.h>
43 #include <avr/wdt.h>
44 #include <avr/power.h>
45 #include <avr/interrupt.h>
46 #include <stdbool.h>
47 #include <string.h>
48 #include <LUFA/Version.h>
49 #include <LUFA/Drivers/USB/USB.h>
50 #include "host.h"
51 #ifdef MIDI_ENABLE
52   #include "midi.h"
53 #endif
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 extern host_driver_t lufa_driver;
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 /* extra report structure */
65 typedef struct {
66     uint8_t  report_id;
67     uint16_t usage;
68 } __attribute__ ((packed)) report_extra_t;
69
70 #ifdef MIDI_ENABLE
71   #define MIDI_SYSEX_BUFFER 16 
72   void MIDI_Task(void);
73   MidiDevice midi_device;
74
75   void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data);
76   uint32_t decode_uint32_chunk(uint8_t * data);
77   uint32_t decode_uint8_chunk(uint8_t * data);
78   void encode_uint32_chunk(uint32_t data, uint8_t * pointer);
79   void encode_uint8_chunk(uint8_t data, uint8_t * pointer);
80   void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data);
81   void send_unicode_midi(uint32_t unicode);
82   void send_bytes_sysex(uint8_t type, uint8_t * bytes, uint8_t length);
83 #endif
84
85 // #if LUFA_VERSION_INTEGER < 0x120730
86 //     /* old API 120219 */
87 //     #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank)    Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank)
88 // #else
89     /* new API >= 120730 */
90     #define ENDPOINT_BANK_SINGLE 1
91     #define ENDPOINT_BANK_DOUBLE 2
92     #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank)    Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank)
93 // #endif
94
95 #endif