Fix USB, DOS line endings, integrate and reorganize project
[rapper.git] / new_cmsis / usb / hw.h
similarity index 97%
rename from new_cmsis/usb/usbhw.h
rename to new_cmsis/usb/hw.h
index e3bec8d..7dadecf 100755 (executable)
-/*----------------------------------------------------------------------------\r
- *      U S B  -  K e r n e l\r
- *----------------------------------------------------------------------------\r
- * Name:    usbhw.h\r
- * Purpose: USB Hardware Layer Definitions\r
- * Version: V1.20\r
- *----------------------------------------------------------------------------\r
- *      This software is supplied "AS IS" without any warranties, express,\r
- *      implied or statutory, including but not limited to the implied\r
- *      warranties of fitness for purpose, satisfactory quality and\r
- *      noninfringement. Keil extends you a royalty-free right to reproduce\r
- *      and distribute executable files created using this software for use\r
- *      on NXP Semiconductors LPC family microcontroller devices only. Nothing\r
- *      else gives you the right to use this software.\r
- *\r
- * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.\r
- *----------------------------------------------------------------------------\r
- * History:\r
- *          V1.20 Added USB_ClearEPBuf\r
- *          V1.00 Initial Version\r
- *----------------------------------------------------------------------------*/\r
-\r
-#ifndef __USBHW_H__\r
-#define __USBHW_H__\r
-#include "lpc_types.h"\r
-\r
-/* USB RAM Definitions */\r
-#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */\r
-#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */\r
-\r
-/* DMA Endpoint Descriptors */\r
-#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */\r
-#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */\r
-#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */\r
-#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */\r
-#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */\r
-#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */\r
-#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */\r
-\r
-/* DMA Buffer Memory Definitions */\r
-#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */\r
-#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */\r
-\r
-/* USB Error Codes */\r
-#define USB_ERR_PID         0x0001  /* PID Error */\r
-#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */\r
-#define USB_ERR_DCRC        0x0004  /* Data CRC Error */\r
-#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */\r
-#define USB_ERR_EOP         0x0010  /* End of Packet Error */\r
-#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */\r
-#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */\r
-#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */\r
-\r
-/* USB DMA Status Codes */\r
-#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */\r
-#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */\r
-#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */\r
-#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/\r
-#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */\r
-#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */\r
-#define USB_DMA_ERROR       0x0006  /* Error */\r
-#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */\r
-\r
-/* USB DMA Descriptor */\r
-typedef struct _USB_DMA_DESCRIPTOR {\r
-  uint32_t BufAdr;                     /* DMA Buffer Address */\r
-  uint16_t  BufLen;                     /* DMA Buffer Length */\r
-  uint16_t  MaxSize;                    /* Maximum Packet Size */\r
-  uint32_t InfoAdr;                    /* Packet Info Memory Address */\r
-  union {                           /* DMA Configuration */\r
-    struct {\r
-      uint32_t Link   : 1;             /* Link to existing Descriptors */\r
-      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */\r
-      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */\r
-      uint32_t Rsrvd  : 5;             /* Reserved */\r
-      uint32_t LenPos : 8;             /* Length Position (ATLE) */\r
-    } Type;\r
-    uint32_t Val;\r
-  } Cfg;\r
-} USB_DMA_DESCRIPTOR;\r
-\r
-/* USB Hardware Functions */\r
-extern void  USB_Init       (void);\r
-extern void  USB_Connect    (uint32_t  con);\r
-extern void  USB_Reset      (void);\r
-extern void  USB_Suspend    (void);\r
-extern void  USB_Resume     (void);\r
-extern void  USB_WakeUp     (void);\r
-extern void  USB_WakeUpCfg  (uint32_t  cfg);\r
-extern void  USB_SetAddress (uint32_t adr);\r
-extern void  USB_Configure  (uint32_t  cfg);\r
-extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);\r
-extern void  USB_DirCtrlEP  (uint32_t dir);\r
-extern void  USB_EnableEP   (uint32_t EPNum);\r
-extern void  USB_DisableEP  (uint32_t EPNum);\r
-extern void  USB_ResetEP    (uint32_t EPNum);\r
-extern void  USB_SetStallEP (uint32_t EPNum);\r
-extern void  USB_ClrStallEP (uint32_t EPNum);\r
-extern void USB_ClearEPBuf  (uint32_t  EPNum);\r
-extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);\r
-extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);\r
-extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);\r
-extern void  USB_DMA_Enable (uint32_t EPNum);\r
-extern void  USB_DMA_Disable(uint32_t EPNum);\r
-extern uint32_t USB_DMA_Status (uint32_t EPNum);\r
-extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);\r
-extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);\r
-extern uint32_t USB_GetFrame   (void);\r
-extern void  USB_IRQHandler (void);\r
-\r
-\r
-#endif  /* __USBHW_H__ */\r
+/*----------------------------------------------------------------------------
+ *      U S B  -  K e r n e l
+ *----------------------------------------------------------------------------
+ * Name:    usbhw.h
+ * Purpose: USB Hardware Layer Definitions
+ * Version: V1.20
+ *----------------------------------------------------------------------------
+ *      This software is supplied "AS IS" without any warranties, express,
+ *      implied or statutory, including but not limited to the implied
+ *      warranties of fitness for purpose, satisfactory quality and
+ *      noninfringement. Keil extends you a royalty-free right to reproduce
+ *      and distribute executable files created using this software for use
+ *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
+ *      else gives you the right to use this software.
+ *
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------
+ * History:
+ *          V1.20 Added USB_ClearEPBuf
+ *          V1.00 Initial Version
+ *----------------------------------------------------------------------------*/
+
+#ifndef __USBHW_H__
+#define __USBHW_H__
+#include "lpc_types.h"
+
+/* USB RAM Definitions */
+#define USB_RAM_ADR     0x20080000  /* USB RAM Start Address */
+#define USB_RAM_SZ      0x00004000  /* USB RAM Size (4kB) */
+
+/* DMA Endpoint Descriptors */
+#define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
+#define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
+#define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
+#define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
+#define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
+#define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
+#define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
+
+/* DMA Buffer Memory Definitions */
+#define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
+#define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
+
+/* USB Error Codes */
+#define USB_ERR_PID         0x0001  /* PID Error */
+#define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
+#define USB_ERR_DCRC        0x0004  /* Data CRC Error */
+#define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
+#define USB_ERR_EOP         0x0010  /* End of Packet Error */
+#define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
+#define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
+#define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
+
+/* USB DMA Status Codes */
+#define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
+#define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
+#define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
+#define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
+#define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
+#define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
+#define USB_DMA_ERROR       0x0006  /* Error */
+#define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
+
+/* USB DMA Descriptor */
+typedef struct _USB_DMA_DESCRIPTOR {
+  uint32_t BufAdr;                     /* DMA Buffer Address */
+  uint16_t  BufLen;                     /* DMA Buffer Length */
+  uint16_t  MaxSize;                    /* Maximum Packet Size */
+  uint32_t InfoAdr;                    /* Packet Info Memory Address */
+  union {                           /* DMA Configuration */
+    struct {
+      uint32_t Link   : 1;             /* Link to existing Descriptors */
+      uint32_t IsoEP  : 1;             /* Isonchronous Endpoint */
+      uint32_t ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
+      uint32_t Rsrvd  : 5;             /* Reserved */
+      uint32_t LenPos : 8;             /* Length Position (ATLE) */
+    } Type;
+    uint32_t Val;
+  } Cfg;
+} USB_DMA_DESCRIPTOR;
+
+/* USB Hardware Functions */
+extern void  USB_Init       (void);
+extern void  USB_Connect    (uint32_t  con);
+extern void  USB_Reset      (void);
+extern void  USB_Suspend    (void);
+extern void  USB_Resume     (void);
+extern void  USB_WakeUp     (void);
+extern void  USB_WakeUpCfg  (uint32_t  cfg);
+extern void  USB_SetAddress (uint32_t adr);
+extern void  USB_Configure  (uint32_t  cfg);
+extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
+extern void  USB_DirCtrlEP  (uint32_t dir);
+extern void  USB_EnableEP   (uint32_t EPNum);
+extern void  USB_DisableEP  (uint32_t EPNum);
+extern void  USB_ResetEP    (uint32_t EPNum);
+extern void  USB_SetStallEP (uint32_t EPNum);
+extern void  USB_ClrStallEP (uint32_t EPNum);
+extern void USB_ClearEPBuf  (uint32_t  EPNum);
+extern uint32_t USB_ReadEP     (uint32_t EPNum, uint8_t *pData);
+extern uint32_t USB_WriteEP    (uint32_t EPNum, uint8_t *pData, uint32_t cnt);
+extern uint32_t  USB_DMA_Setup  (uint32_t EPNum, USB_DMA_DESCRIPTOR *pDD);
+extern void  USB_DMA_Enable (uint32_t EPNum);
+extern void  USB_DMA_Disable(uint32_t EPNum);
+extern uint32_t USB_DMA_Status (uint32_t EPNum);
+extern uint32_t USB_DMA_BufAdr (uint32_t EPNum);
+extern uint32_t USB_DMA_BufCnt (uint32_t EPNum);
+extern uint32_t USB_GetFrame   (void);
+extern void  USB_IRQHandler (void);
+
+
+#endif  /* __USBHW_H__ */