Skip to content

Commit

Permalink
atsam: Use enumerations for pin mappings
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Mar 17, 2019
1 parent 8f541d0 commit 8b0195f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 0 additions & 2 deletions klippy/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def beaglebone_pins():
return gpios

MCU_PINS = {
"sam3x8e": port_pins(4, 32), "sam3x8c": port_pins(2, 32),
"sam4s8c": port_pins(3, 32), "sam4e8e" : port_pins(5, 32),
"samd21g18a": port_pins(2, 32), "samd21e18a": port_pins(2, 32),
"samd51g19a": port_pins(2, 32), "samd51j19a": port_pins(3, 32),
"samd51n19a": port_pins(3, 32), "samd51p20a": port_pins(4, 32),
Expand Down
29 changes: 21 additions & 8 deletions src/atsam/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@
#include "internal.h" // gpio_peripheral
#include "sched.h" // sched_shutdown

DECL_ENUMERATION_RANGE("pin", "PA0", GPIO('A', 0), 32);
DECL_ENUMERATION_RANGE("pin", "PB0", GPIO('B', 0), 32);
#ifdef PIOC
DECL_ENUMERATION_RANGE("pin", "PC0", GPIO('C', 0), 32);
#endif
#ifdef PIOD
DECL_ENUMERATION_RANGE("pin", "PD0", GPIO('D', 0), 32);
#endif
#ifdef PIOE
DECL_ENUMERATION_RANGE("pin", "PE0", GPIO('E', 0), 32);
#endif

static Pio * const digital_regs[] = {
#if CONFIG_MACH_SAM3X8E
PIOA, PIOB, PIOC, PIOD
#elif CONFIG_MACH_SAM3X8C
PIOA, PIOB
#elif CONFIG_MACH_SAM4S8C
PIOA, PIOB, PIOC
#elif CONFIG_MACH_SAM4E8E
PIOA, PIOB, PIOC, PIOD, PIOE
PIOA, PIOB,
#ifdef PIOC
PIOC,
#endif
#ifdef PIOD
PIOD,
#endif
#ifdef PIOE
PIOE,
#endif
};

Expand Down

0 comments on commit 8b0195f

Please sign in to comment.