Update TODO list
[trut64.git] / avr / c64tape.h
blob3eaf3e5efb09cf291c445eae76c51013598ae053
1 /*
2 * Copyright (C) 2007 Anton Blad
3 * Copyright (C) 2007 Fredrik Kuivinen
4 * Copyright (C) 2007 Jakob Rosén
6 * This file is licensed under GPL v2.
7 */
9 #ifndef C64TAPE_H
10 #define C64TAPE_H
12 #include <avr/io.h>
14 // Pin definitions for C64 and TAPE interfaces.
16 // For dev-trut:
17 // MOTOR on PB6
18 // C64READ on PC6
19 // C64WRITE on PD1
20 // C64SENSE on PC2
21 // TAPEREAD on PD0
22 // TAPEWRITE on PC5
23 // TAPESENSE on PC4
24 // RSIG on PC7 (Multiplexed input of TAPEREAD and C64WRITE)
25 // RSIGSEL on PB5 (Control signal for RSIG multiplexer)
27 // For usbkey:
28 // MOTOR on PB0
29 // C64READ on PB5
31 #if HWBOARD==DEVTRUT
33 #define DDR_MOTOR DDRB
34 #define PORT_MOTOR PORTB
35 #define PIN_MOTOR PINB
36 #define P_MOTOR 6
38 #define DDR_C64READ DDRC
39 #define PORT_C64READ PORTC
40 #define PIN_C64READ PINC
41 #define P_C64READ 6
43 #define DDR_C64WRITE DDRD
44 #define PORT_C64WRITE PORTD
45 #define PIN_C64WRITE PIND
46 #define P_C64WRITE 1
48 #define DDR_C64SENSE DDRC
49 #define PORT_C64SENSE PORTC
50 #define PIN_C64SENSE PINC
51 #define P_C64SENSE 2
53 #define DDR_TAPEREAD DDRD
54 #define PORT_TAPEREAD PORTD
55 #define PIN_TAPEREAD PIND
56 #define P_TAPEREAD 0
58 #define DDR_TAPEWRITE DDRC
59 #define PORT_TAPEWRITE PORTC
60 #define PIN_TAPEWRITE PINC
61 #define P_TAPEWRITE 5
63 #define DDR_TAPESENSE DDRC
64 #define PORT_TAPESENSE PORTC
65 #define PIN_TAPESENSE PINC
66 #define P_TAPESENSE 4
68 #define DDR_RSIGSEL DDRB
69 #define PORT_RSIGSEL PORTB
70 #define PIN_RSIGSEL PINB
71 #define P_RSIGSEL 5
73 #else /* HWBOARD==DEVTRUT */
75 #define DDR_MOTOR DDRB
76 #define PORT_MOTOR PORTB
77 #define PIN_MOTOR PINB
78 #define P_MOTOR 0
80 #define DDR_C64READ DDRB
81 #define PORT_C64READ PORTB
82 #define PIN_C64READ PINB
83 #define P_C64READ 5
85 #endif
87 void c64tape_init();
89 #define RSIG_C64 0
90 #define RSIG_TAPE 1
92 #if HWBOARD==DEVTRUT
93 static inline void c64read_on() { PORT_C64READ |= _BV(P_C64READ); }
94 static inline void c64read_off() { PORT_C64READ &= ~(_BV(P_C64READ)); }
96 static inline void c64sense_on() { PORT_C64SENSE &= ~(1 << P_C64SENSE); }
97 static inline void c64sense_off() { PORT_C64SENSE |= (1 << P_C64SENSE); }
99 static inline uint8_t c64write_ison()
101 return (PIN_C64WRITE & _BV(P_C64WRITE));
104 static inline uint8_t taperead_ison()
106 return (PIN_TAPEREAD & _BV(P_TAPEREAD));
109 static inline uint8_t tapesense_ison()
111 return !(PIN_TAPESENSE & _BV(P_TAPESENSE));
114 static inline void tapewrite_on() { PORT_TAPEWRITE |= _BV(P_TAPEWRITE); }
115 static inline void tapewrite_off() { PORT_TAPEWRITE &= ~(_BV(P_TAPEWRITE)); }
118 static inline void rsig(uint8_t sel)
120 if(sel == RSIG_C64)
121 PORT_RSIGSEL &= ~(_BV(P_RSIGSEL));
122 else
123 PORT_RSIGSEL |= _BV(P_RSIGSEL);
126 #else
127 static inline void c64sense_on() { }
128 static inline void c64sense_off() { }
129 #endif
131 #endif