SimAVR
AVR Simulator
sim_megax4.h
Go to the documentation of this file.
1 /*
2  sim_megax4.h
3 
4  Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5 
6  This file is part of simavr.
7 
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.
12 
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.
17 
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/>.
20  */
21 
22 #ifndef __SIM_MEGAX4_H__
23 #define __SIM_MEGAX4_H__
24 
25 #include "sim_avr.h"
26 #include "sim_core_declare.h"
27 #include "avr_eeprom.h"
28 #include "avr_flash.h"
29 #include "avr_watchdog.h"
30 #include "avr_extint.h"
31 #include "avr_ioport.h"
32 #include "avr_uart.h"
33 #include "avr_adc.h"
34 #include "avr_timer.h"
35 #include "avr_spi.h"
36 #include "avr_twi.h"
37 
38 void mx4_init(struct avr_t * avr);
39 void mx4_reset(struct avr_t * avr);
40 
41 /*
42  * This is a template for all of the x4 devices, hopefully
43  */
44 struct mcu_t {
45  avr_t core;
52  avr_adc_t adc;
54 #ifdef PRR1
56 #endif
57  avr_spi_t spi;
58  avr_twi_t twi;
59 };
60 
61 #ifdef SIM_CORENAME
62 
63 #ifndef SIM_MMCU
64 #error SIM_MMCU is not declared
65 #endif
66 
67 /* This bit makes the PRR declaration compatible between
68  * all the x4 and the 'special' 1284 that has a few little
69  * differences
70  */
71 #ifndef PD3
72 #define PD3 PORTD3
73 #define PD2 PORTD2
74 #define PB3 PORTB3
75 #endif
76 
77 const struct mcu_t SIM_CORENAME = {
78  .core = {
79  .mmcu = SIM_MMCU,
80  DEFAULT_CORE(4),
81 
82  .init = mx4_init,
83  .reset = mx4_reset,
84  },
85  AVR_EEPROM_DECLARE(EE_READY_vect),
86  AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
87  AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
88  .extint = {
89  AVR_EXTINT_DECLARE(0, 'D', PD2),
90  AVR_EXTINT_DECLARE(1, 'D', PD3),
91  AVR_EXTINT_DECLARE(2, 'B', PB3),
92  },
93  .porta = {
94  .name = 'A', .r_port = PORTA, .r_ddr = DDRA, .r_pin = PINA,
95  .pcint = {
96  .enable = AVR_IO_REGBIT(PCICR, PCIE0),
97  .raised = AVR_IO_REGBIT(PCIFR, PCIF0),
98  .vector = PCINT0_vect,
99  },
100  .r_pcint = PCMSK0,
101  },
102  .portb = {
103  .name = 'B', .r_port = PORTB, .r_ddr = DDRB, .r_pin = PINB,
104  .pcint = {
105  .enable = AVR_IO_REGBIT(PCICR, PCIE1),
106  .raised = AVR_IO_REGBIT(PCIFR, PCIF1),
107  .vector = PCINT1_vect,
108  },
109  .r_pcint = PCMSK1,
110  },
111  .portc = {
112  .name = 'C', .r_port = PORTC, .r_ddr = DDRC, .r_pin = PINC,
113  .pcint = {
114  .enable = AVR_IO_REGBIT(PCICR, PCIE2),
115  .raised = AVR_IO_REGBIT(PCIFR, PCIF2),
116  .vector = PCINT2_vect,
117  },
118  .r_pcint = PCMSK2,
119  },
120  .portd = {
121  .name = 'D', .r_port = PORTD, .r_ddr = DDRD, .r_pin = PIND,
122  .pcint = {
123  .enable = AVR_IO_REGBIT(PCICR, PCIE3),
124  .raised = AVR_IO_REGBIT(PCIFR, PCIF3),
125  .vector = PCINT3_vect,
126  },
127  .r_pcint = PCMSK3,
128  },
129 
130  .uart0 = {
131  .disabled = AVR_IO_REGBIT(PRR0,PRUSART0),
132  .name = '0',
133  .r_udr = UDR0,
134 
135  .u2x = AVR_IO_REGBIT(UCSR0A, U2X0),
136  .txen = AVR_IO_REGBIT(UCSR0B, TXEN0),
137  .rxen = AVR_IO_REGBIT(UCSR0B, RXEN0),
138  .ucsz = AVR_IO_REGBITS(UCSR0C, UCSZ00, 0x3), // 2 bits
139  .ucsz2 = AVR_IO_REGBIT(UCSR0B, UCSZ02), // 1 bits
140 
141  .r_ucsra = UCSR0A,
142  .r_ucsrb = UCSR0B,
143  .r_ucsrc = UCSR0C,
144  .r_ubrrl = UBRR0L,
145  .r_ubrrh = UBRR0H,
146  .rxc = {
147  .enable = AVR_IO_REGBIT(UCSR0B, RXCIE0),
148  .raised = AVR_IO_REGBIT(UCSR0A, RXC0),
149  .vector = USART0_RX_vect,
150  },
151  .txc = {
152  .enable = AVR_IO_REGBIT(UCSR0B, TXCIE0),
153  .raised = AVR_IO_REGBIT(UCSR0A, TXC0),
154  .vector = USART0_TX_vect,
155  },
156  .udrc = {
157  .enable = AVR_IO_REGBIT(UCSR0B, UDRIE0),
158  .raised = AVR_IO_REGBIT(UCSR0A, UDRE0),
159  .vector = USART0_UDRE_vect,
160  },
161  },
162  .uart1 = {
163  .disabled = AVR_IO_REGBIT(PRR0,PRUSART1),
164  .name = '1',
165  .r_udr = UDR1,
166 
167  .u2x = AVR_IO_REGBIT(UCSR1A, U2X1),
168  .txen = AVR_IO_REGBIT(UCSR1B, TXEN1),
169  .rxen = AVR_IO_REGBIT(UCSR1B, RXEN1),
170  .ucsz = AVR_IO_REGBITS(UCSR1C, UCSZ10, 0x3), // 2 bits
171  .ucsz2 = AVR_IO_REGBIT(UCSR1B, UCSZ12), // 1 bits
172 
173  .r_ucsra = UCSR1A,
174  .r_ucsrb = UCSR1B,
175  .r_ucsrc = UCSR1C,
176  .r_ubrrl = UBRR1L,
177  .r_ubrrh = UBRR1H,
178  .rxc = {
179  .enable = AVR_IO_REGBIT(UCSR1B, RXCIE1),
180  .raised = AVR_IO_REGBIT(UCSR1A, RXC1),
181  .vector = USART1_RX_vect,
182  },
183  .txc = {
184  .enable = AVR_IO_REGBIT(UCSR1B, TXCIE1),
185  .raised = AVR_IO_REGBIT(UCSR1A, TXC1),
186  .vector = USART1_TX_vect,
187  },
188  .udrc = {
189  .enable = AVR_IO_REGBIT(UCSR1B, UDRIE1),
190  .raised = AVR_IO_REGBIT(UCSR1A, UDRE1),
191  .vector = USART1_UDRE_vect,
192  },
193  },
194  .adc = {
195  // .disabled = AVR_IO_REGBIT(PRR0,PRADC),
196  .r_admux = ADMUX,
197  .mux = { AVR_IO_REGBIT(ADMUX, MUX0), AVR_IO_REGBIT(ADMUX, MUX1),
198  AVR_IO_REGBIT(ADMUX, MUX2), AVR_IO_REGBIT(ADMUX, MUX3),
199  AVR_IO_REGBIT(ADMUX, MUX4),},
200  .ref = { AVR_IO_REGBIT(ADMUX, REFS0), AVR_IO_REGBIT(ADMUX, REFS1)},
201  .ref_values = { [1] = ADC_VREF_AVCC, [2] = ADC_VREF_V110, [3] = ADC_VREF_V256 },
202 
203  .adlar = AVR_IO_REGBIT(ADMUX, ADLAR),
204  .r_adcsra = ADCSRA,
205  .aden = AVR_IO_REGBIT(ADCSRA, ADEN),
206  .adsc = AVR_IO_REGBIT(ADCSRA, ADSC),
207  .adate = AVR_IO_REGBIT(ADCSRA, ADATE),
208  .adps = { AVR_IO_REGBIT(ADCSRA, ADPS0), AVR_IO_REGBIT(ADCSRA, ADPS1), AVR_IO_REGBIT(ADCSRA, ADPS2),},
209 
210  .r_adch = ADCH,
211  .r_adcl = ADCL,
212 
213  .r_adcsrb = ADCSRB,
214  .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
215 
216  .muxmode = {
217  [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
218  [2] = AVR_ADC_SINGLE(2), [3] = AVR_ADC_SINGLE(3),
219  [4] = AVR_ADC_SINGLE(4), [5] = AVR_ADC_SINGLE(5),
220  [6] = AVR_ADC_SINGLE(6), [7] = AVR_ADC_SINGLE(7),
221 
222  [ 8] = AVR_ADC_DIFF(0, 0, 10), [ 9] = AVR_ADC_DIFF(1, 0, 10),
223  [10] = AVR_ADC_DIFF(0, 0, 200), [11] = AVR_ADC_DIFF(1, 0, 200),
224  [12] = AVR_ADC_DIFF(2, 2, 10), [13] = AVR_ADC_DIFF(3, 2, 10),
225  [14] = AVR_ADC_DIFF(2, 2, 200), [15] = AVR_ADC_DIFF(3, 2, 200),
226 
227  [16] = AVR_ADC_DIFF(0, 1, 1), [17] = AVR_ADC_DIFF(1, 1, 1),
228  [18] = AVR_ADC_DIFF(2, 1, 1), [19] = AVR_ADC_DIFF(3, 1, 1),
229  [20] = AVR_ADC_DIFF(4, 1, 1), [21] = AVR_ADC_DIFF(5, 1, 1),
230  [22] = AVR_ADC_DIFF(6, 1, 1), [23] = AVR_ADC_DIFF(7, 1, 1),
231 
232  [24] = AVR_ADC_DIFF(0, 2, 1), [25] = AVR_ADC_DIFF(1, 2, 1),
233  [26] = AVR_ADC_DIFF(2, 2, 1), [27] = AVR_ADC_DIFF(3, 2, 1),
234  [28] = AVR_ADC_DIFF(4, 2, 1), [29] = AVR_ADC_DIFF(5, 2, 1),
235 
236  [30] = AVR_ADC_REF(1100), // 1.1V
237  [31] = AVR_ADC_REF(0), // GND
238  },
239 
240  .adc = {
241  .enable = AVR_IO_REGBIT(ADCSRA, ADIE),
242  .raised = AVR_IO_REGBIT(ADCSRA, ADIF),
243  .vector = ADC_vect,
244  },
245  },
246  .timer0 = {
247  .name = '0',
248  .disabled = AVR_IO_REGBIT(PRR0,PRTIM0),
249  .wgm = { AVR_IO_REGBIT(TCCR0A, WGM00), AVR_IO_REGBIT(TCCR0A, WGM01), AVR_IO_REGBIT(TCCR0B, WGM02) },
250  .wgm_op = {
251  [0] = AVR_TIMER_WGM_NORMAL8(),
252  [2] = AVR_TIMER_WGM_CTC(),
253  [3] = AVR_TIMER_WGM_FASTPWM8(),
254  [7] = AVR_TIMER_WGM_OCPWM(),
255  },
256  .cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
257  .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
258 
259  .r_tcnt = TCNT0,
260 
261  .overflow = {
262  .enable = AVR_IO_REGBIT(TIMSK0, TOIE0),
263  .raised = AVR_IO_REGBIT(TIFR0, TOV0),
264  .vector = TIMER0_OVF_vect,
265  },
266  .comp = {
267  [AVR_TIMER_COMPA] = {
268  .r_ocr = OCR0A,
269  .com = AVR_IO_REGBITS(TCCR0A, COM0A0, 0x3),
270  .com_pin = AVR_IO_REGBIT(PORTB, 3),
271  .interrupt = {
272  .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
273  .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
274  .vector = TIMER0_COMPA_vect,
275  },
276  },
277  [AVR_TIMER_COMPB] = {
278  .r_ocr = OCR0B,
279  .com = AVR_IO_REGBITS(TCCR0A, COM0B0, 0x3),
280  .com_pin = AVR_IO_REGBIT(PORTB, 4),
281  .interrupt = {
282  .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
283  .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
284  .vector = TIMER0_COMPB_vect,
285  }
286  }
287  }
288  },
289  .timer1 = {
290  .name = '1',
291  .disabled = AVR_IO_REGBIT(PRR0,PRTIM1),
292  .wgm = { AVR_IO_REGBIT(TCCR1A, WGM10), AVR_IO_REGBIT(TCCR1A, WGM11),
293  AVR_IO_REGBIT(TCCR1B, WGM12), AVR_IO_REGBIT(TCCR1B, WGM13) },
294  .wgm_op = {
295  [0] = AVR_TIMER_WGM_NORMAL16(),
296  [1] = AVR_TIMER_WGM_FCPWM8(),
297  [2] = AVR_TIMER_WGM_FCPWM9(),
298  [3] = AVR_TIMER_WGM_FCPWM10(),
299  [4] = AVR_TIMER_WGM_CTC(),
300  [5] = AVR_TIMER_WGM_FASTPWM8(),
301  [6] = AVR_TIMER_WGM_FASTPWM9(),
302  [7] = AVR_TIMER_WGM_FASTPWM10(),
303  [12] = AVR_TIMER_WGM_ICCTC(),
304  [14] = AVR_TIMER_WGM_ICPWM(),
305  [15] = AVR_TIMER_WGM_OCPWM(),
306  },
307  .cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
308  .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* External clock T1 is not handled */},
309 
310  .r_tcnt = TCNT1L,
311  .r_tcnth = TCNT1H,
312  .r_icr = ICR1L,
313  .r_icrh = ICR1H,
314 
315  .ices = AVR_IO_REGBIT(TCCR1B, ICES1),
316  .icp = AVR_IO_REGBIT(PORTD, 6),
317 
318  .overflow = {
319  .enable = AVR_IO_REGBIT(TIMSK1, TOIE1),
320  .raised = AVR_IO_REGBIT(TIFR1, TOV1),
321  .vector = TIMER1_OVF_vect,
322  },
323  .icr = {
324  .enable = AVR_IO_REGBIT(TIMSK1, ICIE1),
325  .raised = AVR_IO_REGBIT(TIFR1, ICF1),
326  .vector = TIMER1_CAPT_vect,
327  },
328  .comp = {
329  [AVR_TIMER_COMPA] = {
330  .r_ocr = OCR1AL,
331  .r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
332  .com = AVR_IO_REGBITS(TCCR1A, COM1A0, 0x3),
333  .com_pin = AVR_IO_REGBIT(PORTD, 5),
334  .interrupt = {
335  .enable = AVR_IO_REGBIT(TIMSK1, OCIE1A),
336  .raised = AVR_IO_REGBIT(TIFR1, OCF1A),
337  .vector = TIMER1_COMPA_vect,
338  }
339  },
340  [AVR_TIMER_COMPB] = {
341  .r_ocr = OCR1BL,
342  .r_ocrh = OCR1BH,
343  .com = AVR_IO_REGBITS(TCCR1A, COM1B0, 0x3),
344  .com_pin = AVR_IO_REGBIT(PORTD, 4),
345  .interrupt = {
346  .enable = AVR_IO_REGBIT(TIMSK1, OCIE1B),
347  .raised = AVR_IO_REGBIT(TIFR1, OCF1B),
348  .vector = TIMER1_COMPB_vect,
349  }
350  }
351  }
352  },
353  .timer2 = {
354  .name = '2',
355  .disabled = AVR_IO_REGBIT(PRR0,PRTIM2),
356  .wgm = { AVR_IO_REGBIT(TCCR2A, WGM20), AVR_IO_REGBIT(TCCR2A, WGM21), AVR_IO_REGBIT(TCCR2B, WGM22) },
357  .wgm_op = {
358  [0] = AVR_TIMER_WGM_NORMAL8(),
359  [2] = AVR_TIMER_WGM_CTC(),
360  [3] = AVR_TIMER_WGM_FASTPWM8(),
361  [7] = AVR_TIMER_WGM_OCPWM(),
362  },
363  .cs = { AVR_IO_REGBIT(TCCR2B, CS20), AVR_IO_REGBIT(TCCR2B, CS21), AVR_IO_REGBIT(TCCR2B, CS22) },
364  .cs_div = { 0, 0, 3 /* 8 */, 5 /* 32 */, 6 /* 64 */, 7 /* 128 */, 8 /* 256 */, 10 /* 1024 */ },
365 
366  .r_tcnt = TCNT2,
367 
368  // asynchronous timer source bit.. if set, use 32khz frequency
369  .as2 = AVR_IO_REGBIT(ASSR, AS2),
370 
371  .overflow = {
372  .enable = AVR_IO_REGBIT(TIMSK2, TOIE2),
373  .raised = AVR_IO_REGBIT(TIFR2, TOV2),
374  .vector = TIMER2_OVF_vect,
375  },
376  .comp = {
377  [AVR_TIMER_COMPA] = {
378  .r_ocr = OCR2A,
379  .com = AVR_IO_REGBITS(TCCR2A, COM2A0, 0x3),
380  .com_pin = AVR_IO_REGBIT(PORTD, 7),
381  .interrupt = {
382  .enable = AVR_IO_REGBIT(TIMSK2, OCIE2A),
383  .raised = AVR_IO_REGBIT(TIFR2, OCF2A),
384  .vector = TIMER2_COMPA_vect,
385  },
386  },
387  [AVR_TIMER_COMPB] = {
388  .r_ocr = OCR2B,
389  .com = AVR_IO_REGBITS(TCCR2A, COM2B0, 0x3),
390  .com_pin = AVR_IO_REGBIT(PORTD, 6),
391  .interrupt = {
392  .enable = AVR_IO_REGBIT(TIMSK2, OCIE2B),
393  .raised = AVR_IO_REGBIT(TIFR2, OCF2B),
394  .vector = TIMER2_COMPB_vect,
395  },
396  }
397  }
398  },
399 #ifdef PRR1
400  .timer3 = {
401  .name = '3',
402  .disabled = AVR_IO_REGBIT(PRR1,PRTIM3),
403  .wgm = { AVR_IO_REGBIT(TCCR3A, WGM30), AVR_IO_REGBIT(TCCR3A, WGM31),
404  AVR_IO_REGBIT(TCCR3B, WGM32), AVR_IO_REGBIT(TCCR3B, WGM33) },
405  .wgm_op = {
406  [0] = AVR_TIMER_WGM_NORMAL16(),
407  [1] = AVR_TIMER_WGM_FCPWM8(),
408  [2] = AVR_TIMER_WGM_FCPWM9(),
409  [3] = AVR_TIMER_WGM_FCPWM10(),
410  [4] = AVR_TIMER_WGM_CTC(),
411  [5] = AVR_TIMER_WGM_FASTPWM8(),
412  [6] = AVR_TIMER_WGM_FASTPWM9(),
413  [7] = AVR_TIMER_WGM_FASTPWM10(),
414  [12] = AVR_TIMER_WGM_ICCTC(),
415  [14] = AVR_TIMER_WGM_ICPWM(),
416  [15] = AVR_TIMER_WGM_OCPWM(),
417  },
418  .cs = { AVR_IO_REGBIT(TCCR3B, CS30), AVR_IO_REGBIT(TCCR3B, CS31), AVR_IO_REGBIT(TCCR3B, CS32) },
419  .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* External clock T1 is not handled */},
420 
421  .r_tcnt = TCNT3L,
422  .r_tcnth = TCNT3H,
423  .r_icr = ICR3L,
424  .r_icrh = ICR3H,
425 
426  .ices = AVR_IO_REGBIT(TCCR3B, ICES3),
427  .icp = AVR_IO_REGBIT(PORTB, 5),
428 
429  .overflow = {
430  .enable = AVR_IO_REGBIT(TIMSK3, TOIE3),
431  .raised = AVR_IO_REGBIT(TIFR3, TOV3),
432  .vector = TIMER3_OVF_vect,
433  },
434  .icr = {
435  .enable = AVR_IO_REGBIT(TIMSK3, ICIE3),
436  .raised = AVR_IO_REGBIT(TIFR3, ICF3),
437  .vector = TIMER3_CAPT_vect,
438  },
439  .comp = {
440  [AVR_TIMER_COMPA] = {
441  .r_ocr = OCR3AL,
442  .r_ocrh = OCR3AH, // 16 bits timers have two bytes of it
443  .com = AVR_IO_REGBITS(TCCR3A, COM3A0, 0x3),
444  .com_pin = AVR_IO_REGBIT(PORTB, 6),
445  .interrupt = {
446  .enable = AVR_IO_REGBIT(TIMSK3, OCIE3A),
447  .raised = AVR_IO_REGBIT(TIFR3, OCF3A),
448  .vector = TIMER3_COMPA_vect,
449  }
450  },
451  [AVR_TIMER_COMPB] = {
452  .r_ocr = OCR3BL,
453  .r_ocrh = OCR3BH,
454  .com = AVR_IO_REGBITS(TCCR3A, COM3B0, 0x3),
455  .com_pin = AVR_IO_REGBIT(PORTB, 7),
456  .interrupt = {
457  .enable = AVR_IO_REGBIT(TIMSK3, OCIE3B),
458  .raised = AVR_IO_REGBIT(TIFR3, OCF3B),
459  .vector = TIMER3_COMPB_vect,
460  }
461  }
462  }
463  },
464 #endif
465  AVR_SPI_DECLARE(PRR0, PRSPI),
466  .twi = {
467  .disabled = AVR_IO_REGBIT(PRR0,PRTWI),
468 
469  .r_twcr = TWCR,
470  .r_twsr = TWSR,
471  .r_twbr = TWBR,
472  .r_twdr = TWDR,
473  .r_twar = TWAR,
474  .r_twamr = TWAMR,
475 
476  .twen = AVR_IO_REGBIT(TWCR, TWEN),
477  .twea = AVR_IO_REGBIT(TWCR, TWEA),
478  .twsta = AVR_IO_REGBIT(TWCR, TWSTA),
479  .twsto = AVR_IO_REGBIT(TWCR, TWSTO),
480  .twwc = AVR_IO_REGBIT(TWCR, TWWC),
481 
482  .twsr = AVR_IO_REGBITS(TWSR, TWS3, 0x1f), // 5 bits
483  .twps = AVR_IO_REGBITS(TWSR, TWPS0, 0x3), // 2 bits
484 
485  .twi = {
486  .enable = AVR_IO_REGBIT(TWCR, TWIE),
487  .raised = AVR_IO_REGBIT(TWCR, TWINT),
488  .raise_sticky = 1,
489  .vector = TWI_vect,
490  },
491  },
492 
493 };
494 
495 #endif /* SIM_CORENAME */
496 
497 #endif /* __SIM_MEGAX4_H__ */
Definition: avr_adc.h:81
#define AVR_TIMER_WGM_FCPWM9()
Definition: avr_timer.h:95
#define AVR_TIMER_WGM_NORMAL8()
Definition: avr_timer.h:87
Definition: avr_watchdog.h:35
avr_eeprom_t eeprom
Definition: sim_90usb162.c:42
Handles self-programming subsystem if the core supports it.
Definition: avr_flash.h:38
#define SIM_MMCU
Definition: sim_mega324.c:24
#define SIM_CORENAME
Definition: sim_mega324.c:25
#define PD3
Definition: sim_mega128rfr2.c:57
avr_ioport_t portb
Definition: sim_90usb162.c:46
void mx4_init(struct avr_t *avr)
Definition: sim_megax4.c:26
#define AVR_ADC_REF(_t)
Definition: avr_adc.h:166
avr_t * avr
Definition: run_avr.c:54
#define AVR_ADC_SINGLE(_chan)
Definition: avr_adc.h:154
#define AVR_TIMER_WGM_FASTPWM8()
Definition: avr_timer.h:91
#define AVR_TIMER_WGM_FASTPWM10()
Definition: avr_timer.h:93
avr_uart_t uart0
Definition: sim_mega128.c:52
#define AVR_TIMER_WGM_ICCTC()
Definition: avr_timer.h:90
avr_timer_t timer2
Definition: sim_mega128.c:54
#define AVR_SELFPROG_DECLARE(_spmr, _spen, _vector)
Definition: avr_flash.h:82
#define AVR_TIMER_WGM_FASTPWM9()
Definition: avr_timer.h:92
Definition: avr_adc.h:83
#define PD2
Definition: sim_mega128rfr2.c:56
This module is just a "relay" for the pin change IRQ in the IO port module.
Definition: avr_extint.h:56
avr_adc_t adc
Definition: sim_mega128.c:53
#define AVR_SPI_DECLARE(_prr, _prspi)
Definition: avr_spi.h:66
#define AVR_TIMER_WGM_CTC()
Definition: avr_timer.h:89
avr_watchdog_t watchdog
Definition: sim_90usb162.c:44
Definition: sim_90usb162.c:40
#define AVR_EXTINT_DECLARE(_index, _portname, _portpin)
Declares a typical INT into a avr_extint_t in a core.
Definition: avr_extint.h:77
Definition: avr_eeprom.h:35
Definition: avr_spi.h:45
avr_t core
Definition: sim_90usb162.c:41
#define AVR_TIMER_WGM_FCPWM10()
Definition: avr_timer.h:96
#define DEFAULT_CORE(_vector_size)
Definition: sim_core_declare.h:52
Definition: avr_twi.h:74
Definition: avr_timer.h:37
Definition: avr_timer.h:111
avr_timer_t timer0
Definition: sim_90usb162.c:48
avr_ioport_t portd
Definition: sim_90usb162.c:46
Definition: avr_uart.h:91
#define AVR_IO_REGBITS(_io, _bit, _mask)
Definition: sim_regbit.h:153
avr_ioport_t porta
Definition: sim_mega128.c:51
#define AVR_EEPROM_DECLARE(_vector)
The eeprom block seems to be very similar across AVRs, so here is a macro to declare a "typical" one ...
Definition: avr_eeprom.h:70
avr_timer_t timer1
Definition: sim_90usb162.c:48
Definition: avr_adc.h:108
#define AVR_TIMER_WGM_ICPWM()
Definition: avr_timer.h:98
#define AVR_TIMER_WGM_OCPWM()
Definition: avr_timer.h:97
avr_uart_t uart1
Definition: sim_90usb162.c:47
avr_ioport_t portc
Definition: sim_90usb162.c:46
void mx4_reset(struct avr_t *avr)
Definition: sim_megax4.c:51
avr_twi_t twi
Definition: sim_mega128.c:56
avr_flash_t selfprog
Definition: sim_90usb162.c:43
#define AVR_TIMER_WGM_NORMAL16()
Definition: avr_timer.h:88
Definition: avr_timer.h:38
#define AVR_WATCHDOG_DECLARE(_WDSR, _vec)
This helps declare a watchdog block into a core.
Definition: avr_watchdog.h:66
Main AVR instance.
Definition: sim_avr.h:142
avr_timer_t timer3
Definition: sim_mega128.c:54
avr_spi_t spi
Definition: sim_90usb162.c:49
avr_extint_t extint
Definition: sim_90usb162.c:45
#define AVR_ADC_DIFF(_a, _b, _g)
Definition: avr_adc.h:159
#define AVR_IO_REGBIT(_io, _bit)
Definition: sim_regbit.h:150
Definition: avr_adc.h:82
Definition for an IO port.
Definition: avr_ioport.h:97
#define AVR_TIMER_WGM_FCPWM8()
Definition: avr_timer.h:94