Skip to content

Commit

Permalink
Experiment: Add case for boards without ANALOG_PINS_LAST
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Nov 29, 2021
1 parent 21e1629 commit f6dc080
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cores/arduino/gd32/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion variants/GD32E230C_START/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6dc080

Please sign in to comment.