OpenCores
URL https://opencores.org/ocsvn/gecko3/gecko3/trunk

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-fw/] [firmware/] [include/] [usb_dfu.h] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 nussgipfel
/* GECKO3COM
2
 *
3
 * Copyright (C) 2008 by
4
 *   ___    ____  _   _
5
 *  (  _`\ (  __)( ) ( )
6
 *  | (_) )| (_  | |_| |   Berne University of Applied Sciences
7
 *  |  _ <'|  _) |  _  |   School of Engineering and
8
 *  | (_) )| |   | | | |   Information Technology
9
 *  (____/'(_)   (_) (_)
10
 *
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation, either version 3 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
 
25
/*********************************************************************/
26
/** \file     usb_dfu.h
27
 *********************************************************************
28
 * \brief     handles the standard requests according to the USB DFU
29
 *            class.
30
 *
31
 * \author    Christoph Zimmermann bfh.ch
32
 * \date      2009-1-13
33
 *
34
*/
35
 
36
#ifndef _USB_DFU_H_
37
#define _USB_DFU_H_
38
 
39
#define DFU_TIMEOUT    255
40
 
41
/* format of bmRequestType byte */
42
#define bmRT_DFU_OUT   0x21             
43
#define bmRT_DFU_IN    0xA1     
44
 
45
/* DFU class commands */
46
#define DFU_DETACH     0
47
#define DFU_DNLOAD     1
48
#define DFU_UPLOAD     2
49
#define DFU_GETSTATUS  3
50
#define DFU_CLRSTATUS  4
51
#define DFU_GETSTATE   5
52
#define DFU_ABORT      6
53
 
54
/* DFU class status return values */
55
#define DFU_STATUS_OK                   0x00
56
#define DFU_STATUS_errTARGET            0x01
57
#define DFU_STATUS_errFILE              0x02
58
#define DFU_STATUS_errWRITE             0x03
59
#define DFU_STATUS_errERASE             0x04
60
#define DFU_STATUS_errCHECK_ERASED      0x05
61
#define DFU_STATUS_errPROG              0x06
62
#define DFU_STATUS_errVERIFY            0x07
63
#define DFU_STATUS_errADDRESS           0x08
64
#define DFU_STATUS_errNOTDONE           0x09
65
#define DFU_STATUS_errFIRMWARE          0x0a
66
#define DFU_STATUS_errVENDOR            0x0b
67
#define DFU_STATUS_errUSBR              0x0c
68
#define DFU_STATUS_errPOR               0x0d
69
#define DFU_STATUS_errUNKNOWN           0x0e
70
#define DFU_STATUS_errSTALLEDPKT        0x0f
71
 
72
/** \brief device states according to DFU class specificaton
73
 *
74
 *  this enum is used for the DFU state mashine */
75
enum dfu_state {
76
        DFU_STATE_appIDLE               = 0,
77
        DFU_STATE_appDETACH             = 1,
78
        DFU_STATE_dfuIDLE               = 2,
79
        DFU_STATE_dfuDNLOAD_SYNC        = 3,
80
        DFU_STATE_dfuDNBUSY             = 4,
81
        DFU_STATE_dfuDNLOAD_IDLE        = 5,
82
        DFU_STATE_dfuMANIFEST_SYNC      = 6,
83
        DFU_STATE_dfuMANIFEST           = 7,
84
        DFU_STATE_dfuMANIFEST_WAIT_RST  = 8,
85
        DFU_STATE_dfuUPLOAD_IDLE        = 9,
86
        DFU_STATE_dfuERROR              = 10,
87
};
88
 
89
/** Global variable for handling the timeout when after an DFU_DETACH
90
 *  request no USB reset follows and we continue normal operation*/
91
extern volatile uint8_t usb_dfu_timeout;
92
 
93
/** Global variable that contains our current device status */
94
extern volatile uint8_t usb_dfu_status;
95
 
96
/** Global variable that contains our current device state */
97
extern volatile enum dfu_state usb_dfu_state;
98
 
99
/** Makro to check if this setup package is a DFU request */
100
#define usb_dfu_request() ((wIndexL == USB_DFU_RT_INTERFACE && \
101
                           (bRequestType & bmRT_RECIP_INTERFACE) == bmRT_RECIP_INTERFACE) \
102
                           || \
103
                           usb_dfu_state >= DFU_STATE_dfuIDLE \
104
                          )
105
 
106
/** \brief general function to handle the DFU requests. Calls the function
107
 *  app_firmware_write when needed
108
 */
109
uint8_t usb_handle_dfu_packet (void);
110
 
111
/** \brief Provided by user application to write the firmware into the memory.
112
 * \return returns non-zero if it handled the command. */
113
uint8_t app_firmware_write (void);
114
 
115
#endif /* _USB_DFU_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.