forked from microtherion/ScratchMonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMoISP.h
85 lines (83 loc) · 3.74 KB
/
SMoISP.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
75
76
77
78
79
80
81
82
83
84
85
// -*- mode: c++; tab-width: 4; indent-tabs-mode: nil -*-
//
// ScratchMonkey 0.1 - STK500v2 compatible programmer for Arduino
//
// File: SMoISP.h - In-System Programming commands
//
// Copyright (c) 2013 Matthias Neeracher <microtherion@gmail.com>
// All rights reserved.
//
// See license at bottom of this file or at
// http://opensource.org/licenses/bsd-license.php
//
// To use ScratchMonkey for ISP programming, connect the following pins
// of your Arduino (On the Leonardo, some of these are on the ICSP header):
//
// PIN Standard Leonardo/Micro Mega (1280 and 2560)
//
// RESET 10 10 53
// MOSI 11 MOSI 51
// MISO 12 MISO 50
// SCK 13 SCK 52
// XTAL [optional] 9 9 11
//
// The XTAL clock is available in case your chip's fuses are set to require an
// external clock signal. If you want the clock, connect it to XTAL1 on
// your target chip.
//
// On your target system, connect these pins, and power, to the following
// pins of the DIP packages (for other packages, consult the data sheet):
//
// PIN Tiny13/X5 TinyX4 Tiny26/X61 TinyX313 Mega*8 Mega*4
// (8 pin) (14 pin) (20 pin) (20 pin) (28 pin) (40 pin)
//
// RESET 1 (PB5) 4 (PB3) 10 (PB7) 1 (PA2) 1 (PC6) 9
// MOSI 5 (PB0) 7 (PA6) 1 (PB0) 17 (PB5) 17 (PB3) 6 (PB5)
// MISO 6 (PB1) 8 (PA5) 2 (PB1) 18 (PB6) 18 (PB4) 7 (PB6)
// SCK 7 (PB2) 9 (PA4) 3 (PB2) 19 (PB7) 19 (PB5) 8 (PB7)
// GND 4 14 6 10 22 31
// VCC 8 1 5 20 7 10
// XTAL1 2 (PB3) 2 (PB0) 7 (PB4) 5 (PA0) 9 (PB6) 13
//
#ifndef _SMO_ISP_
#define _SMO_ISP_
namespace SMoISP {
void EnterProgmode();
void LeaveProgmode();
void ChipErase();
void ProgramFlash();
void ReadFlash();
void ProgramEEPROM();
void ReadEEPROM();
void ProgramFuse();
void ReadFuse();
inline void ProgramLock() { ProgramFuse(); }
inline void ReadLock() { ReadFuse(); }
inline void ReadSignature() { ReadFuse(); }
inline void ReadOscCal() { ReadFuse(); }
void SPIMulti();
} // namespace SMoISP
#endif /* _SMO_ISP_ */
//
// LICENSE
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//