USBD ROM Stack  1.0
ROM based USB device stack
mw_usbd/mw_usbd_hw.h
Go to the documentation of this file.
00001 /***********************************************************************
00002 * $Id:: mw_usbd_hw.h 331 2012-08-09 18:54:34Z usb10131                        $
00003 *
00004 * Project: USB device ROM Stack
00005 *
00006 * Description:
00007 *     USB Hardware Function prototypes.
00008 *
00009 ***********************************************************************
00010 *   Copyright(C) 2011, NXP Semiconductor
00011 *   All rights reserved.
00012 *
00013 * Software that is described herein is for illustrative purposes only
00014 * which provides customers with programming information regarding the
00015 * products. This software is supplied "AS IS" without any warranties.
00016 * NXP Semiconductors assumes no responsibility or liability for the
00017 * use of the software, conveys no license or title under any patent,
00018 * copyright, or mask work right to the product. NXP Semiconductors
00019 * reserves the right to make changes in the software without
00020 * notification. NXP Semiconductors also make no representation or
00021 * warranty that such application will be suitable for the specified
00022 * use without further testing or modification.
00023 **********************************************************************/
00024 #ifndef __USBHW_H__
00025 #define __USBHW_H__
00026 
00027 #include "error.h"
00028 #include "mw_usbd.h"
00029 #include "mw_usbd_core.h"
00030 
00048 enum USBD_EVENT_T {
00049   USB_EVT_SETUP =1,    
00050   USB_EVT_OUT,         
00051   USB_EVT_IN,          
00052   USB_EVT_OUT_NAK,     
00053   USB_EVT_IN_NAK,      
00054   USB_EVT_OUT_STALL,   
00055   USB_EVT_IN_STALL,    
00056   USB_EVT_OUT_DMA_EOT, 
00057   USB_EVT_IN_DMA_EOT,  
00058   USB_EVT_OUT_DMA_NDR, 
00059   USB_EVT_IN_DMA_NDR,  
00060   USB_EVT_OUT_DMA_ERR, 
00061   USB_EVT_IN_DMA_ERR,  
00062   USB_EVT_RESET,       
00063   USB_EVT_SOF,         
00064   USB_EVT_DEV_STATE,   
00065   USB_EVT_DEV_ERROR   
00066 };
00067 
00075 typedef struct USBD_HW_API
00076 {
00088   uint32_t (*GetMemSize)(USBD_API_INIT_PARAM_T* param);
00089   
00106   ErrorCode_t (*Init)(USBD_HANDLE_T* phUsb, USB_CORE_DESCS_T* pDesc, USBD_API_INIT_PARAM_T* param);
00107   
00121   void (*Connect)(USBD_HANDLE_T hUsb, uint32_t con);
00122   
00134   void (*ISR)(USBD_HANDLE_T hUsb);
00135 
00146   void  (*Reset)(USBD_HANDLE_T hUsb);
00147   
00159   void  (*ForceFullSpeed )(USBD_HANDLE_T hUsb, uint32_t cfg);
00160   
00178   void  (*WakeUpCfg)(USBD_HANDLE_T hUsb, uint32_t  cfg);
00179   
00195   void  (*SetAddress)(USBD_HANDLE_T hUsb, uint32_t adr);
00196 
00211   void  (*Configure)(USBD_HANDLE_T hUsb, uint32_t  cfg);
00212 
00228   void  (*ConfigEP)(USBD_HANDLE_T hUsb, USB_ENDPOINT_DESCRIPTOR *pEPD);
00229 
00244   void  (*DirCtrlEP)(USBD_HANDLE_T hUsb, uint32_t dir);
00245 
00256   void  (*EnableEP)(USBD_HANDLE_T hUsb, uint32_t EPNum);
00257 
00268   void  (*DisableEP)(USBD_HANDLE_T hUsb, uint32_t EPNum);
00269 
00280   void  (*ResetEP)(USBD_HANDLE_T hUsb, uint32_t EPNum);
00281 
00292   void  (*SetStallEP)(USBD_HANDLE_T hUsb, uint32_t EPNum);
00293 
00304   void  (*ClrStallEP)(USBD_HANDLE_T hUsb, uint32_t EPNum);
00305 
00322   ErrorCode_t (*SetTestMode)(USBD_HANDLE_T hUsb, uint8_t mode); 
00323 
00336   uint32_t (*ReadEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData);
00337 
00352   uint32_t (*ReadReqEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t len);
00353 
00366   uint32_t (*ReadSetupPkt)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t *pData);
00367 
00381   uint32_t (*WriteEP)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t cnt);
00382 
00396   void  (*WakeUp)(USBD_HANDLE_T hUsb);
00397 
00413   ErrorCode_t  (*EnableEvent)(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t event_type, uint32_t enable);
00414 
00415 } USBD_HW_API_T;
00416 
00417 /*-----------------------------------------------------------------------------
00418  *  Private functions & structures prototypes used by stack internally
00419  *-----------------------------------------------------------------------------*/
00422 /* Driver functions */
00423 uint32_t hwUSB_GetMemSize(USBD_API_INIT_PARAM_T* param);
00424 ErrorCode_t hwUSB_Init(USBD_HANDLE_T* phUsb, USB_CORE_DESCS_T* pDesc, USBD_API_INIT_PARAM_T* param);
00425 void hwUSB_Connect(USBD_HANDLE_T hUsb, uint32_t con);
00426 void hwUSB_ISR(USBD_HANDLE_T hUsb);
00427 
00428 /* USB Hardware Functions */
00429 extern void  hwUSB_Reset(USBD_HANDLE_T hUsb);
00430 extern void  hwUSB_ForceFullSpeed (USBD_HANDLE_T hUsb, uint32_t con);
00431 extern void  hwUSB_WakeUpCfg(USBD_HANDLE_T hUsb, uint32_t  cfg);
00432 extern void  hwUSB_SetAddress(USBD_HANDLE_T hUsb, uint32_t adr);
00433 extern void  hwUSB_Configure(USBD_HANDLE_T hUsb, uint32_t  cfg);
00434 extern void  hwUSB_ConfigEP(USBD_HANDLE_T hUsb, USB_ENDPOINT_DESCRIPTOR *pEPD);
00435 extern void  hwUSB_DirCtrlEP(USBD_HANDLE_T hUsb, uint32_t dir);
00436 extern void  hwUSB_EnableEP(USBD_HANDLE_T hUsb, uint32_t EPNum);
00437 extern void  hwUSB_DisableEP(USBD_HANDLE_T hUsb, uint32_t EPNum);
00438 extern void  hwUSB_ResetEP(USBD_HANDLE_T hUsb, uint32_t EPNum);
00439 extern void  hwUSB_SetStallEP(USBD_HANDLE_T hUsb, uint32_t EPNum);
00440 extern void  hwUSB_ClrStallEP(USBD_HANDLE_T hUsb, uint32_t EPNum);
00441 extern ErrorCode_t hwUSB_SetTestMode(USBD_HANDLE_T hUsb, uint8_t mode); /* for FS only devices return ERR_USBD_INVALID_REQ */
00442 extern uint32_t hwUSB_ReadEP(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData);
00443 extern uint32_t hwUSB_ReadReqEP(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t len);
00444 extern uint32_t hwUSB_ReadSetupPkt(USBD_HANDLE_T hUsb, uint32_t, uint32_t *);
00445 extern uint32_t hwUSB_WriteEP(USBD_HANDLE_T hUsb, uint32_t EPNum, uint8_t *pData, uint32_t cnt);
00446 
00447 /* generate resume signaling on the bus */
00448 extern void  hwUSB_WakeUp(USBD_HANDLE_T hUsb);
00449 extern ErrorCode_t  hwUSB_EnableEvent(USBD_HANDLE_T hUsb, uint32_t EPNum, uint32_t event_type, uint32_t enable);
00450 /* TODO implement following routines
00451 - function to program TD and queue them to ep Qh
00452 */
00453 
00457 #endif  /* __USBHW_H__ */