37 #ifndef USBHS_OTG_H_INCLUDED    38 #define USBHS_OTG_H_INCLUDED    55     void (*handler)(uint32_t,uint32_t), uint32_t wkup)
    79 # define USB_INT_LEVEL 5   106 #define OTG_ID_DETECT       (defined(CONF_BOARD_USB_PORT) && \   107     defined(CONF_BOARD_USB_ID_DETECT))   108 #define OTG_ID_IO           (defined(USB_ID_PIN) && OTG_ID_DETECT)   111 #define otg_id_init(handler)         otg_io_pin_init(USB_ID_PIN, USB_ID_FLAGS, \   112                         USB_ID_PIN_IRQn, USB_INT_LEVEL, handler, false)   113 # define otg_id_interrupt_enable()   pio_enable_pin_interrupt(USB_ID_PIN)   114 # define otg_id_interrupt_disable()  pio_disable_pin_interrupt(USB_ID_PIN)   115 # define Is_otg_id_device()          ioport_get_pin_level(USB_ID_PIN)   116 # define Is_otg_id_host()            (!Is_otg_id_device())   119 #define otg_force_device_mode()             (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))   120 #define Is_otg_device_mode_forced()         (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))   122 #define otg_force_host_mode()               (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))   124 #define Is_otg_host_mode_forced()           (!Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))   139 #define OTG_VBUS_DETECT (defined(CONF_BOARD_USB_PORT) && \   140     defined(CONF_BOARD_USB_VBUS_DETECT))   141 #define OTG_VBUS_IO     (defined(USB_VBUS_PIN) && OTG_VBUS_DETECT)   142 #ifndef USB_VBUS_WKUP   143 #  define USB_VBUS_WKUP 0   146 #define otg_vbus_init(handler)       otg_io_pin_init(USB_VBUS_PIN, USB_VBUS_FLAGS, \   147   USB_VBUS_PIN_IRQn, USB_INT_LEVEL, handler, USB_VBUS_WKUP)   148 #define Is_otg_vbus_high()           ioport_get_pin_level(USB_VBUS_PIN)   149 #define Is_otg_vbus_low()            (!Is_otg_vbus_high())   150 #define otg_enable_vbus_interrupt()  pio_enable_pin_interrupt(USB_VBUS_PIN)   151 #define otg_disable_vbus_interrupt() pio_disable_pin_interrupt(USB_VBUS_PIN)   158 #define otg_reset()                         \   160                 USBHS->USBHS_CTRL = 0;            \   161                 while( USBHS->USBHS_SR & 0x3FFF) {\   162                         USBHS->USBHS_SCR = 0xFFFFFFFF;\   165 #define otg_enable()                        (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))   167 #define otg_disable()                       (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))   169 #define Is_otg_enabled()                    (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))   173 #define Is_otg_clock_usable()               (Tst_bits(USBHS->USBHS_SR, USBHS_SR_CLKUSABLE))   176 #define otg_freeze_clock()                  (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))   177 #define otg_unfreeze_clock()                (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))   178 #define Is_otg_clock_frozen()               (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))   181 #define otg_enable_rderr_interrupt()          (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))   182 #define otg_disable_rderr_interrupt()         (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))   184 #define Is_otg_rderr_interrupt_enabled()      (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))   185 #define otg_ack_rderr_interrupt()             (USBHS->USBHS_SCR = USBHS_SCR_RDERRIC)   187 #define otg_raise_rderr_interrupt()           (USBHS->USBHS_SFR = USBHS_SFR_RDERRIS)   189 #define Is_otg_rderr_interrupt()              (Tst_bits(USBHS->USBHS_SR, USBHS_SR_RDERRI)) 
static __always_inline void otg_io_pin_init(uint32_t pin, uint32_t flags, IRQn_Type port_irqn, uint8_t irq_level, void(*handler)(uint32_t, uint32_t), uint32_t wkup)
 
void pio_enable_pin_interrupt(uint32_t ul_pin)
Enable interrupt for a GPIO pin. 
 
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
Set Interrupt Priority. 
 
Common IOPORT service main header file for AVR, UC3 and ARM architectures. 
 
Commonly used includes, types and macros. 
 
void pmc_set_fast_startup_input(uint32_t ul_inputs)
Set the wake-up inputs for fast startup mode registers (event generation). 
 
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
Enable External Interrupt. 
 
uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag, void(*p_handler)(uint32_t, uint32_t))
 
void otg_dual_disable(void)
Uninitialize the dual role This function is implemented in usbhs_host.c file. 
 
Parallel Input/Output (PIO) interrupt handler for SAM. 
 
bool otg_dual_enable(void)
Initialize the dual role This function is implemented in usbhs_host.c file. 
 
Standard board header file. 
 
static void ioport_set_pin_sense_mode(ioport_pin_t pin, enum ioport_sense pin_sense)
Set the pin sense mode of a single IOPORT pin.