Instruction manual

Renesas USB MCU and USB ASSP USB Basic Host and Peripheral firmware
R01AN0512EJ0210 Rev.2.10 Page 74 of 157
Apr 1, 2013
read
USB receive process
Format
int32_t read(int16_t fileno, uint8_t *buf, int32_t count)
Argument
fileno File number
*buf Pointer to data buffer
count Data Transfer size
Return Value
Error code
Description
This function executes a data receive transaction request for the USB device class specified by the file number.
Data is read from the FIFO buffer of the specified data transfer size (3rd argument), and then stored in the data
buffer (2nd argument).
When the receive process is complete, the call-back function is called. This call-back function is registered by the
Control API. Please refer to control code USB_CTL_RD_NOTIFY_SET in the Control API.
The actual read size can be obtained by using control API after the receive process is complete. Please refer to
control code USB_CTL_RD_LENGTH_GET in the Control API.
Note
1. Call this function from the user application.
2. Use control(USB_CTL_RD_NOTIFY_SET) to register the call-back function for notification of data transfer
completion before calling this function .
3. This function only executes a data receive request and does not block any processes. Therefore the return
value is always (-1).
Example
int16_t usb_smp_fn;
void usb_apl_task()
{
/* Set data receive complete notification call-back */
control(usb_smp_fn, USB_CTL_RD_NOTIFY_SET, (void*)&usb_ smp_Read_Notify);
/* receiving data request */
read(usb_smp_fn, (uint8_t *)buf, (uint32_t)size)
/* receiving request status check */
err = control(usb_spvendor_bulk_fn, USB_CTL_GET_READ_STATE, (void*)&state);
if(err != USB_CTL_ERR_PROCESS_COMPLETE)
{
/* Error Processing */
}
}