summaryrefslogtreecommitdiffstats
path: root/emulator/pinout.h
blob: 87c9cf1b4c978e9c9960492c5a39047b364950ce (plain)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef AVREMU_PINOUT_H_
#define AVREMU_PINOUT_H_

#include <stdlib.h>


/* Increase these constants as needed. */

/* Maximum number of functions per pin. */
#define AVR_MAX_PIN_FUNCS	10
/* Maximum number of physical pins per device */
#define AVR_MAX_NR_PINS		28



/* The function of a physical pin on the device. */
enum avr_pinout_function {
	PINOUT_NC = 0, /* Not connected */
	PINOUT_VCC,
	PINOUT_GND,
	PINOUT_AVCC,
	PINOUT_AREF,
	PINOUT_PB0,
	PINOUT_PB1,
	PINOUT_PB2,
	PINOUT_PB3,
	PINOUT_PB4,
	PINOUT_PB5,
	PINOUT_PB6,
	PINOUT_PB7,
	PINOUT_PC0,
	PINOUT_PC1,
	PINOUT_PC2,
	PINOUT_PC3,
	PINOUT_PC4,
	PINOUT_PC5,
	PINOUT_PC6,
	PINOUT_PD0,
	PINOUT_PD1,
	PINOUT_PD2,
	PINOUT_PD3,
	PINOUT_PD4,
	PINOUT_PD5,
	PINOUT_PD6,
	PINOUT_PD7,
	PINOUT_RESET,
	PINOUT_RXD,
	PINOUT_TXD,
	PINOUT_INT0,
	PINOUT_INT1,
	PINOUT_T0,
	PINOUT_TOSC1,
	PINOUT_TOSC2,
	PINOUT_T1,
	PINOUT_AIN0,
	PINOUT_AIN1,
	PINOUT_ICP1,
	PINOUT_ADC5,
	PINOUT_ADC4,
	PINOUT_ADC3,
	PINOUT_ADC2,
	PINOUT_ADC1,
	PINOUT_ADC0,
	PINOUT_SCK,
	PINOUT_MISO,
	PINOUT_MOSI,
	PINOUT_SS,
	PINOUT_OC1A,
	PINOUT_PCINT0,
	PINOUT_PCINT1,
	PINOUT_PCINT2,
	PINOUT_PCINT3,
	PINOUT_PCINT4,
	PINOUT_PCINT5,
	PINOUT_PCINT6,
	PINOUT_PCINT7,
	PINOUT_PCINT8,
	PINOUT_PCINT9,
	PINOUT_PCINT10,
	PINOUT_PCINT11,
	PINOUT_PCINT12,
	PINOUT_PCINT13,
	PINOUT_PCINT14,
	PINOUT_PCINT16,
	PINOUT_PCINT17,
	PINOUT_PCINT18,
	PINOUT_PCINT19,
	PINOUT_PCINT20,
	PINOUT_PCINT21,
	PINOUT_PCINT22,
	PINOUT_PCINT23,
	PINOUT_OC2B,
	PINOUT_XCK,
	PINOUT_XTAL1,
	PINOUT_XTAL2,
	PINOUT_OC0B,
	PINOUT_OC0A,
	PINOUT_CLKO,
	PINOUT_SCL,
	PINOUT_SDA,
	PINOUT_OC2A,
	PINOUT_OC1B,
	PINOUT_OC2,
};

/* Data structure of a hardware pin. */
struct avr_hwpin {
	/* The assigned pin number. */
	unsigned int number;
	/* The logical functions assigned to this pin. */
	enum avr_pinout_function funcs[AVR_MAX_PIN_FUNCS];
};

/* Pinout definitions for a specific device. */
struct avr_device_pinout {
	/* Array of pins. */
	struct avr_hwpin *pins;
	/* Number of pins on this device. */
	size_t nr_pins;
};

extern struct avr_device_pinout atmega48_88_168_pinout;
extern struct avr_device_pinout atmega8_pinout;

int avr_get_pin_number(struct avr_device_pinout *pinout,
		       enum avr_pinout_function func);


typedef unsigned int (*pin_query_handler_t)(struct avr_hwpin *pin);
typedef void (*pin_change_handler_t)(struct avr_hwpin *pin, unsigned int state);

/* Dynamic handlers for a physical device pin. */
struct avr_device_pinout_handlers {
	/* Handlers to query the state of a pin from inside of the device. */
	pin_query_handler_t query_handlers[AVR_MAX_NR_PINS];
	/* Handlers to set the state of a pin from inside of the device. */
	pin_change_handler_t change_handlers[AVR_MAX_NR_PINS];
};

extern struct avr_device_pinout_handlers active_pinout_handlers;

#endif /* AVREMU_PINOUT_H_ */
bues.ch cgit interface