Driver for the USB_TYPEC peripheral on RA MCUs. This module implements the USB TYPEC Interface.
Overview
The r_usb_typec module is used in combination with r_usb_basic and other device class for USB communication and with the Type C module alone for Type-C charging.
Target Devices
| Device Group | Devices |
| RA2 | RA2L2 |
Features
The r_usb_typec module has the following key features:
- Detection of Source Connect/Disconnect (CC1/CC2 pin and USB_VBUS pin)
- Detection of Source Partner's Current Capability, Default USB, Type-C 1.5A, or Type-C 3.0A
Usage Notes
Basic Functions
The main functions of thie module are the following:
- Initialization and un-initialization of USB Type-C module.
- Getting of Type-C module information.
Note
If the user is using an MCU that supports the USB Type-C module and all of the following conditions are satisfied, please add code to control the port connected to External Rd immediately after calling the R_USB_TYPEC_Open function. (Because it is necessary to control External Rd after Internal Rd is turned ON.)
- The USB operating mode is Device mode.
- The power mode is BusPower. (External Rd is mounted on board)
Depending on the user board, the user may need code to debaunce the USB_VBUS pin.
Examples
USB Type-C Example
The following is example code for USB Type-C.
{
g_typec_args = *p_typec_args;
g_typec_callback_flg = 1;
}
void usb_typec_example (void)
{
usb_typec_info_t typec_info;
#if TYPEC_APL_SUPPORT_SOFTWARE_STANDBY
g_lpm_on_lpm.
open(&g_lpm_ctrl, &g_lpm_cfg);
#endif
g_typec_on_typec.
open(&g_usbcc0_ctrl, &g_usbcc0_cfg);
while (1)
{
if (1 == g_typec_callback_flg)
{
switch (g_typec_args.status)
{
g_typec_on_typec.
infoGet(&g_usbcc0_ctrl, &typec_info);
switch (typec_info.connection_status)
{
break;
break;
break;
break;
default:
break;
}
break;
#if TYPEC_APL_SUPPORT_SOFTWARE_STANDBY
{
}
break;
#endif
default:
break;
}
g_typec_callback_flg = 0;
}
}
}
◆ usb_typec_instance_ctrl_t
| struct usb_typec_instance_ctrl_t |
USB TYPE-C control block. DO NOT INITIALIZE. Initialization occurs when usb_typec_api_t::open is called.
Data Fields |
|
uint32_t | open |
| | Used to determine if the channel is configured.
|
| |
|
usb_typec_cfg_t * | p_cfg |
| | Pointer to initial configurations.
|
| |
|
uint32_t | module_number |
| | USB module number (USB_IP0/USB_IP1)
|
| |
|
IRQn_Type | irq_typec_cci |
| | USBCC_CCI interrupt number storage variable.
|
| |
|
IRQn_Type | irq_typec_ccs |
| | USBCC_CCS interrupt number storage variable.
|
| |
|
uint32_t | ipl_typec_cci |
| | Variable to store the interrupt priority of USBCC_CCI.
|
| |
|
uint32_t | ipl_typec_ccs |
| | Variable to store the interrupt priority of USBCC_CCS.
|
| |
◆ R_USB_TYPEC_Open()
Initialize USB Type-C module and USB Type-C driver. Implements usb_typec_api_t::open.
- Return values
-
| FSP_SUCCESS | Channel opened successfully. |
| FSP_ERR_NOT_OPEN | USB TYPEC module is not open. |
| FSP_ERR_ALREADY_OPEN | Control block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure. |
◆ R_USB_TYPEC_Close()
Uninitialize USB Type-C module and disable interrupts. Implements usb_typec_api_t::close.
- Return values
-
| FSP_SUCCESS | Channel successfully closed. |
| FSP_ERR_NOT_OPEN | USB TYPEC module is not open. |
◆ R_USB_TYPEC_InfoGet()
Get USB Type-C connect Information. Implements usb_typec_api_t::infoGet.
- Return values
-
| FSP_SUCCESS | Successful completion. |
| FSP_ERR_NOT_OPEN | USB TYPEC module is not open. |
◆ R_USB_TYPEC_LowPowerModeSet()
Set IRQ Mode for USB Type-C module by Low Power Mode. Implements usb_typec_api_t::lowPowerModeSet.
- Return values
-
| FSP_SUCCESS | Successful completion. |
| FSP_ERR_NOT_OPEN | USB TYPEC module is not open. |
| FSP_ERR_USB_PARAMETER | Parameter error. |