/* * $Id: devsupp.c,v 1.8 2002/08/28 18:53:40 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 * **************************************************************************** */ #include #include #include #include "bitpos.h" /* Note: Maybe it would be better to split this file in device specific files, because each device has a lot of specific registers */ static BitPos btab_tccr02_atmega16[] = { { "TCCR02", LEN_BP_TCCRX_TABLE }, { "BIT_CS0", 0 }, { "BIT_CS1", 1 }, { "BIT_CS2", 2 }, { "BIT_WGM0", 6 }, { "BIT_WGM1", 3 }, { NULL /* "BIT_WGM2" */, 0xff }, { NULL /* "BIT_WGM3" */, 0xff }, { "BIT_COMA0", 4 }, { "BIT_COMA1", 5 }, { NULL /* "BIT_COMB0" */, 0xff }, { NULL /* "BIT_COMB1" */, 0xff }, { "BIT_FOCA", 7 }, { NULL /* "BIT_FOCB" */, 0xff }, { NULL /* "BIT_CTC" */, 0xff }, { NULL /* "BIT_ICES" */, 0xff }, { NULL /* "BIT_ICNC" */, 0xff }, }; static BitPos btab_tccr1_atmega16[] = { { "TCCR1", LEN_BP_TCCRX_TABLE }, { "BIT_CS0", 8 }, { "BIT_CS1", 9 }, { "BIT_CS2", 10}, { "BIT_WGM0", 0 }, { "BIT_WGM1", 1 }, { "BIT_WGM2", 11}, { "BIT_WGM3", 12}, { "BIT_COMA0", 6 }, { "BIT_COMA1", 7 }, { "BIT_COMB0", 4 }, { "BIT_COMB1", 5 }, { "BIT_FOCA", 3 }, { "BIT_FOCB", 2 }, { NULL /* "BIT_CTC" */, 0xff }, { "BIT_ICES", 14 }, { "BIT_ICNC", 15 }, }; static BitPos btab_timsk_atmega16[] = { { "TIMSK", LEN_BP_TIMSK_TABLE }, { "BIT_TOIE0", 0 }, { "BIT_TOIE1", 2 }, { "BIT_TOIE2", 6 }, { "BIT_OCIE0", 1 }, { "BIT_OCIE1A", 4 }, { "BIT_OCIE1B", 3 }, { "BIT_OCIE2", 7 }, { "BIT_TICIE1", 5 }, }; static BitPos btab_wdtcr_with_wdtoe[] = { { "WDTCR", LEN_BP_WDTCR_TABLE }, { "BIT_WDP0", 0 }, { "BIT_WDP1", 1 }, { "BIT_WDP2", 2 }, { "BIT_WDE", 3 }, { "BIT_WDTOE", 4 }, }; static BitPos btab_eecr_with_mwe[] = { { "EECR", LEN_BP_EECR_TABLE }, { "BIT_EERE", 0 }, { "BIT_EEWE", 1 }, { "BIT_EEMWE", 2 }, { "BIT_EERIE", 3 }, }; static BitPos *bpt_atmega16[] = { btab_tccr02_atmega16, btab_tccr1_atmega16, btab_tccr02_atmega16, btab_timsk_atmega16, btab_wdtcr_with_wdtoe, btab_eecr_with_mwe, }; BitPos **global_bitpos_device_tables[] = { bpt_atmega16, }; int bitpos_get_register_mask(BitPos *btab_register) { int result=0; int i; for (i=btab_register[0].bit-1; i>0; i--) { if (btab_register[i].bit<0xff) { result|=_BV(btab_register[i].bit); } } return result; }