diff --git a/src/sam4e8e/Makefile b/src/sam4e8e/Makefile index a5b9bbf1..9fb2fd60 100644 --- a/src/sam4e8e/Makefile +++ b/src/sam4e8e/Makefile @@ -33,5 +33,5 @@ $(OUT)klipper.bin: $(OUT)klipper.elf $(Q)$(OBJCOPY) -O binary $< $@ flash: $(OUT)klipper.bin - @echo " Flashing $^ to $(FLASH_DEVICE) via bossac" - $(Q)tools/bossa/bin/bossac --port="$(FLASH_DEVICE)" -b -U -e -w -v $(OUT)klipper.bin -R + @echo "" + @echo " The SAM4E8E build does not currently support 'make flash'" diff --git a/src/sam4e8e/gpio.c b/src/sam4e8e/gpio.c index bbc13005..d08e92a6 100644 --- a/src/sam4e8e/gpio.c +++ b/src/sam4e8e/gpio.c @@ -72,9 +72,10 @@ gpio_out_setup(uint8_t pin, uint8_t val) { if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs)) goto fail; - Pio *regs = digital_regs[GPIO2PORT(pin)]; + uint32_t port = GPIO2PORT(pin); + Pio *regs = digital_regs[port]; uint32_t bit = GPIO2BIT(pin); - uint32_t bank_id = ID_PIOA + GPIO2BIT(pin); + uint32_t bank_id = ID_PIOA + port; irqstatus_t flag = irq_save(); @@ -129,15 +130,23 @@ gpio_in_setup(uint8_t pin, int8_t pull_up) uint32_t port = GPIO2PORT(pin); Pio *regs = digital_regs[port]; uint32_t bit = GPIO2BIT(pin); + uint32_t bank_id = ID_PIOA + port; + regs->PIO_IDR = bit; irqstatus_t flag = irq_save(); - PMC->PMC_PCER0 = 1 << (ID_PIOA + port); + + if ((PMC->PMC_PCSR0 & (1u << bank_id)) == 0) { + PMC->PMC_PCER0 = 1 << bank_id; + } + if (pull_up) regs->PIO_PUER = bit; else regs->PIO_PUDR = bit; + regs->PIO_ODR = bit; regs->PIO_PER = bit; + irq_restore(flag); return (struct gpio_in){ .pin=pin, .regs=regs, .bit=bit }; fail: