00001
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef _HOST_DFU_TASK_H_
00045 #define _HOST_DFU_TASK_H_
00046
00047
00048
00049
00050 #include "config.h"
00051
00052
00053
00054
00055 #define DFU_DETACH 0x00
00056 #define DFU_DNLOAD 0x01
00057 #define DFU_UPLOAD 0x02
00058 #define DFU_GETSTATUS 0x03
00059 #define DFU_CLRSTATUS 0x04
00060 #define DFU_GETSTATE 0x05
00061 #define DFU_ABORT 0x06
00062
00063 #define RECORD_MARK ':'
00064 #define DATA_RECORD 0x00
00065 #define PAGE_RECORD 0x04
00066
00067 #define ATMEL_VID VID_ATMEL
00068 #define AT90DFU_PID PID_AT90USB128_DFU
00069
00070 #define MAX_DATA_PER_RECORD 16
00071
00072
00073 #define Dfu_download(n) (usb_request.bmRequestType = USB_SETUP_SET_CLASS_INTER,\
00074 usb_request.bRequest = DFU_DNLOAD,\
00075 usb_request.wValue = 0,\
00076 usb_request.wIndex = 0,\
00077 usb_request.wLength = n,\
00078 usb_request.uncomplete_read = FALSE,\
00079 host_send_control(data_stage))
00080
00081 #define Dfu_upload(n) (usb_request.bmRequestType = USB_SETUP_GET_CLASS_INTER,\
00082 usb_request.bRequest = DFU_UPLOAD,\
00083 usb_request.wValue = 0,\
00084 usb_request.wIndex = 0,\
00085 usb_request.wLength = n,\
00086 usb_request.uncomplete_read = FALSE,\
00087 host_send_control(data_stage))
00088
00089
00090 #define Dfu_get_status() (usb_request.bmRequestType = USB_SETUP_GET_CLASS_INTER,\
00091 usb_request.bRequest = DFU_GETSTATUS,\
00092 usb_request.wValue = 0,\
00093 usb_request.wIndex = 0,\
00094 usb_request.wLength = 6,\
00095 usb_request.uncomplete_read = FALSE,\
00096 host_send_control(data_stage))
00097
00098 #define Dfu_read_manuf_id() ( data_stage[0]=0x05,\
00099 data_stage[1]=0x01,\
00100 data_stage[2]=0x30,\
00101 Dfu_download(3),\
00102 Dfu_upload(1))
00103
00104 #define Dfu_erase() ( data_stage[0]=0x04,\
00105 data_stage[1]=0x00,\
00106 data_stage[2]=0xFF,\
00107 Dfu_download(3))
00108
00109 #define Dfu_set_page(n) ( data_stage[0]=0x06,\
00110 data_stage[1]=0x03,\
00111 data_stage[2]=0x00,\
00112 data_stage[3]=n,\
00113 Dfu_download(4))
00114
00115 #define Dfu_start_appli(n) ( data_stage[0]=0x04,\
00116 data_stage[1]=0x03,\
00117 data_stage[2]=0x00,\
00118 Dfu_download(3),\
00119 Dfu_get_status())
00120
00121 #define FIRMWARE_NAME "FIRMWARE.HEX"
00122 #define SIZE_BUF_STR 36
00123
00124
00125
00126
00127
00128
00129 extern U8 dfu_connected;
00130
00131 void dfu_read(U16 start,U16 end,U8 *buf);
00132 void dfu_prog(U16 start,U16 end,U8 *buf);
00133 U8 dfu_load_hex(void);
00134 void dfu_flush_prog(void);
00135 U8 ascii_to_bin (U8 b);
00136
00137 #endif