fx2uf2.h

The fx2uf2.h header contains USB UF2 interface support code for the Cypress FX2 series. See the Microsoft UF2 specification for details. When using this header, the fx2, fx2usb, fx2usbmassstor and fx2uf2 libraries must be linked in.

Reference

Typedefs

typedef const struct uf2_configuration uf2_configuration_c

Variables

uf2_configuration_c uf2_config

The global UF2 configuration, defined in the application code. It only makes sense for a single device to expose a single UF2 interface at a time.

struct uf2_configuration
#include <fx2uf2.h>

Configuration of USB UF2 interface.

Public Members

uint32_t total_sectors

Total number of sectors on the virtual USB Mass Storage device. The optimal number depends on the size of the firmware, but in general, 65536 sectors (32 MiB) is a reasonable size.

const char *info_uf2_txt

Contents of the INFO_UF2.TXT file on the virtual USB Mass Storage device. Should be at most one sector (512 bytes) long.

const char *index_htm

Contents of the INDEX.HTM file on the virtual USB Mass Storage device. Should be at most one sector (512 bytes) long.

uint32_t firmware_size

Size of the firmware. Currently rounded up to the nearest UF2 payload size, 256, but this should not be relied on.

bool (*firmware_read)(uint32_t address, uint8_t *data, uint16_t length)

Firmware read function. This function should accept any address and length arguments that read bytes between 0 and firmware_size (after rounding). It should return true if the firmware could be read, and false otherwise.

bool (*firmware_write)(uint32_t address, uint8_t *data, uint16_t length)

Firmware write function. This function is passed the UF2 blocks directly without further verification of address and length against firmware_size. It should return true if the firmware could be written, and false otherwise.