From f6dc080e2524877910f4b8c6240bfbb7901aab44 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Nov 2021 12:24:26 +0100 Subject: [PATCH] Experiment: Add case for boards without ANALOG_PINS_LAST --- cores/arduino/gd32/pins_arduino.h | 7 +++++++ variants/GD32E230C_START/variant.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cores/arduino/gd32/pins_arduino.h b/cores/arduino/gd32/pins_arduino.h index 6bef3983..1a0d7501 100644 --- a/cores/arduino/gd32/pins_arduino.h +++ b/cores/arduino/gd32/pins_arduino.h @@ -147,10 +147,17 @@ uint32_t PinName_to_digital(PinName p); /* Convert an analog pin to a digital pin */ #if ANALOG_PINS_NUM > 0 +#ifndef ANALOG_PINS_LAST +#define ANALOG_PINS_TO_DIGITAL(p) ( \ + ((uint32_t)p < ANALOG_PINS_NUM) ? analog_pins[p] : \ + ((uint32_t)p >= ANALOG_PINS_START) && ((uint32_t)p < DIGITAL_PINS_NUM) ? \ + analog_pins[p-ANALOG_PINS_START] : p) +#else #define ANALOG_PINS_TO_DIGITAL(p) ( \ ((uint32_t)p < ANALOG_PINS_NUM) ? analog_pins[p] : \ ((uint32_t)p >= ANALOG_PINS_START) && ((uint32_t)p <= ANALOG_PINS_LAST) ? \ analog_pins[p-ANALOG_PINS_START] : p) +#endif #else /* No analog pin defined */ #define ANALOG_PINS_TO_DIGITAL(p) (DIGITAL_PINS_NUM) diff --git a/variants/GD32E230C_START/variant.h b/variants/GD32E230C_START/variant.h index a9d96c9c..20521ed4 100644 --- a/variants/GD32E230C_START/variant.h +++ b/variants/GD32E230C_START/variant.h @@ -78,7 +78,7 @@ extern "C" { #define DIGITAL_PINS_NUM 39 #define ANALOG_PINS_NUM 10 #define ANALOG_PINS_START PA0 -#define ANALOG_PINS_LAST PB1 +//#define ANALOG_PINS_LAST PB1 /* LED definitions */ #define LED1 PA7