root/Examples_CP-JR_ARM7_LPC2368/ETT_LPC2368_Examples/USB_DEMO/USBHID/usbhw.h

Revision 8, 4.7 kB (checked in by phil, 16 years ago)

Added Examples etc. from CD

Line 
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.10
7  *----------------------------------------------------------------------------
8  *      This file is part of the uVision/ARM development tools.
9  *      This software may only be used under the terms of a valid, current,
10  *      end user licence from KEIL for a compatible version of KEIL software
11  *      development tools. Nothing else gives you the right to use it.
12  *
13  *      Copyright (c) 2005-2006 Keil Software.
14  *---------------------------------------------------------------------------*/
15
16 #ifndef __USBHW_H__
17 #define __USBHW_H__
18
19
20 /* USB RAM Definitions */
21 #define USB_RAM_ADR     0x7FD00000  /* USB RAM Start Address */
22 #define USB_RAM_SZ      0x00002000  /* USB RAM Size (8kB) */
23
24 /* DMA Endpoint Descriptors */
25 #define DD_NISO_CNT             16  /* Non-Iso EP DMA Descr. Count (max. 32) */
26 #define DD_ISO_CNT               8  /* Iso EP DMA Descriptor Count (max. 32) */
27 #define DD_NISO_SZ    (DD_NISO_CNT * 16)    /* Non-Iso DMA Descr. Size */
28 #define DD_ISO_SZ     (DD_ISO_CNT  * 20)    /* Iso DMA Descriptor Size */
29 #define DD_NISO_ADR   (USB_RAM_ADR + 128)   /* Non-Iso DMA Descr. Address */
30 #define DD_ISO_ADR    (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
31 #define DD_SZ                 (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
32
33 /* DMA Buffer Memory Definitions */
34 #define DMA_BUF_ADR   (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
35 #define DMA_BUF_SZ    (USB_RAM_SZ  - DD_SZ) /* DMA Buffer Size */
36
37 /* USB Error Codes */
38 #define USB_ERR_PID         0x0001  /* PID Error */
39 #define USB_ERR_UEPKT       0x0002  /* Unexpected Packet */
40 #define USB_ERR_DCRC        0x0004  /* Data CRC Error */
41 #define USB_ERR_TIMOUT      0x0008  /* Bus Time-out Error */
42 #define USB_ERR_EOP         0x0010  /* End of Packet Error */
43 #define USB_ERR_B_OVRN      0x0020  /* Buffer Overrun */
44 #define USB_ERR_BTSTF       0x0040  /* Bit Stuff Error */
45 #define USB_ERR_TGL         0x0080  /* Toggle Bit Error */
46
47 /* USB DMA Status Codes */
48 #define USB_DMA_INVALID     0x0000  /* DMA Invalid - Not Configured */
49 #define USB_DMA_IDLE        0x0001  /* DMA Idle - Waiting for Trigger */
50 #define USB_DMA_BUSY        0x0002  /* DMA Busy - Transfer in progress */
51 #define USB_DMA_DONE        0x0003  /* DMA Transfer Done (no Errors)*/
52 #define USB_DMA_OVER_RUN    0x0004  /* Data Over Run */
53 #define USB_DMA_UNDER_RUN   0x0005  /* Data Under Run (Short Packet) */
54 #define USB_DMA_ERROR       0x0006  /* Error */
55 #define USB_DMA_UNKNOWN     0xFFFF  /* Unknown State */
56
57 /* USB DMA Descriptor */
58 typedef struct _USB_DMA_DESCRIPTOR {
59   DWORD BufAdr;                     /* DMA Buffer Address */
60   WORD  BufLen;                     /* DMA Buffer Length */
61   WORD  MaxSize;                    /* Maximum Packet Size */
62   DWORD InfoAdr;                    /* Packet Info Memory Address */
63   union {                           /* DMA Configuration */
64     struct {
65       DWORD Link   : 1;             /* Link to existing Descriptors */
66       DWORD IsoEP  : 1;             /* Isonchronous Endpoint */
67       DWORD ATLE   : 1;             /* ATLE (Auto Transfer Length Extract) */
68       DWORD Rsrvd  : 5;             /* Reserved */
69       DWORD LenPos : 8;             /* Length Position (ATLE) */
70     } Type;
71     DWORD Val;
72   } Cfg;
73 } USB_DMA_DESCRIPTOR;
74
75 /* USB Hardware Functions */
76 extern void  USB_Init       (void);
77 extern void  USB_Connect    (BOOL  con);
78 extern void  USB_Reset      (void);
79 extern void  USB_Suspend    (void);
80 extern void  USB_Resume     (void);
81 extern void  USB_WakeUp     (void);
82 extern void  USB_WakeUpCfg  (BOOL  cfg);
83 extern void  USB_SetAddress (DWORD adr);
84 extern void  USB_Configure  (BOOL  cfg);
85 extern void  USB_ConfigEP   (USB_ENDPOINT_DESCRIPTOR *pEPD);
86 extern void  USB_DirCtrlEP  (DWORD dir);
87 extern void  USB_EnableEP   (DWORD EPNum);
88 extern void  USB_DisableEP  (DWORD EPNum);
89 extern void  USB_ResetEP    (DWORD EPNum);
90 extern void  USB_SetStallEP (DWORD EPNum);
91 extern void  USB_ClrStallEP (DWORD EPNum);
92 extern DWORD USB_ReadEP     (DWORD EPNum, BYTE *pData);
93 extern DWORD USB_WriteEP    (DWORD EPNum, BYTE *pData, DWORD cnt);
94 extern BOOL  USB_DMA_Setup  (DWORD EPNum, USB_DMA_DESCRIPTOR *pDD);
95 extern void  USB_DMA_Enable (DWORD EPNum);
96 extern void  USB_DMA_Disable(DWORD EPNum);
97 extern DWORD USB_DMA_Status (DWORD EPNum);
98 extern DWORD USB_DMA_BufAdr (DWORD EPNum);
99 extern DWORD USB_DMA_BufCnt (DWORD EPNum);
100 extern DWORD USB_GetFrame   (void);
101 extern void  USB_ISR        (void) __irq;
102
103
104 #endif  /* __USBHW_H__ */
Note: See TracBrowser for help on using the browser.