- Main Page
- Classes
- Files
- Related Pages

- File List
- File Members

# usbhw_lpc.h

    00001 /*
    00002         LPCUSB, an USB device driver for LPC microcontrollers
    00003         Copyright (C) 2006 Bertrik Sikken (bertrik@sikken.nl)
    00004
    00005         Redistribution and use in source and binary forms, with or without
    00006         modification, are permitted provided that the following conditions are met:
    00007
    00008         1. Redistributions of source code must retain the above copyright
    00009            notice, this list of conditions and the following disclaimer.
    00010         2. Redistributions in binary form must reproduce the above copyright
    00011            notice, this list of conditions and the following disclaimer in the
    00012            documentation and/or other materials provided with the distribution.
    00013         3. The name of the author may not be used to endorse or promote products
    00014            derived from this software without specific prior written permission.
    00015
    00016         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    00017         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00018         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    00019         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    00020         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    00021         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    00022         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    00023         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00024         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00025         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00026 */
    00027
    00028
    00036 /* Common LPC2148 definitions, related to USB */
    00037 #define PCONP                   *(volatile unsigned int *)0xE01FC0C4
    00038 #define PLL1CON                 *(volatile unsigned int *)0xE01FC0A0
    00039 #define PLL1CFG                 *(volatile unsigned int *)0xE01FC0A4
    00040 #define PLL1STAT                *(volatile unsigned int *)0xE01FC0A8
    00041 #define PLL1FEED                *(volatile unsigned int *)0xE01FC0AC
    00042
    00043 #define PINSEL0                 *(volatile unsigned int *)0xE002C000
    00044 #define PINSEL1                 *(volatile unsigned int *)0xE002C004
    00045 #define IOPIN0                  *(volatile unsigned int *)0xE0028000
    00046 #define IOSET0                  *(volatile unsigned int *)0xE0028004
    00047 #define IODIR0                  *(volatile unsigned int *)0xE0028008
    00048 #define IOCLR0                  *(volatile unsigned int *)0xE002800C
    00049
    00050 /* USB register definitions */
    00051 #define USBIntSt                *(volatile unsigned int *)0xE01FC1C0
    00052
    00053 #define USBDevIntSt             *(volatile unsigned int *)0xE0090000
    00054 #define USBDevIntEn             *(volatile unsigned int *)0xE0090004
    00055 #define USBDevIntClr    *(volatile unsigned int *)0xE0090008
    00056 #define USBDevIntSet    *(volatile unsigned int *)0xE009000C
    00057 #define USBDevIntPri    *(volatile unsigned int *)0xE009002C
    00058
    00059 #define USBEpIntSt              *(volatile unsigned int *)0xE0090030
    00060 #define USBEpIntEn              *(volatile unsigned int *)0xE0090034
    00061 #define USBEpIntClr             *(volatile unsigned int *)0xE0090038
    00062 #define USBEpIntSet             *(volatile unsigned int *)0xE009003C
    00063 #define USBEpIntPri             *(volatile unsigned int *)0xE0090040
    00064
    00065 #define USBReEP                 *(volatile unsigned int *)0xE0090044
    00066 #define USBEpInd                *(volatile unsigned int *)0xE0090048
    00067 #define USBMaxPSize             *(volatile unsigned int *)0xE009004C
    00068
    00069 #define USBRxData               *(volatile unsigned int *)0xE0090018
    00070 #define USBRxPLen               *(volatile unsigned int *)0xE0090020
    00071 #define USBTxData               *(volatile unsigned int *)0xE009001C
    00072 #define USBTxPLen               *(volatile unsigned int *)0xE0090024
    00073 #define USBCtrl                 *(volatile unsigned int *)0xE0090028
    00074
    00075 #define USBCmdCode              *(volatile unsigned int *)0xE0090010
    00076 #define USBCmdData              *(volatile unsigned int *)0xE0090014
    00077
    00078 /* USBIntSt bits */
    00079 #define USB_INT_REQ_LP                          (1<<0)
    00080 #define USB_INT_REQ_HP                          (1<<1)
    00081 #define USB_INT_REQ_DMA                         (1<<2)
    00082 #define USB_need_clock                          (1<<8)
    00083 #define EN_USB_BITS                                     (1<<31)
    00084
    00085 /* USBDevInt... bits */
    00086 #define FRAME                                           (1<<0)
    00087 #define EP_FAST                                         (1<<1)
    00088 #define EP_SLOW                                         (1<<2)
    00089 #define DEV_STAT                                        (1<<3)
    00090 #define CCEMTY                                          (1<<4)
    00091 #define CDFULL                                          (1<<5)
    00092 #define RxENDPKT                                        (1<<6)
    00093 #define TxENDPKT                                        (1<<7)
    00094 #define EP_RLZED                                        (1<<8)
    00095 #define ERR_INT                                         (1<<9)
    00096
    00097 /* USBRxPLen bits */
    00098 #define PKT_LNGTH                                       (1<<0)
    00099 #define PKT_LNGTH_MASK                          0x3FF
    00100 #define DV                                                      (1<<10)
    00101 #define PKT_RDY                                         (1<<11)
    00102
    00103 /* USBCtrl bits */
    00104 #define RD_EN                                           (1<<0)
    00105 #define WR_EN                                           (1<<1)
    00106 #define LOG_ENDPOINT                            (1<<2)
    00107
    00108 /* protocol engine command codes */
    00109         /* device commands */
    00110 #define CMD_DEV_SET_ADDRESS                     0xD0
    00111 #define CMD_DEV_CONFIG                          0xD8
    00112 #define CMD_DEV_SET_MODE                        0xF3
    00113 #define CMD_DEV_READ_CUR_FRAME_NR       0xF5
    00114 #define CMD_DEV_READ_TEST_REG           0xFD
    00115 #define CMD_DEV_STATUS                          0xFE            /* read/write */
    00116 #define CMD_DEV_GET_ERROR_CODE          0xFF
    00117 #define CMD_DEV_READ_ERROR_STATUS       0xFB
    00118         /* endpoint commands */
    00119 #define CMD_EP_SELECT                           0x00
    00120 #define CMD_EP_SELECT_CLEAR                     0x40
    00121 #define CMD_EP_SET_STATUS                       0x40
    00122 #define CMD_EP_CLEAR_BUFFER                     0xF2
    00123 #define CMD_EP_VALIDATE_BUFFER          0xFA
    00124
    00125 /* set address command */
    00126 #define DEV_ADDR                                        (1<<0)
    00127 #define DEV_EN                                          (1<<7)
    00128
    00129 /* configure device command */
    00130 #define CONF_DEVICE                                     (1<<0)
    00131
    00132 /* set mode command */
    00133 #define AP_CLK                                          (1<<0)
    00134 #define INAK_CI                                         (1<<1)
    00135 #define INAK_CO                                         (1<<2)
    00136 #define INAK_II                                         (1<<3)
    00137 #define INAK_IO                                         (1<<4)
    00138 #define INAK_BI                                         (1<<5)
    00139 #define INAK_BO                                         (1<<6)
    00140
    00141 /* set get device status command */
    00142 #define CON                                                     (1<<0)
    00143 #define CON_CH                                          (1<<1)
    00144 #define SUS                                                     (1<<2)
    00145 #define SUS_CH                                          (1<<3)
    00146 #define RST                                                     (1<<4)
    00147
    00148 /* get error code command */
    00149 // ...
    00150
    00151 /* Select Endpoint command read bits */
    00152 #define EPSTAT_FE                                       (1<<0)
    00153 #define EPSTAT_ST                                       (1<<1)
    00154 #define EPSTAT_STP                                      (1<<2)
    00155 #define EPSTAT_PO                                       (1<<3)
    00156 #define EPSTAT_EPN                                      (1<<4)
    00157 #define EPSTAT_B1FULL                           (1<<5)
    00158 #define EPSTAT_B2FULL                           (1<<6)
    00159
    00160 /* CMD_EP_SET_STATUS command */
    00161 #define EP_ST                                           (1<<0)
    00162 #define EP_DA                                           (1<<5)
    00163 #define EP_RF_MO                                        (1<<6)
    00164 #define EP_CND_ST                                       (1<<7)
    00165
    00166 /* read error status command */
    00167 #define PID_ERR                                         (1<<0)
    00168 #define UEPKT                                           (1<<1)
    00169 #define DCRC                                            (1<<2)
    00170 #define TIMEOUT                                         (1<<3)
    00171 #define EOP                                                     (1<<4)
    00172 #define B_OVRN                                          (1<<5)
    00173 #define BTSTF                                           (1<<6)
    00174 #define TGL_ERR                                         (1<<7)
    00175
    00176
    00177
    00178
    00179
    00180
    00181
    00182