/* * AVR emulator * Device pinout * * Copyright (C) 2007 Michael Buesch * * 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. */ #include "pinout.h" #include "util.h" #undef p #undef PIN #define p(pinname) PINOUT_##pinname #define PIN(_number, ...) \ [_number - 1] = { \ .number = _number, \ .funcs = { __VA_ARGS__ }, \ } static struct avr_hwpin atmega48_88_168_pins[] = { PIN(1, p(PC6), p(RESET), p(PCINT14)), PIN(2, p(PD0), p(RXD), p(PCINT16)), PIN(3, p(PD1), p(TXD), p(PCINT17)), PIN(4, p(PD2), p(INT0), p(PCINT18)), PIN(5, p(PD3), p(INT1), p(OC2B), p(PCINT19)), PIN(6, p(PD4), p(T0), p(XCK), p(PCINT20)), PIN(7, p(VCC)), PIN(8, p(GND)), PIN(9, p(PB6), p(TOSC1), p(XTAL1), p(PCINT6)), PIN(10, p(PB7), p(TOSC2), p(XTAL2), p(PCINT7)), PIN(11, p(PD5), p(T1), p(OC0B), p(PCINT21)), PIN(12, p(PD6), p(AIN0), p(OC0A), p(PCINT22)), PIN(13, p(PD7), p(AIN1), p(PCINT23)), PIN(14, p(PB0), p(ICP1), p(CLKO), p(PCINT0)), PIN(15, p(PB1), p(OC1A), p(PCINT1)), PIN(16, p(PB2), p(SS), p(OC1B), p(PCINT2)), PIN(17, p(PB3), p(MOSI), p(OC2A), p(PCINT3)), PIN(18, p(PB4), p(MISO), p(PCINT4)), PIN(19, p(PB5), p(SCK), p(PCINT5)), PIN(20, p(AVCC)), PIN(21, p(AREF)), PIN(22, p(GND)), PIN(23, p(PC0), p(ADC0), p(PCINT8)), PIN(24, p(PC1), p(ADC1), p(PCINT9)), PIN(25, p(PC2), p(ADC2), p(PCINT10)), PIN(26, p(PC3), p(ADC3), p(PCINT11)), PIN(27, p(PC4), p(ADC4), p(SDA), p(PCINT12)), PIN(28, p(PC5), p(ADC5), p(SCL), p(PCINT13)), }; struct avr_device_pinout atmega48_88_168_pinout = { .pins = atmega48_88_168_pins, .nr_pins = ARRAY_SIZE(atmega48_88_168_pins), }; static struct avr_hwpin atmega8_pins[] = { PIN(1, p(PC6), p(RESET)), PIN(2, p(PD0), p(RXD)), PIN(3, p(PD1), p(TXD)), PIN(4, p(PD2), p(INT0)), PIN(5, p(PD3), p(INT1)), PIN(6, p(PD4), p(T0)), PIN(7, p(VCC)), PIN(8, p(GND)), PIN(9, p(PB6), p(TOSC1), p(XTAL1)), PIN(10, p(PB7), p(TOSC2), p(XTAL2)), PIN(11, p(PD5), p(T1)), PIN(12, p(PD6), p(AIN0)), PIN(13, p(PD7), p(AIN1)), PIN(14, p(PB0), p(ICP1)), PIN(15, p(PB1), p(OC1A)), PIN(16, p(PB2), p(SS), p(OC1B)), PIN(17, p(PB3), p(MOSI), p(OC2)), PIN(18, p(PB4), p(MISO)), PIN(19, p(PB5), p(SCK)), PIN(20, p(AVCC)), PIN(21, p(AREF)), PIN(22, p(GND)), PIN(23, p(PC0), p(ADC0)), PIN(24, p(PC1), p(ADC1)), PIN(25, p(PC2), p(ADC2)), PIN(26, p(PC3), p(ADC3)), PIN(27, p(PC4), p(ADC4), p(SDA)), PIN(28, p(PC5), p(ADC5), p(SCL)), }; struct avr_device_pinout atmega8_pinout = { .pins = atmega8_pins, .nr_pins = ARRAY_SIZE(atmega8_pins), }; #undef p #undef PIN int avr_get_pin_number(struct avr_device_pinout *pinout, enum avr_pinout_function func) { struct avr_hwpin *pin; enum avr_pinout_function f; size_t i, j; for (i = 0; i < pinout->nr_pins; i++) { pin = &(pinout->pins[i]); for (j = 0; j < AVR_MAX_PIN_FUNCS; i++) { f = pin->funcs[j]; if (f == PINOUT_NC) break; if (f == func) return i + 1; } } return -1; } struct avr_device_pinout_handlers active_pinout_handlers;