USBC OTG Driver header file.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "compiler.h"
#include "preprocessor.h"
#include "conf_board.h"
#include "board.h"
#include "ioport.h"
#include "gpio.h"
#include "eic.h"
Macros | |
#define | Is_otg_clock_frozen() USBC_TST_BITS(USBCON,FRZCLK) |
#define | Is_otg_clock_usable() USBC_TST_BITS(USBSTA,CLKUSABLE) |
Check USB interface clock usable. More... | |
#define | Is_otg_suspend() USBC_TST_BITS(USBSTA,SUSPEND) |
Check transceiver state. More... | |
#define | Is_otg_transceiver_off() (Is_otg_suspend()) |
#define | Is_otg_transceiver_on() (!Is_otg_suspend()) |
#define | otg_freeze_clock() USBC_SET_BITS(USBCON,FRZCLK) |
#define | otg_get_fsm_drd_state() USBC_RD_BITFIELD(USBFSM,DRDSTATE) |
Get the dual-role device state of the internal USB finite state machine. More... | |
#define | otg_register_desc_tab(addr) (Wr_bitfield(USBC->USBC_UDESC, USBC_UDESC_UDESCA_Msk, addr)) |
#define | otg_unfreeze_clock() USBC_CLR_BITS(USBCON,FRZCLK) |
#define | USBC_CLR_BITS(reg, bit) (Clr_bits(USBC->TPASTE2(USBC_,reg), TPASTE4(USBC_,reg,_,bit))) |
#define | USBC_RD_BITFIELD(reg, bit) |
#define | USBC_RD_BITS(reg, bit) (Rd_bits(USBC->TPASTE2(USBC_,reg), TPASTE4(USBC_,reg,_,bit))) |
#define | USBC_REG_CLR(reg, bit) (USBC->TPASTE3(USBC_,reg,CLR) = TPASTE5(USBC_,reg,CLR_,bit,C)) |
#define | USBC_REG_SET(reg, bit) (USBC->TPASTE3(USBC_,reg,SET) = TPASTE5(USBC_,reg,SET_,bit,S)) |
#define | USBC_SET_BITS(reg, bit) (Set_bits(USBC->TPASTE2(USBC_,reg), TPASTE4(USBC_,reg,_,bit))) |
#define | USBC_TST_BITS(reg, bit) (Tst_bits(USBC->TPASTE2(USBC_,reg), TPASTE4(USBC_,reg,_,bit))) |
#define | USBC_WR_BITFIELD(reg, bit, value) |
USBC IP properties | |
These macros give access to IP properties | |
#define | otg_get_ip_name() (((uint64_t)USBC->USBC_UNAME1<<32)|(uint64_t)USBC->USBC_UNAME2) |
Get IP name part 1 or 2. More... | |
#define | otg_data_memory_barrier() do { barrier(); } while (0) |
#define | otg_get_ip_version() USBC_RD_BITFIELD(UVERS,VERSION) |
Get IP version. More... | |
#define | otg_get_max_nbr_endpoints() USBC_RD_BITFIELD(UFEATURES, EPTNBRMAX) |
Get maximal number of pipes/endpoints. More... | |
#define | otg_get_max_nbr_pipes() USBC_RD_BITFIELD(UFEATURES, EPTNBRMAX) |
USBC OTG ID pin management | |
The ID pin come from the USB OTG connector (A and B receptable) and allows to select the USB mode host or device. The ID pin can be managed through GPIO or EIC pin. This feature is optional, and it is enabled if USB_ID_PIN or USB_ID_EIC is defined in board.h and CONF_BOARD_USB_ID_DETECT defined in conf_board.h. | |
#define | OTG_ID_DETECT (defined(CONF_BOARD_USB_ID_DETECT)) |
#define | OTG_ID_IO (defined(USB_ID_PIN) && OTG_ID_DETECT) |
#define | OTG_ID_EIC (defined(USB_ID_EIC) && OTG_ID_DETECT) |
#define | pad_id_init() eic_pad_init(USB_ID_EIC_LINE, otg_id_handler, USB_ID_EIC_IRQn, USB_ID_EIC, UHD_USB_INT_LEVEL); |
#define | pad_id_interrupt_disable() eic_line_disable_interrupt(EIC, USB_ID_EIC_LINE) |
#define | pad_ack_id_interrupt() |
#define | Is_pad_id_device() ioport_get_pin_level(USB_ID_EIC) |
USBC Vbus management | |
The VBus line can be monitored through a GPIO pin and a basic resitor voltage divider. This feature is optional, and it is enabled if USB_VBUS_PIN or USB_VBUS_EIC is defined in board.h and CONF_BOARD_USB_VBUS_DETECT defined in conf_board.h. | |
#define | OTG_VBUS_DETECT (defined(CONF_BOARD_USB_VBUS_DETECT)) |
#define | OTG_VBUS_IO (defined(USB_VBUS_PIN) && OTG_VBUS_DETECT) |
#define | OTG_VBUS_EIC (defined(USB_VBUS_EIC) && OTG_VBUS_DETECT) |
#define | pad_vbus_init(level) eic_pad_init(USB_VBUS_EIC_LINE, uhd_vbus_handler, USB_VBUS_EIC_IRQn, USB_VBUS_EIC, level); |
#define | pad_vbus_interrupt_disable() eic_line_disable_interrupt(EIC, USB_VBUS_EIC_LINE) |
#define | pad_ack_vbus_interrupt() |
#define | Is_pad_vbus_high() ioport_get_pin_level(USB_VBUS_EIC) |
#define | uhd_vbus_is_on() USBC_REG_SET(USBSTA,VBUSRQ) |
Notify USBC that the VBUS on the usb line is powered. More... | |
#define | uhd_vbus_is_off() USBC_REG_CLR(USBSTA,VBUSRQ) |
Notify USBC that the VBUS on the usb line is not powered. More... | |
USBC OTG main management | |
These macros allows to enable/disable pad and USBC hardware | |
#define | otg_enable() USBC_SET_BITS(USBCON,USBE) |
#define | otg_disable() USBC_CLR_BITS(USBCON,USBE) |
USBC mode management | |
The USBC mode device or host must be selected manualy by user | |
#define | otg_enable_device_mode() USBC_SET_BITS(USBCON,UIMOD) |
#define | Is_otg_device_mode_enabled() USBC_TST_BITS(USBCON,UIMOD) |
#define | otg_enable_host_mode() USBC_CLR_BITS(USBCON,UIMOD) |
#define | Is_otg_host_mode_enabled() (!Is_otg_device_mode_enabled()) |
Functions | |
void | otg_dual_disable (void) |
Uninitialize the dual role This function is implemented in usbc_host.c file. More... | |
bool | otg_dual_enable (void) |
Initialize the dual role This function is implemented in usbc_host.c file. More... | |
USB IO PADs management | |
static __always_inline void | eic_line_change_config (uint8_t line, bool b_high) |
static __always_inline void | eic_pad_init (uint8_t line, eic_callback_t callback, uint8_t irq_line, ioport_pin_t pin, uint8_t irq_level) |
static __always_inline void | io_pad_init (ioport_pin_t pin, ioport_mode_t mode, gpio_pin_callback_t callback, uint8_t irq_level) |
USBC Power Manager wake-up feature | |
static __always_inline void | usbc_async_wake_up_enable (void) |
Enable one or several asynchronous wake-up source. More... | |
static __always_inline void | usbc_async_wake_up_disable (void) |
Disable one or several asynchronous wake-up source. More... | |
#define USBC_RD_BITFIELD | ( | reg, | |
bit | |||
) |
#define USBC_WR_BITFIELD | ( | reg, | |
bit, | |||
value | |||
) |
|
static |
|
static |
|
static |
|
static |
Disable one or several asynchronous wake-up source.
awen_mask | Mask of asynchronous wake-up sources (use one of the defines PM_AWEN_xxxx in the part-specific header file) |
|
static |
Enable one or several asynchronous wake-up source.
awen_mask | Mask of asynchronous wake-up sources (use one of the defines PM_AWEN_xxxx in the part-specific header file) |
Referenced by udd_enable().