Rev Author Line No. Line
3471 miho 1 /*
2 * usbasp.c - part of USBasp
3 *
4 * Autor..........: Thomas Fischl <tfischl@gmx.de>
5 * Description....: Definitions and macros for usbasp
6 * Licence........: GNU GPL v2 (see Readme.txt)
7 * Creation Date..: 2009-02-28
8 * Last change....: 2009-02-28
9 */
10  
11 #ifndef USBASP_H_
12 #define USBASP_H_
13  
14 /* USB function call identifiers */
15 #define USBASP_FUNC_CONNECT 1
16 #define USBASP_FUNC_DISCONNECT 2
17 #define USBASP_FUNC_TRANSMIT 3
18 #define USBASP_FUNC_READFLASH 4
19 #define USBASP_FUNC_ENABLEPROG 5
20 #define USBASP_FUNC_WRITEFLASH 6
21 #define USBASP_FUNC_READEEPROM 7
22 #define USBASP_FUNC_WRITEEEPROM 8
23 #define USBASP_FUNC_SETLONGADDRESS 9
24 #define USBASP_FUNC_SETISPSCK 10
25 #define USBASP_FUNC_TPI_CONNECT 11
26 #define USBASP_FUNC_TPI_DISCONNECT 12
27 #define USBASP_FUNC_TPI_RAWREAD 13
28 #define USBASP_FUNC_TPI_RAWWRITE 14
29 #define USBASP_FUNC_TPI_READBLOCK 15
30 #define USBASP_FUNC_TPI_WRITEBLOCK 16
31 #define USBASP_FUNC_GETCAPABILITIES 127
32  
33 /* USBASP capabilities */
34 #define USBASP_CAP_0_TPI 0x01
35  
36 /* programming state */
37 #define PROG_STATE_IDLE 0
38 #define PROG_STATE_WRITEFLASH 1
39 #define PROG_STATE_READFLASH 2
40 #define PROG_STATE_READEEPROM 3
41 #define PROG_STATE_WRITEEEPROM 4
42 #define PROG_STATE_TPI_READ 5
43 #define PROG_STATE_TPI_WRITE 6
44  
45 /* Block mode flags */
46 #define PROG_BLOCKFLAG_FIRST 1
47 #define PROG_BLOCKFLAG_LAST 2
48  
49 /* ISP SCK speed identifiers */
50 #define USBASP_ISP_SCK_AUTO 0
51 #define USBASP_ISP_SCK_0_5 1 /* 500 Hz */
52 #define USBASP_ISP_SCK_1 2 /* 1 kHz */
53 #define USBASP_ISP_SCK_2 3 /* 2 kHz */
54 #define USBASP_ISP_SCK_4 4 /* 4 kHz */
55 #define USBASP_ISP_SCK_8 5 /* 8 kHz */
56 #define USBASP_ISP_SCK_16 6 /* 16 kHz */
57 #define USBASP_ISP_SCK_32 7 /* 32 kHz */
58 #define USBASP_ISP_SCK_93_75 8 /* 93.75 kHz */
59 #define USBASP_ISP_SCK_187_5 9 /* 187.5 kHz */
60 #define USBASP_ISP_SCK_375 10 /* 375 kHz */
61 #define USBASP_ISP_SCK_750 11 /* 750 kHz */
62 #define USBASP_ISP_SCK_1500 12 /* 1.5 MHz */
63  
64 /* macros for gpio functions */
65 #define ledRedOn() PORTC &= ~(1 << PC1)
66 #define ledRedOff() PORTC |= (1 << PC1)
67 #define ledGreenOn() PORTC &= ~(1 << PC0)
68 #define ledGreenOff() PORTC |= (1 << PC0)
69  
70 #endif /* USBASP_H_ */