My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

usbhw.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*----------------------------------------------------------------------------
  2. * U S B - K e r n e l
  3. *----------------------------------------------------------------------------
  4. * Name: usbhw.h
  5. * Purpose: USB Hardware Layer Definitions
  6. * Version: V1.20
  7. *----------------------------------------------------------------------------
  8. * This software is supplied "AS IS" without any warranties, express,
  9. * implied or statutory, including but not limited to the implied
  10. * warranties of fitness for purpose, satisfactory quality and
  11. * noninfringement. Keil extends you a royalty-free right to reproduce
  12. * and distribute executable files created using this software for use
  13. * on NXP Semiconductors LPC family microcontroller devices only. Nothing
  14. * else gives you the right to use this software.
  15. *
  16. * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
  17. *----------------------------------------------------------------------------
  18. * History:
  19. * V1.20 Added USB_ClearEPBuf
  20. * V1.00 Initial Version
  21. *----------------------------------------------------------------------------*/
  22. #ifndef __USBHW_H__
  23. #define __USBHW_H__
  24. extern "C" {
  25. #include "lpc_types.h"
  26. }
  27. /* USB RAM Definitions */
  28. #define USB_RAM_ADR 0x2007C000 /* USB RAM Start Address */
  29. #define USB_RAM_SZ 0x00004000 /* USB RAM Size (16kB) */
  30. /* DMA Endpoint Descriptors */
  31. #define DD_NISO_CNT 16 /* Non-Iso EP DMA Descr. Count (max. 32) */
  32. #define DD_ISO_CNT 8 /* Iso EP DMA Descriptor Count (max. 32) */
  33. #define DD_NISO_SZ (DD_NISO_CNT * 16) /* Non-Iso DMA Descr. Size */
  34. #define DD_ISO_SZ (DD_ISO_CNT * 20) /* Iso DMA Descriptor Size */
  35. #define DD_NISO_ADR (USB_RAM_ADR + 128) /* Non-Iso DMA Descr. Address */
  36. #define DD_ISO_ADR (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
  37. #define DD_SZ (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
  38. /* DMA Buffer Memory Definitions */
  39. #define DMA_BUF_ADR (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
  40. #define DMA_BUF_SZ (USB_RAM_SZ - DD_SZ) /* DMA Buffer Size */
  41. /* USB Error Codes */
  42. #define USB_ERR_PID 0x0001 /* PID Error */
  43. #define USB_ERR_UEPKT 0x0002 /* Unexpected Packet */
  44. #define USB_ERR_DCRC 0x0004 /* Data CRC Error */
  45. #define USB_ERR_TIMOUT 0x0008 /* Bus Time-out Error */
  46. #define USB_ERR_EOP 0x0010 /* End of Packet Error */
  47. #define USB_ERR_B_OVRN 0x0020 /* Buffer Overrun */
  48. #define USB_ERR_BTSTF 0x0040 /* Bit Stuff Error */
  49. #define USB_ERR_TGL 0x0080 /* Toggle Bit Error */
  50. /* USB DMA Status Codes */
  51. #define USB_DMA_INVALID 0x0000 /* DMA Invalid - Not Configured */
  52. #define USB_DMA_IDLE 0x0001 /* DMA Idle - Waiting for Trigger */
  53. #define USB_DMA_BUSY 0x0002 /* DMA Busy - Transfer in progress */
  54. #define USB_DMA_DONE 0x0003 /* DMA Transfer Done (no Errors)*/
  55. #define USB_DMA_OVER_RUN 0x0004 /* Data Over Run */
  56. #define USB_DMA_UNDER_RUN 0x0005 /* Data Under Run (Short Packet) */
  57. #define USB_DMA_ERROR 0x0006 /* Error */
  58. #define USB_DMA_UNKNOWN 0xFFFF /* Unknown State */
  59. /* USB DMA Descriptor */
  60. typedef struct _USB_DMA_DESCRIPTOR {
  61. uint32_t BufAdr; /* DMA Buffer Address */
  62. uint16_t BufLen; /* DMA Buffer Length */
  63. uint16_t MaxSize; /* Maximum Packet Size */
  64. uint32_t InfoAdr; /* Packet Info Memory Address */
  65. union { /* DMA Configuration */
  66. struct {
  67. uint32_t Link : 1; /* Link to existing Descriptors */
  68. uint32_t IsoEP : 1; /* Isonchronous Endpoint */
  69. uint32_t ATLE : 1; /* ATLE (Auto Transfer Length Extract) */
  70. uint32_t Rsrvd : 5; /* Reserved */
  71. uint32_t LenPos : 8; /* Length Position (ATLE) */
  72. } Type;
  73. uint32_t Val;
  74. } Cfg;
  75. } USB_DMA_DESCRIPTOR;
  76. extern "C" {
  77. /* USB Hardware Functions */
  78. extern void USB_Init (void);
  79. extern void USB_Connect (uint32_t con);
  80. extern void USB_Reset (void);
  81. extern void USB_Suspend (void);
  82. extern void USB_Resume (void);
  83. extern void USB_WakeUp (void);
  84. extern void USB_WakeUpCfg (uint32_t cfg);
  85. extern void USB_SetAddress (uint32_t adr);
  86. extern void USB_Configure (uint32_t cfg);
  87. extern void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD);
  88. extern void USB_DirCtrlEP (uint32_t dir);
  89. extern void USB_EnableEP (uint32_t EPNum);
  90. extern void USB_DisableEP (uint32_t EPNum);
  91. extern void USB_ResetEP (uint32_t EPNum);
  92. extern void USB_SetStallEP (uint32_t EPNum);
  93. extern void USB_ClrStallEP (uint32_t EPNum);
  94. extern void USB_ClearEPBuf (uint32_t EPNum);
  95. extern uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData);
  96. extern uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
  97. extern uint32_t USB_DMA_Setup (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
  98. extern void USB_DMA_Enable (uint32_t EPNum);
  99. extern void USB_DMA_Disable(uint32_t EPNum);
  100. extern uint32_t USB_DMA_Status (uint32_t EPNum);
  101. extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
  102. extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
  103. extern uint32_t USB_GetFrame (void);
  104. extern void USB_IRQHandler (void);
  105. }
  106. #endif /* __USBHW_H__ */