Skip to content

Handle analogRead(n) for n in 8..15 #238

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

Open
wants to merge 4 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
5 changes: 5 additions & 0 deletions cores/arduino/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ uint32_t analogRead(uint32_t pin)
if (pin <= 5) {
pin += A0;
}
#if NUM_ANALOG_INPUTS > 8
else if (pin < 16) { // Grand Central's extra 8 pins are discontinuous
pin += PIN_A8 - 8; // and are on LOWER digital Pins than A0..A7
}
#endif

pinPeripheral(pin, PIO_ANALOG);
//ATSAMR, for example, doesn't have a DAC
Expand Down
2 changes: 1 addition & 1 deletion variants/arduino_mzero/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (34u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (19u)
#define NUM_ANALOG_INPUTS (5u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/blm_badge/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ void SERCOM1_Handler()
WIRE_IT_HANDLER();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/blm_badge/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (20u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (17u)
#define NUM_ANALOG_INPUTS (5u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/circuitplay/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ void SERCOM4_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/circuitplay/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// ----

// Number of pins defined in PinDescription array
#define PINS_COUNT (39u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (39u)
#define NUM_ANALOG_INPUTS (11u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/crickit_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ void SERCOM5_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/crickit_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/feather_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ void SERCOM5_Handler()
Serial5.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/feather_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (8u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/feather_m0_express/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ void SERCOM0_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/feather_m0_express/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (42u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (42u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/feather_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ void SERCOM5_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/feather_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (40u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (6u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
2 changes: 1 addition & 1 deletion variants/feather_m4_can/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (43u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (23u)
#define NUM_ANALOG_INPUTS (6u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/gemma_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ void SERCOM0_Handler()
WIRE_IT_HANDLER();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/gemma_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (16u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (16u)
#define NUM_ANALOG_INPUTS (3u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/grand_central_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,4 @@ void SERCOM0_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/grand_central_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (96)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (53)
#define NUM_ANALOG_INPUTS (19)
#define NUM_ANALOG_OUTPUTS (2)
Expand Down
1 change: 1 addition & 0 deletions variants/hallowing_m0_express/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ void SERCOM2_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/hallowing_m0_express/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (42u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (42u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/hallowing_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ void SERCOM4_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/hallowing_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (50u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (50u)
#define NUM_ANALOG_INPUTS (10u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/itsybitsy_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ void SERCOM0_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/itsybitsy_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/itsybitsy_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ void SERCOM3_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/itsybitsy_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (38u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (26u)
#define NUM_ANALOG_INPUTS (7u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/matrixportal_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,4 @@ void SERCOM4_3_Handler()
{
Serial2.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/matrixportal_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (40u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (6u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/metro_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ void SERCOM0_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/metro_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (8u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/metro_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ void SERCOM3_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/metro_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (8u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/metro_m4_airlift/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ void SERCOM0_3_Handler()
{
Serial2.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/metro_m4_airlift/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (49u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (20u)
#define NUM_ANALOG_INPUTS (8u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
2 changes: 1 addition & 1 deletion variants/mkr1000/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// ----

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (22u)
#define NUM_ANALOG_INPUTS (7u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
2 changes: 1 addition & 1 deletion variants/mkrzero/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// ----

// Number of pins defined in PinDescription array
#define PINS_COUNT (26u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (15u)
#define NUM_ANALOG_INPUTS (7u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/monster_m4sk/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ SERCOM sercom2( SERCOM2 ) ;
SERCOM sercom3( SERCOM3 ) ;
SERCOM sercom4( SERCOM4 ) ;
SERCOM sercom5( SERCOM5 ) ;
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/monster_m4sk/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (37u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (37u)
#define NUM_ANALOG_INPUTS (4u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/pirkey/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ void SERCOM1_Handler()
Serial1.IrqHandler();
}

const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pirkey/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (22u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (22u)
#define NUM_ANALOG_INPUTS (5u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/pybadge_airlift_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ void SERCOM5_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pybadge_airlift_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (55u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (25u)
#define NUM_ANALOG_INPUTS (10u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/pybadge_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ void SERCOM5_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pybadge_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (51u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (25u)
#define NUM_ANALOG_INPUTS (10u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/pygamer_advance_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ void SERCOM5_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pygamer_advance_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (54u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (25u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/pygamer_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ void SERCOM5_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pygamer_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (54u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (25u)
#define NUM_ANALOG_INPUTS (12u)
#define NUM_ANALOG_OUTPUTS (2u)
Expand Down
1 change: 1 addition & 0 deletions variants/pyportal_m4/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ void SERCOM4_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pyportal_m4/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (52u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (42u)
#define NUM_ANALOG_INPUTS (9u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/pyportal_m4_titano/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ void SERCOM4_3_Handler()
{
Serial1.IrqHandler();
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/pyportal_m4_titano/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (52u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (42u)
#define NUM_ANALOG_INPUTS (9u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
1 change: 1 addition & 0 deletions variants/qtpy_m0/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ void initVariant(void) {
pinMode(12, OUTPUT);
digitalWrite(12, HIGH);
}
const int PINS_COUNT = sizeof(g_APinDescription)/sizeof(*g_APinDescription);
2 changes: 1 addition & 1 deletion variants/qtpy_m0/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C"
*----------------------------------------------------------------------------*/

// Number of pins defined in PinDescription array
#define PINS_COUNT (21u)
extern const int PINS_COUNT;
#define NUM_DIGITAL_PINS (21u)
#define NUM_ANALOG_INPUTS (9u)
#define NUM_ANALOG_OUTPUTS (1u)
Expand Down
Loading