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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* AVR emulator
* Device pinout
*
* Copyright (C) 2007 Michael Buesch <mb@bu3sch.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "pinout.h"
#include "util.h"
#undef p
#undef PIN
#define p(pinname) PINOUT_##pinname
#define PIN(_number, ...) \
[_number - 1] = { \
.number = _number, \
.funcs = { __VA_ARGS__ }, \
}
static struct avr_hwpin atmega48_88_168_pins[] = {
PIN(1, p(PC6), p(RESET), p(PCINT14)),
PIN(2, p(PD0), p(RXD), p(PCINT16)),
PIN(3, p(PD1), p(TXD), p(PCINT17)),
PIN(4, p(PD2), p(INT0), p(PCINT18)),
PIN(5, p(PD3), p(INT1), p(OC2B), p(PCINT19)),
PIN(6, p(PD4), p(T0), p(XCK), p(PCINT20)),
PIN(7, p(VCC)),
PIN(8, p(GND)),
PIN(9, p(PB6), p(TOSC1), p(XTAL1), p(PCINT6)),
PIN(10, p(PB7), p(TOSC2), p(XTAL2), p(PCINT7)),
PIN(11, p(PD5), p(T1), p(OC0B), p(PCINT21)),
PIN(12, p(PD6), p(AIN0), p(OC0A), p(PCINT22)),
PIN(13, p(PD7), p(AIN1), p(PCINT23)),
PIN(14, p(PB0), p(ICP1), p(CLKO), p(PCINT0)),
PIN(15, p(PB1), p(OC1A), p(PCINT1)),
PIN(16, p(PB2), p(SS), p(OC1B), p(PCINT2)),
PIN(17, p(PB3), p(MOSI), p(OC2A), p(PCINT3)),
PIN(18, p(PB4), p(MISO), p(PCINT4)),
PIN(19, p(PB5), p(SCK), p(PCINT5)),
PIN(20, p(AVCC)),
PIN(21, p(AREF)),
PIN(22, p(GND)),
PIN(23, p(PC0), p(ADC0), p(PCINT8)),
PIN(24, p(PC1), p(ADC1), p(PCINT9)),
PIN(25, p(PC2), p(ADC2), p(PCINT10)),
PIN(26, p(PC3), p(ADC3), p(PCINT11)),
PIN(27, p(PC4), p(ADC4), p(SDA), p(PCINT12)),
PIN(28, p(PC5), p(ADC5), p(SCL), p(PCINT13)),
};
struct avr_device_pinout atmega48_88_168_pinout = {
.pins = atmega48_88_168_pins,
.nr_pins = ARRAY_SIZE(atmega48_88_168_pins),
};
static struct avr_hwpin atmega8_pins[] = {
PIN(1, p(PC6), p(RESET)),
PIN(2, p(PD0), p(RXD)),
PIN(3, p(PD1), p(TXD)),
PIN(4, p(PD2), p(INT0)),
PIN(5, p(PD3), p(INT1)),
PIN(6, p(PD4), p(T0)),
PIN(7, p(VCC)),
PIN(8, p(GND)),
PIN(9, p(PB6), p(TOSC1), p(XTAL1)),
PIN(10, p(PB7), p(TOSC2), p(XTAL2)),
PIN(11, p(PD5), p(T1)),
PIN(12, p(PD6), p(AIN0)),
PIN(13, p(PD7), p(AIN1)),
PIN(14, p(PB0), p(ICP1)),
PIN(15, p(PB1), p(OC1A)),
PIN(16, p(PB2), p(SS), p(OC1B)),
PIN(17, p(PB3), p(MOSI), p(OC2)),
PIN(18, p(PB4), p(MISO)),
PIN(19, p(PB5), p(SCK)),
PIN(20, p(AVCC)),
PIN(21, p(AREF)),
PIN(22, p(GND)),
PIN(23, p(PC0), p(ADC0)),
PIN(24, p(PC1), p(ADC1)),
PIN(25, p(PC2), p(ADC2)),
PIN(26, p(PC3), p(ADC3)),
PIN(27, p(PC4), p(ADC4), p(SDA)),
PIN(28, p(PC5), p(ADC5), p(SCL)),
};
struct avr_device_pinout atmega8_pinout = {
.pins = atmega8_pins,
.nr_pins = ARRAY_SIZE(atmega8_pins),
};
#undef p
#undef PIN
int avr_get_pin_number(struct avr_device_pinout *pinout,
enum avr_pinout_function func)
{
struct avr_hwpin *pin;
enum avr_pinout_function f;
size_t i, j;
for (i = 0; i < pinout->nr_pins; i++) {
pin = &(pinout->pins[i]);
for (j = 0; j < AVR_MAX_PIN_FUNCS; i++) {
f = pin->funcs[j];
if (f == PINOUT_NC)
break;
if (f == func)
return i + 1;
}
}
return -1;
}
struct avr_device_pinout_handlers active_pinout_handlers;
|