Robobo
USB Host Driver (UHD)

Macros

#define uhd_ack_errors_interrupt()   (UOTGHS->UOTGHS_SCR = (UOTGHS_SCR_VBERRIC|UOTGHS_SCR_BCERRIC|UOTGHS_SCR_HNPERRIC|UOTGHS_SCR_STOIC))
 
#define Is_uhd_errors_interrupt()   (Tst_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBERRE|UOTGHS_CTRL_BCERRE|UOTGHS_CTRL_HNPERRE|UOTGHS_CTRL_STOE))
 
#define uhd_enable_suspend_error_interrupt()
 
#define uhd_enable_hnp_error_interrupt()
 
#define uhd_enable_bconn_error_interrupt()
 

UOTGHS Host IP properties

Get maximal number of endpoints

#define uhd_get_pipe_max_nbr()   (9)
 
#define UOTGHS_EPT_NUM   (uhd_get_pipe_max_nbr()+1)
 

Host Vbus line control

VBOF is an optional output pin which allows to enable or disable the external VBus generator.

Enables hardware control of USB_VBOF output pin when a Vbus error occur

#define uhd_enable_vbus_error_hw_control()   (Clr_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBUSHWC))
 
#define uhd_disable_vbus_error_hw_control()   (Set_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBUSHWC))
 Disables hardware control of USB_VBOF output pin when a Vbus error occur.
 
#define USB_VBOF_PIN   USB_VBOF_GPIO
 Pin and function for USB_VBOF according to configuration from USB_VBOF.
 
#define USB_VBOF_FUNCTION   USB_VBOF_FLAGS
 
#define uhd_output_vbof_pin()
 Output USB_VBOF onto its pin. More...
 
#define uhd_set_vbof_active_high()   (Set_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBUSPO))
 Set USB_VBOF output pin polarity.
 
#define uhd_set_vbof_active_low()   (Clr_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBUSPO))
 
#define uhd_enable_vbus()   (Set_bits(UOTGHS->UOTGHS_SFR, UOTGHS_SR_VBUSRQ))
 Requests VBus activation.
 
#define uhd_disable_vbus()   (Set_bits(UOTGHS->UOTGHS_SCR, UOTGHS_SR_VBUSRQ))
 Requests VBus deactivation.
 
#define Is_uhd_vbus_enabled()   (Tst_bits(UOTGHS->UOTGHS_SR, UOTGHS_SR_VBUSRQ))
 Tests if VBus activation has been requested.
 

Host Vbus line monitoring

The VBus level is always checked by USBC hardware.

#define uhd_enable_vbus_error_interrupt()   (Set_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBERRE))
 
#define uhd_disable_vbus_error_interrupt()   (Clr_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBERRE))
 
#define Is_uhd_vbus_error_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_CTRL, UOTGHS_CTRL_VBERRE))
 
#define uhd_ack_vbus_error_interrupt()   (Set_bits(UOTGHS->UOTGHS_SCR, UOTGHS_SCR_VBERRIC))
 
#define Is_uhd_vbus_error_interrupt()   (Tst_bits(UOTGHS->UOTGHS_SR, UOTGHS_SR_VBERRI))
 

USB device connection/disconnection monitoring

#define uhd_enable_connection_int()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_DCONNIES)
 
#define uhd_disable_connection_int()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_DCONNIEC)
 
#define Is_uhd_connection_int_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_DCONNIE))
 
#define uhd_ack_connection()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_DCONNIC)
 
#define Is_uhd_connection()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_DCONNI))
 
#define uhd_enable_disconnection_int()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_DDISCIES)
 
#define uhd_disable_disconnection_int()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_DDISCIEC)
 
#define Is_uhd_disconnection_int_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_DDISCIE))
 
#define uhd_ack_disconnection()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_DDISCIC)
 
#define Is_uhd_disconnection()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_DDISCI))
 

USB device speed control

#define uhd_get_speed_mode()   (Rd_bits(UOTGHS->UOTGHS_SR, UOTGHS_SR_SPEED_Msk))
 
#define Is_uhd_low_speed_mode()   (uhd_get_speed_mode() == UOTGHS_SR_SPEED_LOW_SPEED)
 
#define Is_uhd_full_speed_mode()   (uhd_get_speed_mode() == UOTGHS_SR_SPEED_FULL_SPEED)
 
#define Is_uhd_high_speed_mode()   (uhd_get_speed_mode() == UOTGHS_SR_SPEED_HIGH_SPEED)
 
#define uhd_enable_high_speed_mode()   (Wr_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, UOTGHS_HSTCTRL_SPDCONF_HIGH_SPEED))
 Enable high speed mode.
 
#define uhd_disable_high_speed_mode()   (Wr_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, UOTGHS_HSTCTRL_SPDCONF_FORCED_FS))
 Disable high speed mode.
 

Bus events control

These macros manage the bus events: reset, SOF, resume, wakeup.

#define uhd_start_reset()   (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESET))
 
#define Is_uhd_starting_reset()   (Tst_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESET))
 
#define uhd_stop_reset()   (Clr_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESET))
 
#define uhd_enable_reset_sent_interrupt()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_RSTIES)
 
#define uhd_disable_reset_sent_interrupt()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_RSTIEC)
 
#define Is_uhd_reset_sent_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_RSTIE))
 
#define uhd_ack_reset_sent()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_RSTIC)
 
#define Is_uhd_reset_sent()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_RSTI))
 
#define uhd_enable_sof()   (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SOFE))
 
#define uhd_disable_sof()   (Clr_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SOFE))
 
#define Is_uhd_sof_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SOFE))
 
#define uhd_get_sof_number()   ((UOTGHS->UOTGHS_HSTFNUM&UOTGHS_HSTFNUM_FNUM_Msk)>>UOTGHS_HSTFNUM_FNUM_Pos)
 
#define uhd_get_microsof_number()   ((UOTGHS->UOTGHS_HSTFNUM&UOTGHS_HSTFNUM_MFNUM_Msk)>>UOTGHS_HSTFNUM_MFNUM_Pos)
 
#define uhd_get_frame_position()   (Rd_bits(UOTGHS->UOTGHS_HSTFNUM, UOTGHS_HSTFNUM_FLENHIGH_Msk))
 
#define uhd_enable_sof_interrupt()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_HSOFIES)
 
#define uhd_disable_sof_interrupt()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_HSOFIEC)
 
#define Is_uhd_sof_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_HSOFIE))
 
#define uhd_ack_sof()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_HSOFIC)
 
#define Is_uhd_sof()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_HSOFI))
 
#define uhd_send_resume()   (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESUME))
 
#define Is_uhd_sending_resume()   (Tst_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESUME))
 
#define uhd_enable_downstream_resume_interrupt()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_RSMEDIES)
 
#define uhd_disable_downstream_resume_interrupt()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_RSMEDIEC)
 
#define Is_uhd_downstream_resume_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_RSMEDIE))
 
#define uhd_ack_downstream_resume()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_RSMEDIC)
 
#define Is_uhd_downstream_resume()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_RSMEDI))
 
#define uhd_enable_wakeup_interrupt()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_HWUPIES)
 
#define uhd_disable_wakeup_interrupt()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_HWUPIEC)
 
#define Is_uhd_wakeup_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_HWUPIE))
 
#define uhd_ack_wakeup()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_HWUPIC)
 
#define Is_uhd_wakeup()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_HWUPI))
 
#define uhd_enable_upstream_resume_interrupt()   (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_RXRSMIES)
 
#define uhd_disable_upstream_resume_interrupt()   (UOTGHS->UOTGHS_HSTIDR = UOTGHS_HSTIDR_RXRSMIEC)
 
#define Is_uhd_upstream_resume_interrupt_enabled()   (Tst_bits(UOTGHS->UOTGHS_HSTIMR, UOTGHS_HSTIMR_RXRSMIE))
 
#define uhd_ack_upstream_resume()   (UOTGHS->UOTGHS_HSTICR = UOTGHS_HSTICR_RXRSMIC)
 
#define Is_uhd_upstream_resume()   (Tst_bits(UOTGHS->UOTGHS_HSTISR, UOTGHS_HSTISR_RXRSMI))
 

Detailed Description

UOTGHS low-level driver for USB host mode

Macro Definition Documentation

#define uhd_enable_sof ( )    (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SOFE))

Initiates a SOF events

#define uhd_enable_wakeup_interrupt ( )    (UOTGHS->UOTGHS_HSTIER = UOTGHS_HSTIER_HWUPIES)

Detection of a wake-up event A wake-up event is received when the host controller is in the suspend mode:

  • and an upstream resume from the peripheral is detected.
  • and a peripheral disconnection is detected.
#define uhd_output_vbof_pin ( )
Value:
do {\
pio_configure_pin(USB_VBOF_PIN, USB_VBOF_FUNCTION); \
} while (0)
#define USB_VBOF_PIN
Pin and function for USB_VBOF according to configuration from USB_VBOF.
Definition: uotghs_host.h:59

Output USB_VBOF onto its pin.

#define uhd_send_resume ( )    (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESUME))

Initiates a resume event It is called downstream resume event.

#define uhd_start_reset ( )    (Set_bits(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_RESET))

Initiates a reset event