📄 dfu.h
字号:
/* * dfu.h * * DFU download utility * * Copyright Brad Hards and Bas Vermeulen * *//* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include "usb.h"/* DFU states */#define STATE_IDLE 0x00#define STATE_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/* DFU commands */#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 6struct dfu_status { unsigned char bStatus; unsigned char bwPollTimeout[3]; unsigned char bState; unsigned char iString;} __attribute__ ((packed));#ifdef __cplusplusextern "C" {#endifint AtmelGetModeOfOperation(usb_dev_handle * dev, unsigned char *mode);int DFUDetach(usb_dev_handle * dev);int DFUDownload(usb_dev_handle * dev, unsigned char *Buffer, unsigned long Bytes, unsigned short Block);int DFUGetStatus(usb_dev_handle * dev, struct dfu_status *status);unsigned char DFUGetState(usb_dev_handle * dev, unsigned char *state);int DownloadFirmware(usb_dev_handle * dev, unsigned char *DfuBuffer, unsigned int DfuLen);unsigned long ReadFirmware(char *file, unsigned char **buffer);int DeviceFirmwareUpgrade(int idVendor, int idProduct, char *filename);#ifdef __cplusplus}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -