fx2usbdfu.h¶
The fx2usbdfu.h
header contains USB DFU interface support code for the Cypress FX2 series. When using this header, the fx2
, fx2usb
, and fx2usbdfu
libraries must be linked in.
Reference¶
Typedefs
-
typedef struct usb_dfu_iface_state usb_dfu_iface_state_t¶
Functions
-
bool usb_dfu_setup(usb_dfu_iface_state_t *state, struct usb_req_setup *request)¶
Handle USB Device Firmware Update 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.
-
void usb_dfu_setup_deferred(usb_dfu_iface_state_t *state)¶
Handle USB Device Firmware Update interface SETUP packets that perform lengthy operations (i.e. actual firmware upload/download).
Variables
-
usb_dfu_iface_state_t usb_dfu_iface_state¶
The global DFU configuration, defined in the application code. It only makes sense for a single device to expose a single DFU interface at a time.
-
struct usb_dfu_iface_state
- #include <fx2usbdfu.h>
State of an USB Device Firmware Upgrade interface.
Public Members
-
uint8_t interface¶
The bInterfaceNumber field corresponding to this interface in runtime mode. (In upgrade mode, only one interface must be exported, so this field is ignored.)
-
usb_dfu_status_t (*firmware_upload)(uint32_t offset, uint8_t *data, uint16_t *length)¶
Firmware upload function. This function reads the firmware block at
offset
of requestedlength
intodata
. When end of firmware is reached, this function should report this a block size shorter than providedlength
by changing it.The
offset
argument is maintained internally by this library and is increased after eachfirmware_upload
call bylength
; it is not related to thewBlockNum
field fromDFU_UPLOAD
request.The firmware read out by this function must be in a format identical to that accepted by the
firmware_dnload
function to be DFU compliant.This function should return
USB_DFU_STATUS_OK
if the firmware could be read, and one of the otherenum usb_dfu_status
values otherwise.
-
usb_dfu_status_t (*firmware_dnload)(uint32_t offset, uint8_t *data, uint16_t length)¶
Firmware download function. This function writes the firmware block at
offset
fromdata
that islength
bytes long, which may be no greater thanwTransferSize
field in the DFU functional descriptor. If this function receives a block lenght of zero, it must validate whether it has received the complete firmware.The
offset
argument is maintained internally by this library and is increased after eachfirmware_dnload
call bylength
; it is not related to thewBlockNum
field fromDFU_DNLOAD
request.This function should return
USB_DFU_STATUS_OK
if the firmware could be written (or, in case oflength == 0
, if the complete firmware was downloaded), and one of the otherenum usb_dfu_status
values otherwise.
-
usb_dfu_status_t (*firmware_manifest)()¶
Firmware manifestation function. This function could perform any application-specific actions required to finish updating firmware, such as changing the boot address.
This function should return
USB_DFU_STATUS_OK
if the firmware could be manifested, and one of the otherenum usb_dfu_status
values otherwise.If this callback is set to
NULL
, the behavior is the same as if the callback was implemented as an empty function returningUSB_DFU_STATUS_OK
.
-
enum usb_dfu_state state¶
State of the DFU interface, as per DFU specification.
-
uint8_t interface¶