diff --git a/klippy/pins.py b/klippy/pins.py index 26d0bf67..8cd9f636 100644 --- a/klippy/pins.py +++ b/klippy/pins.py @@ -13,18 +13,7 @@ class error(Exception): # Hardware pin names ###################################################################### -def named_pins(fmt, port_count, bit_count=32): - return { fmt % (port, portbit) : port * bit_count + portbit - for port in range(port_count) - for portbit in range(bit_count) } - -def beaglebone_pins(): - gpios = named_pins("gpio%d_%d", 4) - gpios.update({"AIN%d" % i: i+4*32 for i in range(8)}) - return gpios - MCU_PINS = { - "pru": beaglebone_pins(), "linux": {"analog%d" % i: i for i in range(8)}, # XXX } @@ -141,8 +130,7 @@ beagleboneblack_mappings = { def update_map_beaglebone(pins, mcu): if mcu != 'pru': raise error("Beaglebone aliases not supported on mcu '%s'" % (mcu,)) - for pin, gpio in beagleboneblack_mappings.items(): - pins[pin] = pins[gpio] + pins.update(beagleboneblack_mappings) ###################################################################### diff --git a/src/pru/adc.c b/src/pru/adc.c index 81ec7fe3..d4458628 100644 --- a/src/pru/adc.c +++ b/src/pru/adc.c @@ -51,6 +51,8 @@ adc_full_reset(void) have_done_reset = 1; } +DECL_ENUMERATION_RANGE("pin", "AIN0", 4 * 32, 8); + struct gpio_adc gpio_adc_setup(uint8_t pin) { diff --git a/src/pru/gpio.c b/src/pru/gpio.c index 79b313ad..1e298657 100644 --- a/src/pru/gpio.c +++ b/src/pru/gpio.c @@ -29,6 +29,11 @@ struct gpio_regs { volatile uint32_t setdataout; }; +DECL_ENUMERATION_RANGE("pin", "gpio0_0", GPIO(0, 0), 32); +DECL_ENUMERATION_RANGE("pin", "gpio1_0", GPIO(1, 0), 32); +DECL_ENUMERATION_RANGE("pin", "gpio2_0", GPIO(2, 0), 32); +DECL_ENUMERATION_RANGE("pin", "gpio3_0", GPIO(3, 0), 32); + static struct gpio_regs *digital_regs[] = { (void*)0x44e07000, (void*)0x4804c000, (void*)0x481ac000, (void*)0x481ae000 };