Mercurial > louis > kiibohd-controller
annotate Output/pjrcUSB/arm/usb_dev.h @ 308:ab4515606277
Fix whitespace
Use a consistent standard - Tabs in front for indenting, spaces after for anything else. This way everything stays nice and lined up while also letting users change there prefered indent level. Most of the new files from Haata where already in this format.
author | Rowan Decker <Smasher816@gmail.com> |
---|---|
date | Sun, 08 Mar 2015 18:40:01 -0700 |
parents | d5bf41d7f7ef |
children | f7b14e25ca5b |
rev | line source |
---|---|
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
1 /* Teensyduino Core Library |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
2 * http://www.pjrc.com/teensy/ |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
3 * Copyright (c) 2013 PJRC.COM, LLC. |
177
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
4 * Modifications by Jacob Alexander 2014 |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
5 * |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
6 * Permission is hereby granted, free of charge, to any person obtaining |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
7 * a copy of this software and associated documentation files (the |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
8 * "Software"), to deal in the Software without restriction, including |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
9 * without limitation the rights to use, copy, modify, merge, publish, |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
10 * distribute, sublicense, and/or sell copies of the Software, and to |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
11 * permit persons to whom the Software is furnished to do so, subject to |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
12 * the following conditions: |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
13 * |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
14 * 1. The above copyright notice and this permission notice shall be |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
15 * included in all copies or substantial portions of the Software. |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
16 * |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
17 * 2. If the Software is incorporated into a build system that allows |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
18 * selection among a list of target devices, then similar target |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
19 * devices manufactured by PJRC.COM must be included in the list of |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
20 * target devices and selectable in the same manner. |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
21 * |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
26 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
27 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
28 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
29 * SOFTWARE. |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
30 */ |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
31 |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
32 #ifndef _usb_dev_h_ |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
33 #define _usb_dev_h_ |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
34 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
35 // ----- Includes ----- |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
36 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
37 // Local Includes |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
38 #include "usb_mem.h" |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
39 #include "usb_desc.h" |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
40 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
41 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
42 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
43 // ----- Defines ----- |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
44 |
177
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
45 #define usb_device_software_reset() SOFTWARE_RESET() |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
46 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
47 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
48 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
49 // ----- Variables ----- |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
50 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
51 extern volatile uint8_t usb_configuration; |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
52 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
53 extern uint16_t usb_rx_byte_count_data[NUM_ENDPOINTS]; |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
54 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
55 extern volatile uint8_t usb_cdc_line_coding[7]; |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
56 extern volatile uint8_t usb_cdc_line_rtsdtr; |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
57 extern volatile uint8_t usb_cdc_transmit_flush_timer; |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
58 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
59 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
60 |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
61 // ----- Functions ----- |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
62 |
177
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
63 uint8_t usb_configured(); // is the USB port configured |
275
d5bf41d7f7ef
Initial code for USB cable detection
Jacob Alexander <haata@kiibohd.com>
parents:
231
diff
changeset
|
64 uint8_t usb_init(); // Returns 1 on success, 0 if no cable is attached |
177
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
65 |
175 | 66 void usb_isr(); |
177
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
67 void usb_tx( uint32_t endpoint, usb_packet_t *packet ); |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
68 void usb_tx_isr( uint32_t endpoint, usb_packet_t *packet ); |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
69 |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
70 uint32_t usb_tx_byte_count( uint32_t endpoint ); |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
71 uint32_t usb_tx_packet_count( uint32_t endpoint ); |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
72 |
3420e018ffbc
Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
73 usb_packet_t *usb_rx( uint32_t endpoint ); |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
74 |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
75 static inline uint32_t usb_rx_byte_count(uint32_t endpoint) __attribute__((always_inline)); |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
76 static inline uint32_t usb_rx_byte_count(uint32_t endpoint) |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
77 { |
308 | 78 endpoint--; |
79 if ( endpoint >= NUM_ENDPOINTS ) | |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
80 return 0; |
308 | 81 return usb_rx_byte_count_data[ endpoint ]; |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
82 } |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
83 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
84 void usb_device_reload(); |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
85 |
231
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
86 extern void usb_serial_flush_callback(); |
4afb170978e9
More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents:
177
diff
changeset
|
87 |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
88 |
117
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
89 |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
90 #endif |
5ffefdf89b37
Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
91 |