Electronics and Software
Engineering Innovation
BMeasure-lib  0.7.9
Dfu.cpp File Reference
#include <Dfu.h>
#include <BFile.h>
#include <BDebug.h>
#include <unistd.h>

Classes

struct  BFirmwareInfo
 

Macros

#define BDEBUGL1   0
 
#define BDEBUGL2   0
 
#define STATE_APP_IDLE   0x00
 
#define STATE_APP_DETACH   0x01
 
#define STATE_DFU_IDLE   0x02
 
#define STATE_DFU_DOWNLOAD_SYNC   0x03
 
#define STATE_DFU_DOWNLOAD_BUSY   0x04
 
#define STATE_DFU_DOWNLOAD_IDLE   0x05
 
#define STATE_DFU_MANIFEST_SYNC   0x06
 
#define STATE_DFU_MANIFEST   0x07
 
#define STATE_DFU_MANIFEST_WAIT_RESET   0x08
 
#define STATE_DFU_UPLOAD_IDLE   0x09
 
#define STATE_DFU_ERROR   0x0a
 
#define DFU_STATUS_OK   0x00
 
#define DFU_STATUS_ERROR_TARGET   0x01
 
#define DFU_STATUS_ERROR_FILE   0x02
 
#define DFU_STATUS_ERROR_WRITE   0x03
 
#define DFU_STATUS_ERROR_ERASE   0x04
 
#define DFU_STATUS_ERROR_CHECK_ERASED   0x05
 
#define DFU_STATUS_ERROR_PROG   0x06
 
#define DFU_STATUS_ERROR_VERIFY   0x07
 
#define DFU_STATUS_ERROR_ADDRESS   0x08
 
#define DFU_STATUS_ERROR_NOTDONE   0x09
 
#define DFU_STATUS_ERROR_FIRMWARE   0x0a
 
#define DFU_STATUS_ERROR_VENDOR   0x0b
 
#define DFU_STATUS_ERROR_USBR   0x0c
 
#define DFU_STATUS_ERROR_POR   0x0d
 
#define DFU_STATUS_ERROR_UNKNOWN   0x0e
 
#define DFU_STATUS_ERROR_STALLEDPKT   0x0f
 
#define DFU_DETACH   0
 
#define DFU_DNLOAD   1
 
#define DFU_UPLOAD   2
 
#define DFU_GETSTATUS   3
 
#define DFU_CLRSTATUS   4
 
#define DFU_GETSTATE   5
 
#define DFU_ABORT   6
 
#define DFU_IFF_DFU   0x0001 /* DFU Mode, (not Runtime) */
 
#define DFU_IFF_VENDOR   0x0100
 
#define DFU_IFF_PRODUCT   0x0200
 
#define DFU_IFF_CONFIG   0x0400
 
#define DFU_IFF_IFACE   0x0800
 
#define DFU_IFF_ALT   0x1000
 
#define DFU_IFF_DEVNUM   0x2000
 
#define DFU_IFF_PATH   0x4000
 

Enumerations

enum  dfuse_command { SET_ADDRESS, ERASE_PAGE, MASS_ERASE, READ_UNPROTECT }
 

Functions

static BInt32 pageNumber (BUInt32 address)
 
static BUInt32 pageAddress (BUInt32 page)
 

Variables

const BUInt32 BFirmwareInfoMagic = 0xBBEEAA00
 
const BUInt8 BFirmwareInfoEncrypt1 = 0x40
 

Macro Definition Documentation

◆ BDEBUGL1

#define BDEBUGL1   0

◆ BDEBUGL2

#define BDEBUGL2   0

◆ DFU_ABORT

#define DFU_ABORT   6

◆ DFU_CLRSTATUS

#define DFU_CLRSTATUS   4

◆ DFU_DETACH

#define DFU_DETACH   0

◆ DFU_DNLOAD

#define DFU_DNLOAD   1

◆ DFU_GETSTATE

#define DFU_GETSTATE   5

◆ DFU_GETSTATUS

#define DFU_GETSTATUS   3

◆ DFU_IFF_ALT

#define DFU_IFF_ALT   0x1000

◆ DFU_IFF_CONFIG

#define DFU_IFF_CONFIG   0x0400

◆ DFU_IFF_DEVNUM

#define DFU_IFF_DEVNUM   0x2000

◆ DFU_IFF_DFU

#define DFU_IFF_DFU   0x0001 /* DFU Mode, (not Runtime) */

◆ DFU_IFF_IFACE

#define DFU_IFF_IFACE   0x0800

◆ DFU_IFF_PATH

#define DFU_IFF_PATH   0x4000

◆ DFU_IFF_PRODUCT

#define DFU_IFF_PRODUCT   0x0200

◆ DFU_IFF_VENDOR

#define DFU_IFF_VENDOR   0x0100

◆ DFU_STATUS_ERROR_ADDRESS

#define DFU_STATUS_ERROR_ADDRESS   0x08

◆ DFU_STATUS_ERROR_CHECK_ERASED

#define DFU_STATUS_ERROR_CHECK_ERASED   0x05

◆ DFU_STATUS_ERROR_ERASE

#define DFU_STATUS_ERROR_ERASE   0x04

◆ DFU_STATUS_ERROR_FILE

#define DFU_STATUS_ERROR_FILE   0x02

◆ DFU_STATUS_ERROR_FIRMWARE

#define DFU_STATUS_ERROR_FIRMWARE   0x0a

◆ DFU_STATUS_ERROR_NOTDONE

#define DFU_STATUS_ERROR_NOTDONE   0x09

◆ DFU_STATUS_ERROR_POR

#define DFU_STATUS_ERROR_POR   0x0d

◆ DFU_STATUS_ERROR_PROG

#define DFU_STATUS_ERROR_PROG   0x06

◆ DFU_STATUS_ERROR_STALLEDPKT

#define DFU_STATUS_ERROR_STALLEDPKT   0x0f

◆ DFU_STATUS_ERROR_TARGET

#define DFU_STATUS_ERROR_TARGET   0x01

◆ DFU_STATUS_ERROR_UNKNOWN

#define DFU_STATUS_ERROR_UNKNOWN   0x0e

◆ DFU_STATUS_ERROR_USBR

#define DFU_STATUS_ERROR_USBR   0x0c

◆ DFU_STATUS_ERROR_VENDOR

#define DFU_STATUS_ERROR_VENDOR   0x0b

◆ DFU_STATUS_ERROR_VERIFY

#define DFU_STATUS_ERROR_VERIFY   0x07

◆ DFU_STATUS_ERROR_WRITE

#define DFU_STATUS_ERROR_WRITE   0x03

◆ DFU_STATUS_OK

#define DFU_STATUS_OK   0x00

◆ DFU_UPLOAD

#define DFU_UPLOAD   2

◆ STATE_APP_DETACH

#define STATE_APP_DETACH   0x01

◆ STATE_APP_IDLE

#define STATE_APP_IDLE   0x00

◆ STATE_DFU_DOWNLOAD_BUSY

#define STATE_DFU_DOWNLOAD_BUSY   0x04

◆ STATE_DFU_DOWNLOAD_IDLE

#define STATE_DFU_DOWNLOAD_IDLE   0x05

◆ STATE_DFU_DOWNLOAD_SYNC

#define STATE_DFU_DOWNLOAD_SYNC   0x03

◆ STATE_DFU_ERROR

#define STATE_DFU_ERROR   0x0a

◆ STATE_DFU_IDLE

#define STATE_DFU_IDLE   0x02

◆ STATE_DFU_MANIFEST

#define STATE_DFU_MANIFEST   0x07

◆ STATE_DFU_MANIFEST_SYNC

#define STATE_DFU_MANIFEST_SYNC   0x06

◆ STATE_DFU_MANIFEST_WAIT_RESET

#define STATE_DFU_MANIFEST_WAIT_RESET   0x08

◆ STATE_DFU_UPLOAD_IDLE

#define STATE_DFU_UPLOAD_IDLE   0x09

Enumeration Type Documentation

◆ dfuse_command

Enumerator
SET_ADDRESS 
ERASE_PAGE 
MASS_ERASE 
READ_UNPROTECT 

Function Documentation

◆ pageAddress()

static BUInt32 pageAddress ( BUInt32  page)
static

◆ pageNumber()

static BInt32 pageNumber ( BUInt32  address)
static

Variable Documentation

◆ BFirmwareInfoEncrypt1

const BUInt8 BFirmwareInfoEncrypt1 = 0x40

◆ BFirmwareInfoMagic

const BUInt32 BFirmwareInfoMagic = 0xBBEEAA00