Port of Keils USBCDC example, compiles ok. Gets stuck at init

Dependencies:   mbed

Committer:
tecnosys
Date:
Mon Jul 05 10:16:57 2010 +0000
Revision:
0:0b777ff85deb

        

Who changed what in which revision?

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