stm32f1: Use enumerations for pin mappings

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-03-12 12:30:21 -04:00 committed by KevinOConnor
parent 8aa8feedb8
commit 91cf497656
2 changed files with 6 additions and 11 deletions

View File

@ -13,16 +13,6 @@ class error(Exception):
# Hardware pin names # Hardware pin names
###################################################################### ######################################################################
def port_pins(port_count, bit_count=8):
pins = {}
for port in range(port_count):
portchr = chr(65 + port)
if portchr == 'I':
continue
for portbit in range(bit_count):
pins['P%c%d' % (portchr, portbit)] = port * bit_count + portbit
return pins
def named_pins(fmt, port_count, bit_count=32): def named_pins(fmt, port_count, bit_count=32):
return { fmt % (port, portbit) : port * bit_count + portbit return { fmt % (port, portbit) : port * bit_count + portbit
for port in range(port_count) for port in range(port_count)
@ -34,7 +24,6 @@ def beaglebone_pins():
return gpios return gpios
MCU_PINS = { MCU_PINS = {
"stm32f103": port_pins(5, 16),
"pru": beaglebone_pins(), "pru": beaglebone_pins(),
"linux": {"analog%d" % i: i for i in range(8)}, # XXX "linux": {"analog%d" % i: i for i in range(8)}, # XXX
} }

View File

@ -17,6 +17,12 @@
* Pin mappings * Pin mappings
****************************************************************/ ****************************************************************/
DECL_ENUMERATION_RANGE("pin", "PA0", GPIO('A', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PB0", GPIO('B', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PC0", GPIO('C', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PD0", GPIO('D', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PE0", GPIO('E', 0), 16);
GPIO_TypeDef *const digital_regs[] = { GPIO_TypeDef *const digital_regs[] = {
GPIOA, GPIOB, GPIOC, GPIOD, GPIOE GPIOA, GPIOB, GPIOC, GPIOD, GPIOE
}; };