These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

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