Update TODO list
[trut64.git] / avr / passtask.c
blob7d1a5573b86b0ff82d9c9bd81cfe6acb27dffb58
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 #include "passtask.h"
10 #include "fcpu.h"
11 #include "c64tape.h"
12 #include "motor.h"
13 #include <avr/io.h>
14 #include "trutcomm.h"
15 #include <util/delay.h>
17 void passtask_init()
21 void passtask_setup()
23 // First clear the interrupt enable flags
24 EIMSK &= ~(_BV(INT0) | _BV(INT1));
26 // Enable interrupts of both edges for taperead and c64write
27 EICRA &= ~(_BV(ISC11));
28 EICRA |= _BV(ISC10);
29 EICRA &= ~(_BV(ISC01));
30 EICRA |= _BV(ISC00);
32 // Clear possible interrupt flags
33 EIFR |= (_BV(INTF1) | _BV(INTF0));
35 // Set the interrupt enable flags
36 EIMSK |= (_BV(INT0) | _BV(INT1));
38 // Finally update the signals
39 if(taperead_ison())
40 c64read_on();
41 else
42 c64read_off();
44 if(tapesense_ison())
45 c64sense_on();
46 else
47 c64sense_off();
49 if(c64write_ison())
50 tapewrite_on();
51 else
52 tapewrite_off();
55 void passtask_disable()
57 // Clear the interrupt enable flags
58 EIMSK &= ~(_BV(INT0) | _BV(INT1));
61 void passtask()
63 if(tapesense_ison())
64 c64sense_on();
65 else
66 c64sense_off();
69 // Interrupt handler for TAPEREAD
70 ISR(INT0_vect)
72 if(taperead_ison())
73 c64read_on();
74 else
75 c64read_off();
78 // Interrupt handler for C64WRITE
79 ISR(INT1_vect)
81 if(c64write_ison())
82 tapewrite_on();
83 else
84 tapewrite_off();