Wixel SDK
usb.c
1 #include <usb.h>
2 #include <cc2511_map.h>
3 #include <cc2511_types.h>
4 #include <board.h>
5 
6 // TODO: make the usb library work will with Sleep Mode 0 (an interrupt should be enabled for all the endpoints we care about so we can handle them quickly)
7 // TODO: SUSPEND MODE!
8 
9 extern uint8 CODE usbConfigurationDescriptor[];
10 
11 static void usbStandardDeviceRequestHandler();
12 
13 #define CONTROL_TRANSFER_STATE_NONE 0
14 #define CONTROL_TRANSFER_STATE_WRITE 1
15 #define CONTROL_TRANSFER_STATE_READ 2
16 
18 uint8 XDATA usbDeviceState = USB_STATE_DETACHED;
19 
20 uint8 XDATA controlTransferState = CONTROL_TRANSFER_STATE_NONE;
21 uint16 XDATA controlTransferBytesLeft;
22 XDATA uint8 * controlTransferPointer;
23 
24 volatile BIT usbSuspendMode = 0;
25 
26 // TODO: eventually: Enable the USB interrupt and only set usbActivityFlag in the ISR
27 volatile BIT usbActivityFlag = 0;
28 
29 void usbInit()
30 {
31 }
32 
33 // TODO: try using DMA in usbReadFifo and usbWriteFifo and see how that affects the speed of usbComTxSend(x, 128).
34 void usbReadFifo(uint8 endpointNumber, uint8 count, uint8 XDATA * buffer)
35 {
36  XDATA uint8 * fifo = (XDATA uint8 *)(0xDE20 + (uint8)(endpointNumber<<1));
37  while(count > 0)
38  {
39  count--;
40  *(buffer++) = *fifo;
41  }
42 
43  usbActivityFlag = 1;
44 }
45 
46 void usbWriteFifo(uint8 endpointNumber, uint8 count, const uint8 XDATA * buffer)
47 {
48  XDATA uint8 * fifo = (XDATA uint8 *)(0xDE20 + (uint8)(endpointNumber<<1));
49  while(count > 0)
50  {
51  count--;
52  *fifo = *(buffer++);
53  }
54 
55  // We don't set the usbActivityFlag here; we wait until the packet is
56  // actually sent.
57 }
58 
59 // Performs some basic tasks that should be done after USB is connected and after every
60 // Reset interrupt.
61 static void basicUsbInit()
62 {
63  usbSuspendMode = 0;
64 
65  // Enable suspend detection and disable any other weird features.
66  USBPOW = 1;
67 
68  // Enable the USB common interrupts we care about: Reset, Resume, Suspend.
69  // Without this, we USBCIF.SUSPENDIF will not get set (the datasheet is incomplete).
70  USBCIE = 0b0111;
71 }
72 
73 void usbPoll()
74 {
75  uint8 usbcif;
76  uint8 usbiif;
77  //uint8 usboif = USBOIF;
78 
79  if (!usbPowerPresent())
80  {
81  // The VBUS line is low. This usually means that the USB cable has been
82  // disconnected or the computer has been turned off.
83 
84  SLEEP &= ~(1<<7); // Disable the USB module (SLEEP.USB_EN = 0).
85 
87  usbDeviceState = USB_STATE_DETACHED;
88  usbSuspendMode = 0;
89  return;
90  }
91 
92  if (usbDeviceState == USB_STATE_DETACHED)
93  {
95  SLEEP |= (1<<7); // Enable the USB module (SLEEP.USB_EN = 1).
96  __asm nop __endasm; // Datasheet doesn't say so, but David suspects we need some NOPs here before writing to USB registers.
97  __asm nop __endasm;
98  __asm nop __endasm;
99  __asm nop __endasm;
100  usbDeviceState = USB_STATE_POWERED;
101 
102  basicUsbInit();
103  }
104 
105  usbcif = USBCIF;
106  usbiif = USBIIF;
107 
108  if (usbcif & (1<<0)) // Check SUSPENDIF
109  {
110  // The bus has been idle for 3 ms, so we are now in Suspend mode.
111  // It is the user's responsibility to check usbSuspended() and go to sleep (PM1)
112  // if necessary.
113  usbSuspendMode = 1;
114  }
115 
116  if (usbcif & (1<<2)) // check RSTIF, the reset flag
117  {
118  // A USB reset signal has been received.
119  usbDeviceState = USB_STATE_DEFAULT;
120  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
121 
122  basicUsbInit();
123  }
124 
125  if (usbcif & (1<<1)) // Check RESUMEIF
126  {
127  usbSuspendMode = 0;
128  }
129 
130  if (usbiif & (1<<0)) // Check EP0IF
131  {
132  // Something happened on Endpoint 0, the endpoint for control transfers.
133  uint8 usbcs0;
134  USBINDEX = 0;
135  usbcs0 = USBCS0;
136 
137  usbActivityFlag = 1;
138 
139  if (usbcs0 & (1<<4)) // Check SETUP_END
140  {
141  // A new setup packet has arrived, prematurely ending the previous control transfer.
142  USBCS0 = 0x80; // Clear the SETUP_END bit
143  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
144  }
145 
146  if (usbcs0 & (1<<2)) // Check SENT_STALL
147  {
148  // A STALL packet was sent
149  USBCS0 = 0x00; // Reset endpoint 0.
150  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
151  }
152 
153  if (usbcs0 & (1<<0)) // Check OUTPKT_RDY
154  {
155  // Requirement: Every codepath from here must result in writing a 1 to
156  // bit 6 of USBCS0 to clear the OUTPKT_RDY flag: USBCS0 = (1<<6).
157 
158  if (controlTransferState == CONTROL_TRANSFER_STATE_WRITE)
159  {
160  // A data packet has been received as part of a control write transfer.
161  uint8 bytesReceived = USBCNT0;
162  if (bytesReceived > controlTransferBytesLeft)
163  {
164  bytesReceived = controlTransferBytesLeft;
165  }
166  usbReadFifo(0, bytesReceived, controlTransferPointer);
167  controlTransferPointer += bytesReceived;
168  controlTransferBytesLeft -= bytesReceived;
169 
170  if (controlTransferBytesLeft)
171  {
172  // Arm the endpoint to receive more bytes
173  USBCS0 = (1<<6); // De-asserts the OUTPKT_RDY bit (bit 0).
174  }
175  else
176  {
177  // The host has sent all the data we were expecting.
178 
179  if (usbSetupPacket.requestType != USB_REQUEST_TYPE_STANDARD) // OPT: remove this check
180  {
182  }
183 
184  USBINDEX = 0; // Just in case USBINDEX was changed above.
185 
186  if (controlTransferState == CONTROL_TRANSFER_STATE_NONE)
187  {
188  // The data received was invalid.
189  USBCS0 = (1<<6) | (1<<3) | (1<<5); // clear OUTPKT_RDY, set DATA_END, SEND_STALL
190  }
191  else
192  {
193  // The data received was valid.
194  USBCS0 = (1<<6) | (1<<3); // clear OUTPKT_RDY, set DATA_END
195  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
196  }
197  }
198  }
199  else if (USBCNT0 == 8)
200  {
201  // A SETUP packet has been received from the computer, starting a new
202  // control transfer.
203 
204  usbReadFifo(0, 8, (uint8 XDATA *)&usbSetupPacket); // Store the data in usbSetupPacket.
205 
206  // Wipe out the information about the last control transfer.
207  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
208 
209  if (usbSetupPacket.requestType == USB_REQUEST_TYPE_STANDARD)
210  {
211  // The request_type field indicates that this is a Standard Device Request
212  // as described in USB2.0 Chapter 9.4 Standard Device Requests.
213  // These requests are handled by the library in the function below.
214  usbStandardDeviceRequestHandler();
215  }
216  else
217  {
218  // Otherwise, we use this callback so the user can decide how to handle the
219  // setup packet. In this callback, the user can call various helper
220  // functions that set controlTransferState.
222  }
223 
224  USBINDEX = 0; // Select EP0 again because the functions above might have changed USBINDEX.
225 
226  // Modify the count so that we don't send more data than the host requested.
227  if(controlTransferBytesLeft > usbSetupPacket.wLength)
228  {
229  controlTransferBytesLeft = usbSetupPacket.wLength;
230  }
231 
232  // Prepare for the first transaction after the SETUP packet.
233  if (controlTransferState == CONTROL_TRANSFER_STATE_NONE)
234  {
235  // This is invalid/unrecognized control transfer, so send a STALL packet.
236  USBCS0 = (1<<6) | (1<<5); // Clears the OUTPKT_RDY flag because we've handled it, and sends a STALL.
237  }
238  else if (controlTransferState == CONTROL_TRANSFER_STATE_WRITE)
239  {
240  if (controlTransferBytesLeft)
241  {
242  // Arm the endpoint to receive the first data packet of a control write transfer.
243  USBCS0 = (1<<6); // De-asserts the OUTPKT_RDY bit.
244  }
245  else
246  {
247  // Acknowledge a control write transfer with no data phase.
248  USBCS0 = (1<<6) | (1<<3) | (1<<1); // De-asserts OUTPKY_RDY, asserts DATA_END, asserts INPKT_RDY.
249  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
250  }
251  }
252  }
253  else
254  {
255  // An OUT packet was received on Endpoint 0, but we are not in the middle of a
256  // control write transfer and it was not the right length to be a setup packet.
257  // This situation is not expected.
258  USBCS0 = (1<<6); // De-asserts the OUTPKT_RDY.
259  }
260  }
261 
262  if (!(usbcs0 & (1<<1)) && (controlTransferState == CONTROL_TRANSFER_STATE_READ))
263  {
264  // We are doing a control read transfer, and Endpoint 0 is ready to accept another
265  // IN packet to send to the computer.
266  uint8 bytesToSend;
267  if (controlTransferBytesLeft < USB_EP0_PACKET_SIZE)
268  {
269  // Send the last packet (might be an empty packet).
270  usbcs0 = (1<<1)|(1<<3); // INPKT_RDY and DATA_END
271  bytesToSend = controlTransferBytesLeft;
272  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
273  }
274  else
275  {
276  // Send a packet.
277  usbcs0 = (1<<1); // INPKT_RDY
278  bytesToSend = USB_EP0_PACKET_SIZE;
279  }
280 
281  // Arm endpoint 0 to send the next packet.
282  usbWriteFifo(0, bytesToSend, controlTransferPointer);
283  USBCS0 = usbcs0;
284 
285  // Update the control transfer state.
286  controlTransferPointer += bytesToSend;
287  controlTransferBytesLeft -= bytesToSend;
288  }
289  }
290 }
291 
292 // usbStandardDeviceRequestHandler(): Implementation of USB2.0 Section 9.4, Standard Device Requests.
293 // This function gets called whenever we receive a SETUP packet on endpoint zero with the requestType
294 // field set to STANDARD. This function reads the SETUP packet and uses that to set the control
295 // transfer state variables with all the information needed to respond to the request.
296 // Assumption: controlTransferState is CONTROL_TRANSFER_STATE_NONE when this function is called.
297 static void usbStandardDeviceRequestHandler()
298 {
299  // Prepare a convenient two-byte buffer for sending 1 or 2 byte responses.
300  static XDATA uint8 response[2];
301  response[0] = 0;
302  response[1] = 0;
303 
304  // Now we decide how to handle the new setup packet. There are several possibilities:
305  // * Invalid: The SETUP packet had a problem with it, or we don't support the feature,
306  // so we need to STALL the next transaction to indicate an request error to the host.
307  // * Control Read: We must send some data to the computer, so we need to decide
308  // where the data is coming from (address, plus RAM/ROM selection)
309  // * Control Write with no data phase: We need to prepare for the status phase, where
310  // our device must send a zero-length EP0 IN packet to indicate success.
311  // * Control Write with data phase: The computer will send data to us, and we need to
312  // decide where in RAM to put it. (No standard device requests use this type,
313  // so ignore this case.)
314 
315  switch(usbSetupPacket.bRequest)
316  {
317  case USB_REQUEST_GET_DESCRIPTOR: // USB Spec 9.4.3 Get Descriptor
318  {
319  switch(usbSetupPacket.wValue >> 8)
320  {
321  case USB_DESCRIPTOR_TYPE_DEVICE:
322  {
323  controlTransferPointer = (uint8 XDATA *)&usbDeviceDescriptor;
324  controlTransferBytesLeft = sizeof(USB_DESCRIPTOR_DEVICE);
325  break;
326  }
327  case USB_DESCRIPTOR_TYPE_CONFIGURATION:
328  {
329  if ((usbSetupPacket.wValue & 0xFF) != 0)
330  {
331  // Invalid configuration index.
332  return;
333  }
334 
335  // The configuration descriptor has an application-dependent size, which
336  // we determine by reading the 3rd and 4th byte.
337  controlTransferPointer = (uint8 XDATA *)usbConfigurationDescriptor;
338  controlTransferBytesLeft = *(uint16 *)&usbConfigurationDescriptor[2];
339  break;
340  }
341  case USB_DESCRIPTOR_TYPE_STRING:
342  {
343  if ((usbSetupPacket.wValue & 0xFF) >= usbStringDescriptorCount)
344  {
345  // This is either an invalid string index or it is 0xEE,
346  // which is defined by Microsoft OS Descriptors 1.0.
347  // This library provides no features for handling such requests,
348  // but we call the user's callback in case they want to.
350  return;
351  }
352 
353  controlTransferPointer = (uint8 XDATA *)usbStringDescriptors[usbSetupPacket.wValue & 0xFF];
354  controlTransferBytesLeft = controlTransferPointer[0];
355  break;
356  }
357  default:
358  {
359  // see if the class recognizes the descriptor type; it should call usbControlRead if it does
361 
362  if (controlTransferState == CONTROL_TRANSFER_STATE_NONE)
363  {
364  // unknown type of descriptor
365  return;
366  }
367  break;
368  }
369  }
370 
371  controlTransferState = CONTROL_TRANSFER_STATE_READ;
372  return;
373  }
374  case USB_REQUEST_SET_ADDRESS: // USB Spec, 9.4.6 Set Address
375  {
376  // Get ready to set the address when the status phase is complete.
377  // We always set the most siginificant bit, because .device_address might be 0
378  // and that is a valid request, meaning we should revert to address 0.
379  //pendingDeviceAddress = (usbSetupPacket.wValue & 0xFF) | 0x80;
380 
381  USBADDR = (uint8)usbSetupPacket.wValue;
382  usbDeviceState = ((uint8)usbSetupPacket.wValue) ? USB_STATE_ADDRESS : USB_STATE_DEFAULT;
383 
384  // Get ready to provide a handshake.
386  return;
387  }
388  case USB_REQUEST_SET_CONFIGURATION: // USB Spec, 9.4.7 Set Configuration
389  {
390  // Assumption: there is only one configuration and its value is 1.
391  switch(usbSetupPacket.wValue)
392  {
393  case 0:
394  {
395  // We have been deconfigured.
396 
397  // TODO: Add resetNonzeroEndpoints() and call it here.
398 
399  if (usbDeviceState > USB_STATE_ADDRESS)
400  {
401  usbDeviceState = USB_STATE_ADDRESS;
402  }
403  break;
404  }
405  case 1:
406  {
407  // The device has been configured. This is normal operating
408  // state of a USB device. We can now start using non-zero
409  // endpoints.
410  usbDeviceState = USB_STATE_CONFIGURED;
412  break;
413  }
414  default:
415  {
416  // Invalid configuration value, so STALL.
417  return;
418  }
419  }
420 
421  // Get ready to provide a handshake.
423  return;
424  }
425  case USB_REQUEST_GET_CONFIGURATION: // USB Spec 9.4.2 Get Configuration
426  {
427  // Assumption: there is only one configuration and its value is 1.
428  response[0] = (usbDeviceState == USB_STATE_CONFIGURED) ? 1 : 0;
429  usbControlRead(1, response);
430  return;
431  }
432  case USB_REQUEST_GET_INTERFACE: // USB Spec 9.4.4 Get Interface
433  {
434  // Assumption: the "alternate setting number" of each interface
435  // is zero and there are no alternate settings.
436  // Assumption: interface numbers go from 0 to
437  // config->interface_count-1, with no gaps.
438 
439  if (usbDeviceState < USB_STATE_CONFIGURED)
440  {
441  // Invalid request because we have not reached the configured state.
442  return;
443  }
444 
445  if (usbSetupPacket.wIndex >= ((USB_DESCRIPTOR_CONFIGURATION *)&usbConfigurationDescriptor)->bNumInterfaces)
446  {
447  // Invalid index: there is no such interface.
448  return;
449  }
450 
451  // Send a single-byte response of "0".
452  // Assumption: response[0] == 0
453  usbControlRead(1, response);
454  return;
455  }
456  case USB_REQUEST_GET_STATUS: // USB Spec 9.4.5 Get Status
457  {
458  switch(usbSetupPacket.recipient)
459  {
460  case USB_RECIPIENT_DEVICE:
461  {
462  // See USB Spec Table 9-4.
463  response[0] = vinPowerPresent() ? 1 : 0;
464  // Assumption: response[1] == 0
465  usbControlRead(2, response);
466  return;
467  }
468  case USB_RECIPIENT_INTERFACE:
469  {
470  if (usbDeviceState < USB_STATE_CONFIGURED && usbSetupPacket.wIndex != 0)
471  {
472  // It is invalid to ask about interfaces other than 0 before the
473  // configured state.
474  return;
475  }
476 
477  if (usbSetupPacket.wIndex >= ((USB_DESCRIPTOR_CONFIGURATION *)&usbConfigurationDescriptor)->bNumInterfaces)
478  {
479  // Invalid index: there is no such interface.
480  return;
481  }
482 
483  // Send a 2-byte response of 0,0 (all of the bits are reserved)
484  // Assumption: response[0] == 0 and response[1] == 0
485  usbControlRead(2, response);
486  return;
487  }
488  case USB_RECIPIENT_ENDPOINT:
489  {
490  if ((usbSetupPacket.wValue & 15) == 0)
491  {
492  // We don't support the halt feature on Endpoint 0
493  // (the USB Spec does not require or recommend it).
494  return;
495  }
496 
497  if (usbDeviceState < USB_STATE_CONFIGURED)
498  {
499  // It is invalid to ask about non-zero endpoints before
500  // the configured state.
501  return;
502  }
503 
504  // Assumption: We don't have a USB halt feature, i.e. we
505  // don't stall on non-zero endpoints.
506 
507  // Send a 2-byte response of 0,0.
508  // Assumption: response[0] == 0 and response[1] == 0
509  usbControlRead(2, response);
510  return;
511  }
512  }
513  return;
514  }
515 
516  // Here are some more standard device requests we would need
517  // to be USB compliant. We didn't use them yet on any of our
518  // PIC devices and it has not caused a problem as far as I
519  // know. We pay lip service to them here just in case they are
520  // needed by some future driver.
521  case USB_REQUEST_SET_FEATURE:
522  case USB_REQUEST_CLEAR_FEATURE:
523  {
524  // Acknowledge the request but don't do anything.
526  return;
527  }
528  case USB_REQUEST_SYNCH_FRAME:
529  {
530  // Send a two-byte response of 0,0.
531  usbControlRead(2, response);
532  return;
533  }
534  }
535 }
536 
538 {
539  return usbSuspendMode;
540 }
541 
542 // Sleeps until we receive USB resume signaling.
543 // This uses PM1. ( PM2 and PM3 are not usable because they will reset the USB module. )
544 // NOTE: For some reason, USB suspend does not work if you plug your device into a computer
545 // that is already sleeping. If you do that, the device will remain awake with
546 // usbDeviceState == USB_STATE_POWERED and it will draw more power than it should from USB.
547 // TODO: figure out how to wake up when self power is connected. Probably we should use the
548 // sleep timer to wake up regularly and check (that's going to be easier than using a P2
549 // interrupt I think).
550 // TODO: make sure suspend mode doesn't interfere with the radio libraries. We should
551 // probably make a simple power-event registration thing using function pointers,
552 // (either an array, or a linked list where the memory is contributed by the modules using it).
553 // When going to sleep, we would call these functions in the order they were added;
554 // when waking up, we would call them in the opposite order. Look at how we handle power
555 // on the jrk, maestros, and simple motor controller to see if this pattern works.
556 void usbSleep()
557 {
558  uint8 savedPICTL = PICTL;
559  BIT savedP0IE = P0IE;
560 
561  // The USB resume interrupt is mapped to the non-existent pin, P0_7.
562 
563  P0IE = 0; // Disable the P0 interrupt while we are reconfiguring it (maybe not necessary).
564  PICTL |= (1<<4); // PICTL.P0IENH = 1 Enable the Port 0 interrupts for inputs 4-7 (USB_RESUME is #7).
565  PICTL &= ~(1<<0); // PICTL.P0ICON = 0 Detect rising edges (this is required for waking up).
566 
567  do
568  {
569  // Clear the P0 interrupt flag that might prevent us from sleeping.
570  P0IFG = 0; // Clear Port 0 module interrupt flags.
571  P0IF = 0; // Clear Port 0 CPU interrupt flag (IRCON.P0IF = 0).
572 
573  P0IE = 1; // Enable the Port 0 interrupt (IEN1.P0IE = 1) so we can wake up.
574 
575  // Put the device to sleep by following the recommended pseudo code in the datasheet section 12.1.3:
576  SLEEP = (SLEEP & ~3) | 1; // SLEEP.MODE = 1 : Selects Power Mode 1 (PM1).
577  __asm nop __endasm; __asm nop __endasm; __asm nop __endasm;
578  if (SLEEP & 3)
579  {
580  P1_0 = 1;
581  PCON |= 1; // PCON.IDLE = 1 : Actually go to sleep.
582  P1_0 = 0;
583  }
584 
585  // Disable the Port 0 interrupt. If we don't do this, and there is no ISR
586  // (just a reti), then the non-existent ISR could run many times while we
587  // are awake, slowing down this loop.
588  P0IE = 0; // (IEN1.P0IE = 1)
589 
590  // Check to see if the USB_RESUME bit is set. If it is set, then there was
591  // activity detected on the USB and it is time to wake up.
592  // NOTE: The P0INT ISR might also set usbSuspendMode to 0 if the user defines
593  // that ISR. See the comment about P0INT in usb.h for more info.
594  if (P0IFG & 0x80)
595  {
596  usbSuspendMode = 0;
597  }
598  }
599  while(usbSuspendMode && !vinPowerPresent());
600 
601  // Wait for the high speed crystal oscillator to become stable again
602  // because we can't write to USB registers until that happens.
603  while(!(SLEEP & (1<<6))){};
604 
605  // Restore the interrupt registers to their original states.
606  PICTL = savedPICTL;
607  P0IE = savedP0IE;
608 }
609 
610 void usbControlRead(uint16 bytesCount, uint8 XDATA * source)
611 {
612  controlTransferState = CONTROL_TRANSFER_STATE_READ;
613  controlTransferBytesLeft = bytesCount;
614  controlTransferPointer = source;
615 }
616 
617 void usbControlWrite(uint16 bytesCount, uint8 XDATA * source)
618 {
619  controlTransferState = CONTROL_TRANSFER_STATE_WRITE;
620  controlTransferBytesLeft = bytesCount;
621  controlTransferPointer = source;
622 }
623 
625 {
626  controlTransferState = CONTROL_TRANSFER_STATE_WRITE;
627  controlTransferBytesLeft = 0;
628 }
629 
631 {
632  controlTransferState = CONTROL_TRANSFER_STATE_NONE;
633 }
634 
635 void usbInitEndpointIn(uint8 endpointNumber, uint8 maxPacketSize)
636 {
637  USBINDEX = endpointNumber;
638  USBMAXI = (maxPacketSize + 7) >> 3;
639  USBCSIH = 1; // Enable Double buffering
640 }
641 
642 void usbInitEndpointOut(uint8 endpointNumber, uint8 maxPacketSize)
643 {
644  USBINDEX = endpointNumber;
645  USBMAXO = (maxPacketSize + 7) >> 3;
646  USBCSOH = 1; // Enable Double buffering
647 }
BIT usbSuspended(void)
Definition: usb.c:537
struct USB_DESCRIPTOR_DEVICE USB_DESCRIPTOR_DEVICE
void usbCallbackInitEndpoints(void)
Definition: usb_cdc_acm.c:234
uint8 CODE usbStringDescriptorCount
Definition: usb_cdc_acm.c:224
void usbInitEndpointOut(uint8 endpointNumber, uint8 maxPacketSize)
Definition: usb.c:642
volatile BIT usbActivityFlag
Definition: usb.c:27
#define XDATA
Definition: cc2511_types.h:65
#define USB_EP0_PACKET_SIZE
Definition: usb.h:34
BIT usbPowerPresent()
Definition: board.c:142
enum USB_DEVICE_STATES XDATA usbDeviceState
Definition: usb.c:18
void usbControlWrite(uint16 bytesCount, uint8 XDATA *source)
Definition: usb.c:617
USB_DESCRIPTOR_DEVICE CODE usbDeviceDescriptor
Definition: usb_cdc_acm.c:109
USB_SETUP_PACKET XDATA usbSetupPacket
Definition: usb.c:17
void usbWriteFifo(uint8 endpointNumber, uint8 count, const uint8 XDATA *buffer)
Definition: usb.c:46
void usbInitEndpointIn(uint8 endpointNumber, uint8 maxPacketSize)
Definition: usb.c:635
void usbReadFifo(uint8 endpointNumber, uint8 count, uint8 XDATA *buffer)
Definition: usb.c:34
__bit BIT
Definition: cc2511_types.h:32
void usbPoll(void)
Definition: usb.c:73
unsigned short uint16
Definition: cc2511_types.h:15
void usbSleep(void)
Definition: usb.c:556
void usbCallbackSetupHandler(void)
Definition: usb_cdc_acm.c:246
void usbControlStall(void)
Definition: usb.c:630
unsigned char uint8
Definition: cc2511_types.h:9
void usbControlAcknowledge(void)
Definition: usb.c:624
void usbInit(void)
Definition: usb.c:29
void enableUsbPullup()
Definition: board.c:158
void usbCallbackControlWriteHandler(void)
Definition: usb_cdc_acm.c:281
void usbControlRead(uint16 bytesCount, uint8 XDATA *source)
Definition: usb.c:610
void usbCallbackClassDescriptorHandler(void)
Definition: usb_cdc_acm.c:271
volatile BIT usbSuspendMode
Definition: usb.c:24
uint16 CODE *CODE usbStringDescriptors[]
Definition: usb_cdc_acm.c:228
BIT vinPowerPresent()
Definition: board.c:148
#define CODE
Definition: cc2511_types.h:39
void disableUsbPullup()
Definition: board.c:153