Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix in macro digitalPinToPCMSK(p) #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Mighty 1284P: Platform files for Arduino to run on ATmega1284P

## GEKO Navsat disclaimer
This is a library originally written by maniacbug.
Check: https://github.com/maniacbug/mighty-1284p/

We are keeping a copy here for support/development purposes. Perhaps, we might detect and fix some little bugs, in which case the original author of this work will be notified.

We keep the original description for giving credit to the original author.

## What is it?

Everything you need to run Arduino on ATmega1284P.
Everything you need to run Arduino on ATmega1284P.

## Current state

Expand Down
68 changes: 35 additions & 33 deletions variants/standard/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,30 @@

#include <avr/pgmspace.h>

// ATMEL ATMEGA1284P
//
// +---\/---+
// (D 0) PB0 1| |40 PA0 (AI 0 / D24)
// (D 1) PB1 2| |39 PA1 (AI 1 / D25)
// INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D26)
// PWM (D 3) PB3 4| |37 PA3 (AI 3 / D27)
// PWM/SS (D 4) PB4 5| |36 PA4 (AI 4 / D28)
// MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D29)
// PWM/MISO (D 6) PB6 7| |34 PA6 (AI 6 / D30)
// PWM/SCK (D 7) PB7 8| |33 PA7 (AI 7 / D31)
// RST 9| |32 AREF
// VCC 10| |31 GND
// GND 11| |30 AVCC
// XTAL2 12| |29 PC7 (D 23)
// XTAL1 13| |28 PC6 (D 22)
// RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
// TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
// RX1/INT0 (D 10) PD2 16| |25 PC3 (D 19) TMS
// TX1/INT1 (D 11) PD3 17| |24 PC2 (D 18) TCK
// PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
// PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
// PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
// +--------+
//

/*
PCINT15-8: D7-0 : bit 1
PCINT31-24: D15-8 : bit 3
PCINT23-16: D23-16 : bit 2
PCINT7-0: D31-24 : bit 0
*/
/** ATMEL ATMEGA1284P
* +---\/---+
* (D 0) PB0 1| |40 PA0 (AI 0 / D24)
* (D 1) PB1 2| |39 PA1 (AI 1 / D25)
* INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D26)
* PWM (D 3) PB3 4| |37 PA3 (AI 3 / D27)
* PWM/SS (D 4) PB4 5| |36 PA4 (AI 4 / D28)
* MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D29)
* PWM/MISO (D 6) PB6 7| |34 PA6 (AI 6 / D30)
* PWM/SCK (D 7) PB7 8| |33 PA7 (AI 7 / D31)
* RST 9| |32 AREF
* VCC 10| |31 GND
* GND 11| |30 AVCC
* XTAL2 12| |29 PC7 (D 23)
* XTAL1 13| |28 PC6 (D 22)
* RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
* TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
* RX1/INT0 (D 10) PD2 16| |25 PC3 (D 19) TMS
* TX1/INT1 (D 11) PD3 17| |24 PC2 (D 18) TCK
* PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
* PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
* PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
* +--------+
*/

#define NUM_DIGITAL_PINS 31
#define NUM_ANALOG_INPUTS 8
Expand All @@ -60,11 +52,21 @@ static const uint8_t A5 = 29;
static const uint8_t A6 = 30;
static const uint8_t A7 = 31;


/* Port Change Interrupts
* PCINT15-8: D7-0 : bit 1
* PCINT31-24: D15-8 : bit 3
* PCINT23-16: D23-16 : bit 2
* PCINT7-0: D31-24 : bit 0
*/

#define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))
#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK1) : (((p) <= 15) ? (&PCMSK3) : (((p) <= 23) ? (&PCMSK2) : (((p) <= 31) ? (&PCMSK0) : ((uint8_t *)0))))) // bug fix
#define digitalPinToPCMSKbit(p) ((p) % 8)



#ifdef ARDUINO_MAIN

#define PA 1
Expand Down