1 | #ifndef __M200_WIRING_H__ |
---|
2 | #define __M200_WIRING_H__ |
---|
3 | |
---|
4 | /** |
---|
5 | * AVR M200 Punch card reader controller |
---|
6 | * Wiring constants |
---|
7 | * |
---|
8 | * Defined symbols for the wiring of the uC on our board. |
---|
9 | * This is *very* specific to our hardware setup. |
---|
10 | * |
---|
11 | * This file is part of the Punched Paper Project - Punch Card Device Drivers |
---|
12 | * Copyright (C) 2009 Sven Koeppel |
---|
13 | * |
---|
14 | * This program is free software; you can redistribute it and/or |
---|
15 | * modify it under the terms of the GNU General Public License as |
---|
16 | * published by the Free Software Foundation; either version 3 of |
---|
17 | * the License, or (at your option) any later version. |
---|
18 | * |
---|
19 | * This program is distributed in the hope that it will be useful, |
---|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | * GNU General Public License for more details. |
---|
23 | * |
---|
24 | * You should have received a copy of the GNU General Public License |
---|
25 | * along with this program; if not, see |
---|
26 | * <http://www.gnu.org/licenses/>. |
---|
27 | * |
---|
28 | * |
---|
29 | **/ |
---|
30 | |
---|
31 | #include "avr/io.h" |
---|
32 | #include "avr/interrupt.h" |
---|
33 | |
---|
34 | // pracitcal utilities |
---|
35 | #define check(where, what) ( ((what) & (where)) ? 1 : 0 ) |
---|
36 | #define check_pin(where, which) ( ((1 << (which)) & (where)) ? 1 : 0 ) |
---|
37 | |
---|
38 | // 1. Pin Input Names |
---|
39 | // (PINx registers for INPUT reading) |
---|
40 | |
---|
41 | // Port Input A: Data |
---|
42 | #define PINA_D0 PINA0 |
---|
43 | #define PINA_D1 PINA1 |
---|
44 | #define PINA_D2 PINA2 |
---|
45 | #define PINA_D3 PINA3 |
---|
46 | #define PINA_D4 PINA4 |
---|
47 | #define PINA_D5 PINA5 |
---|
48 | #define PINA_D6 PINA6 |
---|
49 | #define PINA_D7 PINA7 |
---|
50 | |
---|
51 | // Port Input B: Error, Button |
---|
52 | #define PINB_BUT PINB4 |
---|
53 | #define PINB_ERROR PINB1 |
---|
54 | #define PINB_HCK PINB2 |
---|
55 | #define PINB_MOCK PINB3 |
---|
56 | |
---|
57 | // Port Input C: Error, Signals, Data |
---|
58 | #define PINC_BSY PINC7 |
---|
59 | #define PINC_RDY PINC5 |
---|
60 | #define PINC_IM PINC4 |
---|
61 | #define PINC_PC PINC6 // only for reading in the current state |
---|
62 | #define PINC_D8 PINC0 |
---|
63 | #define PINC_D9 PINC1 |
---|
64 | #define PINC_D11 PINC2 |
---|
65 | #define PINC_D12 PINC3 |
---|
66 | |
---|
67 | // Port Input D: (RS232 Hardware flow control) |
---|
68 | |
---|
69 | |
---|
70 | // 2. Port Output Names |
---|
71 | // (PORTx registers for OUTPUT writing) |
---|
72 | |
---|
73 | // Port Output B: LED |
---|
74 | #define PORTB_LED PORTB0 |
---|
75 | |
---|
76 | // Port Output C: Pick Command |
---|
77 | #define PORTC_PC PORTC6 |
---|
78 | |
---|
79 | |
---|
80 | // 3. Port Interrupts |
---|
81 | |
---|
82 | // Pin Change Masks |
---|
83 | #define PCINT_IM PCINT20 |
---|
84 | #define PCINT_RDY PCINT21 |
---|
85 | #define PCINT_ERROR PCINT9 |
---|
86 | #define PCINT_HCK PCINT10 |
---|
87 | #define PCINT_MOCK PCINT11 |
---|
88 | #define PCINT_PC PCINT22 |
---|
89 | #define PCINT_BSY PCINT23 |
---|
90 | |
---|
91 | // 4. Output Lines |
---|
92 | |
---|
93 | #define start_reader() ( PORTC |= (1 << PORTC_PC) ) |
---|
94 | #define stop_reader() ( PORTC &= ~(1 << PORTC_PC) ) |
---|
95 | #define is_reading() ( PINC & (1 << PORTC_PC) ) |
---|
96 | |
---|
97 | // sic! mit ja/nein und so |
---|
98 | #define start_led() ( PORTB &= ~(1 << PORTB_LED) ) |
---|
99 | #define stop_led() ( PORTB |= (1 << PORTB_LED) ) |
---|
100 | #define is_led() ( PINB & (1 << PORTB_LED) ) |
---|
101 | #define toggle_led() ( is_led() ? stop_led() : start_led() ) |
---|
102 | |
---|
103 | #endif /* __M200_WIRING_H__ */ |
---|