fx2usbmassstor.h¶
The fx2usbmassstor.h
header contains USB Mass Storage Bulk-Only Transfer interface class support code for the Cypress FX2 series. When using this header, the fx2
and fx2usb
libraries must be linked in.
Reference¶
Typedefs
-
typedef struct usb_mass_storage_bbb_state usb_mass_storage_bbb_state_t¶
Functions
-
bool usb_mass_storage_bbb_setup(usb_mass_storage_bbb_state_t *state, struct usb_req_setup *request)¶
Handle USB Mass Storage Bulk-Only Transport interface SETUP packets. This function makes the appropriate changes to the state and returns
true
if a SETUP packet addressed this interface, or returnsfalse
otherwise.
-
bool usb_mass_storage_bbb_bulk_out(usb_mass_storage_bbb_state_t *state, const uint8_t *data, uint16_t length)¶
Process USB Mass Storage Bulk-Only Transport interface BULK OUT packets.
This function should be called each time a BULK OUT packet is received.
It returns a result flag. If the result is
true
, a packet should be ended. If the result isfalse
, both the BULK OUT and BULK IN endpoint should be stalled.
-
bool usb_mass_storage_bbb_bulk_in(usb_mass_storage_bbb_state_t *state, uint8_t *data, uint16_t *length)¶
Emit USB Mass Storage Bulk-Only Transport interface BULK IN packets.
This function should be called each time an IN BULK NAK interrupt occurs.
It returns a result flag. If the result is
true
, a packet should be committed iflength
is nonzero. If the result isfalse
, the BULK IN endpoint should be stalled.
-
struct usb_mass_storage_bbb_state¶
- #include <fx2usbmassstor.h>
State of an USB Mass Storage Bulk-Only Transport interface.
Public Members
-
uint8_t interface¶
The bInterfaceNumber field corresponding to this interface.
-
uint16_t max_in_size¶
The value of the wMaxPacketSize field of the BULK IN endpoint of this interface.
-
uint8_t max_lun¶
The maximum LUN number of this interface. Most interfaces will only use a single LUN, and so will have
max_lun
set to zero.
-
bool (*command)(uint8_t lun, uint8_t *command, uint8_t length)¶
The Command callback. This function is called for each CBW. It should return
true
if the command is recognized and well-formed, which either proceeds to the Data callbacks (if there is any data to be transferred) or returns a Passed CSW immediately; orfalse
, in which case the data callbacks are never called and a Failed CSW is returned.
-
bool (*data_out)(uint8_t lun, const uint8_t *data, uint16_t length)¶
The Data-Out callback. This function is called with chunks of data that follow a CBW that specifies an OUT transfer. It can read exactly
length
bytes from thedata
buffer. If data is processed successfully, this function should returntrue
, which will eventually return a Passed CSW to the host; otherwise, the rest of the transfer is skipped (this callback is not invoked again), and a Failed CSW is returned.
-
bool (*data_in)(uint8_t lun, uint8_t *data, uint16_t length)¶
The Data-In callback. This function is called each time a chunk of data is necessary following a CBW that specifies an IN transfer. It should fill exactly
length
bytes into thedata
buffer. If data is processed successfully, this function should returntrue
, which will eventually return a Passed CSW to the host; otherwise, the rest of the transfer is skipped (this callback is not invoked again), and a Failed CSW is returned.
-
uint8_t interface¶