Instruction manual
Renesas USB MCU and USB ASSP USB Basic Host and Peripheral firmware
R01AN0512EJ0210 Rev.2.10 Page 72 of 157
Apr 1, 2013
open
Establish connection with USB device
Format
int16_t open (int8_t *name, uint16_t mode, uint16_t flg)
Argument
*name Class code : USB_CLASS_HSTD_BULK / USB_CLASS_HSTD_INT
mode Mode ( Not used, set to 0)
flg Flag (Not used, set to 0)
Return Value
- File number (Success: 0x10 -- 0x1F /Failure: -1)
As the File Number is required for subsequent communication using read() and write(), the
open() function must be called first.
Description
This function secures a hardware pipe for the class specified in the argument, and establishes connection with the
USB peripheral. If a connection is successful, the function sends the file number (0x10~0x1f) as the return value; if
the connection fails, it returns (-1). USB device class communications using read() and write() can be executed after
obtaining the file number.
Since HCD does the actual data transfer, the user can request data transfers only by using these functions.
Subsequent read() and write() will only cause data transfer to occur via the pipe registered into the opened “file”.
The following vendor example “class codes” are supported by USB-BASIC-FW.
Class Class code Note
VENDOR USB_CLASS_HSTD_BULK
USB_CLASS_PSTD_BULK is an example class that
only has (two) bulk type endpoints
VENDOR USB_CLASS_HSTD_INT
USB_CLASS_PSTD_INT is an example class which
only has (two) interrupt endpoints.
Note
1. Call this function from the user application.
2. As the file number is required for USB device class communications using read() or write(), the open
function must be called before performing the communication.
Example
int16_t usb_smp_fn;
void usb_apl_task()
{
:
usb_smp_fn = open((int8_t *)USB_CLASS_HSTD_BULK, 0, 0);
if(usb_smp_fn != -1)
{
/* USB Transfer */
}
:
}