Mercurial > louis > kiibohd-controller
comparison Output/pjrcUSB/arm/usb_dev.c @ 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 | 4f47971c45c2 |
comparison
equal
deleted
inserted
replaced
305:4617ef5e06f1 | 308:ab4515606277 |
---|---|
49 //#define UART_DEBUG 1 | 49 //#define UART_DEBUG 1 |
50 // Debug Unknown USB requests, usually what you want to debug USB issues | 50 // Debug Unknown USB requests, usually what you want to debug USB issues |
51 //#define UART_DEBUG_UNKNOWN 1 | 51 //#define UART_DEBUG_UNKNOWN 1 |
52 | 52 |
53 | 53 |
54 #define TX_STATE_BOTH_FREE_EVEN_FIRST 0 | 54 #define TX_STATE_BOTH_FREE_EVEN_FIRST 0 |
55 #define TX_STATE_BOTH_FREE_ODD_FIRST 1 | 55 #define TX_STATE_BOTH_FREE_ODD_FIRST 1 |
56 #define TX_STATE_EVEN_FREE 2 | 56 #define TX_STATE_EVEN_FREE 2 |
57 #define TX_STATE_ODD_FREE 3 | 57 #define TX_STATE_ODD_FREE 3 |
58 #define TX_STATE_NONE_FREE_EVEN_FIRST 4 | 58 #define TX_STATE_NONE_FREE_EVEN_FIRST 4 |
59 #define TX_STATE_NONE_FREE_ODD_FIRST 5 | 59 #define TX_STATE_NONE_FREE_ODD_FIRST 5 |
60 | 60 |
61 #define BDT_OWN 0x80 | 61 #define BDT_OWN 0x80 |
62 #define BDT_DATA1 0x40 | 62 #define BDT_DATA1 0x40 |
63 #define BDT_DATA0 0x00 | 63 #define BDT_DATA0 0x00 |
64 #define BDT_DTS 0x08 | 64 #define BDT_DTS 0x08 |
65 #define BDT_STALL 0x04 | 65 #define BDT_STALL 0x04 |
66 | 66 |
67 #define TX 1 | 67 #define TX 1 |
68 #define RX 0 | 68 #define RX 0 |
69 #define ODD 1 | 69 #define ODD 1 |
70 #define EVEN 0 | 70 #define EVEN 0 |
71 #define DATA0 0 | 71 #define DATA0 0 |
72 #define DATA1 1 | 72 #define DATA1 1 |
73 | 73 |
74 | 74 |
75 #define GET_STATUS 0 | 75 #define GET_STATUS 0 |
76 #define CLEAR_FEATURE 1 | 76 #define CLEAR_FEATURE 1 |
77 #define SET_FEATURE 3 | 77 #define SET_FEATURE 3 |
78 #define SET_ADDRESS 5 | 78 #define SET_ADDRESS 5 |
79 #define GET_DESCRIPTOR 6 | 79 #define GET_DESCRIPTOR 6 |
80 #define SET_DESCRIPTOR 7 | 80 #define SET_DESCRIPTOR 7 |
81 #define GET_CONFIGURATION 8 | 81 #define GET_CONFIGURATION 8 |
82 #define SET_CONFIGURATION 9 | 82 #define SET_CONFIGURATION 9 |
83 #define GET_INTERFACE 10 | 83 #define GET_INTERFACE 10 |
84 #define SET_INTERFACE 11 | 84 #define SET_INTERFACE 11 |
85 #define SYNCH_FRAME 12 | 85 #define SYNCH_FRAME 12 |
86 | 86 |
87 #define TX_STATE_BOTH_FREE_EVEN_FIRST 0 | 87 #define TX_STATE_BOTH_FREE_EVEN_FIRST 0 |
88 #define TX_STATE_BOTH_FREE_ODD_FIRST 1 | 88 #define TX_STATE_BOTH_FREE_ODD_FIRST 1 |
89 #define TX_STATE_EVEN_FREE 2 | 89 #define TX_STATE_EVEN_FREE 2 |
90 #define TX_STATE_ODD_FREE 3 | 90 #define TX_STATE_ODD_FREE 3 |
91 #define TX_STATE_NONE_FREE 4 | 91 #define TX_STATE_NONE_FREE 4 |
92 | 92 |
93 | 93 |
94 | 94 |
95 | 95 |
96 | 96 |
97 // ----- Macros ----- | 97 // ----- Macros ----- |
98 | 98 |
99 #define BDT_PID(n) (((n) >> 2) & 15) | 99 #define BDT_PID(n) (((n) >> 2) & 15) |
100 | 100 |
101 #define BDT_DESC(count, data) (BDT_OWN | BDT_DTS \ | 101 #define BDT_DESC(count, data) (BDT_OWN | BDT_DTS \ |
102 | ((data) ? BDT_DATA1 : BDT_DATA0) \ | 102 | ((data) ? BDT_DATA1 : BDT_DATA0) \ |
103 | ((count) << 16)) | 103 | ((count) << 16)) |
104 | 104 |
105 #define index(endpoint, tx, odd) (((endpoint) << 2) | ((tx) << 1) | (odd)) | 105 #define index(endpoint, tx, odd) (((endpoint) << 2) | ((tx) << 1) | (odd)) |
106 #define stat2bufferdescriptor(stat) (table + ((stat) >> 2)) | 106 #define stat2bufferdescriptor(stat) (table + ((stat) >> 2)) |
920 serial_print(((uint32_t)b & 8) ? ", odd" : ", even"); | 920 serial_print(((uint32_t)b & 8) ? ", odd" : ", even"); |
921 serial_print(", count:"); | 921 serial_print(", count:"); |
922 serial_phex(b->desc >> 16); | 922 serial_phex(b->desc >> 16); |
923 serial_print("\n"); | 923 serial_print("\n"); |
924 #endif | 924 #endif |
925 endpoint--; // endpoint is index to zero-based arrays | 925 endpoint--; // endpoint is index to zero-based arrays |
926 | 926 |
927 if ( stat & 0x08 ) | 927 if ( stat & 0x08 ) |
928 { // transmit | 928 { // transmit |
929 usb_free( packet ); | 929 usb_free( packet ); |
930 packet = tx_first[ endpoint ]; | 930 packet = tx_first[ endpoint ]; |
1105 #endif | 1105 #endif |
1106 | 1106 |
1107 // If no USB cable is attached, do not initialize usb | 1107 // If no USB cable is attached, do not initialize usb |
1108 // XXX Test -HaaTa | 1108 // XXX Test -HaaTa |
1109 //if ( USB0_OTGISTAT & USB_OTGSTAT_ID ) | 1109 //if ( USB0_OTGISTAT & USB_OTGSTAT_ID ) |
1110 // return 0; | 1110 // return 0; |
1111 | 1111 |
1112 // Clear out endpoints table | 1112 // Clear out endpoints table |
1113 for ( int i = 0; i <= NUM_ENDPOINTS * 4; i++ ) | 1113 for ( int i = 0; i <= NUM_ENDPOINTS * 4; i++ ) |
1114 { | 1114 { |
1115 table[i].desc = 0; | 1115 table[i].desc = 0; |