6 #include "errorstack.hh"
7 #include "radiointerface.hh"
22 struct __attribute__((packed)) status_t {
24 unsigned poll_timeout : 24;
26 unsigned string_index : 8;
56 static QList<USBDeviceDescriptor>
detect(uint16_t vid, uint16_t pid);
76 libusb_device_handle *
_dev;
Specialization to address a DFU device uniquely.
Definition: dfu_libusb.hh:32
Descriptor(const USBDeviceInfo &info, uint8_t bus, uint8_t device)
Constructor from interface info, bus number and device address.
Definition: dfu_libusb.cc:39
This class implements DFU protocol to access radios.
Definition: dfu_libusb.hh:17
int get_status(const ErrorStack &err=ErrorStack())
Internal used function to read the current status.
Definition: dfu_libusb.cc:233
libusb_context * _ctx
USB context.
Definition: dfu_libusb.hh:74
DFUDevice(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), QObject *parent=nullptr)
Opens a connection to the USB-DFU device at vendor vid and product pid.
Definition: dfu_libusb.cc:49
int get_state(int &pstate, const ErrorStack &err=ErrorStack())
Internal used function to read the state.
Definition: dfu_libusb.cc:257
int wait_idle(const ErrorStack &err=ErrorStack())
Internal used function to busy-wait for a response from the device.
Definition: dfu_libusb.cc:285
status_t _status
Device status.
Definition: dfu_libusb.hh:78
int detach(int timeout, const ErrorStack &err=ErrorStack())
Internal used function to detach the device.
Definition: dfu_libusb.cc:221
int download(unsigned block, uint8_t *data, unsigned len, const ErrorStack &err=ErrorStack())
Downloads some data to the device.
Definition: dfu_libusb.cc:195
int abort(const ErrorStack &err=ErrorStack())
Internal used function to abort the current operation.
Definition: dfu_libusb.cc:272
bool isOpen() const
Returns true if the DFU device interface is open.
Definition: dfu_libusb.cc:177
static QList< USBDeviceDescriptor > detect(uint16_t vid, uint16_t pid)
Finds all DFU interfaces with the specified VID/PID combination.
Definition: dfu_libusb.cc:136
int clear_status(const ErrorStack &err=ErrorStack())
Internal used function to clear the status.
Definition: dfu_libusb.cc:245
virtual ~DFUDevice()
Destructor.
Definition: dfu_libusb.cc:131
libusb_device_handle * _dev
USB device object.
Definition: dfu_libusb.hh:76
int upload(unsigned block, uint8_t *data, unsigned len, const ErrorStack &err=ErrorStack())
Uploads some data from the device.
Definition: dfu_libusb.cc:208
void close()
Closes the DFU interface.
Definition: dfu_libusb.cc:182
Implements the ST MCU extensions for the DFU protocol, aka DfuSe.
Definition: dfu_libusb.hh:88
void close()
Closes the connection.
Definition: dfu_libusb.cc:332
bool writeBlock(unsigned block, const uint8_t *data, const ErrorStack &err=ErrorStack())
Writes a block of data to the device.
Definition: dfu_libusb.cc:366
bool leaveDFU(const ErrorStack &err=ErrorStack())
Leaves the DFU mode, may boot into the application code.
Definition: dfu_libusb.cc:429
uint16_t _blocksize
Holds the block size in bytes.
Definition: dfu_libusb.hh:121
bool erasePage(uint32_t address, const ErrorStack &err=ErrorStack())
Erases an entire page of memory at the specified address.
Definition: dfu_libusb.cc:379
bool setAddress(uint32_t address, const ErrorStack &err=ErrorStack())
Sets the read/write reference address.
Definition: dfu_libusb.cc:343
bool readBlock(unsigned block, uint8_t *data, const ErrorStack &err=ErrorStack())
Reads a block of data from the device.
Definition: dfu_libusb.cc:361
uint16_t blocksize() const
Returns the blocksize in bytes.
Definition: dfu_libusb.cc:338
bool releaseReadLock(const ErrorStack &err=ErrorStack())
Releases the read lock.
Definition: dfu_libusb.cc:413
DFUSEDevice(const USBDeviceDescriptor &descr, const ErrorStack &err=ErrorStack(), uint16_t blocksize=32, QObject *parent=nullptr)
Constructor, also connects to the specified VID/PID device found first.
Definition: dfu_libusb.cc:325
bool eraseAll(const ErrorStack &err=ErrorStack())
Erases the entire memory.
Definition: dfu_libusb.cc:397
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Base class for all radio interface descriptors representing a unique interface to a connected radio.
Definition: usbdevice.hh:197
const QVariant & device() const
Returns the device information identifying the interface uniquely.
Definition: usbdevice.cc:276
Generic information about a possible radio interface.
Definition: usbdevice.hh:121