Macros | Functions
USBHS OTG Driver
Collaboration diagram for USBHS OTG Driver:

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.

Note
ioport_init() must be invoked before using VBus pin functions since they use IOPORT API,
See also
Common IOPORT API.
#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))
 For parts with HS feature, this one corresponding at UTMI clock. 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...
 

Detailed Description

USBHS low-level driver for OTG features

Macro Definition Documentation

◆ Is_otg_clock_frozen

#define Is_otg_clock_frozen ( )    (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))

Definition at line 178 of file usbhs_otg.h.

◆ Is_otg_clock_usable

#define Is_otg_clock_usable ( )    (Tst_bits(USBHS->USBHS_SR, USBHS_SR_CLKUSABLE))

For parts with HS feature, this one corresponding at UTMI clock.

Check Clock Usable

Definition at line 173 of file usbhs_otg.h.

◆ Is_otg_device_mode_forced

#define Is_otg_device_mode_forced ( )    (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))

Test if device mode is forced.

Definition at line 121 of file usbhs_otg.h.

◆ Is_otg_enabled

#define Is_otg_enabled ( )    (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))

Definition at line 169 of file usbhs_otg.h.

◆ Is_otg_host_mode_forced

#define Is_otg_host_mode_forced ( )    (!Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))

Test if host mode is forced.

Definition at line 125 of file usbhs_otg.h.

◆ Is_otg_id_device

#define Is_otg_id_device ( )    ioport_get_pin_level(USB_ID_PIN)

Definition at line 115 of file usbhs_otg.h.

◆ Is_otg_id_host

#define Is_otg_id_host ( )    (!Is_otg_id_device())

Definition at line 116 of file usbhs_otg.h.

◆ Is_otg_rderr_interrupt

#define Is_otg_rderr_interrupt ( )    (Tst_bits(USBHS->USBHS_SR, USBHS_SR_RDERRI))

Tests if a RDERR occurs.

Definition at line 190 of file usbhs_otg.h.

◆ Is_otg_rderr_interrupt_enabled

#define Is_otg_rderr_interrupt_enabled ( )    (Tst_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))

Definition at line 184 of file usbhs_otg.h.

◆ Is_otg_vbus_high

#define Is_otg_vbus_high ( )    ioport_get_pin_level(USB_VBUS_PIN)

Definition at line 148 of file usbhs_otg.h.

◆ Is_otg_vbus_low

#define Is_otg_vbus_low ( )    (!Is_otg_vbus_high())

Definition at line 149 of file usbhs_otg.h.

◆ otg_ack_rderr_interrupt

#define otg_ack_rderr_interrupt ( )    (USBHS->USBHS_SCR = USBHS_SCR_RDERRIC)

ACKs RDERR interrupt.

Definition at line 186 of file usbhs_otg.h.

◆ otg_disable

#define otg_disable ( )    (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))

Disable USB macro.

Definition at line 168 of file usbhs_otg.h.

◆ otg_disable_rderr_interrupt

#define otg_disable_rderr_interrupt ( )    (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))

Disables RDERR interrupt.

Definition at line 183 of file usbhs_otg.h.

◆ otg_disable_vbus_interrupt

#define otg_disable_vbus_interrupt ( )    pio_disable_pin_interrupt(USB_VBUS_PIN)

Definition at line 151 of file usbhs_otg.h.

◆ otg_enable

#define otg_enable ( )    (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_USBE))

Enable USB macro.

Definition at line 166 of file usbhs_otg.h.

◆ otg_enable_rderr_interrupt

#define otg_enable_rderr_interrupt ( )    (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_RDERRE))

Enables RDERR interrupt.

Definition at line 181 of file usbhs_otg.h.

◆ otg_enable_vbus_interrupt

#define otg_enable_vbus_interrupt ( )    pio_enable_pin_interrupt(USB_VBUS_PIN)

Definition at line 150 of file usbhs_otg.h.

◆ otg_force_device_mode

#define otg_force_device_mode ( )    (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))

Definition at line 119 of file usbhs_otg.h.

◆ otg_force_host_mode

#define otg_force_host_mode ( )    (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_UIMOD))

Disable external OTG_ID pin and force host mode.

Definition at line 123 of file usbhs_otg.h.

◆ otg_freeze_clock

#define otg_freeze_clock ( )    (Set_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))

Stop (freeze) internal USB clock.

Definition at line 176 of file usbhs_otg.h.

◆ OTG_ID_DETECT

#define OTG_ID_DETECT
Value:
(defined(CONF_BOARD_USB_PORT) && \
defined(CONF_BOARD_USB_ID_DETECT))

Definition at line 106 of file usbhs_otg.h.

◆ otg_id_init

#define otg_id_init (   handler)
Value:
otg_io_pin_init(USB_ID_PIN, USB_ID_FLAGS, \
USB_ID_PIN_IRQn, USB_INT_LEVEL, handler, false)
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)
Definition: usbhs_otg.h:53
#define USB_INT_LEVEL
USB interrupt level By default USB interrupt have low priority.
Definition: usbhs_otg.h:79

Definition at line 111 of file usbhs_otg.h.

◆ otg_id_interrupt_disable

#define otg_id_interrupt_disable ( )    pio_disable_pin_interrupt(USB_ID_PIN)

Definition at line 114 of file usbhs_otg.h.

◆ otg_id_interrupt_enable

#define otg_id_interrupt_enable ( )    pio_enable_pin_interrupt(USB_ID_PIN)

Definition at line 113 of file usbhs_otg.h.

◆ OTG_ID_IO

#define OTG_ID_IO   (defined(USB_ID_PIN) && OTG_ID_DETECT)

Definition at line 108 of file usbhs_otg.h.

◆ otg_raise_rderr_interrupt

#define otg_raise_rderr_interrupt ( )    (USBHS->USBHS_SFR = USBHS_SFR_RDERRIS)

Raises RDERR interrupt.

Definition at line 188 of file usbhs_otg.h.

◆ otg_reset

#define otg_reset ( )
Value:
do { \
USBHS->USBHS_CTRL = 0; \
while( USBHS->USBHS_SR & 0x3FFF) {\
USBHS->USBHS_SCR = 0xFFFFFFFF;\
} \
} while (0)
#define USBHS
(USBHS ) Base Address
Definition: same70j19.h:508

Reset USB macro.

Definition at line 158 of file usbhs_otg.h.

◆ otg_unfreeze_clock

#define otg_unfreeze_clock ( )    (Clr_bits(USBHS->USBHS_CTRL, USBHS_CTRL_FRZCLK))

Definition at line 177 of file usbhs_otg.h.

◆ OTG_VBUS_DETECT

#define OTG_VBUS_DETECT
Value:
(defined(CONF_BOARD_USB_PORT) && \
defined(CONF_BOARD_USB_VBUS_DETECT))

Definition at line 139 of file usbhs_otg.h.

◆ otg_vbus_init

#define otg_vbus_init (   handler)
Value:
otg_io_pin_init(USB_VBUS_PIN, USB_VBUS_FLAGS, \
USB_VBUS_PIN_IRQn, USB_INT_LEVEL, handler, USB_VBUS_WKUP)
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)
Definition: usbhs_otg.h:53
#define USB_VBUS_WKUP
Definition: usbhs_otg.h:143
#define USB_INT_LEVEL
USB interrupt level By default USB interrupt have low priority.
Definition: usbhs_otg.h:79

Definition at line 146 of file usbhs_otg.h.

◆ OTG_VBUS_IO

#define OTG_VBUS_IO   (defined(USB_VBUS_PIN) && OTG_VBUS_DETECT)

Definition at line 141 of file usbhs_otg.h.

◆ USB_INT_LEVEL

#define USB_INT_LEVEL   5

USB interrupt level By default USB interrupt have low priority.

Definition at line 79 of file usbhs_otg.h.

◆ USB_VBUS_WKUP

#define USB_VBUS_WKUP   0

Definition at line 143 of file usbhs_otg.h.

Function Documentation

◆ otg_dual_disable()

void otg_dual_disable ( void  )

Uninitialize the dual role This function is implemented in usbhs_host.c file.

◆ otg_dual_enable()

bool otg_dual_enable ( void  )

Initialize the dual role This function is implemented in usbhs_host.c file.

Returns
true if the ID pin management has been started, otherwise false.


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:07