host_dfu_task.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of Atmel may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef _HOST_DFU_TASK_H_
00045 #define _HOST_DFU_TASK_H_
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 
00049 
00050 #include "config.h"
00051 
00052 //_____ M A C R O S ________________________________________________________
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 //_____ D E C L A R A T I O N S ____________________________________________
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 /* _HOST_DFU_TASK_H_ */

Generated on Wed Sep 23 09:33:17 2009 for ATMEL by  doxygen 1.5.3