lufa.h 3.0 KB

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