RZ/A Flexible Software Package Documentation  Release v3.3.0

 
USB (r_usb_basic)

Functions

fsp_err_t R_USB_Open (usb_ctrl_t *const p_api_ctrl, usb_cfg_t const *const p_cfg)
 Applies power to the USB module specified in the argument (p_ctrl). More...
 
fsp_err_t R_USB_Close (usb_ctrl_t *const p_api_ctrl)
 Terminates power to the USB module specified in argument (p_ctrl). USB0 module stops when USB_IP0 is specified to the member (module), USB1 module stops when USB_IP1 is specified to the member (module). More...
 
fsp_err_t R_USB_Read (usb_ctrl_t *const p_api_ctrl, uint8_t *p_buf, uint32_t size, uint8_t destination)
 Bulk/interrupt data transfer and control data transfer. More...
 
fsp_err_t R_USB_Write (usb_ctrl_t *const p_api_ctrl, uint8_t const *const p_buf, uint32_t size, uint8_t destination)
 Bulk/Interrupt data transfer and control data transfer. More...
 
fsp_err_t R_USB_Stop (usb_ctrl_t *const p_api_ctrl, usb_transfer_t direction, uint8_t destination)
 Requests a data read/write transfer be terminated when a data read/write transfer is being performed. More...
 
fsp_err_t R_USB_Suspend (usb_ctrl_t *const p_api_ctrl)
 Sends a SUSPEND signal from the USB module assigned to the member (module) of the usb_crtl_t structure. More...
 
fsp_err_t R_USB_Resume (usb_ctrl_t *const p_api_ctrl)
 Sends a RESUME signal from the USB module assigned to the member (module) of the usb_ctrl_tstructure. More...
 
fsp_err_t R_USB_VbusSet (usb_ctrl_t *const p_api_ctrl, uint16_t state)
 Specifies starting or stopping the VBUS supply. More...
 
fsp_err_t R_USB_InfoGet (usb_ctrl_t *const p_api_ctrl, usb_info_t *p_info, uint8_t destination)
 Obtains completed USB-related events. More...
 
fsp_err_t R_USB_PipeRead (usb_ctrl_t *const p_api_ctrl, uint8_t *p_buf, uint32_t size, uint8_t pipe_number)
 Requests a data read (bulk/interrupt transfer) via the pipe specified in the argument. More...
 
fsp_err_t R_USB_PipeWrite (usb_ctrl_t *const p_api_ctrl, uint8_t *p_buf, uint32_t size, uint8_t pipe_number)
 Requests a data write (bulk/interrupt transfer). More...
 
fsp_err_t R_USB_PipeStop (usb_ctrl_t *const p_api_ctrl, uint8_t pipe_number)
 Terminates a data read/write operation. More...
 
fsp_err_t R_USB_UsedPipesGet (usb_ctrl_t *const p_api_ctrl, uint16_t *p_pipe, uint8_t destination)
 Gets the selected pipe number (number of the pipe that has completed initalization) via bit map information. More...
 
fsp_err_t R_USB_PipeInfoGet (usb_ctrl_t *const p_api_ctrl, usb_pipe_t *p_info, uint8_t pipe_number)
 Gets the following pipe information regarding the pipe specified in the argument (p_ctrl) member (pipe): endpoint number, transfer type, transfer direction and maximum packet size. More...
 
fsp_err_t R_USB_PullUp (usb_ctrl_t *const p_api_ctrl, uint8_t state)
 This API enables or disables pull-up of D+/D- line. More...
 
fsp_err_t R_USB_EventGet (usb_ctrl_t *const p_api_ctrl, usb_status_t *event)
 Obtains completed USB related events. (OS-less Only) More...
 
fsp_err_t R_USB_Callback (usb_callback_t *p_callback)
 Register a callback function to be called upon completion of a USB related event. (RTOS only) More...
 
fsp_err_t R_USB_HostControlTransfer (usb_ctrl_t *const p_api_ctrl, usb_setup_t *p_setup, uint8_t *p_buf, uint8_t device_address)
 Performs settings and transmission processing when transmitting a setup packet. More...
 
fsp_err_t R_USB_PeriControlDataGet (usb_ctrl_t *const p_api_ctrl, uint8_t *p_buf, uint32_t size)
 Receives data sent by control transfer. More...
 
fsp_err_t R_USB_PeriControlDataSet (usb_ctrl_t *const p_api_ctrl, uint8_t *p_buf, uint32_t size)
 Performs transfer processing for control transfer. More...
 
fsp_err_t R_USB_PeriControlStatusSet (usb_ctrl_t *const p_api_ctrl, usb_setup_status_t status)
 Set the response to the setup packet. More...
 
fsp_err_t R_USB_RemoteWakeup (usb_ctrl_t *const p_api_ctrl)
 Sends a remote wake-up signal to the connected Host. More...
 
fsp_err_t R_USB_ModuleNumberGet (usb_ctrl_t *const p_api_ctrl, uint8_t *module_number)
 This API gets the module number. More...
 
fsp_err_t R_USB_ClassTypeGet (usb_ctrl_t *const p_api_ctrl, usb_class_t *class_type)
 This API gets the class type. More...
 
fsp_err_t R_USB_DeviceAddressGet (usb_ctrl_t *const p_api_ctrl, uint8_t *device_address)
 This API gets the device address. More...
 
fsp_err_t R_USB_PipeNumberGet (usb_ctrl_t *const p_api_ctrl, uint8_t *pipe_number)
 This API gets the pipe number. More...
 
fsp_err_t R_USB_DeviceStateGet (usb_ctrl_t *const p_api_ctrl, uint16_t *state)
 This API gets the state of the device. More...
 
fsp_err_t R_USB_DataSizeGet (usb_ctrl_t *const p_api_ctrl, uint32_t *data_size)
 This API gets the data size. More...
 
fsp_err_t R_USB_SetupGet (usb_ctrl_t *const p_api_ctrl, usb_setup_t *setup)
 This API gets the setup type. More...
 
fsp_err_t R_USB_OtgCallbackSet (usb_ctrl_t *const p_api_ctrl, usb_otg_callback_t *p_callback)
 Set callback function to be called when the OTG role swap was completed on Azure RTOS. More...
 
fsp_err_t R_USB_OtgSRP (usb_ctrl_t *const p_api_ctrl)
 Start the SRP processing for OTG on Azure RTOS. More...
 
fsp_err_t R_USB_DriverActivate (usb_ctrl_t *const p_api_ctrl)
 Activate USB Driver for USB Peripheral BareMetal. More...
 
fsp_err_t R_USB_CallbackMemorySet (usb_ctrl_t *const p_api_ctrl, usb_callback_args_t *p_callback_memory)
 Set callback memory to USB Driver for USB Peripheral BareMetal. More...
 

Detailed Description

Driver for the USB peripheral on RZ MCUs. This module implements the USB Interface.

Overview

The USB module operates in combination with the device class drivers provided by Renesas to form a complete USB stack.

Features

The USB module has the following key features:

Configuration

Build Time Configurations for r_usb_basic

The following build time configurations are defined in fsp_cfg/r_usb_basic_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
CPU Bus Access Wait CyclesMCU Specific OptionsThis setting controls the delay for consecutive USB peripheral register access. Set this value to a number of CPU cycles that is equivalent to 40.8ns or more.
Power IC Shutdown PolarityMCU Specific OptionsSelect the polarity of the Shutdown signal on the power supply IC (if provided).
Notifications for SET_INTERFACE/SET_FEATURE/CLEAR_FEATURE
  • Disabled
  • Enabled
Enabled When enabled, the application will receive notifications for SET_INTERFACE, SET_FEATURE and CLEAR_FEATURE messages.
Double Buffering
  • Disabled
  • Enabled
Enabled When enabled, the FIFOs for Pipes 1-5 are double-buffered.
Continuous Transfer ModeMCU Specific OptionsEnable or disable continuous transfer mode.
DMA SupportMCU Specific OptionsEnable or disable DMA support for the USB module.
USB Compliance Test mode
  • Enabled
  • Disabled
Disabled Display the information required to take the compliance test.
USB TPL table nameEnter the TPL table name.NULL Enter the name of the TPL Table.

Peripheral module

Describes the setting items at the time of Peripheral.

Configurations for Connectivity > USB (r_usb_basic)

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_basic0 Module name.
USB Mode
  • Host mode
  • Peri mode
  • OTG mode
Host mode Select the usb mode.
USB SpeedHi SpeedHi Speed Select the USB speed.
USB Module NumberUSB_ch0 PortUSB_ch0 Port Specify the USB module number to be used.
USB Device Class
  • Peripheral Communications Device Class
  • Peripheral Human Interface Device Class
  • Peripheral Mass Storage Class
  • Peripheral Vendor Class
  • Peripheral Audio Class
  • Host Communications Device Class
  • Host Human Interface Device Class
  • Host Mass Storage Class
  • Host Vendor Class
Peripheral Communications Device Class Select the USB device class.
USB DescriptorUSB Descriptor must be a valid C symbol.g_usb_descriptor Enter the name of the descriptor to be used.
For how to create a descriptor structure, refer to the Descriptor definition chapter in the usb_basic manual.
Specify NULL when using the Host class.
USB Compliance CallbackCompliance Callback must be a valid C symbol.NULL Set the callback for compliance tests here.
USB ch0 Interrupt PriorityValue must be an integer between 0 and 3124 Select the interrupt priority used by the main USB ch0 ISR.
USBFS D0FIFO Interrupt PriorityValue must be an integer between 0 and 3124 Select the interrupt priority used by the USBFS D0FIFO.
USBFS D1FIFO Interrupt PriorityValue must be an integer between 0 and 3124 Select the interrupt priority used by the USBFS D1FIFO.
USB RTOS CallbackEnter the address of the function.NULL If an FreeRTOS is used, set the callback function here.
USB Callback ContextEnter the address of the context.NULL Set the callback context here.

Host module

Describes the setting items at the time of Host.

Configurations for Connectivity > USB (r_usb_basic)

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_basic0 Module name.
USB Mode
  • Host mode
  • Peri mode
  • OTG mode
Host mode Select the usb mode.
USB SpeedHi SpeedHi Speed Select the USB speed.
USB Module Number
  • USB_ch0 Port
  • USB_ch1 Port
USB_ch0 Port Specify the USB module number to be used.
USB Device Class
  • Peripheral Communications Device Class
  • Peripheral Human Interface Device Class
  • Peripheral Mass Storage Class
  • Peripheral Vendor Class
  • Peripheral Audio Class
  • Host Communications Device Class
  • Host Human Interface Device Class
  • Host Mass Storage Class
  • Host Vendor Class
Peripheral Communications Device Class Select the USB device class.
USB Compliance CallbackCompliance Callback must be a valid C symbol.NULL Set the callback for compliance tests here.
USB ch0 Interrupt PriorityValue must be an integer between 0 and 3124 Select the interrupt priority used by the main USB ch0 ISR.
USB ch1 Interrupt PriorityValue must be an integer between 0 and 3124 Select the interrupt priority used by the main USB ch1 ISR.
USB RTOS CallbackEnter the address of the function.NULL If an FreeRTOS is used, set the callback function here.
USB Callback ContextEnter the address of the context.NULL Set the callback context here.

Pin Configuration

In peripheral mode the USB0_VBUSIN pins are used to detect the USB connection status (connected or disconnected) and should be connected to the USB VBUS signal.

In host mode the USB0_VBUSEN, USB1_VBUSEN, USB_OVRCUR pins should be connected to the relevant pins of an external power supply IC, if available. These pins will be used to manage the USB VBUS supply.

Descriptor definition

In Peripheral mode, the usb_descriptor_t structure stores descriptor information including the device and configuration descriptors. The values set in this structure are sent to the USB host as part of enumeration.

typedef struct usb_descriptor
{
uint8_t *p_device; /* Pointer to device descriptor */
uint8_t *p_config_f; /* Pointer to full-speed configuration descriptor */
uint8_t *p_config_h; /* Pointer to high-speed configuration descriptor (HS only) */
uint8_t *p_qualifier; /* Pointer to device qualifier descriptor (HS only) */
uint8_t **pp_string; /* Pointer to string descriptor table */
uint8_t num_string; /* Number of strings in table */
} usb_descriptor_t;
Note
Even in high-speed mode the full-speed configuration must be made available:
/* Example USB FS descriptor struct */
usb_descriptor_t g_usb_descriptor =
{
smp_device,
smp_config_f,
NULL,
NULL,
smp_str_table,
3,
};
/* Example USB HS descriptor struct */
usb_descriptor_t g_usb_descriptor =
{
smp_device,
smp_config_f,
smp_config_h,
smp_qualifier,
smp_str_table,
3,
};

String Descriptor

This USB driver requires string descriptors to be registered in the string descriptor table. Use the following format to define the elements:

/* String descriptor 0 is reserved for language ID information */
uint8_t str_descriptor_0[]
{
0x04, /* Length */
0x03, /* Descriptor type */
0x09, 0x04 /* Language ID */
};
uint8_t str_descriptor_manufacturer[] =
{
0x10, /* Length */
0x03, /* Descriptor type */
'R', 0x00,
'E', 0x00,
'N', 0x00,
'E', 0x00,
'S', 0x00,
'A', 0x00,
'S', 0x00
};
uint8_t str_descriptor_product[] =
{
0x12, /* Length */
0x03, /* Descriptor type */
'C', 0x00,
'D', 0x00,
'C', 0x00,
'_', 0x00,
'D', 0x00,
'E', 0x00,
'M', 0x00,
'O', 0x00
};
/* String descriptor table */
uint8_t * smp_str_table[] =
{
str_descriptor_0, /* Index: 0 */
str_descriptor_manufacturer, /* Index: 1 */
str_descriptor_product, /* Index: 2 */
};
Note
Set the string index values in the device/configuration descriptors (iManufacturer, iConfiguration etc.) to the index of the desired string in the string descriptor table. For example, in the table below, the manufacturer is described in str_descriptor_manufacturer and the value of iManufacturer in the device descriptor is 1.

Other Descriptors

Refer to the Universal Serial Bus Revision 2.0 specification (http://www.usb.org/developers/docs/) for details on how to construct the device, configuration and qualifier descriptors.

Usage Notes

Program Structure

USB applications (whether using an RTOS or not) should be written as an event-handling loop. Either a callback function (RTOS only) or R_USB_EventGet should be used to provide event data to the application loop where a switch statement handles the event.

Note
The USB_STATUS_CONFIGURED event should be confirmed before calling R_USB_Read or R_USB_Write.

Limitations

Developers should be aware of the following limitations when using the USB driver:

Peripheral Limitations

Host Limitations

Examples

USB Basic Example

This is a basic example of minimal use of the USB in an application.

void usb_basic_example (void)
{
usb_event_info_t event_info;
usb_status_t event;
g_usb_on_usb.open(&g_basic0_ctrl, &g_basic0_cfg);
/* Loop back between PC(TerminalSoft) and USB MCU */
while (1)
{
g_usb_on_usb.eventGet(&event_info, &event);
switch (event)
{
g_usb_on_usb.read(&g_basic0_ctrl, g_buf, DATA_LEN, USB_CLASS_PCDC);
break;
g_usb_on_usb.write(&g_basic0_ctrl, g_buf, event_info.data_size, USB_CLASS_PCDC);
break;
case USB_STATUS_REQUEST: /* Receive Class Request */
if (USB_PCDC_SET_LINE_CODING == (event_info.setup.request_type & USB_BREQUEST))
{
g_usb_on_usb.periControlDataGet(&g_basic0_ctrl, (uint8_t *) &g_line_coding, LINE_CODING_LENGTH);
}
else if (USB_PCDC_GET_LINE_CODING == (event_info.setup.request_type & USB_BREQUEST))
{
g_usb_on_usb.periControlDataSet(&g_basic0_ctrl, (uint8_t *) &g_line_coding, LINE_CODING_LENGTH);
}
else
{
g_usb_on_usb.periControlStatusSet(&g_basic0_ctrl, USB_SETUP_STATUS_ACK);
}
break;
break;
default:
break;
}
}
} /* End of function usb_main() */

Typedefs

typedef usb_event_info_t usb_instance_ctrl_t
 

Typedef Documentation

◆ usb_instance_ctrl_t

typedef usb_event_info_t usb_instance_ctrl_t

USB private control block. DO NOT MODIFY. Initialization occurs when R_USB_Open is called.

Function Documentation

◆ R_USB_Open()

fsp_err_t R_USB_Open ( usb_ctrl_t *const  p_api_ctrl,
usb_cfg_t const *const  p_cfg 
)

Applies power to the USB module specified in the argument (p_ctrl).

Return values
FSP_SUCCESSSuccess in open.
FSP_ERR_USB_BUSYSpecified USB module now in use.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Close()

fsp_err_t R_USB_Close ( usb_ctrl_t *const  p_api_ctrl)

Terminates power to the USB module specified in argument (p_ctrl). USB0 module stops when USB_IP0 is specified to the member (module), USB1 module stops when USB_IP1 is specified to the member (module).

Return values
FSP_SUCCESSSuccess.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_NOT_OPENUSB module is not open.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Read()

fsp_err_t R_USB_Read ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  p_buf,
uint32_t  size,
uint8_t  destination 
)

Bulk/interrupt data transfer and control data transfer.

  1. Bulk/interrupt data transfer

    Requests USB data read (bulk/interrupt transfer). The read data is stored in the area specified by argument (p_buf). After data read is completed, confirm the operation by checking the return value (USB_STATUS_READ_COMPLETE) of the R_USB_GetEvent function. The received data size is set in member (size) of the usb_ctrl_t structure. To figure out the size of the data when a read is complete, check the return value (USB_STATUS_READ_COMPLETE) of the R_USB_GetEvent function, and then refer to the member (size) of the usb_crtl_t structure.

  2. Control data transfer

    The R_USB_Read function is used to receive data in the data stage and the R_USB_Write function is used to send data to the USB host.

Return values
FSP_SUCCESSSuccessfully completed (Data read request completed).
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_BUSYData receive request already in process for USB device with same device address.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Write()

fsp_err_t R_USB_Write ( usb_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_buf,
uint32_t  size,
uint8_t  destination 
)

Bulk/Interrupt data transfer and control data transfer.

  1. Bulk/Interrupt data transfer

    Requests USB data write (bulk/interrupt transfer). Stores write data in area specified by argument (p_buf). Set the device class type in usb_ctrl_t structure member (type). Confirm after data write is completed by checking the return value (USB_STATUS_WRITE_COMPLETE) of the R_USB_GetEvent function. To request the transmission of a NULL packet, assign USB_NULL(0) to the third argument (size).

  2. Control data transfer

    The R_USB_Read function is used to receive data in the data stage and the R_USB_Write function is used to send data to the USB host.

Return values
FSP_SUCCESSSuccessfully completed. (Data write request completed)
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_BUSYData write request already in process for USB device with same device address.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Stop()

fsp_err_t R_USB_Stop ( usb_ctrl_t *const  p_api_ctrl,
usb_transfer_t  direction,
uint8_t  destination 
)

Requests a data read/write transfer be terminated when a data read/write transfer is being performed.

To stop a data read, set USB_TRANSFER_READ as the argument (type); to stop a data write, specify USB_WRITE as the argument (type).

Return values
FSP_SUCCESSSuccessfully completed. (stop completed)
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_BUSYStop processing is called multiple times.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Suspend()

fsp_err_t R_USB_Suspend ( usb_ctrl_t *const  p_api_ctrl)

Sends a SUSPEND signal from the USB module assigned to the member (module) of the usb_crtl_t structure.

After the suspend request is completed, confirm the operation with the return value (USB_STATUS_SUSPEND) of the R_USB_EventGet function.

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_BUSYDuring a suspend request to the specified USB module, or when the USB module is already in the suspended state.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_Resume()

fsp_err_t R_USB_Resume ( usb_ctrl_t *const  p_api_ctrl)

Sends a RESUME signal from the USB module assigned to the member (module) of the usb_ctrl_tstructure.

After the resume request is completed, confirm the operation with the return value (USB_STATUS_RESUME) of the R_USB_EventGet function

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_BUSYResume already requested for same device address. (USB host mode only)
FSP_ERR_USB_NOT_SUSPENDUSB device is not in the SUSPEND state.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_VbusSet()

fsp_err_t R_USB_VbusSet ( usb_ctrl_t *const  p_api_ctrl,
uint16_t  state 
)

Specifies starting or stopping the VBUS supply.

Return values
FSP_SUCCESSSuccessful completion. (VBUS supply start/stop completed)
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_InfoGet()

fsp_err_t R_USB_InfoGet ( usb_ctrl_t *const  p_api_ctrl,
usb_info_t *  p_info,
uint8_t  destination 
)

Obtains completed USB-related events.

Return values
FSP_SUCCESSSuccessful completion. (VBUS supply start/stop completed)
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_USB_PARAMETERParameter error.

◆ R_USB_PipeRead()

fsp_err_t R_USB_PipeRead ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  p_buf,
uint32_t  size,
uint8_t  pipe_number 
)

Requests a data read (bulk/interrupt transfer) via the pipe specified in the argument.

The read data is stored in the area specified in the argument (p_buf). After the data read is completed, confirm the operation with the R_USB_GetEvent function return value(USB_STATUS_READ_COMPLETE). To figure out the size of the data when a read is complete, check the return value (USB_STATUS_READ_COMPLETE) of the R_USB_GetEvent function, and then refer to the member (size) of the usb_crtl_t structure.

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_BUSYSpecified pipe now handling data receive/send request.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_PipeWrite()

fsp_err_t R_USB_PipeWrite ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  p_buf,
uint32_t  size,
uint8_t  pipe_number 
)

Requests a data write (bulk/interrupt transfer).

The write data is stored in the area specified in the argument (p_buf). After data write is completed, confirm the operation with the return value (USB_STATUS_WRITE_COMPLETE) of the EventGet function. To request the transmission of a NULL packet, assign USB_NULL (0) to the third argument (size).

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_BUSYSpecified pipe now handling data receive/send request.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_PipeStop()

fsp_err_t R_USB_PipeStop ( usb_ctrl_t *const  p_api_ctrl,
uint8_t  pipe_number 
)

Terminates a data read/write operation.

Return values
FSP_SUCCESSSuccessfully completed. (Stop request completed)
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_UsedPipesGet()

fsp_err_t R_USB_UsedPipesGet ( usb_ctrl_t *const  p_api_ctrl,
uint16_t *  p_pipe,
uint8_t  destination 
)

Gets the selected pipe number (number of the pipe that has completed initalization) via bit map information.

The bit map information is stored in the area specified in argument (p_pipe). Based on the information (module member and address member) assigned to the usb_ctrl_t structure, obtains the PIPE information of that USB device.

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.

◆ R_USB_PipeInfoGet()

fsp_err_t R_USB_PipeInfoGet ( usb_ctrl_t *const  p_api_ctrl,
usb_pipe_t *  p_info,
uint8_t  pipe_number 
)

Gets the following pipe information regarding the pipe specified in the argument (p_ctrl) member (pipe): endpoint number, transfer type, transfer direction and maximum packet size.

The obtained pipe information is stored in the area specified in the argument (p_info).

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.

◆ R_USB_PullUp()

fsp_err_t R_USB_PullUp ( usb_ctrl_t *const  p_api_ctrl,
uint8_t  state 
)

This API enables or disables pull-up of D+/D- line.

Return values
FSP_SUCCESSSuccessful completion. (Pull-up enable/disable setting completed)
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_EventGet()

fsp_err_t R_USB_EventGet ( usb_ctrl_t *const  p_api_ctrl,
usb_status_t event 
)

Obtains completed USB related events. (OS-less Only)

In USB host mode, the device address value of the USB device that completed an event is specified in the usb_ctrl_t structure member (address) specified by the event's argument. In USB peripheral mode, USB_NULL is specified in member (address). If this function is called in the RTOS execution environment, a failure is returned.

Return values
FSP_SUCCESSEvent Get Success.
FSP_ERR_USB_FAILEDIf called in the RTOS environment, an error is returned.
Note
Do not use the same variable as the first argument of R_USB_Open for the first argument.
Do not call this API in the interrupt function.

◆ R_USB_Callback()

fsp_err_t R_USB_Callback ( usb_callback_t *  p_callback)

Register a callback function to be called upon completion of a USB related event. (RTOS only)

This function registers a callback function to be called when a USB-related event has completed. If this function is called in the OS-less execution environment, a failure is returned.

Return values
FSP_SUCCESSSuccessfully completed.
FSP_ERR_ASSERTIONParameter is NULL error.
Note
Do not call this API in the interrupt function.

◆ R_USB_HostControlTransfer()

fsp_err_t R_USB_HostControlTransfer ( usb_ctrl_t *const  p_api_ctrl,
usb_setup_t *  p_setup,
uint8_t *  p_buf,
uint8_t  device_address 
)

Performs settings and transmission processing when transmitting a setup packet.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_PARAMETERParameter error.
FSP_ERR_USB_BUSYSpecified pipe now handling data receive/send request.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_PeriControlDataGet()

fsp_err_t R_USB_PeriControlDataGet ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  p_buf,
uint32_t  size 
)

Receives data sent by control transfer.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_BUSYSpecified pipe now handling data receive/send request.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_PeriControlDataSet()

fsp_err_t R_USB_PeriControlDataSet ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  p_buf,
uint32_t  size 
)

Performs transfer processing for control transfer.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_BUSYSpecified pipe now handling data receive/send request.
FSP_ERR_USB_PARAMETERParameter error.
Note
The address specified in the argument p_buf must be 4-byte aligned.
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_PeriControlStatusSet()

fsp_err_t R_USB_PeriControlStatusSet ( usb_ctrl_t *const  p_api_ctrl,
usb_setup_status_t  status 
)

Set the response to the setup packet.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_RemoteWakeup()

fsp_err_t R_USB_RemoteWakeup ( usb_ctrl_t *const  p_api_ctrl)

Sends a remote wake-up signal to the connected Host.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
FSP_ERR_USB_NOT_SUSPENDDevice is not suspended.
FSP_ERR_USB_BUSYThe device is in resume operation.
Note
Do not call this API in the following function.
(1). Interrupt function.
(2). Callback function ( for RTOS ).

◆ R_USB_ModuleNumberGet()

fsp_err_t R_USB_ModuleNumberGet ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  module_number 
)

This API gets the module number.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_ClassTypeGet()

fsp_err_t R_USB_ClassTypeGet ( usb_ctrl_t *const  p_api_ctrl,
usb_class_t class_type 
)

This API gets the class type.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_DeviceAddressGet()

fsp_err_t R_USB_DeviceAddressGet ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  device_address 
)

This API gets the device address.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_PipeNumberGet()

fsp_err_t R_USB_PipeNumberGet ( usb_ctrl_t *const  p_api_ctrl,
uint8_t *  pipe_number 
)

This API gets the pipe number.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_DeviceStateGet()

fsp_err_t R_USB_DeviceStateGet ( usb_ctrl_t *const  p_api_ctrl,
uint16_t *  state 
)

This API gets the state of the device.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_DataSizeGet()

fsp_err_t R_USB_DataSizeGet ( usb_ctrl_t *const  p_api_ctrl,
uint32_t *  data_size 
)

This API gets the data size.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_SetupGet()

fsp_err_t R_USB_SetupGet ( usb_ctrl_t *const  p_api_ctrl,
usb_setup_t *  setup 
)

This API gets the setup type.

Return values
FSP_SUCCESSSuccessful completion.

◆ R_USB_OtgCallbackSet()

fsp_err_t R_USB_OtgCallbackSet ( usb_ctrl_t *const  p_api_ctrl,
usb_otg_callback_t *  p_callback 
)

Set callback function to be called when the OTG role swap was completed on Azure RTOS.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.

◆ R_USB_OtgSRP()

fsp_err_t R_USB_OtgSRP ( usb_ctrl_t *const  p_api_ctrl)

Start the SRP processing for OTG on Azure RTOS.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
Note
Do not support the VBUS Pulsing since OTG 2.0 does not support the VBUS Pulsing..

◆ R_USB_DriverActivate()

fsp_err_t R_USB_DriverActivate ( usb_ctrl_t *const  p_api_ctrl)

Activate USB Driver for USB Peripheral BareMetal.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
Note
Call this API in the in the infinite loop of the application program or a timer interrupt.

◆ R_USB_CallbackMemorySet()

fsp_err_t R_USB_CallbackMemorySet ( usb_ctrl_t *const  p_api_ctrl,
usb_callback_args_t *  p_callback_memory 
)

Set callback memory to USB Driver for USB Peripheral BareMetal.

Return values
FSP_SUCCESSSuccessful completion.
FSP_ERR_USB_FAILEDThe function could not be completed successfully.
FSP_ERR_ASSERTIONParameter is NULL error.
Note
Call this API after calling R_USB_Open function.