SAMV71 Xplained Ultra Software Package 1.3

usbhs.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2010, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /** \file */
00031 
00032 #ifndef USBHS_H
00033 #define USBHS_H
00034 /** addtogroup usbd_hal
00035  *@{
00036  */
00037 
00038 #define  USB_DEVICE_HS_SUPPORT
00039 
00040 //! Control endpoint size
00041 #define  USB_DEVICE_EP_CTRL_SIZE       64
00042 
00043 /** Indicates chip has an UDP High Speed. */
00044 #define CHIP_USB_UDP
00045 
00046 /** Indicates chip has an internal pull-up. */
00047 #define CHIP_USB_PULLUP_INTERNAL
00048 
00049 /** Number of USB endpoints */
00050 #define CHIP_USB_NUMENDPOINTS   10
00051 
00052 /** Endpoints max packet size */
00053 #define CHIP_USB_ENDPOINTS_MAXPACKETSIZE(ep) \
00054    ((ep == 0) ? 64 : 1024)
00055 
00056 /** Endpoints Number of Bank */
00057 #define CHIP_USB_ENDPOINTS_BANKS(ep)            ((ep==0)?1:((ep<=2)?3:2))
00058      
00059      
00060 #define CHIP_USB_ENDPOINTS_HBW(ep)               ((((ep)>=1) &&((ep)<=2))?true:false)
00061 
00062 /** Endpoints DMA support */
00063 #define CHIP_USB_ENDPOINTS_DMA(ep)              ((((ep)>=1)&&((ep)<=7))?true:false)
00064     
00065 /** Max size of the FMA FIFO */
00066 #define DMA_MAX_FIFO_SIZE     (65536/1)
00067 /** fifo space size in DW */
00068 #define EPT_VIRTUAL_SIZE      16384     
00069          
00070      
00071      //! @name USBHS Host IP properties
00072 //!
00073 //! @{
00074 //! Get maximal number of endpoints
00075 #define uhd_get_pipe_max_nbr()                (9)
00076 #define USBHS_EPT_NUM                        (uhd_get_pipe_max_nbr()+1)
00077   //! Get maximal number of banks of endpoints
00078 #define uhd_get_pipe_bank_max_nbr(ep)         ((ep == 0) ? 1 : (( ep <= 2) ? 3 : 2))
00079   //! Get maximal size of endpoint (3X, 1024/64)
00080 #define uhd_get_pipe_size_max(ep)             (((ep) == 0) ? 64 : 1024)
00081   //! Get DMA support of endpoints
00082 #define Is_uhd_pipe_dma_supported(ep)         ((((ep) >= 1) && ((ep) <= 6)) ? true : false)
00083   //! Get High Band Width support of endpoints
00084 #define Is_uhd_pipe_high_bw_supported(ep)     (((ep) >= 2) ? true : false)
00085 //! @}
00086 
00087 typedef enum
00088 {
00089   HOST_MODE= 0,
00090   DEVICE_MODE=1
00091 }USB_Mode_t;
00092 
00093 //! Maximum transfer size on USB DMA
00094 #define UHD_PIPE_MAX_TRANS 0x8000
00095 
00096 /**
00097 =================================  
00098         USBHS_CTRL 
00099 =================================
00100 **/
00101 
00102 /**
00103  * \brief Freeze or unfreeze USB clock
00104  * \param pUsbhs   Pointer to an USBHS instance.
00105  * \param Enable Enable or disable
00106  */
00107 __STATIC_INLINE void USBHS_FreezeClock(Usbhs *pUsbhs)
00108 {
00109     pUsbhs->USBHS_CTRL |= USBHS_CTRL_FRZCLK;
00110 }
00111 
00112 /**
00113  * \brief Freeze or unfreeze USB clock
00114  * \param pUsbhs   Pointer to an USBHS instance.
00115  * \param Enable Enable or disable
00116  */
00117 __STATIC_INLINE void USBHS_UnFreezeClock(Usbhs *pUsbhs)
00118 {
00119   pUsbhs->USBHS_CTRL &= ~((uint32_t)USBHS_CTRL_FRZCLK);
00120 }
00121 /**
00122  * \brief Freeze or unfreeze USB clock
00123  * \param pUsbhs   Pointer to an USBHS instance.
00124  * \param Enable Enable or disable
00125  */
00126 __STATIC_INLINE void USBHS_VBusHWC(Usbhs *pUsbhs, uint8_t Enable)
00127 {
00128       
00129     if(!Enable) {
00130         pUsbhs->USBHS_CTRL |= (1<<8);
00131     } else {
00132         pUsbhs->USBHS_CTRL &= ~((uint32_t)(1<<8));
00133     }
00134 }
00135 
00136 /**
00137  * \brief Enables or disables USB 
00138  * \param pUsbhs   Pointer to an USBHS instance.
00139  * \param Enable Enable or disable
00140  */
00141 
00142 __STATIC_INLINE void USBHS_UsbEnable(Usbhs *pUsbhs, uint8_t Enable)
00143 {
00144     if(Enable) {
00145         pUsbhs->USBHS_CTRL |= USBHS_CTRL_USBE;
00146     } else {
00147         pUsbhs->USBHS_CTRL &= ~((uint32_t)USBHS_CTRL_USBE);
00148     }
00149 }
00150 
00151 
00152 /**
00153  * \brief Device or Host Mode
00154  * \param pUsbhs   Pointer to an USBHS instance.
00155  * \param Mode   Device or Host Mode
00156  */
00157 
00158 __STATIC_INLINE void USBHS_UsbMode(Usbhs *pUsbhs, USB_Mode_t Mode)
00159 {
00160     if(Mode) {
00161         pUsbhs->USBHS_CTRL |= USBHS_CTRL_UIMOD_DEVICE;
00162     } else {
00163         pUsbhs->USBHS_CTRL &= ~((uint32_t)USBHS_CTRL_UIMOD_DEVICE);
00164     }
00165 }
00166 
00167 /********************* USBHS_SR  *****************/
00168 
00169 /**
00170  * \brief Check if clock is usable or not
00171  * \param pUsbhs   Pointer to an USBHS instance.
00172  * \return 1 if USB clock is usable
00173  */
00174 
00175 __STATIC_INLINE uint8_t USBHS_ISUsableClock(Usbhs *pUsbhs)
00176 { 
00177     return (( pUsbhs->USBHS_SR & USBHS_SR_CLKUSABLE) >> 14);
00178 }
00179 
00180 
00181 /**
00182  * \brief Raise interrupt for endpoint.
00183  * \param pUsbhs   Pointer to an USBHS instance.
00184  * \return USB status
00185  */
00186 
00187 __STATIC_INLINE uint32_t USBHS_ReadStatus(Usbhs *pUsbhs)
00188 {   
00189     return (pUsbhs->USBHS_SR);   
00190 }
00191 
00192 /**
00193  * \brief Enable or disable USB address
00194  * \param pUsbhs   Pointer to an USBHS instance.
00195  * \return USB speed status
00196  */
00197 
00198 __STATIC_INLINE uint32_t USBHS_GetUsbSpeed(Usbhs *pUsbhs)
00199 {
00200     return ( (pUsbhs->USBHS_SR & USBHS_SR_SPEED_Msk) );
00201 }
00202 
00203 
00204 /**
00205  * \brief Enable or disable USB address
00206  * \param pUsbhs   Pointer to an USBHS instance.
00207  * \return USB speed status
00208  */
00209 
00210 __STATIC_INLINE bool USBHS_IsUsbFullSpeed(Usbhs *pUsbhs)
00211 {
00212   return ( (pUsbhs->USBHS_SR & USBHS_SR_SPEED_Msk) == USBHS_SR_SPEED_FULL_SPEED) ? true:false;
00213 }
00214 
00215 
00216 /**
00217  * \brief Enable or disable USB address
00218  * \param pUsbhs   Pointer to an USBHS instance.
00219  * \return USB speed status
00220  */
00221 
00222 __STATIC_INLINE bool USBHS_IsUsbHighSpeed(Usbhs *pUsbhs)
00223 {
00224     return ( (pUsbhs->USBHS_SR & USBHS_SR_SPEED_Msk) == USBHS_SR_SPEED_HIGH_SPEED) ? true:false;
00225 }
00226 
00227 /**
00228  * \brief Enable or disable USB address
00229  * \param pUsbhs   Pointer to an USBHS instance.
00230  * \return USB speed status
00231  */
00232 
00233 __STATIC_INLINE bool USBHS_IsUsbLowSpeed(Usbhs *pUsbhs)
00234 {
00235     return ( (pUsbhs->USBHS_SR & USBHS_SR_SPEED_Msk) == USBHS_SR_SPEED_LOW_SPEED) ? true:false;
00236 }
00237 /********************* USBHS_SCR  *****************/
00238 
00239 /**
00240  * \brief Raise interrupt for endpoint.
00241  * \param pUsbhs   Pointer to an USBHS instance.
00242  * \param AckType Interrupt Acknowledge type
00243  */
00244 
00245 __STATIC_INLINE void USBHS_Ack(Usbhs *pUsbhs, uint32_t AckType)
00246 {
00247     pUsbhs->USBHS_SCR |= AckType;
00248 }
00249 
00250 /********************* USBHS_SFR  *****************/
00251 
00252 /**
00253  * \brief Raise interrupt for endpoint.
00254  * \param pUsbhs   Pointer to an USBHS instance.
00255  * \param SetStatus Set USB status
00256  */
00257 
00258 __STATIC_INLINE void USBHS_Set(Usbhs *pUsbhs, uint32_t SetStatus)
00259 {
00260     pUsbhs->USBHS_SFR |= SetStatus;
00261 }
00262 
00263 
00264  /*--------------------------------------------------------
00265  * =========== USB Device functions ======================
00266  *---------------------------------------------------------*/
00267 
00268 /**
00269  * \brief Enable or disable USB address
00270  * \param pUsbhs   Pointer to an USBHS instance.
00271  * \param SetStatus Set USB status
00272  */
00273 
00274 __STATIC_INLINE void USBHS_EnableAddress(Usbhs *pUsbhs, uint8_t Enable)
00275 {
00276     if(Enable) {
00277         pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_ADDEN;
00278     } else {
00279         pUsbhs->USBHS_DEVCTRL &= ~((uint32_t)USBHS_DEVCTRL_ADDEN);
00280     }
00281 }
00282 
00283 /**
00284  * \brief Configure USB address and enable or disable it
00285  * \param pUsbhs   Pointer to an USBHS instance.
00286  * \param Addr   USB device status
00287  */
00288 
00289 __STATIC_INLINE void USBHS_SetAddress(Usbhs *pUsbhs, uint8_t Addr)
00290 {
00291     pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_UADD(Addr);
00292     pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_ADDEN;
00293 }
00294 
00295 /**
00296  * \brief Get USB address
00297  * \param pUsbhs   Pointer to an USBHS instance.
00298  */
00299 
00300 __STATIC_INLINE uint8_t USBHS_GetAddress(Usbhs *pUsbhs)
00301 {
00302     return ( pUsbhs->USBHS_DEVCTRL & USBHS_DEVCTRL_UADD_Msk);
00303 }
00304 
00305 /**
00306  * \brief Attach or detach USB.
00307  * \param pUsbhs   Pointer to an USBHS instance.
00308  * \param Enable Attachs or detach USB device
00309  */
00310 
00311 __STATIC_INLINE void USBHS_DetachUsb(Usbhs *pUsbhs, uint8_t Enable)
00312 {
00313     if(Enable) {
00314         pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_DETACH;
00315     } else {
00316         pUsbhs->USBHS_DEVCTRL &= ~((uint32_t)USBHS_DEVCTRL_DETACH);
00317     }
00318   
00319 }
00320 
00321 /**
00322  * \brief Force Low Speed mode
00323  * \param pUsbhs   Pointer to an USBHS instance.
00324  * \param Enable Enables the Full speed
00325  */
00326 
00327 __STATIC_INLINE void USBHS_ForceLowSpeed(Usbhs *pUsbhs, uint8_t Enable)
00328 {
00329     if(Enable) {
00330         pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_LS;
00331     } else {
00332         pUsbhs->USBHS_DEVCTRL &= ~((uint32_t)USBHS_DEVCTRL_LS);
00333     }
00334 }
00335 
00336 /**
00337  * \brief Disable/Enables High Speed mode
00338  * \param pUsbhs   Pointer to an USBHS instance.
00339  * \param Enable Enables/disable option
00340  */
00341 
00342 __STATIC_INLINE void USBHS_EnableHighSpeed(Usbhs *pUsbhs, uint8_t Enable)
00343 {
00344     uint32_t cfg = pUsbhs->USBHS_DEVCTRL;
00345     cfg &= ~((uint32_t)USBHS_DEVCTRL_SPDCONF_Msk);
00346     if(Enable) {
00347         pUsbhs->USBHS_DEVCTRL |= cfg;
00348     } else {
00349         pUsbhs->USBHS_DEVCTRL |= (cfg | USBHS_DEVCTRL_SPDCONF_FORCED_FS);
00350     }
00351   
00352 }
00353 
00354 /**
00355  * \brief Set Remote WakeUp mode
00356  * \param pUsbhs   Pointer to an USBHS instance.
00357  */
00358 
00359 __STATIC_INLINE void USBHS_SetRemoteWakeUp(Usbhs *pUsbhs)
00360 {
00361     pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_RMWKUP;
00362 }
00363 
00364 /**
00365  * \brief Disable/Enables Test mode
00366  * \param pUsbhs   Pointer to an USBHS instance.
00367  * \param mode Enables/disable option
00368  */
00369 
00370 __STATIC_INLINE void USBHS_EnableTestMode(Usbhs *pUsbhs, uint32_t mode)
00371 {
00372     pUsbhs->USBHS_DEVCTRL |= mode;
00373 }
00374 
00375 
00376 /**
00377  * \brief Disable/Enables HS Test mode
00378  * \param pUsbhs   Pointer to an USBHS instance.
00379  */
00380 
00381 __STATIC_INLINE void USBHS_EnableHSTestMode(Usbhs *pUsbhs)
00382 {
00383     pUsbhs->USBHS_DEVCTRL |= USBHS_DEVCTRL_SPDCONF_HIGH_SPEED;
00384 }
00385 
00386 /**
00387  * \brief Read status for an interrupt
00388  * \param pUsbhs   Pointer to an USBHS instance.
00389  * \param IntType Interrupt type
00390  */
00391 
00392 __STATIC_INLINE uint32_t USBHS_ReadIntStatus(Usbhs *pUsbhs, uint32_t IntType)
00393 {   
00394     return (pUsbhs->USBHS_DEVISR & IntType);    
00395 }
00396 
00397 /**
00398  * \brief Read status for an Endpoint
00399  * \param pUsbhs   Pointer to an USBHS instance.
00400  * \param EpNum  Endpoint
00401  */
00402 
00403 __STATIC_INLINE uint32_t USBHS_ReadEpIntStatus(Usbhs *pUsbhs, uint8_t EpNum)
00404 {   
00405     return (pUsbhs->USBHS_DEVISR & ( USBHS_DEVISR_PEP_0 << EpNum) );    
00406 }
00407 
00408 /**
00409  * \brief Read status for a DMA Endpoint
00410  * \param pUsbhs   Pointer to an USBHS instance.
00411  * \param DmaNum  DMA Endpoint
00412  */
00413 __STATIC_INLINE uint32_t USBHS_ReadDmaIntStatus(Usbhs *pUsbhs, uint8_t DmaNum)
00414 {   
00415     return (pUsbhs->USBHS_DEVISR & ( USBHS_DEVISR_DMA_1 << DmaNum) );
00416 }
00417 
00418 /**
00419  * \brief Acknowledge interrupt for endpoint.
00420  * \param pUsbhs   Pointer to an USBHS instance.
00421  * \param IntType Interrupt Type
00422  */
00423 
00424 __STATIC_INLINE void USBHS_AckInt(Usbhs *pUsbhs, uint32_t IntType)
00425 {   
00426     pUsbhs->USBHS_DEVICR |=  IntType;
00427 }
00428 
00429 /**
00430  * \brief Raise interrupt for endpoint.
00431  * \param pUsbhs   Pointer to an USBHS instance.
00432  * \param IntType Interrupt Type
00433  */
00434 
00435 
00436 __STATIC_INLINE void USBHS_RaiseInt(Usbhs *pUsbhs, uint32_t IntType)
00437 {   
00438     pUsbhs->USBHS_DEVIFR |=  IntType;
00439 }
00440 
00441 /**
00442  * \brief Raise DMA interrupt for endpoint.
00443  * \param pUsbhs   Pointer to an USBHS instance.
00444  * \param IntType Interrupt Type
00445  */
00446 __STATIC_INLINE void USBHS_RaiseDmaInt(Usbhs *pUsbhs, uint8_t Dma)
00447 {   
00448     assert(Dma< USBHSDEVDMA_NUMBER);
00449     pUsbhs->USBHS_DEVIFR |=  ( USBHS_DEVIFR_DMA_1 << Dma );
00450 }
00451 
00452 /**
00453  * \brief check for interrupt of endpoint.
00454  * \param pUsbhs   Pointer to an USBHS instance.
00455  * \param IntType Interrupt Type
00456  */
00457 
00458 __STATIC_INLINE uint32_t USBHS_IsIntEnable(Usbhs *pUsbhs, uint32_t IntType)
00459 {
00460     return (pUsbhs->USBHS_DEVIMR &  IntType);
00461 }
00462 
00463 /**
00464  * \brief Check if endpoint's interrupt is enabled for a given endpoint number
00465  * \param pUsbhs   Pointer to an USBHS instance.
00466  * \param EpNum Endpoint number
00467  */
00468 
00469 __STATIC_INLINE uint32_t USBHS_IsIntEnableEP(Usbhs *pUsbhs, uint8_t EpNum)
00470 {
00471     return (pUsbhs->USBHS_DEVIMR &  (USBHS_DEVIMR_PEP_0 << EpNum ));
00472 }
00473 
00474 
00475 /**
00476  * \brief Check if endpoint's DMA interrupt is enabled for a given endpoint 
00477  * DMA number
00478  * \param pUsbhs   Pointer to an USBHS instance.
00479  * \param DmaNum Endpoint's DMA number
00480  */
00481 
00482 __STATIC_INLINE uint32_t USBHS_IsDmaIntEnable(Usbhs *pUsbhs, uint8_t DmaNum)
00483 {
00484     return (pUsbhs->USBHS_DEVIMR &  (USBHS_DEVIMR_DMA_1 << DmaNum));
00485 }
00486 
00487 
00488 /**
00489  * \brief Enables Interrupt
00490  * \param pUsbhs   Pointer to an USBHS instance.
00491  * \param IntType Interrupt Type
00492  */
00493 __STATIC_INLINE void USBHS_EnableInt(Usbhs *pUsbhs, uint32_t IntType)
00494 {   
00495     pUsbhs->USBHS_DEVIER |=  IntType;
00496 }
00497 
00498 /**
00499  * \brief Enables interrupt for a given endpoint.
00500  * \param pUsbhs   Pointer to an USBHS instance.
00501  * \param DmaNum Endpoint's DMA number
00502  */
00503 __STATIC_INLINE void USBHS_EnableIntEP(Usbhs *pUsbhs, uint8_t EpNum)
00504 {   
00505     pUsbhs->USBHS_DEVIER |=  (USBHS_DEVIER_PEP_0 << EpNum);
00506 }
00507 
00508 /**
00509  * \brief Enables DMA interrupt for a given endpoint.
00510  * \param pUsbhs   Pointer to an USBHS instance.
00511  * \param DmaEp  Endpoint's DMA interrupt number
00512  */
00513 
00514 __STATIC_INLINE void USBHS_EnableDMAIntEP(Usbhs *pUsbhs, uint32_t DmaEp)
00515 {   
00516     assert(DmaEp< USBHSDEVDMA_NUMBER);
00517     pUsbhs->USBHS_DEVIER |=  (USBHS_DEVIER_DMA_1 << DmaEp);
00518 }
00519   
00520  /**
00521  * \brief Disables interrupt for endpoint.
00522  * \param pUsbhs   Pointer to an USBHS instance.
00523  * \param IntType Int type
00524  */  
00525 
00526 __STATIC_INLINE void USBHS_DisableInt(Usbhs *pUsbhs, uint32_t IntType)
00527 {   
00528     pUsbhs->USBHS_DEVIDR |=  IntType;
00529 }
00530 
00531  /**
00532  * \brief Disables interrupt for endpoint.
00533  * \param pUsbhs  Pointer to an USBHS instance.
00534  * \param Ep    Endpoint number
00535  */ 
00536 
00537 __STATIC_INLINE void USBHS_DisableIntEP(Usbhs *pUsbhs, uint8_t Ep)
00538 {   
00539     pUsbhs->USBHS_DEVIDR |=  (USBHS_DEVIDR_PEP_0 << Ep);    
00540 }
00541 
00542  /**
00543  * \brief Disables DMA interrupt for endpoint.
00544  * \param pUsbhs  Pointer to an USBHS instance.
00545  * \param DmaEp Endpoint's DMA number
00546  */
00547 __STATIC_INLINE void USBHS_DisableDMAIntEP(Usbhs *pUsbhs, uint8_t DmaEp)
00548 {   
00549     assert(DmaEp< USBHSDEVDMA_NUMBER);
00550     pUsbhs->USBHS_DEVIDR |=  (USBHS_DEVIDR_DMA_1 << DmaEp);
00551 }
00552 
00553 
00554  /**
00555  * \brief Enables or disables endpoint.
00556  * \param pUsbhs  Pointer to an USBHS instance.
00557  * \param Enable Enable/disable endpoint
00558  */
00559 
00560 __STATIC_INLINE void USBHS_EnableEP(Usbhs *pUsbhs, uint8_t Ep, uint8_t Enable)
00561 {
00562     if(Enable) {
00563         pUsbhs->USBHS_DEVEPT |= (USBHS_DEVEPT_EPEN0 << Ep);
00564     } else {
00565         pUsbhs->USBHS_DEVEPT &= ~(uint32_t)(USBHS_DEVEPT_EPEN0 << Ep);
00566     }
00567     
00568 }
00569 
00570 
00571  /**
00572  * \brief Rests Endpoint
00573  * \param pUsbhs  Pointer to an USBHS instance.
00574  * \param Ep    Endpoint Number
00575  */
00576 
00577 __STATIC_INLINE void USBHS_ResetEP(Usbhs *pUsbhs, uint8_t Ep)
00578 {
00579     pUsbhs->USBHS_DEVEPT |=  (USBHS_DEVEPT_EPRST0 << Ep);
00580    //pUsbhs->USBHS_DEVEPT &=  ~(uint32_t)(USBHS_DEVEPT_EPRST0 << Ep);
00581 }
00582 
00583  /**
00584  * \brief Checks if Endpoint is enable
00585  * \param pUsbhs  Pointer to an USBHS instance.
00586  * \param Ep    Endpoint Number
00587  */
00588 
00589 __STATIC_INLINE uint32_t USBHS_IsEPEnabled(Usbhs *pUsbhs, uint8_t Ep)
00590 {
00591     return (pUsbhs->USBHS_DEVEPT & (USBHS_DEVEPT_EPEN0 << Ep) );
00592 }
00593 
00594  /**
00595  * \brief Get MicrFrame number
00596  * \param pUsbhs  Pointer to an USBHS instance.
00597  * \retruns Micro frame number
00598  */
00599 __STATIC_INLINE uint8_t USBHS_GetMicroFrameNum(Usbhs *pUsbhs)
00600 {
00601     return (pUsbhs->USBHS_DEVFNUM & USBHS_DEVFNUM_MFNUM_Msk);    
00602 }
00603 
00604 
00605  /**
00606  * \brief Get Frame number
00607  * \param pUsbhs  Pointer to an USBHS instance.
00608  * \retruns frame number
00609  */
00610 __STATIC_INLINE uint8_t USBHS_GetFrameNum(Usbhs *pUsbhs)
00611 {
00612     return ( (pUsbhs->USBHS_DEVFNUM & USBHS_DEVFNUM_FNUM_Msk) 
00613             >> USBHS_DEVFNUM_FNUM_Pos); 
00614 }
00615 
00616  /**
00617  * \brief Get Frame number CRC error
00618  * \param pUsbhs  Pointer to an USBHS instance.
00619  * \retruns Frame number error status
00620  */
00621 __STATIC_INLINE uint8_t USBHS_GetFrameNumCrcErr(Usbhs *pUsbhs)
00622 {
00623     return ( (pUsbhs->USBHS_DEVFNUM & USBHS_DEVFNUM_FNCERR) >> 15);
00624 }
00625 
00626  /*-----------------------------------------
00627  * =========== USB Device's Endpoint functions ========
00628  *------------------------------------------*/
00629 
00630 /**
00631  * Set Endpoints configuration
00632  * Bank size, type and direction
00633  */
00634 __STATIC_INLINE void USBHS_ConfigureEPs(Usbhs *pUsbhs, const uint8_t Ep,
00635         const uint8_t Type, const uint8_t Dir, 
00636         const uint8_t Size, const uint8_t Bank)
00637 {  
00638     
00639     pUsbhs->USBHS_DEVEPTCFG[Ep] |= 
00640         ((Size << USBHS_DEVEPTCFG_EPSIZE_Pos) & USBHS_DEVEPTCFG_EPSIZE_Msk);
00641     pUsbhs->USBHS_DEVEPTCFG[Ep] |= 
00642         ((Dir << 8 ) & USBHS_DEVEPTCFG_EPDIR);
00643     pUsbhs->USBHS_DEVEPTCFG[Ep] |= 
00644         (( (Type) << USBHS_DEVEPTCFG_EPTYPE_Pos) & USBHS_DEVEPTCFG_EPTYPE_Msk);
00645     pUsbhs->USBHS_DEVEPTCFG[Ep] |= 
00646         (( (Bank) << USBHS_DEVEPTCFG_EPBK_Pos) & USBHS_DEVEPTCFG_EPBK_Msk);
00647 }
00648 
00649 
00650 /**
00651  * Enable or disable Auto switch of banks
00652  */
00653 __STATIC_INLINE void USBHS_AutoSwitchBankEnable(Usbhs *pUsbhs, uint8_t Ep, uint8_t Enable)
00654 {
00655     if(Enable) {
00656         pUsbhs->USBHS_DEVEPTCFG[Ep] |=USBHS_DEVEPTCFG_AUTOSW;
00657     } else {
00658         pUsbhs->USBHS_DEVEPTCFG[Ep] &= ~((uint32_t)USBHS_DEVEPTCFG_AUTOSW);
00659     }
00660 }
00661 
00662 
00663 /**
00664  * Allocate Endpoint memory
00665  */
00666 __STATIC_INLINE void USBHS_AllocateMemory(Usbhs *pUsbhs, uint8_t Ep)
00667 {
00668     pUsbhs->USBHS_DEVEPTCFG[Ep] |=USBHS_DEVEPTCFG_ALLOC;
00669 }
00670 
00671 
00672 /**
00673  * Free allocated Endpoint memory
00674  */
00675 __STATIC_INLINE void USBHS_FreeMemory(Usbhs *pUsbhs, uint8_t Ep)
00676 {
00677     pUsbhs->USBHS_DEVEPTCFG[Ep] &= ~((uint32_t)USBHS_DEVEPTCFG_ALLOC);
00678 }
00679 
00680 
00681 /**
00682  * Get Endpoint configuration
00683  */
00684 __STATIC_INLINE uint32_t USBHS_GetConfigureEPs(Usbhs *pUsbhs, uint8_t Ep,
00685                                                 uint32_t IntType)
00686 {  
00687     return ((pUsbhs->USBHS_DEVEPTCFG[Ep] ) & IntType);
00688 }
00689 
00690 /**
00691  * Get Endpoint Type
00692  */
00693 __STATIC_INLINE uint8_t USBHS_GetEpType(Usbhs *pUsbhs, uint8_t Ep)
00694 {  
00695     return ((pUsbhs->USBHS_DEVEPTCFG[Ep] & USBHS_DEVEPTCFG_EPTYPE_Msk) 
00696             >> USBHS_DEVEPTCFG_EPTYPE_Pos);
00697 }
00698 
00699 /**
00700  * Get Endpoint Size
00701  */
00702 __STATIC_INLINE uint32_t USBHS_GetEpSize(Usbhs *pUsbhs, uint8_t Ep)
00703 {  
00704     return ( 8 << ( (pUsbhs->USBHS_DEVEPTCFG[Ep] & USBHS_DEVEPTCFG_EPSIZE_Msk)
00705             >> USBHS_DEVEPTCFG_EPSIZE_Pos) );
00706 }
00707 
00708 
00709 /**
00710  * Sets ISO endpoint's Number of Transfer for High Speed
00711  */
00712 __STATIC_INLINE void USBHS_SetIsoTrans(Usbhs *pUsbhs, uint8_t Ep, 
00713         uint8_t nbTrans)
00714 {  
00715     pUsbhs->USBHS_DEVEPTCFG[Ep] |= USBHS_DEVEPTCFG_NBTRANS(nbTrans) ;
00716 }
00717 
00718 /**
00719  * Check for interrupt types enabled for a given endpoint
00720  */
00721 __STATIC_INLINE uint32_t USBHS_IsEpIntEnable(Usbhs *pUsbhs, uint8_t Ep,
00722         uint32_t EpIntType)
00723 {  
00724     return (pUsbhs->USBHS_DEVEPTIMR[Ep] & EpIntType);
00725 }
00726 
00727 
00728 /**
00729  * Enables an interrupt type for a given endpoint
00730  */
00731 __STATIC_INLINE void USBHS_EnableEPIntType(Usbhs *pUsbhs, uint8_t Ep, 
00732         uint32_t EpInt)
00733 {
00734     pUsbhs->USBHS_DEVEPTIER[Ep] |=  EpInt;
00735 }
00736 
00737 /**
00738  * Enables an interrupt type for a given endpoint
00739  */
00740 __STATIC_INLINE uint32_t USBHS_IsBankKilled(Usbhs *pUsbhs, uint8_t Ep)
00741 {   
00742     return (pUsbhs->USBHS_DEVEPTIMR[Ep] & USBHS_DEVEPTIMR_KILLBK);
00743 }
00744 
00745 /**
00746  * Enables an interrupt type for a given endpoint
00747  */
00748 __STATIC_INLINE void USBHS_KillBank(Usbhs *pUsbhs, uint8_t Ep)
00749 {
00750     pUsbhs->USBHS_DEVEPTIER[Ep] =  USBHS_DEVEPTIER_KILLBKS;
00751 }
00752 /**
00753  * Disables an interrupt type for a given endpoint
00754  */
00755 __STATIC_INLINE void USBHS_DisableEPIntType(Usbhs *pUsbhs, uint8_t Ep, 
00756         uint32_t EpInt)
00757 {
00758     pUsbhs->USBHS_DEVEPTIDR[Ep] |=  EpInt;
00759 }
00760 
00761 /**
00762  * Clears register/acknowledge for a given endpoint
00763  */
00764 __STATIC_INLINE void USBHS_AckEpInterrupt(Usbhs *pUsbhs, uint8_t Ep, uint32_t EpInt)
00765 {
00766     pUsbhs->USBHS_DEVEPTICR[Ep] |=  EpInt;
00767 }
00768 
00769 /**
00770  * Sets/Raise register for a given endpoint
00771  */
00772 __STATIC_INLINE void USBHS_RaiseEPInt(Usbhs *pUsbhs, uint8_t Ep, uint32_t EpInt)
00773 {   
00774     pUsbhs->USBHS_DEVEPTIFR[Ep] |=  EpInt;    
00775 }
00776 
00777 /**
00778  * Gets interrupt status for a given EP
00779  */
00780 __STATIC_INLINE uint32_t USBHS_ReadEPStatus(Usbhs *pUsbhs, uint8_t Ep, 
00781         uint32_t EpInt)
00782 {
00783     return (pUsbhs->USBHS_DEVEPTISR[Ep] & EpInt);
00784 }
00785 
00786 /**
00787  * Check if given endpoint's bank is free
00788  */
00789 __STATIC_INLINE uint8_t USBHS_IsBankFree(Usbhs *pUsbhs, uint8_t Ep)
00790 {
00791     if( (pUsbhs->USBHS_DEVEPTISR[Ep] & USBHS_DEVEPTISR_NBUSYBK_Msk)) {
00792         return false;
00793     } else {
00794         return true;
00795     }
00796 }
00797 
00798 /**
00799  * Read endpoint's bank number in use
00800  */
00801 __STATIC_INLINE uint8_t USBHS_NumOfBanksInUse(Usbhs *pUsbhs, uint8_t Ep)
00802 {
00803     return ( (pUsbhs->USBHS_DEVEPTISR[Ep] & USBHS_DEVEPTISR_NBUSYBK_Msk) 
00804         >> USBHS_DEVEPTISR_NBUSYBK_Pos);
00805 }
00806 
00807 
00808 /**
00809  * Read endpoint's bank number in use
00810  */
00811 __STATIC_INLINE uint16_t USBHS_ByteCount(Usbhs *pUsbhs, uint8_t Ep)
00812 {
00813     return (uint16_t)( (pUsbhs->USBHS_DEVEPTISR[Ep] & USBHS_DEVEPTISR_BYCT_Msk)
00814         >> USBHS_DEVEPTISR_BYCT_Pos);
00815 }
00816 
00817  /*--------------------------------------------------------
00818  * =========== USB Device's Ep's DMA functions =========
00819  *---------------------------------------------------------*/
00820 
00821  /**
00822  * \brief Sets DMA next descriptor address
00823  * \param pUsbDma  USBHS device DMA instance
00824  * \param Desc NDA address
00825  */ 
00826 __STATIC_INLINE void USBHS_SetDmaNDA(UsbhsDevdma *pUsbDma, uint32_t Desc)
00827 {
00828     pUsbDma->USBHS_DEVDMANXTDSC = Desc;
00829 }
00830 
00831  /**
00832  * \brief Gets DMA next descriptor address
00833  * \param pUsbDma  USBHS device DMA instance
00834  * \return Next DMA descriptor
00835  */ 
00836 __STATIC_INLINE uint32_t USBHS_GetDmaNDA(UsbhsDevdma *pUsbDma)
00837 {
00838     return (pUsbDma->USBHS_DEVDMANXTDSC);
00839 }
00840 
00841  /**
00842  * \brief Sets USBHS's DMA Buffer addresse
00843  * \param pUsbDma  USBHS device DMA instance
00844  * \param Addr  DMA's buffer Addrs
00845  */ 
00846 __STATIC_INLINE void USBHS_SetDmaBuffAdd(UsbhsDevdma *pUsbDma, uint32_t Addr)
00847 {
00848     pUsbDma->USBHS_DEVDMAADDRESS = Addr;
00849 }
00850 
00851 
00852  /**
00853  * \brief Gets USBHS's DMA Buffer addresse
00854  * \param pUsbDma  USBHS device DMA instance
00855  * \return DMA addrs
00856  */ 
00857 __STATIC_INLINE uint32_t USBHS_GetDmaBuffAdd(UsbhsDevdma *pUsbDma)
00858 {
00859     return (pUsbDma->USBHS_DEVDMAADDRESS);
00860 }
00861 
00862  /**
00863  * \brief Setup the USBHS DMA
00864  * \param pUsbDma  USBHS device DMA instance
00865  * \param Cfg  DMA's configuration
00866  */ 
00867 __STATIC_INLINE void USBHS_ConfigureDma(UsbhsDevdma *pUsbDma, uint32_t Cfg)
00868 {
00869     pUsbDma->USBHS_DEVDMACONTROL |= Cfg;
00870 }
00871 
00872  /**
00873  * \brief Get DMA configuration
00874  * \param pUsbDma  USBHS device DMA instance
00875  * \return DMA control setup
00876  */ 
00877 __STATIC_INLINE uint32_t USBHS_GetDmaConfiguration(UsbhsDevdma *pUsbDma)
00878 {
00879     return (pUsbDma->USBHS_DEVDMACONTROL);
00880 }
00881 
00882 
00883  /**
00884  * \brief Set DMA status
00885  * \param pUsbDma  USBHS device DMA instance
00886  * \Status Set DMA status
00887  */ 
00888 __STATIC_INLINE void USBHS_SetDmaStatus(UsbhsDevdma *pUsbDma, uint32_t Status)
00889 {
00890     pUsbDma->USBHS_DEVDMASTATUS = Status;
00891 }
00892 
00893 
00894  /**
00895  * \brief Get Dma Status
00896  * \param pUsbDma  USBHS device DMA instance
00897  * \return Dma status
00898  */ 
00899 __STATIC_INLINE uint32_t USBHS_GetDmaStatus(UsbhsDevdma *pUsbDma)
00900 {
00901     return (pUsbDma->USBHS_DEVDMASTATUS);
00902 }
00903 
00904 
00905  /**
00906  * \brief Get DMA buffer's count
00907  * \param pUsbDma  USBHS device DMA instance
00908  * \return Buffer count
00909  */ 
00910 __STATIC_INLINE uint16_t USBHS_GetDmaBuffCount(UsbhsDevdma *pUsbDma)
00911 {
00912     return ( (pUsbDma->USBHS_DEVDMASTATUS & USBHS_DEVDMASTATUS_BUFF_COUNT_Msk)
00913         >> USBHS_DEVDMASTATUS_BUFF_COUNT_Pos);
00914 }
00915 
00916 
00917  /*--------------------------------------------------------
00918  * =========== USB Host Functions  ========================
00919  *---------------------------------------------------------*/
00920 
00921 /** Number of USB endpoints */
00922 #define CHIP_USB_NUMPIPE            10
00923 /** Number of USB endpoints */
00924 #define CHIP_USB_DMA_NUMPIPE        7
00925 
00926 /** Endpoints max paxcket size */
00927 #define CHIP_USB_PIPE_MAXPACKETSIZE(ep) \
00928    ((ep == 0) ? 64 : 1024)
00929 
00930 /** Endpoints Number of Bank */
00931 #define CHIP_USB_PIPE_BANKS(ep)                 ((ep==0)?1:((ep<=2)?3:2))
00932      
00933      
00934 #define CHIP_USB_PIPE_HBW(ep)                   ((((ep)>=1) &&((ep)<=2))?true:false)
00935 
00936 /** Endpoints DMA support */
00937 #define CHIP_USB_PIPE_DMA(ep)                   ((((ep)>=1)&&((ep)<=7))?true:false)
00938 
00939  /**
00940  * \brief Sets USB host's speed to Normal , it sets to HS from FS
00941  * \param pUsbhs  USBHS host instance
00942  */ 
00943 __STATIC_INLINE void USBHS_SetHostHighSpeed(Usbhs *pUsbhs)
00944 {
00945    pUsbhs->USBHS_HSTCTRL |= USBHS_HSTCTRL_SPDCONF_NORMAL;
00946 }
00947 
00948  /**
00949  * \brief Sets USB host's speed to Low speed
00950  * \param pUsbhs  USBHS host instance
00951  */ 
00952 __STATIC_INLINE void USBHS_SetHostLowSpeed(Usbhs *pUsbhs)
00953 {
00954    pUsbhs->USBHS_HSTCTRL |= USBHS_HSTCTRL_SPDCONF_LOW_POWER;
00955 }
00956 
00957  /**
00958  * \brief Sets USB host's speed to forced Full speed
00959  * \param pUsbhs  USBHS host instance
00960  */ 
00961 __STATIC_INLINE void USBHS_SetHostForcedFullSpeed(Usbhs *pUsbhs)
00962 {
00963    pUsbhs->USBHS_HSTCTRL |= USBHS_HSTCTRL_SPDCONF_FORCED_FS;
00964 }
00965 
00966  /**
00967  * \brief Sets USB host sends reste signal on USB Bus
00968  * \param pUsbhs  USBHS host instance
00969  */ 
00970 __STATIC_INLINE void USBHS_Reset(void)
00971 {
00972    USBHS->USBHS_HSTCTRL |= USBHS_HSTCTRL_RESET;
00973 }
00974 
00975  /**
00976  * \brief Sets USB host sends reste signal on USB Bus
00977  * \param pUsbhs  USBHS host instance
00978  */ 
00979 __STATIC_INLINE void USBHS_StopReset(void)
00980 {
00981    USBHS->USBHS_HSTCTRL &= ~USBHS_HSTCTRL_RESET;
00982 }
00983 
00984  /**
00985  * \brief Sets USB host send Resume on USB bus
00986  * \param pUsbhs  USBHS host instance
00987  */ 
00988 __STATIC_INLINE void USBHS_Resume(void)
00989 {
00990    USBHS->USBHS_HSTCTRL |= USBHS_HSTCTRL_RESUME;
00991 }
00992 
00993  /**
00994  * \brief Sets USB host Enable the Generation of  Start of Frame
00995  * \param pUsbhs  USBHS host instance
00996  */ 
00997 __STATIC_INLINE void USBHS_EnableSOF(Usbhs *pUsbhs)
00998 {
00999    pUsbhs->USBHS_HSTCTRL |= USBHS_HSTCTRL_SOFE;
01000 }
01001 
01002  /**
01003  * \brief Sets USB host Enable the Generation of  Start of Frame
01004  * \param pUsbhs  USBHS host instance
01005  */ 
01006 __STATIC_INLINE uint8_t USBHS_IsEnableSOF(Usbhs *pUsbhs)
01007 {
01008     return (pUsbhs->USBHS_HSTCTRL & USBHS_HSTCTRL_SOFE) >> 8;
01009 }
01010  /**
01011  * \brief Sets USB host disable the Generation of  Start of Frame
01012  * \param pUsbhs  USBHS host instance
01013  */ 
01014 __STATIC_INLINE void USBHS_DisableSOF(void)
01015 {
01016    USBHS->USBHS_HSTCTRL &= ~USBHS_HSTCTRL_SOFE;
01017 }
01018 
01019  /**
01020  * \brief Gets USB host interrupt status
01021  * \param pUsbhs  USBHS host instance
01022  */ 
01023 __STATIC_INLINE uint32_t USBHS_GetHostStatus(Usbhs *pUsbhs, uint8_t IntType)
01024 {
01025    return (pUsbhs->USBHS_HSTISR & IntType);
01026 }
01027 
01028 
01029 /**
01030  * \brief Gets USB host interrupt status
01031  * \param pUsbhs  USBHS host instance
01032  */ 
01033 __STATIC_INLINE uint32_t USBHS_GetHostPipeStatus(Usbhs *pUsbhs, uint8_t PipeInt)
01034 {
01035    assert( PipeInt < CHIP_USB_NUMPIPE);
01036    return (pUsbhs->USBHS_HSTISR & ( USBHS_HSTISR_PEP_0 << PipeInt) );
01037 }
01038 
01039 
01040 /**
01041  * \brief Gets USB host interrupt status
01042  * \param pUsbhs  USBHS host instance
01043  */ 
01044 __STATIC_INLINE uint32_t USBHS_GetHostDmaPipeStatus(Usbhs *pUsbhs, uint8_t PipeInt)
01045 {
01046     assert( PipeInt);
01047     assert( PipeInt < CHIP_USB_DMA_NUMPIPE);
01048     return (pUsbhs->USBHS_HSTISR & ( USBHS_HSTISR_DMA_1 << PipeInt) );
01049 }
01050 
01051 /**
01052  * \brief Gets USB host interrupt status
01053  * \param pUsbhs  USBHS host instance
01054  */ 
01055 __STATIC_INLINE void USBHS_ClearHostStatus(Usbhs *pUsbhs, uint32_t IntType)
01056 {
01057     pUsbhs->USBHS_HSTICR = IntType;
01058 }
01059 
01060 /**
01061  * \brief Gets USB host interrupt status
01062  * \param pUsbhs  USBHS host instance
01063  */ 
01064 __STATIC_INLINE void USBHS_SetHostStatus(Usbhs *pUsbhs, uint32_t IntType)
01065 {
01066     pUsbhs->USBHS_HSTIFR = IntType;
01067 }
01068 
01069 /**
01070  * \brief Gets USB host interrupt status
01071  * \param pUsbhs  USBHS host instance
01072  */ 
01073 __STATIC_INLINE void USBHS_SetHostDmaStatus(Usbhs *pUsbhs, uint8_t PipeInt)
01074 {
01075     assert( PipeInt);
01076     assert( PipeInt < CHIP_USB_DMA_NUMPIPE);
01077     pUsbhs->USBHS_HSTIFR =  (USBHS_HSTIFR_DMA_1 << PipeInt) ;
01078 }
01079 
01080 /*** Interrupt Mask ****/
01081 /**
01082  * \brief Gets USB host interrupt status
01083  * \param pUsbhs  USBHS host instance
01084  */ 
01085 __STATIC_INLINE uint8_t USBHS_IsHostIntEnable(Usbhs *pUsbhs, uint8_t IntType)
01086 {
01087     return (pUsbhs->USBHS_HSTIMR & IntType) ;
01088 }
01089 
01090 /**
01091  * \brief Gets USB host interrupt status
01092  * \param pUsbhs  USBHS host instance
01093  */ 
01094 __STATIC_INLINE uint32_t USBHS_IsHostPipeIntEnable(Usbhs *pUsbhs, uint8_t PipeInt)
01095 {
01096     assert( PipeInt < CHIP_USB_NUMPIPE);
01097     return ( pUsbhs->USBHS_HSTIMR & (USBHS_HSTIMR_PEP_0 << PipeInt) );
01098 }
01099 
01100 /**
01101  * \brief Gets USB host interrupt status
01102  * \param pUsbhs  USBHS host instance
01103  */ 
01104 __STATIC_INLINE uint32_t USBHS_IsHostDmaIntEnable(Usbhs *pUsbhs, uint8_t PipeInt)
01105 {
01106     assert( PipeInt);
01107     assert( PipeInt < CHIP_USB_DMA_NUMPIPE);
01108     return ( pUsbhs->USBHS_HSTIMR & (USBHS_HSTIMR_DMA_1 << PipeInt) );
01109 }
01110 
01111 /*** Interrupt Disable ****/
01112 /**
01113  * \brief Gets USB host interrupt status
01114  * \param pUsbhs  USBHS host instance
01115  */ 
01116 __STATIC_INLINE void USBHS_HostIntDisable(Usbhs *pUsbhs, uint32_t IntType)
01117 {
01118     pUsbhs->USBHS_HSTIDR = IntType ;
01119 }
01120 
01121 /**
01122  * \brief Gets USB host interrupt status
01123  * \param pUsbhs  USBHS host instance
01124  */ 
01125 __STATIC_INLINE void USBHS_HostPipeIntDisable(Usbhs *pUsbhs, uint8_t PipeInt)
01126 {
01127     assert( PipeInt < CHIP_USB_NUMPIPE);
01128     pUsbhs->USBHS_HSTIDR  = (USBHS_HSTIDR_PEP_0 << PipeInt);
01129 }
01130 
01131 /**
01132  * \brief Gets USB host interrupt status
01133  * \param pUsbhs  USBHS host instance
01134  */ 
01135 __STATIC_INLINE void USBHS_HostDmaIntDisable(Usbhs *pUsbhs, uint8_t PipeInt)
01136 {
01137     assert( PipeInt);
01138     assert( PipeInt < CHIP_USB_DMA_NUMPIPE);
01139     pUsbhs->USBHS_HSTIDR = (USBHS_HSTIDR_DMA_1 << PipeInt) ;
01140 }
01141 
01142 /*** Interrupt Enable ****/
01143 
01144 /**
01145  * \brief Gets USB host interrupt status
01146  * \param pUsbhs  USBHS host instance
01147  */ 
01148 __STATIC_INLINE void USBHS_HostIntEnable(Usbhs *pUsbhs, uint32_t IntType)
01149 {
01150     pUsbhs->USBHS_HSTIER = IntType ;
01151 }
01152 
01153 /**
01154  * \brief Gets USB host interrupt status
01155  * \param pUsbhs  USBHS host instance
01156  */ 
01157 __STATIC_INLINE void USBHS_HostPipeIntEnable(Usbhs *pUsbhs, uint8_t PipeInt)
01158 {
01159      assert( PipeInt < CHIP_USB_NUMPIPE);
01160      pUsbhs->USBHS_HSTIER =(USBHS_HSTIER_PEP_0 << PipeInt) ;
01161 }
01162 
01163 /**
01164  * \brief Gets USB host interrupt status
01165  * \param pUsbhs  USBHS host instance
01166  */ 
01167 __STATIC_INLINE void USBHS_HostDmaIntEnable(Usbhs *pUsbhs, uint8_t PipeInt)
01168 {
01169     assert( PipeInt < CHIP_USB_DMA_NUMPIPE);
01170     pUsbhs->USBHS_HSTIER |= (USBHS_HSTIER_DMA_1 << PipeInt);
01171 }
01172 
01173 /**
01174  * \brief Gets USB host interrupt status
01175  * \param pUsbhs  USBHS host instance
01176  */ 
01177 __STATIC_INLINE uint16_t USBHS_HostGetSOF(void)
01178 {
01179    return ( (USBHS->USBHS_HSTFNUM & USBHS_HSTFNUM_FNUM_Msk) >> USBHS_HSTFNUM_FNUM_Pos);
01180 }
01181 
01182 /**
01183  * \brief Gets USB host interrupt status
01184  * \param pUsbhs  USBHS host instance
01185  */ 
01186 __STATIC_INLINE uint16_t USBHS_HostGetFramePos(void)
01187 {
01188    return ( (USBHS->USBHS_HSTFNUM & USBHS_HSTFNUM_FLENHIGH_Msk) >> USBHS_HSTFNUM_FLENHIGH_Pos);
01189 }
01190 
01191 
01192 /**
01193  * \brief Gets USB host interrupt status
01194  * \param pUsbhs  USBHS host instance
01195  */ 
01196 __STATIC_INLINE uint16_t USBHS_HostGetMSOF(void)
01197 {
01198    return ( (USBHS->USBHS_HSTFNUM & USBHS_HSTFNUM_MFNUM_Msk) >> USBHS_HSTFNUM_MFNUM_Pos);
01199 }
01200 
01201 __STATIC_INLINE void USBHS_HostSetAddr(Usbhs *pUsbhs, uint8_t Pipe, uint8_t Addr)
01202 {
01203   assert( Pipe < CHIP_USB_NUMPIPE);
01204   if (Pipe <4)
01205   {
01206     pUsbhs->USBHS_HSTADDR1 |= (Addr << (8*Pipe));
01207   }
01208   else if( (Pipe <8) && (Pipe >=4))
01209   {
01210     pUsbhs->USBHS_HSTADDR2 |= (Addr << (8* (Pipe -4)));
01211   }
01212   else
01213   {
01214     pUsbhs->USBHS_HSTADDR3 |= (Addr << (8*(Pipe -8)));
01215   }
01216   
01217 }
01218 
01219 __STATIC_INLINE uint8_t USBHS_HostGetAddr(Usbhs *pUsbhs, uint8_t Pipe)
01220 {
01221   assert( Pipe < CHIP_USB_NUMPIPE);
01222   if (Pipe <4)
01223   {
01224     return ( pUsbhs->USBHS_HSTADDR1 >>  (8*Pipe)) ;
01225   }
01226   else if( (Pipe <8) && (Pipe >=4))
01227   {
01228     return (pUsbhs->USBHS_HSTADDR2  >>  (8*(Pipe -4)));
01229   }
01230   else
01231   {
01232     return (pUsbhs->USBHS_HSTADDR3  >> (8*(Pipe -8)));
01233   }
01234   
01235 }
01236 
01237 /**
01238  * \brief Gets USB host interrupt status
01239  * \param pUsbhs  USBHS host instance
01240  */ 
01241 __STATIC_INLINE void USBHS_HostPipeEnable(Usbhs *pUsbhs, uint8_t Pipe)
01242 {
01243     assert( Pipe < CHIP_USB_NUMPIPE);
01244     pUsbhs->USBHS_HSTPIP |= (USBHS_HSTPIP_PEN0 << Pipe);
01245 }
01246 
01247 /**
01248  * \brief Gets USB host interrupt status
01249  * \param pUsbhs  USBHS host instance
01250  */ 
01251 __STATIC_INLINE void USBHS_HostPipeDisable(Usbhs *pUsbhs, uint8_t Pipe)
01252 {
01253     assert( Pipe < CHIP_USB_NUMPIPE);
01254     pUsbhs->USBHS_HSTPIP &= ~(USBHS_HSTPIP_PEN0 << Pipe);
01255 }
01256 
01257 /**
01258  * \brief Gets USB host interrupt status
01259  * \param pUsbhs  USBHS host instance
01260  */ 
01261 __STATIC_INLINE uint32_t USBHS_IsHostPipeEnable(Usbhs *pUsbhs, uint8_t Pipe)
01262 {
01263     assert( Pipe < CHIP_USB_NUMPIPE);
01264     return (pUsbhs->USBHS_HSTPIP &(USBHS_HSTPIP_PEN0 << Pipe));
01265 }
01266 /**
01267  * \brief Gets USB host interrupt status
01268  * \param pUsbhs  USBHS host instance
01269  */ 
01270 __STATIC_INLINE void USBHS_HostPipeReset(Usbhs *pUsbhs, uint8_t Pipe)
01271 {
01272     assert( Pipe < CHIP_USB_NUMPIPE);
01273     pUsbhs->USBHS_HSTPIP |= (USBHS_HSTPIP_PRST0 << Pipe);
01274     pUsbhs->USBHS_HSTPIP &= ~(USBHS_HSTPIP_PRST0 << Pipe);
01275 }
01276 
01277 /**
01278  * \brief Gets USB host interrupt status
01279  * \param pUsbhs  USBHS host instance
01280  */ 
01281 __STATIC_INLINE void USBHS_HostConfigure(Usbhs *pUsbhs, uint8_t Pipe, uint32_t pipeBank, uint8_t pipeSize, uint32_t pipeType, uint32_t pipeToken, uint8_t pipeEpNum, uint8_t PipeIntFreq)
01282 {
01283     assert( Pipe < CHIP_USB_NUMPIPE);
01284     pUsbhs->USBHS_HSTPIPCFG[Pipe] |= ( pipeBank | pipeToken | USBHS_HSTPIPCFG_PSIZE(pipeSize) | pipeType | USBHS_HSTPIPCFG_PEPNUM(pipeEpNum) |  USBHS_HSTPIPCFG_INTFRQ(PipeIntFreq));
01285 }
01286 
01287 /**
01288  * \brief Gets USB host interrupt status
01289  * \param pUsbhs  USBHS host instance
01290  */ 
01291 __STATIC_INLINE void USBHS_HostAllocMem(Usbhs *pUsbhs, uint8_t Pipe)
01292 {
01293   pUsbhs->USBHS_HSTPIPCFG[Pipe] |= USBHS_HSTPIPCFG_ALLOC;
01294   
01295 }
01296 
01297 /**
01298  * \brief Gets USB host interrupt status
01299  * \param pUsbhs  USBHS host instance
01300  */ 
01301 __STATIC_INLINE void USBHS_HostFreeMem(Usbhs *pUsbhs, uint8_t Pipe)
01302 {
01303   pUsbhs->USBHS_HSTPIPCFG[Pipe] &= ~USBHS_HSTPIPCFG_ALLOC;
01304   
01305 }
01306 
01307 
01308 /**
01309  * \brief Gets USB host interrupt status
01310  * \param pUsbhs  USBHS host instance
01311  */ 
01312 __STATIC_INLINE uint16_t USBHS_HostGetSize(Usbhs *pUsbhs, uint8_t Pipe)
01313 {
01314     return (8 << ((pUsbhs->USBHS_HSTPIPCFG[Pipe] & USBHS_HSTPIPCFG_PSIZE_Msk) >> USBHS_HSTPIPCFG_PSIZE_Pos)) ;
01315   
01316 }
01317 
01318      /**
01319  * \brief Gets USB host interrupt status
01320  * \param pUsbhs  USBHS host instance
01321  */ 
01322 __STATIC_INLINE void USBHS_HostSetToken(Usbhs *pUsbhs, uint8_t Pipe, uint32_t Token)
01323 {
01324     pUsbhs->USBHS_HSTPIPCFG[Pipe] &= ~USBHS_HSTPIPCFG_PTOKEN_Msk;
01325     pUsbhs->USBHS_HSTPIPCFG[Pipe] |= Token;
01326   
01327 }
01328 
01329 
01330 /**
01331  * \brief Gets USB host interrupt status
01332  * \param pUsbhs  USBHS host instance
01333  */ 
01334 __STATIC_INLINE uint32_t USBHS_HostGetToken(Usbhs *pUsbhs, uint8_t Pipe)
01335 {
01336     return (pUsbhs->USBHS_HSTPIPCFG[Pipe] & USBHS_HSTPIPCFG_PTOKEN_Msk) ;
01337   
01338 }
01339 
01340 
01341 /**
01342  * \brief Gets USB host interrupt status
01343  * \param pUsbhs  USBHS host instance
01344  */ 
01345 __STATIC_INLINE void USBHS_HostSetPipeType(Usbhs *pUsbhs, uint8_t Pipe, uint8_t PipeType)
01346 {
01347     pUsbhs->USBHS_HSTPIPCFG[Pipe] &= ~USBHS_HSTPIPCFG_PTYPE_Msk ;
01348     pUsbhs->USBHS_HSTPIPCFG[Pipe] |= PipeType ;
01349   
01350 }
01351 
01352 /**
01353  * \brief Gets USB host interrupt status
01354  * \param pUsbhs  USBHS host instance
01355  */ 
01356 __STATIC_INLINE uint32_t USBHS_HostGetPipeType(Usbhs *pUsbhs, uint8_t Pipe )
01357 {
01358     return (pUsbhs->USBHS_HSTPIPCFG[Pipe] & USBHS_HSTPIPCFG_PTYPE_Msk) ;
01359   
01360 }
01361 
01362 __STATIC_INLINE uint8_t USBHS_GetPipeEpAddr(Usbhs *pUsbhs, uint8_t Pipe)
01363 {
01364   
01365    if( USBHS_HostGetToken(USBHS, Pipe) == USBHS_HSTPIPCFG_PTOKEN_IN)
01366    {
01367      return ( ((pUsbhs->USBHS_HSTPIPCFG[Pipe] & USBHS_HSTPIPCFG_PEPNUM_Msk) >> USBHS_HSTPIPCFG_PEPNUM_Pos) | 0x80);
01368    }
01369    else
01370    {
01371      return ( ((pUsbhs->USBHS_HSTPIPCFG[Pipe] & USBHS_HSTPIPCFG_PEPNUM_Msk) >> USBHS_HSTPIPCFG_PEPNUM_Pos) | 0x00) ;
01372    }  
01373 }
01374 
01375 
01376 
01377 /**
01378  * \brief Gets USB host interrupt status
01379  * \param pUsbhs  USBHS host instance
01380  */ 
01381 __STATIC_INLINE void USBHS_HostEnableAutoSw(Usbhs *pUsbhs, uint8_t Pipe)
01382 {
01383   pUsbhs->USBHS_HSTPIPCFG[Pipe] |= USBHS_HSTPIPCFG_AUTOSW;  
01384 }
01385 
01386 /**
01387  * \brief Gets USB host interrupt status
01388  * \param pUsbhs  USBHS host instance
01389  */ 
01390 __STATIC_INLINE void USBHS_HostDisableAutoSw(Usbhs *pUsbhs, uint8_t Pipe)
01391 {
01392   pUsbhs->USBHS_HSTPIPCFG[Pipe] &= ~USBHS_HSTPIPCFG_AUTOSW;  
01393 }
01394 
01395 /**
01396  * \brief Gets USB host interrupt status
01397  * \param pUsbhs  USBHS host instance
01398  */ 
01399 __STATIC_INLINE void USBHS_HostSetIntFreq(Usbhs *pUsbhs, uint8_t Pipe, uint8_t Freq)
01400 {
01401   pUsbhs->USBHS_HSTPIPCFG[Pipe] |= USBHS_HSTPIPCFG_BINTERVAL(Freq);  
01402 }
01403 
01404 
01405 /**
01406  * \brief Gets USB host interrupt status
01407  * \param pUsbhs  USBHS host instance
01408  */ 
01409 __STATIC_INLINE void USBHS_HostEnablePing(Usbhs *pUsbhs, uint8_t Pipe)
01410 {
01411   pUsbhs->USBHS_HSTPIPCFG[Pipe] |= USBHS_HSTPIPCFG_PINGEN;  
01412 }
01413 
01414 
01415 /**
01416  * \brief Gets USB host interrupt status
01417  * \param pUsbhs  USBHS host instance
01418  */ 
01419 __STATIC_INLINE uint8_t USBHS_HostGetDataTogSeq(Usbhs *pUsbhs, uint8_t Pipe)
01420 {
01421     return ( (pUsbhs->USBHS_HSTPIPISR[Pipe] & USBHS_HSTPIPISR_DTSEQ_Msk) >> USBHS_HSTPIPISR_DTSEQ_Pos ) ;  
01422 }
01423 
01424 
01425 /**
01426  * \brief Gets USB host interrupt status
01427  * \param pUsbhs  USBHS host instance
01428  */ 
01429 __STATIC_INLINE uint8_t USBHS_HostGetNumOfBusyBank(Usbhs *pUsbhs, uint8_t Pipe)
01430 {
01431     return ( (pUsbhs->USBHS_HSTPIPISR[Pipe] & USBHS_HSTPIPISR_NBUSYBK_Msk) >> USBHS_HSTPIPISR_NBUSYBK_Pos ) ;  
01432 }
01433 
01434 
01435 /**
01436  * \brief Gets USB host interrupt status
01437  * \param pUsbhs  USBHS host instance
01438  */ 
01439 __STATIC_INLINE uint8_t USBHS_HostGetCurrentBank(Usbhs *pUsbhs, uint8_t Pipe)
01440 {
01441     return ( (pUsbhs->USBHS_HSTPIPISR[Pipe] & USBHS_HSTPIPISR_CURRBK_Msk) >> USBHS_HSTPIPISR_CURRBK_Pos ) ;  
01442 }
01443 
01444 
01445 /**
01446  * \brief Gets USB host interrupt status
01447  * \param pUsbhs  USBHS host instance
01448  */ 
01449 __STATIC_INLINE uint8_t USBHS_HostGetPipeByteCount(Usbhs *pUsbhs, uint8_t Pipe)
01450 {
01451     return ( (pUsbhs->USBHS_HSTPIPISR[Pipe] & USBHS_HSTPIPISR_PBYCT_Msk) >> USBHS_HSTPIPISR_PBYCT_Pos ) ;  
01452 }
01453 
01454 /**
01455  * \brief Gets USB host interrupt status
01456  * \param pUsbhs  USBHS host instance
01457  */ 
01458 __STATIC_INLINE uint32_t USBHS_IsHostConfigOk(Usbhs *pUsbhs, uint8_t Pipe)
01459 {
01460     return (pUsbhs->USBHS_HSTPIPISR[Pipe] & USBHS_DEVEPTISR_CFGOK);  
01461 }
01462 
01463 /**
01464  * \brief Gets USB host interrupt status
01465  * \param pUsbhs  USBHS host instance
01466  */ 
01467 __STATIC_INLINE uint32_t USBHS_HostGetIntTypeStatus(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01468 {
01469     return (pUsbhs->USBHS_HSTPIPISR[Pipe] & intType);  
01470 }
01471 
01472 /**
01473  * \brief Gets USB host interrupt status
01474  * \param pUsbhs  USBHS host instance
01475  */ 
01476 __STATIC_INLINE void USBHS_HostAckPipeIntType(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01477 {
01478     pUsbhs->USBHS_HSTPIPICR[Pipe] = intType;  
01479 }
01480 
01481 /**
01482  * \brief Gets USB host interrupt status
01483  * \param pUsbhs  USBHS host instance
01484  */ 
01485 __STATIC_INLINE void USBHS_HostSetPipeIntType(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01486 {
01487     pUsbhs->USBHS_HSTPIPIFR[Pipe] = intType;  
01488 }
01489 
01490 /**
01491  * \brief Gets USB host interrupt status
01492  * \param pUsbhs  USBHS host instance
01493  */ 
01494 __STATIC_INLINE uint32_t USBHS_IsHostPipeIntTypeEnable(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01495 {
01496     return ( pUsbhs->USBHS_HSTPIPIMR[Pipe] & intType);  
01497 }
01498 
01499 /**
01500  * \brief Gets USB host interrupt status
01501  * \param pUsbhs  USBHS host instance
01502  */ 
01503 __STATIC_INLINE void USBHS_HostDisablePipeIntType(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01504 {
01505     pUsbhs->USBHS_HSTPIPIDR[Pipe] = intType;  
01506 }
01507 
01508 /**
01509  * \brief Gets USB host interrupt status
01510  * \param pUsbhs  USBHS host instance
01511  */ 
01512 __STATIC_INLINE void USBHS_HostEnablePipeIntType(Usbhs *pUsbhs, uint8_t Pipe, uint32_t intType)
01513 {
01514     pUsbhs->USBHS_HSTPIPIER[Pipe] = intType;  
01515 }
01516 
01517 /**
01518  * \brief Gets USB host interrupt status
01519  * \param pUsbhs  USBHS host instance
01520  */ 
01521 __STATIC_INLINE void USBHS_HostEnableInReq(Usbhs *pUsbhs, uint8_t Pipe)
01522 {
01523     pUsbhs->USBHS_HSTPIPINRQ[Pipe] |= USBHS_HSTPIPINRQ_INMODE;  
01524 }
01525 
01526 /**
01527  * \brief Gets USB host interrupt status
01528  * \param pUsbhs  USBHS host instance
01529  */ 
01530 __STATIC_INLINE void USBHS_HostDisableInReq(Usbhs *pUsbhs, uint8_t Pipe)
01531 {
01532     pUsbhs->USBHS_HSTPIPINRQ[Pipe] &= ~USBHS_HSTPIPINRQ_INMODE;  
01533 }
01534 
01535 /**
01536  * \brief Gets USB host interrupt status
01537  * \param pUsbhs  USBHS host instance
01538  */ 
01539 __STATIC_INLINE uint8_t USBHS_IsHostInReqEnable(Usbhs *pUsbhs, uint8_t Pipe)
01540 {
01541     return ((pUsbhs->USBHS_HSTPIPINRQ[Pipe] & USBHS_HSTPIPINRQ_INMODE) >> 8); 
01542 }
01543 
01544 /**
01545  * \brief Gets USB host interrupt status
01546  * \param pUsbhs  USBHS host instance
01547  */ 
01548 __STATIC_INLINE void USBHS_HostInReq(Usbhs *pUsbhs, uint8_t Pipe, uint8_t InReq)
01549 {
01550     pUsbhs->USBHS_HSTPIPINRQ[Pipe] = USBHS_HSTPIPINRQ_INRQ(InReq-1);  
01551 }
01552 
01553 
01554 /**
01555  * \brief Gets USB host interrupt status
01556  * \param pUsbhs  USBHS host instance
01557  */ 
01558 __STATIC_INLINE void USBHS_HostSetErr(Usbhs *pUsbhs, uint8_t Pipe, uint8_t Err)
01559 {
01560     pUsbhs->USBHS_HSTPIPERR[Pipe] |= Err;  
01561 }
01562 
01563 /**
01564  * \brief Gets USB host interrupt status
01565  * \param pUsbhs  USBHS host instance
01566  */ 
01567 __STATIC_INLINE uint8_t USBHS_HostGetErr(Usbhs *pUsbhs, uint8_t Pipe, uint8_t Err)
01568 {
01569     return (pUsbhs->USBHS_HSTPIPERR[Pipe] & Err);  
01570 }
01571 
01572 
01573 /**
01574  * \brief Gets USB host interrupt status
01575  * \param pUsbhs  USBHS host instance
01576  */ 
01577 __STATIC_INLINE void USBHS_HostClearErr(Usbhs *pUsbhs, uint8_t Pipe, uint8_t Err)
01578 {
01579     pUsbhs->USBHS_HSTPIPERR[Pipe] = Err;  
01580 }
01581 
01582 
01583 __STATIC_INLINE  uint8_t USBHS_GetInterruptPipeNum(void)
01584 {
01585     uint32_t status = USBHS->USBHS_HSTISR;
01586     uint32_t mask = USBHS->USBHS_HSTIMR;
01587     return ctz(((status & mask) >> 8) | (1 << USBHS_EPT_NUM));
01588 }
01589 
01590 static inline uint8_t USBHS_GetInterruptPipeDmaNum(void)
01591 {
01592     uint32_t status = USBHS->USBHS_HSTISR;
01593     uint32_t mask = USBHS->USBHS_HSTIMR;
01594     return (ctz(((status & mask) >> 25) | (1 << (USBHS_EPT_NUM-1))) + 1);
01595 }
01596  /*--------------------------------------------------------
01597  * =========== USB Host's pipe DMA functions =========
01598  *---------------------------------------------------------*/
01599 
01600  /**
01601  * \brief Sets DMA next descriptor address
01602  * \param pUsbDma  USBHS device DMA instance
01603  * \param Desc NDA addrs
01604  */ 
01605 __STATIC_INLINE void USBHS_SetHostDmaNDA(UsbhsHstdma *pUsbDma, uint32_t Desc)
01606 {
01607   pUsbDma->USBHS_HSTDMANXTDSC = Desc;
01608 }
01609 
01610  /**
01611  * \brief Gets DMA next descriptor address
01612  * \param pUsbDma  USBHS device DMA instance
01613  * \return Next DMA descriptor
01614  */ 
01615 __STATIC_INLINE uint32_t USBHS_GetHostDmaNDA(UsbhsHstdma *pUsbDma)
01616 {
01617    return (pUsbDma->USBHS_HSTDMANXTDSC);
01618 }
01619 
01620  /**
01621  * \brief Sets USBHS's DMA Buffer addresse
01622  * \param pUsbDma  USBHS device DMA instance
01623  * \param Addr  DMA's buffer Addrs
01624  */ 
01625 __STATIC_INLINE void USBHS_SetHostDmaBuffAdd(UsbhsHstdma *pUsbDma, uint32_t Addr)
01626 {
01627   pUsbDma->USBHS_HSTDMAADDRESS = Addr;
01628 }
01629 
01630 
01631  /**
01632  * \brief Gets USBHS's DMA Buffer addresse
01633  * \param pUsbDma  USBHS device DMA instance
01634  * \return DMA addrs
01635  */ 
01636 __STATIC_INLINE uint32_t USBHS_GetHostDmaBuffAdd(UsbhsHstdma *pUsbDma)
01637 {
01638    return (pUsbDma->USBHS_HSTDMAADDRESS);
01639 }
01640 
01641  /**
01642  * \brief Setup the USBHS DMA
01643  * \param pUsbDma  USBHS device DMA instance
01644  * \param Cfg  DMA's configuration
01645  */ 
01646 __STATIC_INLINE void USBHS_HostConfigureDma(UsbhsHstdma *pUsbDma, uint32_t Cfg)
01647 {
01648   pUsbDma->USBHS_HSTDMACONTROL |= Cfg;
01649 }
01650 
01651  /**
01652  * \brief Get DMA configuration
01653  * \param pUsbDma  USBHS device DMA instance
01654  * \return DMA control setup
01655  */ 
01656 __STATIC_INLINE uint32_t USBHS_GetHostDmaConfiguration(UsbhsHstdma *pUsbDma)
01657 {
01658    return (pUsbDma->USBHS_HSTDMACONTROL);
01659 }
01660 
01661 
01662  /**
01663  * \brief Set DMA status
01664  * \param pUsbDma  USBHS device DMA instance
01665  * \Status Set DMA status
01666  */ 
01667 __STATIC_INLINE void USBHS_SetHostPipeDmaStatus(UsbhsHstdma *pUsbDma, uint32_t Status)
01668 {
01669   pUsbDma->USBHS_HSTDMASTATUS = Status;
01670 }
01671 
01672 
01673  /**
01674  * \brief Get Dma Status
01675  * \param pUsbDma  USBHS device DMA instance
01676  * \return Dma status
01677  */ 
01678 __STATIC_INLINE uint32_t USBHS_GetHostPipeDmaStatus(UsbhsHstdma *pUsbDma)
01679 {
01680    return (pUsbDma->USBHS_HSTDMASTATUS);
01681 }
01682 
01683 /**@}*/
01684 #endif /* #ifndef USBHS_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines