-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for the ATmega2560. This was completely broken on most pins,
but now it works.
- Loading branch information
Mike Schwager
committed
Feb 15, 2015
1 parent
169b67a
commit 726efdb
Showing
6 changed files
with
143 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
README for AdaEncoder | ||
|
||
Note that you MUST connect the two pins for your rotary encoder to 2 pins on the same PORT | ||
on the ATmega chip. If you do not, your sketch will simply reset. I should probably remove | ||
this restriction one day. | ||
|
||
These are the PORTs on the ATmega328: | ||
* Arduino Pins PORT | ||
* ------------ ---- | ||
* Digital 0-7 D | ||
* Digital 8-13 B | ||
* Analog 0-5 C (== digital pins 14-19) | ||
|
||
ATMEGA2560 Pin Change Interrupts, pins and PORTs: | ||
|
||
Arduino Arduino Arduino | ||
Pin* PORT PCINT Pin PORT PCINT Pin PORT PCINT | ||
A8 PK0 16 10 PB4 4 SS PB0 0 | ||
A9 PK1 17 11 PB5 5 SCK PB1 1 | ||
A10 PK2 18 12 PB6 6 MOSI PB2 2 | ||
A11 PK3 19 13 PB7 7 MISO PB3 3 | ||
A12 PK4 20 14 PJ1 10 | ||
A13 PK5 21 15 PJ0 9 | ||
A14 PK6 22 0 PE0 8 - this one is a little odd.* | ||
A15 PK7 23 | ||
|
||
* Note: Arduino Pin 0 is PE0 (PCINT8), which is RX0. Also, it is the only other | ||
pin on another port on PCI1. Therefore, this pin is not supported by this library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// The Pin map below is copyright by the Arduino people. I include it here so I can remember stuff as I code. | ||
// ATMEL ATMEGA8 & 168 / ARDUINO | ||
// // | ||
// // +-\/-+ | ||
// // PC6 1| |28 PC5 (AI 5) | ||
// // (D 0) PD0 2| |27 PC4 (AI 4) | ||
// // (D 1) PD1 3| |26 PC3 (AI 3) | ||
// // (D 2) PD2 4| |25 PC2 (AI 2) | ||
// // PWM+ (D 3) PD3 5| |24 PC1 (AI 1) | ||
// // (D 4) PD4 6| |23 PC0 (AI 0) | ||
// // VCC 7| |22 GND | ||
// // GND 8| |21 AREF | ||
// // PB6 9| |20 AVCC | ||
// // PB7 10| |19 PB5 (D 13) | ||
// // PWM+ (D 5) PD5 11| |18 PB4 (D 12) | ||
// // PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM | ||
// // (D 7) PD7 13| |16 PB2 (D 10) PWM | ||
// // (D 8) PB0 14| |15 PB1 (D 9) PWM | ||
// // +----+ | ||
// | ||
// const static uint8_t A0 = 14; | ||
// const static uint8_t A1 = 15; | ||
// const static uint8_t A2 = 16; | ||
// const static uint8_t A3 = 17; | ||
// const static uint8_t A4 = 18; | ||
// const static uint8_t A5 = 19; | ||
// const static uint8_t A6 = 20; | ||
// const static uint8_t A7 = 21; | ||
// | ||
// Macros to find pins: | ||
// #define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) | ||
// #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) | ||
// #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) | ||
// #define analogInPinToBit(P) (P) | ||
// #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) | ||
// #define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) | ||
// #define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) | ||
|
||
/* | ||
struct encoder { | ||
volatile uint8_t* port; | ||
|
||
uint8_t bitA; | ||
uint8_t bitB; | ||
|
||
uint8_t turning; // Flag to keep track of turning state | ||
int8_t clicks; // Counter to indicate cumulative clicks in either direction | ||
int8_t direction; // indicator | ||
|
||
char id; | ||
|
||
encoder *next; | ||
};*/ |