bcf76ef7573042faf5663fb2337411a8760af4f2
[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 #define AVR 0x32
13
14 //! Setup the AVR pins.
15 void avrsetup();
16
17 //! Initialized an attached AVR.
18 void avrconnect();
19
20 //! Enable AVR programming mode.
21 void avr_prgen();
22 //! Read AVR device code.
23 u8 avr_sig(u8 i);
24 //! Erase an AVR device
25 void avr_erase();
26 //! Read lock bits.
27 u8 avr_lockbits();
28 //! Write lock bits.
29 void avr_setlock(u8 bits);
30
31 //! Read a byte of Flash
32 u8 avr_peekflash(u16 adr);
33
34 //! Read a byte of EEPROM.
35 u8 avr_peekeeprom(u16 adr);
36 //! Read a byte of EEPROM.
37 u8 avr_pokeeeprom(u16 adr, u8 val);
38
39 //! Is the AVR ready or busy?
40 u8 avr_isready();
41
42 //Command codes.
43 //! Perform a chip erase.
44 #define AVR_ERASE 0xF0
45 //! Fetch RDY/!BSY byte.
46 #define AVR_RDYBSY 0xF1
47
48 //! Read Program Memory
49 #define AVR_PEEKPGM 0x80
50 //! Read EEPROM
51 #define AVR_PEEKEEPROM 0x81
52 //! Write EEPROM
53 #define AVR_POKEEEPROM 0x91
54 //! Read lock bits.
55 #define AVR_PEEKLOCK 0x82
56 //! Write lock its.
57 #define AVR_POKELOCK 0x92
58 //! Read signature.
59 #define AVR_PEEKSIG 0x83
60 //! Read fuse bits.
61 #define AVR_READFUSES 0x84
62 //! Read calibration byte.
63 #define AVR_READCAL 0x85
64 //! Bulk load data
65 #define AVR_BULKLOAD 0x86
66
67 extern app_t const avr_app;
68
69 #endif // AVR_H