USBHS low-level driver for OTG features.
Macros | |
#define | USB_INT_LEVEL 5 |
USB interrupt level By default USB interrupt have low priority. More... | |
Functions | |
void | otg_dual_disable (void) |
Uninitialize the dual role This function is implemented in usbhs_host.c file. More... | |
bool | otg_dual_enable (void) |
Initialize the dual role This function is implemented in usbhs_host.c file. More... | |
USBHS OTG ID pin management | |
The ID pin come from the USB OTG connector (A and B receptacle) and allows to select the USB mode host or device. The ID pin can be managed through PIO pin. This feature is optional, and it is enabled if USB_ID_PIN is defined in board.h and CONF_BOARD_USB_ID_DETECT defined in conf_board.h. | |
#define | OTG_ID_DETECT |
#define | OTG_ID_IO (defined(USB_ID_PIN) && OTG_ID_DETECT) |
#define | otg_id_init(handler) |
#define | otg_id_interrupt_enable() pio_enable_pin_interrupt(USB_ID_PIN) |
#define | otg_id_interrupt_disable() pio_disable_pin_interrupt(USB_ID_PIN) |
#define | Is_otg_id_device() ioport_get_pin_level(USB_ID_PIN) |
#define | Is_otg_id_host() (!Is_otg_id_device()) |
#define | otg_force_device_mode() (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
#define | Is_otg_device_mode_forced() (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Test if device mode is forced. More... | |
#define | otg_force_host_mode() (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Disable external OTG_ID pin and force host mode. More... | |
#define | Is_otg_host_mode_forced() (!Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Test if host mode is forced. More... | |
USBHS OTG VBUS pin management | |
USBHS peripheral does not support VBUS management and it's monitored by a PIO pin. This feature is optional, and it is enabled if USB_VBUS_PIN is defined in board.h and CONF_BOARD_USB_VBUS_DETECT defined in conf_board.h.
| |
#define | OTG_VBUS_DETECT |
#define | OTG_VBUS_IO (defined(USB_VBUS_PIN) && OTG_VBUS_DETECT) |
#define | USB_VBUS_WKUP 0 |
#define | otg_vbus_init(handler) |
#define | Is_otg_vbus_high() ioport_get_pin_level(USB_VBUS_PIN) |
#define | Is_otg_vbus_low() (!Is_otg_vbus_high()) |
#define | otg_enable_vbus_interrupt() pio_enable_pin_interrupt(USB_VBUS_PIN) |
#define | otg_disable_vbus_interrupt() pio_disable_pin_interrupt(USB_VBUS_PIN) |
USBHS OTG main management | |
These macros allows to enable/disable pad and USBHS hardware | |
#define | otg_reset() |
Reset USB macro. More... | |
#define | otg_enable() (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
Enable USB macro. More... | |
#define | otg_disable() (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
Disable USB macro. More... | |
#define | Is_otg_enabled() (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
#define | Is_otg_clock_usable() (Tst_bits(USBHS->USBHS_SR, USBHS_SR_CLKUSABLE)) |
Check Clock Usable. More... | |
#define | otg_freeze_clock() (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
Stop (freeze) internal USB clock. More... | |
#define | otg_unfreeze_clock() (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
#define | Is_otg_clock_frozen() (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
#define | otg_enable_rderr_interrupt() (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
Enables RDERR interrupt. More... | |
#define | otg_disable_rderr_interrupt() (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
Disables RDERR interrupt. More... | |
#define | Is_otg_rderr_interrupt_enabled() (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
#define | otg_ack_rderr_interrupt() (USBHS->USBHS_SCR = USBHS_SCR_RDERRIC) |
ACKs RDERR interrupt. More... | |
#define | otg_raise_rderr_interrupt() (USBHS->USBHS_SFR = USBHS_SFR_RDERRIS) |
Raises RDERR interrupt. More... | |
#define | Is_otg_rderr_interrupt() (Tst_bits(USBHS->USBHS_SR, USBHS_SR_RDERRI)) |
Tests if a RDERR occurs. More... | |
#define Is_otg_clock_frozen | ( | ) | (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
#define Is_otg_clock_usable | ( | ) | (Tst_bits(USBHS->USBHS_SR, USBHS_SR_CLKUSABLE)) |
Check Clock Usable.
For parts with HS feature, this one corresponding at UTMI clock
Referenced by udd_attach(), udd_enable(), udd_interrupt(), uhd_disable(), uhd_enable(), uhd_interrupt(), and uhd_resume().
#define Is_otg_device_mode_forced | ( | ) | (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Test if device mode is forced.
Referenced by ISR().
#define Is_otg_enabled | ( | ) | (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
#define Is_otg_host_mode_forced | ( | ) | (!Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Test if host mode is forced.
Referenced by udd_disable().
#define Is_otg_id_device | ( | ) | ioport_get_pin_level(USB_ID_PIN) |
Referenced by otg_dual_enable(), otg_id_handler(), udd_enable(), and uhd_enable().
#define Is_otg_id_host | ( | ) | (!Is_otg_id_device()) |
Referenced by udd_disable().
#define Is_otg_rderr_interrupt | ( | ) | (Tst_bits(USBHS->USBHS_SR, USBHS_SR_RDERRI)) |
Tests if a RDERR occurs.
#define Is_otg_rderr_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
#define Is_otg_vbus_high | ( | ) | ioport_get_pin_level(USB_VBUS_PIN) |
Referenced by udd_enable(), uhd_enable(), and uhd_vbus_handler().
#define Is_otg_vbus_low | ( | ) | (!Is_otg_vbus_high()) |
#define otg_ack_rderr_interrupt | ( | ) | (USBHS->USBHS_SCR = USBHS_SCR_RDERRIC) |
ACKs RDERR interrupt.
#define otg_disable | ( | ) | (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
Disable USB macro.
Referenced by otg_dual_disable(), udd_disable(), and uhd_disable().
#define otg_disable_rderr_interrupt | ( | ) | (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
Disables RDERR interrupt.
#define otg_disable_vbus_interrupt | ( | ) | pio_disable_pin_interrupt(USB_VBUS_PIN) |
#define otg_enable | ( | ) | (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE)) |
Enable USB macro.
Referenced by udd_enable(), and uhd_enable().
#define otg_enable_rderr_interrupt | ( | ) | (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE)) |
Enables RDERR interrupt.
#define otg_enable_vbus_interrupt | ( | ) | pio_enable_pin_interrupt(USB_VBUS_PIN) |
#define otg_force_device_mode | ( | ) | (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
#define otg_force_host_mode | ( | ) | (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD)) |
Disable external OTG_ID pin and force host mode.
Referenced by otg_dual_enable(), otg_id_handler(), and uhd_enable().
#define otg_freeze_clock | ( | ) | (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
Stop (freeze) internal USB clock.
Referenced by otg_dual_disable(), udd_attach(), udd_detach(), udd_disable(), udd_enable(), udd_interrupt(), uhd_delayed_suspend(), uhd_disable(), and uhd_vbus_handler().
#define OTG_ID_DETECT |
#define otg_id_init | ( | handler | ) |
Referenced by otg_dual_enable().
#define otg_id_interrupt_disable | ( | ) | pio_disable_pin_interrupt(USB_ID_PIN) |
Referenced by otg_dual_disable().
#define otg_id_interrupt_enable | ( | ) | pio_enable_pin_interrupt(USB_ID_PIN) |
#define OTG_ID_IO (defined(USB_ID_PIN) && OTG_ID_DETECT) |
#define otg_raise_rderr_interrupt | ( | ) | (USBHS->USBHS_SFR = USBHS_SFR_RDERRIS) |
Raises RDERR interrupt.
#define otg_reset | ( | ) |
Reset USB macro.
#define otg_unfreeze_clock | ( | ) | (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK)) |
#define OTG_VBUS_DETECT |
#define otg_vbus_init | ( | handler | ) |
Referenced by udd_enable(), and uhd_enable().
#define OTG_VBUS_IO (defined(USB_VBUS_PIN) && OTG_VBUS_DETECT) |
#define USB_INT_LEVEL 5 |
USB interrupt level By default USB interrupt have low priority.
#define USB_VBUS_WKUP 0 |
void otg_dual_disable | ( | void | ) |
Uninitialize the dual role This function is implemented in usbhs_host.c file.
References otg_disable, otg_freeze_clock, otg_id_interrupt_disable, otg_unfreeze_clock, pmc_clr_fast_startup_input(), pmc_disable_periph_clk(), sysclk_disable_usb(), uhd_sleep_mode(), and UHD_STATE_OFF.
Referenced by uhd_disable().
bool otg_dual_enable | ( | void | ) |
Initialize the dual role This function is implemented in usbhs_host.c file.
true
if the ID pin management has been started, otherwise false
. References Is_otg_id_device, otg_force_host_mode, otg_id_handler(), otg_id_init, pmc_enable_periph_clk(), pmc_set_fast_startup_input(), sysclk_enable_usb(), udc_start(), UHC_MODE_CHANGE, uhc_start(), uhd_sleep_mode(), UHD_STATE_OFF, UHD_STATE_WAIT_ID_HOST, and UHD_USB_INT_LEVEL.
Referenced by udd_enable(), and uhd_enable().