usbpic_defs.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef USBPIC_H
  2. #define USBPIC_H
  3. // Version 1.1 Compatible with SDCC 3.x
  4. // Buffer Descriptor bit masks (from PIC datasheet)
  5. #define UOWN 0x80 // USB Own Bit
  6. #define DTS 0x40 // Data Toggle Synchronization Bit
  7. #define KEN 0x20 // BD Keep Enable Bit
  8. #define INCDIS 0x10 // Address Increment Disable Bit
  9. #define DTSEN 0x08 // Data Toggle Synchronization Enable Bit
  10. #define BSTALL 0x04 // Buffer Stall Enable Bit
  11. #define BC9 0x02 // Byte count bit 9
  12. #define BC8 0x01 // Byte count bit 8
  13. typedef struct _BDT
  14. {
  15. unsigned char STAT;
  16. unsigned char CNT;
  17. unsigned int ADDR;
  18. } BDT; //Buffer Descriptor Table
  19. // Every device request starts with an 8 unsigned char setup packet (USB 2.0, chap 9.3)
  20. // with a standard layout. The meaning of wValue and wIndex will
  21. // vary depending on the request type and specific request.
  22. typedef struct _setup_packet_struct
  23. {
  24. unsigned char bmrequesttype; // D7: Direction, D6..5: Type, D4..0: Recipient
  25. unsigned char brequest; // Specific request
  26. unsigned char wvalue0; // LSB of wValue
  27. unsigned char wvalue1; // MSB of wValue
  28. unsigned char windex0; // LSB of wIndex
  29. unsigned char windex1; // MSB of wIndex
  30. unsigned short wlength; // Number of unsigned chars to transfer if there's a data stage
  31. unsigned char extra[56]; // Fill out to same size as Endpoint 0 max buffer
  32. } setup_packet_struct;
  33. #define USTAT_IN (0x04)
  34. #define USTAT_OUT (0x00)
  35. //endpoints
  36. volatile BDT __at (0x0400+0*8) ep0_o;
  37. volatile BDT __at (0x0404+0*8) ep0_i;
  38. volatile BDT __at (0x0400+1*8) ep1_o;
  39. volatile BDT __at (0x0404+1*8) ep1_i;
  40. volatile BDT __at (0x0400+2*8) ep2_o;
  41. volatile BDT __at (0x0404+2*8) ep2_i;
  42. volatile BDT __at (0x0400+3*8) ep3_o;
  43. volatile BDT __at (0x0404+3*8) ep3_i;
  44. #endif