-
Notifications
You must be signed in to change notification settings - Fork 0
/
isp.h
74 lines (53 loc) · 1.79 KB
/
isp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
isp.h - part of USBasp
Autor..........: Thomas Fischl <[email protected]>
Description....: Provides functions for communication/programming
over ISP interface
Licence........: Free under certain conditions. See Documentation.
Creation Date..: 2005-02-23
Last change....: 2005-04-20
*/
#ifndef __isp_h_included__
#define __isp_h_included__
#ifndef uchar
#define uchar unsigned char
#endif
#define ISP_OUT PORTB
#define ISP_IN PINB
#define ISP_DDR DDRB
#define ISP_RST PB2
#define ISP_MOSI PB3
#define ISP_MISO PB4
#define ISP_SCK PB5
#define ISP_DELAY 1
#define ISP_SCK_SLOW 0
#define ISP_SCK_FAST 1
#define ATM 0x00
#define S5x 0xFF
unsigned char chip;
/* Prepare connection to target device */
void ispConnect();
/* Close connection to target device */
void ispDisconnect();
/* read an write a byte from isp using software (slow) */
uchar ispTransmit_sw(uchar send_byte);
/* read an write a byte from isp using software (S5x) */
uchar ispTransmit_5x(uchar send_byte);
/* read an write a byte from isp using hardware (fast) */
uchar ispTransmit_hw(uchar send_byte);
/* enter programming mode */
uchar ispEnterProgrammingMode();
/* read byte from eeprom at given address */
uchar ispReadEEPROM(unsigned int address);
/* write byte to flash at given address */
uchar ispWriteFlash(unsigned int address, uchar data, uchar pollmode);
uchar ispFlushPage(unsigned int address, uchar pollvalue);
/* read byte from flash at given address */
uchar ispReadFlash(unsigned int address);
/* write byte to eeprom at given address */
uchar ispWriteEEPROM(unsigned int address, uchar data);
/* pointer to sw or hw transmit function */
uchar (*ispTransmit)(uchar);
/* set SCK speed. call before ispConnect! */
void ispSetSCKOption(uchar sckoption);
#endif /* __isp_h_included__ */