M480 BSP  V3.05.001
The Board Support Package for M480 Series
otg.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __OTG_H__
10 #define __OTG_H__
11 
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16 
17 
33 /*---------------------------------------------------------------------------------------------------------*/
34 /* OTG constant definitions */
35 /*---------------------------------------------------------------------------------------------------------*/
36 #define OTG_VBUS_EN_ACTIVE_HIGH (0UL)
37 #define OTG_VBUS_EN_ACTIVE_LOW (1UL)
38 #define OTG_VBUS_ST_VALID_HIGH (0UL)
39 #define OTG_VBUS_ST_VALID_LOW (1UL)
42  /* end of group OTG_EXPORTED_CONSTANTS */
43 
44 
49 /*---------------------------------------------------------------------------------------------------------*/
50 /* Define Macros and functions */
51 /*---------------------------------------------------------------------------------------------------------*/
52 
53 
61 #define OTG_ENABLE() (OTG->CTL |= OTG_CTL_OTGEN_Msk)
62 
70 #define OTG_DISABLE() (OTG->CTL &= ~OTG_CTL_OTGEN_Msk)
71 
80 #define OTG_ENABLE_PHY() (OTG->PHYCTL |= OTG_PHYCTL_OTGPHYEN_Msk)
81 
89 #define OTG_DISABLE_PHY() (OTG->PHYCTL &= ~OTG_PHYCTL_OTGPHYEN_Msk)
90 
98 #define OTG_ENABLE_ID_DETECT() (OTG->PHYCTL |= OTG_PHYCTL_IDDETEN_Msk)
99 
107 #define OTG_DISABLE_ID_DETECT() (OTG->PHYCTL &= ~OTG_PHYCTL_IDDETEN_Msk)
108 
116 #define OTG_ENABLE_WAKEUP() (OTG->CTL |= OTG_CTL_WKEN_Msk)
117 
125 #define OTG_DISABLE_WAKEUP() (OTG->CTL &= ~OTG_CTL_WKEN_Msk)
126 
136 #define OTG_SET_VBUS_EN_POL(u32Pol) (OTG->PHYCTL = (OTG->PHYCTL & (~OTG_PHYCTL_VBENPOL_Msk)) | ((u32Pol)<<OTG_PHYCTL_VBENPOL_Pos))
137 
147 #define OTG_SET_VBUS_STS_POL(u32Pol) (OTG->PHYCTL = (OTG->PHYCTL & (~OTG_PHYCTL_VBSTSPOL_Msk)) | ((u32Pol)<<OTG_PHYCTL_VBSTSPOL_Pos))
148 
169 #define OTG_ENABLE_INT(u32Mask) (OTG->INTEN |= (u32Mask))
170 
191 #define OTG_DISABLE_INT(u32Mask) (OTG->INTEN &= ~(u32Mask))
192 
213 #define OTG_GET_INT_FLAG(u32Mask) (OTG->INTSTS & (u32Mask))
214 
235 #define OTG_CLR_INT_FLAG(u32Mask) (OTG->INTSTS = (u32Mask))
236 
250 #define OTG_GET_STATUS(u32Mask) (OTG->STATUS & (u32Mask))
251 
252 
253  /* end of group OTG_EXPORTED_FUNCTIONS */
255  /* end of group OTG_Driver */
257  /* end of group Standard_Driver */
259 
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 
266 #endif /*__OTG_H__ */
267 
268 /*** (C) COPYRIGHT 2017 Nuvoton Technology Corp. ***/