Bob, I'm not sure what you're doing in the code. I think the pins files should be more generic, like targeted to a specific processor. Its then up to the developer to use the pins accpording to what they do on the board.
The argument can be made to assign pins to serve a specific purpose.
For example, pin numbers and port B bit numbers are one and the same in Alessandro Saporetti's ATtiny45 core. This deviates from the way pin numbers are typically assigned (sequentially top-left to top-right). At first, the pin assignment is confusing. But, it allows the user to go from the Atmel datasheet to their sketch without having to translate from port + bit to Arduino pin. In my experience, it has made using his core a breeze; I truly appreciate the deviant pin assignment.
I believe CrossRoads is trying to do something similar; create a pin assignment that simplifies using his board.
The pins_xxx.cxx files map physical pins to ports besed on the chip design. In this case, the 1284P DIP is the same is the 644P DIP, so the pins_duino644.cxx is exactly what he needs. I am trying to recall if I needed to make any changes for my 1284P based board. If I did, it was to add this:
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
//* pin defs for duino644 and sanquino board
#include "pins_duino644.cxx"
to the pins_arduino.c file that shipped with the cores from avr-developers. But I think it was already there.
So if Bob's board uses non-arduino-standard pins for things like the SPI pins and so on, then he would want to make changes to the arduino headers that map those, but not in the pins_xxx.cxx files. I'll look and see what I did, if anything, to make that happen. I really need to keep better notes
(edit - fixed code tags)
I have arduino_extras set up already.
pins_duino644.cxx would seem to be the right file, yet PB0 is accessed as Digitalpin8 and not
D4.
D0 is accessed on PA0 and not PD0, where UART is.
So I think if I rearrange the Px0-7 as I started above, then my software mapping of pins to Dx names as used in my schematic should work, and a shield connected to D0, D1 etc, will see software commanded D0/D1 electrical action show up in the right place.
I can try adding 1284 to this line on arduino-extras/pin_arduino.c and see what happens
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
//* pin defs for duino644 and sanquino board
#include "pins_duino644.cxx"
but pins_duin.cxx doesn't seem to reflect the usage I want.
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 0 - PB0 */
NOT_ON_TIMER, /* 1 - PB1 */
NOT_ON_TIMER, /* 2 - PB2 */
TIMER0A, /* 3 - PB3 */
TIMER0B, /* 4 - PB4 */
NOT_ON_TIMER, /* 5 - PB5 */
NOT_ON_TIMER, /* 6 - PB6 */
NOT_ON_TIMER, /* 7 - PB7 */
NOT_ON_TIMER, /* 8 - PD0 */
NOT_ON_TIMER, /* 9 - PD1 */
NOT_ON_TIMER, /* 10 - PD2 */
NOT_ON_TIMER, /* 11 - PD3 */
TIMER1B, /* 12 - PD4 */
TIMER1A, /* 13 - PD5 */
TIMER2B, /* 14 - PD6 */
TIMER2A, /* 15 - PD7 */
NOT_ON_TIMER, /* 16 - PC0 */
NOT_ON_TIMER, /* 17 - PC1 */
NOT_ON_TIMER, /* 18 - PC2 */
NOT_ON_TIMER, /* 19 - PC3 */
NOT_ON_TIMER, /* 20 - PC4 */
NOT_ON_TIMER, /* 21 - PC5 */
NOT_ON_TIMER, /* 22 - PC6 */
NOT_ON_TIMER, /* 23 - PC7 */
NOT_ON_TIMER, /* 24 - PA0 */
NOT_ON_TIMER, /* 25 - PA1 */
NOT_ON_TIMER, /* 26 - PA2 */
NOT_ON_TIMER, /* 27 - PA3 */
NOT_ON_TIMER, /* 28 - PA4 */
NOT_ON_TIMER, /* 29 - PA5 */
NOT_ON_TIMER, /* 30 - PA6 */
NOT_ON_TIMER /* 31 - PA7 */
};
Okay, I'm probably mistaken then. Let me review your posts again and see if I have anything to suggest.
but pins_duin.cxx doesn't seem to reflect the usage I want.
[/quote]
Okay so you want to remap the Arduino "digital pins" to different ports. Now i see, sorry I was a bit brain dead earlier. I worked on this a bit some time ago, I'll dig in and see if I can get it going.
Do you have a mapping of what you want?
Ok, I think I got it, this should agree with the schematic post of the 1284 I posted earlier:
added to pins_arduino.c:
#elif defined(__AVR_ATmega1284__)
//* pin defs for bobuino & 1284 board
#include "pins_duino1284.cxx"
created new pins_duino1284.cxx
/*
24 July - Modified for 1284 - RWP
pins_arduino.c - pin definitions for the Arduino board
Part of Arduino / Wiring Lite
Copyright (c) 2005 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
*/
#ifndef _AVR_IO_H_
#include <avr/io.h>
#endif
//#include "wiring_private.h"
#ifndef Wiring_h
#include "wiring.h"
#endif
#ifndef Pins_Arduino_h
#include "pins_arduino.h"
#endif
// On the Sanguino/Bobuino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATMEGA1284P / BOBUINO
//
// +---\/---+
// INT0 (D 4) PB0 1| |40 PA0 (AI 0 / D14)
// INT1 (D 5) PB1 2| |39 PA1 (AI 1 / D15)
// INT2 (D 6) PB2 3| |38 PA2 (AI 2 / D16)
// PWM (D 7) PB3 4| |37 PA3 (AI 3 / D17)
// PWM (D 10) PB4 5| |36 PA4 (AI 4 / D18)
// MOSI (D 11) PB5 6| |35 PA5 (AI 5 / D19)
// MISO (D 12) PB6 7| |34 PA6 (AI 6 / D21)
// SCK (D 13) PB7 8| |33 PA7 (AI 7 / D22)
// RST 9| |32 AREF
// VCC 10| |31 GND
// GND 11| |30 AVCC
// XTAL2 12| |29 PC7 (D 29)
// XTAL1 13| |28 PC6 (D 28)
// RX0 (D 0) PD0 14| |27 PC5 (D 27) TDI
// TX0 (D 1) PD1 15| |26 PC4 (D 26) TDO
// RX1 (D 2) PD2 16| |25 PC3 (D 25) TMS
// TX1 (D 3) PD3 17| |24 PC2 (D 24) TCK
// PWM (D 30) PD4 18| |23 PC1 (D 23) SDA
// PWM (D 8 ) PD5 19| |22 PC0 (D 22) SCL
// PWM (D 9) PD6 20| |21 PD7 (D 31) PWM
// +--------+
//
#define PA 1
#define PB 2
#define PC 3
#define PD 4
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
&DDRA,
&DDRB,
&DDRC,
&DDRD,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTA,
&PORTB,
&PORTC,
&PORTD,
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
&PINA,
&PINB,
&PINC,
&PIND,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PD, /* 0 PD0 */
PD, /* 1 PD1 */
PD, /* 2 PD2 */
PD, /* 3 PD3 */
PB, /* 4 PB0 */
PB, /* 5 PB1 */
PB, /* 6 PB2 */
PB, /* 7 PB3 */
PD, /* 8 PD5 */
PD, /* 9 PD6 */
PB, /* 10 PB4 */
PB, /* 11 PB5 */
PB, /* 12 PB6 */
PB, /* 13 PB7 */
PA, /* 14 PA0 */
PA, /* 15 PA1 */
PA, /* 16 PA2 */
PA, /* 17 PA3 */
PA, /* 18 PA4 */
PA, /* 19 PA5 */
PA, /* 20 PA6 */
PA, /* 21 PA7 */
PC, /* 22 PC0 */
PC, /* 23 PC1 */
PC, /* 24 PC2 */
PC, /* 25 PC3 */
PC, /* 26 PC4 */
PC, /* 27 PC5 */
PC, /* 28 PC6 */
PC, /* 29 PC7 */
PD, /* 30 PD4 */
PD /* 31 PD7 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /*D0: 0, port D */
_BV(1), /*D1: 1, port D */
_BV(2), /*D2: 2, port D */
_BV(3), /*D3: 3, port D */
_BV(0), /*D4: 0, port B */
_BV(1), /*D5: 1, port B */
_BV(2), /*D6: 2, port B */
_BV(3), /*D7: 3, port B */
_BV(5), /*D8: 5, port D */
_BV(6), /*D9: 6, port D */
_BV(4), /*D10: 4, port B */
_BV(5), /*D11: 5, port B */
_BV(6), /*D12: 6, port B */
_BV(7), /*D13: 7, port B */
_BV(0), /*D14: 0, port A */
_BV(1), /*D15: 1, port A */
_BV(2), /*D16, 2, port A */
_BV(3), /*D17: 3, port A */
_BV(4), /*D18: 4, port A */
_BV(5), /*D19: 5, port A */
_BV(6), /*D20: 6, port A */
_BV(7), /*D21: 7, port A */
_BV(0), /*D22: 0, port C */
_BV(1), /*D23: 1, port C */
_BV(2), /*D24, 2, port C */
_BV(3), /*D25: 3, port C */
_BV(4), /*D26: 4, port C */
_BV(5), /*D27: 5, port C */
_BV(6), /*D28: 6, port C */
_BV(7), /*D29: 7, port C */
_BV(4), /*D30: 4, port D */
_BV(7) /*D31: 7, port D */
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 0 - PD0 */
NOT_ON_TIMER, /* 1 - PD1 */
NOT_ON_TIMER, /* 2 - PD2 */
NOT_ON_TIMER, /* 3 - PD3 */
NOT_ON_TIMER, /* 4 - PB0 */
NOT_ON_TIMER, /* 5 - PB1 */
NOT_ON_TIMER, /* 6 - PB2 */
TIMER0A, /* 7 - PB3 */ // PWM
TIMER1A, /* 8 - PD5 */ // PWM
TIMER2B, /* 9 - PD6 */ // PWM
TIMER0B /* 10 - PB4 */ // PWM
NOT_ON_TIMER, /* 11 - PB5 */
NOT_ON_TIMER, /* 12 - PB6 */
NOT_ON_TIMER, /* 13 - PB7 */
NOT_ON_TIMER, /* 14 - PA0 */
NOT_ON_TIMER, /* 15 - PA1 */
NOT_ON_TIMER, /* 16 - PA2 */
NOT_ON_TIMER, /* 17 - PA3 */
NOT_ON_TIMER, /* 18 - PA4 */
NOT_ON_TIMER, /* 19 - PA5 */
NOT_ON_TIMER, /* 20 - PA6 */
NOT_ON_TIMER, /* 21 - PA7 */
NOT_ON_TIMER, /* 22 - PC0 */
NOT_ON_TIMER, /* 23 - PC1 */
NOT_ON_TIMER, /* 24 - PC2 */
NOT_ON_TIMER, /* 25 - PC3 */
NOT_ON_TIMER, /* 26 - PC4 */
NOT_ON_TIMER, /* 27 - PC5 */
NOT_ON_TIMER, /* 28 - PC6 */
NOT_ON_TIMER, /* 29 - PC7 */
TIMER1B, /* 30 - PD4 */ // PWM
TIMER2A /* 31 - PD7 */ // PWM
};
This is just getting aggravating now. I've got this great file
http://www.crossroadsfencing.com/pins_duino1284.cxx
in this folder
c:\program file\arduino-0022\hardware\arduino-extras\cores\arduino
and nothing I seem to do gets it used, so my pin mappings never change.
pins_arduino.c has this
#elif defined(__AVR_ATmega1284__)
//* pin defs for bobuino & 1284 board
#include "pins_duino1284.cxx"
Where do I get that defined?
Seems like
pins_duino1284.cxx
is getting compiled as I had to fix a couple of errors the first time I used it after creating it (extra commas at the end of lists of ports I think).
Any ideas?
I think the environment causes that to be defined based on the boards.txt file. Try commenting it out and see if that helps...
Where do I get that defined?
So long as the entries in boards.txt are correct, it's defined for you.
so my pin mappings never change
One potential problem is the way a sketch is linked. The core is packaged into a (GCC not Arduino) library and then the sketch object file is linked to the library. The linker uses a "weak reference" for symbols found in libraries. This means that there could be more than one "port_to_mode_PGM" in the library without triggering an error. The linker seems to use the first symbol found.
On the one hand, the "#elif" should ensure only one set of pin definitions makes it into the library. On the other hand, the symptom is a perfect fit for the "multiple symbol" problem.
OK, I had added this to the arduinos-extras boards.txt
The -0022 boards.txt has no 1284 references at all.
extras.name=EXTRAS==============================
##############################################################
# extras added for arduino boards
##############################################################
atmega1284p.name=Arduino-Bobuino 1284p
atmega1284p.upload.protocol=stk500
atmega1284p.upload.maximum_size=129024
atmega1284p.upload.speed=38400
atmega1284p.bootloader.low_fuses=0xFF
atmega1284p.bootloader.high_fuses=0xDC
atmega1284p.bootloader.extended_fuses=0xFD
atmega1284p.bootloader.path=atmega
atmega1284p.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
atmega1284p.bootloader.unlock_bits=0x3F
atmega1284p.bootloader.lock_bits=0x0F
atmega1284p.build.mcu=atmega1284p
atmega1284p.build.f_cpu=18432000L
atmega1284p.build.core=arduino
avrdude.conf has this for the 1284 - I will add the P to the end of 1284 in pins_arduino.c and see what happens.
#------------------------------------------------------------
# ATmega1284P
#------------------------------------------------------------
# similar to ATmega164p
part
id = "m1284p";
desc = "ATMEGA1284P";
has_jtag = yes;
stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one
avr910_devcode = 0x74;
signature = 0x1e 0x97 0x05;
pagel = 0xd7;
bs2 = 0xa0;
chip_erase_delay = 9000;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
"x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 1;
pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
hventerstabdelay = 100;
progmodedelay = 0;
latchcycles = 6;
togglevtg = 1;
poweroffdelay = 15;
resetdelayms = 1;
resetdelayus = 0;
hvleavestabdelay = 15;
chiperasepulsewidth = 0;
chiperasepolltimeout = 10;
programfusepulsewidth = 0;
programfusepolltimeout = 5;
programlockpulsewidth = 0;
programlockpolltimeout = 5;
idr = 0x31;
spmcr = 0x57;
allowfullpagebitstream = no;
memory "eeprom"
paged = no; /* leave this "no" */
page_size = 8; /* for parallel programming */
size = 4096;
min_write_delay = 9000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 1 1 0 0 0 0 0 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 a2 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" x x x x x x x x";
mode = 0x41;
delay = 10;
blocksize = 128;
readsize = 256;
;
memory "flash"
paged = yes;
size = 131072;
page_size = 256;
num_pages = 512;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 x x x x x x x",
" x x x x x x x x";
mode = 0x41;
delay = 10;
blocksize = 256;
readsize = 256;
;
memory "lock"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x x x o o o o o o";
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "lfuse"
size = 1;
read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
"x x x x x x x x i i i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "hfuse"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
"x x x x x x x x i i i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "efuse"
size = 1;
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
"x x x x x x x x 1 1 1 1 1 i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 x x x x x x x x",
"x x x x x x a1 a0 o o o o o o o o";
;
memory "calibration"
size = 1;
read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
"0 0 0 0 0 0 0 0 o o o o o o o o";
;
;
[/code
No help - pin3 still blinks on A3.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
byte pinx = 3; // do not use 0, 1
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(pinx, OUTPUT);
}
void loop() {
digitalWrite(pinx, HIGH); // set the LED on
delay(200); // wait for a second
digitalWrite(pinx, LOW); // set the LED off
delay(200); // wait for a second
}
In "pins_duino1284.cxx", very near the "digital_pin_to_port_PGM" declaration, add a "#error" line, save, and try to compile your test sketch. Did the compiler stop at the "#error" line?
I just knew that the arduino IDE mods would be a big pot hole in progress of the Bobuino.
Where is that auto installing Bobuino zip file when you need it.
Lefty
Coding: Yes.
added here
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
#error
PD, /* 0 PD0 */
PD, /* 1 PD1 */
PD, /* 2 PD2 */
PD, /* 3 PD3 */
PB, /* 4 PB0 */
PB, /* 5 PB1 */
PB, /* 6 PB2 */
PB, /* 7 PB3 */
Got this when compiled:
In file included from C:\Program Files\Arduino-0022\hardware\arduino-extras\cores\arduino\pins_arduino.c:114:
C:\Program Files\Arduino-0022\hardware\arduino-extras\cores\arduino/pins_duino1284.cxx:105:2: error: #error
Lefty, am collecting lots of bits & pieces for it, thats for sure!
Auto installing, I don't know, maybe just a ReadMeFirst.txt file 8)
CrossRoads:
Lefty, am collecting lots of bits & pieces for it, thats for sure!
Auto installing, I don't know, maybe just a ReadMeFirst.txt file 8)
So did the Bobuino have a change in crystal freq?
extras added for arduino boards
##############################################################
atmega1284p.name=Arduino-Bobuino 1284patmega1284p.upload.protocol=stk500
atmega1284p.upload.maximum_size=129024
atmega1284p.upload.speed=38400atmega1284p.bootloader.low_fuses=0xFF
atmega1284p.bootloader.high_fuses=0xDC
atmega1284p.bootloader.extended_fuses=0xFD
atmega1284p.bootloader.path=atmega
atmega1284p.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
atmega1284p.bootloader.unlock_bits=0x3F
atmega1284p.bootloader.lock_bits=0x0Fatmega1284p.build.mcu=atmega1284p
atmega1284p.build.f_cpu=18432000L
atmega1284p.build.core=arduino
Got boards.txt corrected to call out the correct frequency. Didn't help with pin mapping.
Putting an error in pins_duino1284.cxx did indeed cause an error, so the file would seem to be seen.
You know, Think I just noticed something that might help.
In pins_duino1284.cxx, there are 6 arrays.
I didn't change the first 3, just the second 3.
I just noticed that the pin assignments seem to follow the first 3 arrays, and not the last 3.
Am gonna play with those next:
#define PA 1
#define PB 2
#define PC 3
#define PD 4
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
now to mess with the order of these, since the Digital Pin assignment are going:
PortA: 0-7
PortB: 8-15
PortC: 16-23
PortD: 24-31
&DDRA,
&DDRB,
&DDRC,
&DDRD
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTA,
&PORTB,
&PORTC,
&PORTD
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
&PINA,
&PINB,
&PINC,
&PIND
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PD, /* 0 PD0 */
PD, /* 1 PD1 */
PD, /* 2 PD2 */
PD, /* 3 PD3 */
PB, /* 4 PB0 */
PB, /* 5 PB1 */
PB, /* 6 PB2 */
PB, /* 7 PB3 */
PD, /* 8 PD5 */
PD, /* 9 PD6 */
PB, /* 10 PB4 */
PB, /* 11 PB5 */
PB, /* 12 PB6 */
PB, /* 13 PB7 */
PA, /* 14 PA0 */
PA, /* 15 PA1 */
PA, /* 16 PA2 */
PA, /* 17 PA3 */
PA, /* 18 PA4 */
PA, /* 19 PA5 */
PA, /* 20 PA6 */
PA, /* 21 PA7 */
PC, /* 22 PC0 */
PC, /* 23 PC1 */
PC, /* 24 PC2 */
PC, /* 25 PC3 */
PC, /* 26 PC4 */
PC, /* 27 PC5 */
PC, /* 28 PC6 */
PC, /* 29 PC7 */
PD, /* 30 PD4 */
PD /* 31 PD7 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /*D0: 0, port D */
_BV(1), /*D1: 1, port D */
_BV(2), /*D2: 2, port D */
_BV(3), /*D3: 3, port D */
_BV(0), /*D4: 0, port B */
_BV(1), /*D5: 1, port B */
_BV(2), /*D6: 2, port B */
_BV(3), /*D7: 3, port B */
_BV(5), /*D8: 5, port D */
_BV(6), /*D9: 6, port D */
_BV(4), /*D10: 4, port B */
_BV(5), /*D11: 5, port B */
_BV(6), /*D12: 6, port B */
_BV(7), /*D13: 7, port B */
_BV(0), /*D14: 0, port A */
_BV(1), /*D15: 1, port A */
_BV(2), /*D16, 2, port A */
_BV(3), /*D17: 3, port A */
_BV(4), /*D18: 4, port A */
_BV(5), /*D19: 5, port A */
_BV(6), /*D20: 6, port A */
_BV(7), /*D21: 7, port A */
_BV(0), /*D22: 0, port C */
_BV(1), /*D23: 1, port C */
_BV(2), /*D24, 2, port C */
_BV(3), /*D25: 3, port C */
_BV(4), /*D26: 4, port C */
_BV(5), /*D27: 5, port C */
_BV(6), /*D28: 6, port C */
_BV(7), /*D29: 7, port C */
_BV(4), /*D30: 4, port D */
_BV(7) /*D31: 7, port D */
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 0 - PD0 */
NOT_ON_TIMER, /* 1 - PD1 */
NOT_ON_TIMER, /* 2 - PD2 */
NOT_ON_TIMER, /* 3 - PD3 */
NOT_ON_TIMER, /* 4 - PB0 */
NOT_ON_TIMER, /* 5 - PB1 */
NOT_ON_TIMER, /* 6 - PB2 */
TIMER0A, /* 7 - PB3 */ // PWM
TIMER1A, /* 8 - PD5 */ // PWM
TIMER2B, /* 9 - PD6 */ // PWM
TIMER0B, /* 10 - PB4 */ // PWM
NOT_ON_TIMER, /* 11 - PB5 */
NOT_ON_TIMER, /* 12 - PB6 */
NOT_ON_TIMER, /* 13 - PB7 */
NOT_ON_TIMER, /* 14 - PA0 */
NOT_ON_TIMER, /* 15 - PA1 */
NOT_ON_TIMER, /* 16 - PA2 */
NOT_ON_TIMER, /* 17 - PA3 */
NOT_ON_TIMER, /* 18 - PA4 */
NOT_ON_TIMER, /* 19 - PA5 */
NOT_ON_TIMER, /* 20 - PA6 */
NOT_ON_TIMER, /* 21 - PA7 */
NOT_ON_TIMER, /* 22 - PC0 */
NOT_ON_TIMER, /* 23 - PC1 */
NOT_ON_TIMER, /* 24 - PC2 */
NOT_ON_TIMER, /* 25 - PC3 */
NOT_ON_TIMER, /* 26 - PC4 */
NOT_ON_TIMER, /* 27 - PC5 */
NOT_ON_TIMER, /* 28 - PC6 */
NOT_ON_TIMER, /* 29 - PC7 */
TIMER1B, /* 30 - PD4 */ // PWM
TIMER2A /* 31 - PD7 */ // PWM
};
Success!!
To make it work, I stripped out the pins_arduino.c file in the arduino-0022 folders area and changed it to the listing below.
I renamed the pins_arduino.c in the arduino-extras folders area to a name that didn't start with pins.
If there is a way to make the #ifdef's work for other processors, I'd like some direction on making that work.
For now, I am only compiling correctly for "my" 1284 and have to revert to naming files to use '328 Duemilanoves.
8) 8) 8)!
On to more testing!
/*
heavily modified to only support an atmega1284 as used in the"Bobuino"
pins_arduino.c - pin definitions for the Arduino board
Part of Arduino / Wiring Lite
Copyright (c) 2005 David A. Mellis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id$
*/
#ifndef _AVR_IO_H_
#include <avr/io.h>
#endif
//#include "wiring_private.h"
#ifndef Wiring_h
#include "wiring.h"
#endif
#ifndef Pins_Arduino_h
#include "pins_arduino.h"
#endif
// On the Bobuino board, digital pins are also used
// for the analog output (software PWM). Analog input
// pins are a separate set.
// ATMEL ATMEGA1284P / BOBUINO
//
// +---\/---+
// INT0 (D 4) PB0 1| |40 PA0 (AI 0 / D14)
// INT1 (D 5) PB1 2| |39 PA1 (AI 1 / D15)
// INT2 (D 6) PB2 3| |38 PA2 (AI 2 / D16)
// PWM (D 7) PB3 4| |37 PA3 (AI 3 / D17)
// PWM (D 10) PB4 5| |36 PA4 (AI 4 / D18)
// MOSI (D 11) PB5 6| |35 PA5 (AI 5 / D19)
// MISO (D 12) PB6 7| |34 PA6 (AI 6 / D21)
// SCK (D 13) PB7 8| |33 PA7 (AI 7 / D22)
// RST 9| |32 AREF
// VCC 10| |31 GND
// GND 11| |30 AVCC
// XTAL2 12| |29 PC7 (D 29)
// XTAL1 13| |28 PC6 (D 28)
// RX0 (D 0) PD0 14| |27 PC5 (D 27) TDI
// TX0 (D 1) PD1 15| |26 PC4 (D 26) TDO
// RX1 (D 2) PD2 16| |25 PC3 (D 25) TMS
// TX1 (D 3) PD3 17| |24 PC2 (D 24) TCK
// PWM (D 30) PD4 18| |23 PC1 (D 23) SDA
// PWM (D 8 ) PD5 19| |22 PC0 (D 22) SCL
// PWM (D 9) PD6 20| |21 PD7 (D 31) PWM
// +--------+
//
#define PA 1
#define PB 2
#define PC 3
#define PD 4
// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
NOT_A_PORT,
&DDRA,
&DDRB,
&DDRC,
&DDRD
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
NOT_A_PORT,
&PORTA,
&PORTB,
&PORTC,
&PORTD
};
const uint16_t PROGMEM port_to_input_PGM[] =
{
NOT_A_PORT,
&PINA,
&PINB,
&PINC,
&PIND
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
PD, /* 0 PD0 */
PD, /* 1 PD1 */
PD, /* 2 PD2 */
PD, /* 3 PD3 */
PB, /* 4 PB0 */
PB, /* 5 PB1 */
PB, /* 6 PB2 */
PB, /* 7 PB3 */
PD, /* 8 PD5 */
PD, /* 9 PD6 */
PB, /* 10 PB4 */
PB, /* 11 PB5 */
PB, /* 12 PB6 */
PB, /* 13 PB7 */
PA, /* 14 PA0 */
PA, /* 15 PA1 */
PA, /* 16 PA2 */
PA, /* 17 PA3 */
PA, /* 18 PA4 */
PA, /* 19 PA5 */
PA, /* 20 PA6 */
PA, /* 21 PA7 */
PC, /* 22 PC0 */
PC, /* 23 PC1 */
PC, /* 24 PC2 */
PC, /* 25 PC3 */
PC, /* 26 PC4 */
PC, /* 27 PC5 */
PC, /* 28 PC6 */
PC, /* 29 PC7 */
PD, /* 30 PD4 */
PD /* 31 PD7 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
_BV(0), /*D0: 0, port D */
_BV(1), /*D1: 1, port D */
_BV(2), /*D2: 2, port D */
_BV(3), /*D3: 3, port D */
_BV(0), /*D4: 0, port B */
_BV(1), /*D5: 1, port B */
_BV(2), /*D6: 2, port B */
_BV(3), /*D7: 3, port B */
_BV(5), /*D8: 5, port D */
_BV(6), /*D9: 6, port D */
_BV(4), /*D10: 4, port B */
_BV(5), /*D11: 5, port B */
_BV(6), /*D12: 6, port B */
_BV(7), /*D13: 7, port B */
_BV(0), /*D14: 0, port A */
_BV(1), /*D15: 1, port A */
_BV(2), /*D16, 2, port A */
_BV(3), /*D17: 3, port A */
_BV(4), /*D18: 4, port A */
_BV(5), /*D19: 5, port A */
_BV(6), /*D20: 6, port A */
_BV(7), /*D21: 7, port A */
_BV(0), /*D22: 0, port C */
_BV(1), /*D23: 1, port C */
_BV(2), /*D24, 2, port C */
_BV(3), /*D25: 3, port C */
_BV(4), /*D26: 4, port C */
_BV(5), /*D27: 5, port C */
_BV(6), /*D28: 6, port C */
_BV(7), /*D29: 7, port C */
_BV(4), /*D30: 4, port D */
_BV(7) /*D31: 7, port D */
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
NOT_ON_TIMER, /* 0 - PD0 */
NOT_ON_TIMER, /* 1 - PD1 */
NOT_ON_TIMER, /* 2 - PD2 */
NOT_ON_TIMER, /* 3 - PD3 */
NOT_ON_TIMER, /* 4 - PB0 */
NOT_ON_TIMER, /* 5 - PB1 */
NOT_ON_TIMER, /* 6 - PB2 */
TIMER0A, /* 7 - PB3 */ // PWM
TIMER1A, /* 8 - PD5 */ // PWM
TIMER2B, /* 9 - PD6 */ // PWM
TIMER0B, /* 10 - PB4 */ // PWM
NOT_ON_TIMER, /* 11 - PB5 */
NOT_ON_TIMER, /* 12 - PB6 */
NOT_ON_TIMER, /* 13 - PB7 */
NOT_ON_TIMER, /* 14 - PA0 */
NOT_ON_TIMER, /* 15 - PA1 */
NOT_ON_TIMER, /* 16 - PA2 */
NOT_ON_TIMER, /* 17 - PA3 */
NOT_ON_TIMER, /* 18 - PA4 */
NOT_ON_TIMER, /* 19 - PA5 */
NOT_ON_TIMER, /* 20 - PA6 */
NOT_ON_TIMER, /* 21 - PA7 */
NOT_ON_TIMER, /* 22 - PC0 */
NOT_ON_TIMER, /* 23 - PC1 */
NOT_ON_TIMER, /* 24 - PC2 */
NOT_ON_TIMER, /* 25 - PC3 */
NOT_ON_TIMER, /* 26 - PC4 */
NOT_ON_TIMER, /* 27 - PC5 */
NOT_ON_TIMER, /* 28 - PC6 */
NOT_ON_TIMER, /* 29 - PC7 */
TIMER1B, /* 30 - PD4 */ // PWM
TIMER2A /* 31 - PD7 */ // PWM
};