USBasp 2007.10.23.
[pub/USBasp.git] / firmware / isp.h
1 /*
2 isp.h - part of USBasp
3
4 Autor..........: Thomas Fischl <tfischl@gmx.de>
5 Description....: Provides functions for communication/programming
6 over ISP interface
7 Licence........: GNU GPL v2 (see Readme.txt)
8 Creation Date..: 2005-02-23
9 Last change....: 2007-07-23
10 */
11
12 #ifndef __isp_h_included__
13 #define __isp_h_included__
14
15 #ifndef uchar
16 #define uchar unsigned char
17 #endif
18
19 #define ISP_OUT PORTB
20 #define ISP_IN PINB
21 #define ISP_DDR DDRB
22 #define ISP_RST PB2
23 #define ISP_MOSI PB3
24 #define ISP_MISO PB4
25 #define ISP_SCK PB5
26
27 #define ISP_DELAY 1
28 #define ISP_SCK_SLOW 0
29 #define ISP_SCK_FAST 1
30
31 /* Prepare connection to target device */
32 void ispConnect();
33
34 /* Close connection to target device */
35 void ispDisconnect();
36
37 /* read an write a byte from isp using software (slow) */
38 uchar ispTransmit_sw(uchar send_byte);
39
40 /* read an write a byte from isp using hardware (fast) */
41 uchar ispTransmit_hw(uchar send_byte);
42
43 /* enter programming mode */
44 uchar ispEnterProgrammingMode();
45
46 /* read byte from eeprom at given address */
47 uchar ispReadEEPROM(unsigned int address);
48
49 /* write byte to flash at given address */
50 uchar ispWriteFlash(unsigned long address, uchar data, uchar pollmode);
51
52 uchar ispFlushPage(unsigned long address, uchar pollvalue);
53
54 /* read byte from flash at given address */
55 uchar ispReadFlash(unsigned long address);
56
57 /* write byte to eeprom at given address */
58 uchar ispWriteEEPROM(unsigned int address, uchar data);
59
60 /* pointer to sw or hw transmit function */
61 uchar (*ispTransmit)(uchar);
62
63 /* set SCK speed. call before ispConnect! */
64 void ispSetSCKOption(uchar sckoption);
65
66 #endif /* __isp_h_included__ */