Now that the class instance has been correctly initialized, it’s time to exchange data. PHDC offers 4 functions to do so. summarizes the communication functions provided by the PHDC implementation. See the PHDC API Reference for a complete API reference.
With Metadata Preamble
Via the preamble enabled callback, the application will be notified once the host enables the metadata preamble. If metadata preambles are enabled, you should use the following procedure to perform a read:
- Call
USBD_PHDC_
. Device expects metadata preamble from the host. This function will return opaque data and the number of incoming transfers that the host specified. Note that if the host disables preamble while the application is pending on that function, it will immediately return with error “Preamble
Rd()USBD_ERR_OS_ABORT
”. - Call
USBD_PHDC_Rd()
a number of times corresponding to the number of incoming transfers returned byUSBD_PHDC_
. The application must ensure that the buffer provided to the function is large enough to accommodate all the data. Otherwise, synchronization issues might happen. Note that if the host enables preamble while the application is pending on that function, it will immediately return with error “Preamble
Rd()USBD_ERR_OS_ABORT
”.
You should use the following procedure to perform a write:
- Call
USBD_PHDC_
. The host expects metadata preamble from the device. The application will have to specify opaque data, transfer’s QoS (see ), and a number of following transfers to which the selected QoS applies.Preamble
Wr() - Call
USBD_PHDC_Wr()
a number of times corresponding to the number of transfers following the preamble.
Without Metadata Preamble
If the device does not support metadata preamble or if it supports them but it has not been enabled by the host, you should not call USBD_PHDC_
and Preamble
Rd()USBD_PHDC_
.Preamble
Wr()