/* * $Id: intvects.h,v 1.3 2002/07/16 06:34:58 troth Exp $ * **************************************************************************** * * simulavr - A simulator for the Atmel AVR family of microcontrollers. * Copyright (C) 2001, 2002 Theodore A. Roth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **************************************************************************** */ #ifndef SIM_BITPOS_H #define SIM_BITPOS_H #define _BV(bit) 1<<(bit) typedef struct _BitPos BitPos; struct _BitPos { char *name; /* The name of the flag as described in the datasheet from ATMEL */ unsigned char bit; /* The position in the register */ }; /* We call this tccrx because it can be used for all timers/counters and not only for timer/counter0. Only in the individual definitions you have to difference between tccr0,tccr1a/b,tccr2, etc. */ /* Note: If there's only a bit for port a and b, but the device only has one port (w/o an "a" appended) use the bit for port a for this port! */ /* Note 2: Two registers for the same function are joined in the form reg=reg_a<<8+reg_b. This is easier than always checking two registers */ /* Note 3: If a register DOESN'T exist there must be NO definition of the bits, but in the device's register table you MUST add NULL at its position! */ enum _bitpos_tccrx { TCCRX_LENGHT, BP_CS0, /* timer/counter clock select bit 0*/ BP_CS1, /* timer/counter clock select bit 1*/ BP_CS2, /* timer/counter clock select bit 2*/ BP_WGM0, /* waveform generation mode bit 0*/ BP_WGM1, /* waveform generation mode bit 1*/ BP_WGM2, /* waveform generation mode bit 2*/ BP_WGM3, /* waveform generation mode bit 3*/ BP_COMA0, /* compare match output mode bit 0*/ BP_COMA1, /* compare match output mode bit 1*/ BP_COMB0, BP_COMB1, BP_FOCA, /* force output compare */ BP_FOCB, /* force output compare (on port b)*/ BP_CTC, /* clear timer/counter on compare match */ BP_ICES, /* input capture edge select */ BP_ICNC, /* input capture noise canceler (4 CKs) */ LEN_BP_TCCRX_TABLE, }; enum _bitpos_timsk { TIMSK_LENGHT, BP_TOIE0, /* t/c0 overflow interrupt enable */ BP_TOIE1, /* t/c1 overflow interrupt enable */ BP_TOIE2, /* t/c2 overflow interrupt enable */ BP_OCIE0, /* t/c0 output compare match interrupt enable */ BP_OCIE1A, /* t/c1a output compare match interrupt enable */ BP_OCIE1B, /* t/c1b output compare match interrupt enable */ BP_OCIE2, /* t/c2 output compare match interrupt enable */ BP_TICIE1, /* t/c1 input capture interrupt enable */ LEN_BP_TIMSK_TABLE, }; /* Just the bitnames! Do NOT create an acutal definition as it's the same as timsk */ enum _bitpos_tifr { TIFR_LENGHT, BP_TOV0, /* t/c0 overflow interrupt flag */ BP_TOV1, /* t/c1 overflow interrupt flag */ BP_TOV2, /* t/c2 overflow interrupt flag */ BP_OCF0, /* t/c0 output compare interrupt flag */ BP_OCF1A, /* t/c1a output compare interrupt flag */ BP_OCF1B, /* t/c1b output compare interrupt flag */ BP_OCF2, /* t/c2 output compare interrupt flag */ BP_ICF1, /* t/c1 input capture interrupt flag */ LEN_BP_TIFR_TABLE, }; enum _bitpos_wdtcr { WDTCR_LENGTH, BP_WDP0, /* prescaler bit 0 */ BP_WDP1, /* prescaler bit 1 */ BP_WDP2, /* prescaler bit 2 */ BP_WDE, /* watchdog enable */ BP_WDTOE, /* turn-off enable */ LEN_BP_WDTCR_TABLE, }; enum _bitpos_eecr { EECR_LENGTH, BP_EERE, /* eeprom read enable strobe */ BP_EEWE, /* eeprom write enable strobe */ BP_EEMWE, /* eeprom master write enable strobe */ BP_EERIE, /* eeprom ready interrupt enable */ LEN_BP_EECR_TABLE, }; /* FIXME: Add all registers here */ enum BitPosTableRegisters { BPT_TCCR0, BPT_TCCR1, BPT_TCCR2, BPT_TIMSK, BPT_WDTCR, BPT_EECR, }; enum _bit_pos_table_select { BPT_ATMEGA16 = 0, }; extern BitPos **global_bitpos_device_tables[]; int bitpos_get_register_mask(BitPos *btab_register); #endif