annotate Output/pjrcUSB/arm/usb_dev.h @ 346:1beec5f17e64

Revert "Merge pull request #27 from smasher816/wakeup-devel" This reverts commit 622ea5d85f94be4b1694fdf08e30fa76eeb18fe4, reversing changes made to c21439cb48daec7514da4250c41962205fa96624.
author Jacob Alexander <haata@kiibohd.com>
date Tue, 23 Jun 2015 08:00:16 -0700
parents 66eccdd9ced5
children 23a1868b4ac2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
341
66eccdd9ced5 Code cleanup
Jacob Alexander <haata@kiibohd.com>
parents: 327
diff changeset
4 * Modifications by Jacob Alexander 2014-2015
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
341
66eccdd9ced5 Code cleanup
Jacob Alexander <haata@kiibohd.com>
parents: 327
diff changeset
32 #pragma once
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
34 // ----- Includes -----
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
35
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
36 // Local Includes
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
37 #include "usb_mem.h"
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
38 #include "usb_desc.h"
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
39
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
40
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 // ----- Defines -----
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
43
177
3420e018ffbc Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 175
diff changeset
44 #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
45
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
46
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 // ----- Variables -----
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
49
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
50 extern volatile uint8_t usb_configuration;
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
51
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
52 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
53
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
54 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
55 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
56 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
57
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 // ----- Functions -----
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
61
177
3420e018ffbc Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 175
diff changeset
62 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
63 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
64
175
c70f641581b5 McHCK USB WORKS!!
Jacob Alexander <haata@kiibohd.com>
parents: 117
diff changeset
65 void usb_isr();
177
3420e018ffbc Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 175
diff changeset
66 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
67 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
68
3420e018ffbc Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 175
diff changeset
69 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
70 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
71
3420e018ffbc Adding McHCK flash reload function and some cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 175
diff changeset
72 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
73
117
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 109
diff changeset
74 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
75 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
76 {
326
05a09eda53fb Inital Remote Wakeup Support
Rowan Decker <Smasher816@gmail.com>
parents: 275
diff changeset
77 endpoint--;
05a09eda53fb Inital Remote Wakeup Support
Rowan Decker <Smasher816@gmail.com>
parents: 275
diff changeset
78 if ( endpoint >= NUM_ENDPOINTS )
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
79 return 0;
326
05a09eda53fb Inital Remote Wakeup Support
Rowan Decker <Smasher816@gmail.com>
parents: 275
diff changeset
80 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
81 }
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 109
diff changeset
82
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
83 void usb_device_reload();
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
84
231
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
85 extern void usb_serial_flush_callback();
4afb170978e9 More preparation for NKRO USB for arm
Jacob Alexander <haata@kiibohd.com>
parents: 177
diff changeset
86