4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
22 #include </usr/include/stdio.h>
24 #include "sim_core_declare.h"
25 #include "avr_eeprom.h"
26 #include "avr_ioport.h"
27 #include "avr_timer8.h"
31 #include "avr/iotn85.h"
33 static void init(struct avr_t * avr);
34 static void reset(struct avr_t * avr);
41 avr_timer8_t timer0, timer1;
50 AVR_EEPROM_DECLARE(EE_RDY_vect),
52 .name = 'B', .r_port = PORTB, .r_ddr = DDRB, .r_pin = PINB,
54 .enable = AVR_IO_REGBIT(GIMSK, PCIE),
55 .raised = AVR_IO_REGBIT(GIFR, PCIF),
56 .vector = PCINT0_vect,
62 .wgm = { AVR_IO_REGBIT(TCCR0A, WGM00), AVR_IO_REGBIT(TCCR0A, WGM01), AVR_IO_REGBIT(TCCR0B, WGM02) },
63 .cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
64 .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
71 .enable = AVR_IO_REGBIT(TIMSK, TOIE0),
72 .raised = AVR_IO_REGBIT(TIFR, TOV0),
73 .vector = TIMER0_OVF_vect,
76 .enable = AVR_IO_REGBIT(TIMSK, OCIE0A),
77 .raised = AVR_IO_REGBIT(TIFR, OCF0A),
78 .vector = TIMER0_COMPA_vect,
81 .enable = AVR_IO_REGBIT(TIMSK, OCIE0B),
82 .raised = AVR_IO_REGBIT(TIFR, OCF0B),
83 .vector = TIMER0_COMPB_vect,
89 .cs = { AVR_IO_REGBIT(TCCR1, CS10), AVR_IO_REGBIT(TCCR1, CS11), AVR_IO_REGBIT(TCCR1, CS12), AVR_IO_REGBIT(TCCR1, CS13) },
90 .cs_div = { 0, 0, 1 /* 2 */, 2 /* 4 */, 3 /* 8 */, 4 /* 16 */ },
98 .enable = AVR_IO_REGBIT(TIMSK, TOIE1),
99 .raised = AVR_IO_REGBIT(TIFR, TOV1),
100 .vector = TIMER1_OVF_vect,
103 .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
104 .raised = AVR_IO_REGBIT(TIFR, OCF1A),
105 .vector = TIMER1_COMPA_vect,
108 .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
109 .raised = AVR_IO_REGBIT(TIFR, OCF1B),
110 .vector = TIMER1_COMPB_vect,
117 static avr_t * make()
122 avr_kind_t tiny85 = {
126 static void init(struct avr_t * avr)
128 struct mcu_t * mcu = (struct mcu_t*)avr;
130 printf("%s init\n", avr->mmcu);
132 avr_eeprom_init(avr, &mcu->eeprom);
133 avr_ioport_init(avr, &mcu->portb);
134 avr_timer8_init(avr, &mcu->timer0);
135 avr_timer8_init(avr, &mcu->timer1);
138 static void reset(struct avr_t * avr)
140 // struct mcu_t * mcu = (struct mcu_t*)avr;