Adds client support for the Apimote, which uses the RTS line instead of the DTR line.
[goodfet] / firmware / include / avr.h
1 /*! \file avr.h
2   \author Travis Goodspeed
3   \brief AVR SPI Programmer
4 */
5
6 #ifndef AVR_H
7 #define AVR_H
8
9 #include "spi.h"
10 #include "app.h"
11
12 /* AVR is a known macro for the AVR C includes */
13 #define XAVR 0x32
14
15 //! Setup the AVR pins.
16 void avrsetup();
17
18 //! Initialized an attached AVR.
19 void avrconnect();
20
21 //! Enable AVR programming mode.
22 void avr_prgen();
23 //! Read AVR device code.
24 uint8_t avr_sig(uint8_t i);
25 //! Erase an AVR device
26 void avr_erase();
27 //! Read lock bits.
28 uint8_t avr_lockbits();
29 //! Write lock bits.
30 void avr_setlock(uint8_t bits);
31
32 //! Read a byte of Flash
33 uint8_t avr_peekflash(uint16_t adr);
34
35 //! Read a byte of EEPROM.
36 uint8_t avr_peekeeprom(uint16_t adr);
37 //! Read a byte of EEPROM.
38 uint8_t avr_pokeeeprom(uint16_t adr, uint8_t val);
39
40 //! Is the AVR ready or busy?
41 uint8_t avr_isready();
42
43 //Command codes.
44 //! Perform a chip erase.
45 #define AVR_ERASE 0xF0
46 //! Fetch RDY/!BSY byte.
47 #define AVR_RDYBSY 0xF1
48
49 //! Read Program Memory
50 #define AVR_PEEKPGM 0x80
51 //! Read EEPROM
52 #define AVR_PEEKEEPROM 0x81
53 //! Write EEPROM
54 #define AVR_POKEEEPROM 0x91
55 //! Read lock bits.
56 #define AVR_PEEKLOCK 0x82
57 //! Write lock its.
58 #define AVR_POKELOCK 0x92
59 //! Read signature.
60 #define AVR_PEEKSIG 0x83
61 //! Read fuse bits.
62 #define AVR_READFUSES 0x84
63 //! Read calibration byte.
64 #define AVR_READCAL 0x85
65 //! Bulk load data
66 #define AVR_BULKLOAD 0x86
67
68 extern app_t const avr_app;
69
70 #endif // AVR_H