From 0c2416ea7fd5ae15af079f11947902c4e7b51364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20M=C3=A9ndez?= Date: Tue, 24 Mar 2026 13:51:44 -0300 Subject: [PATCH] avr: Fix missing SP definition in newer avr-libc and missing include in adc.c (#7233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compatibility fix for newer avr-libc - define stack pointer add missing avr/io.h include to adc.c add missing avr/io.h include to spi.c Signed-off-by: Nicolás Méndez <9phhsyrbm@relay.firefox.com> --- src/avr/adc.c | 1 + src/avr/main.c | 6 ++++++ src/avr/spi.c | 1 + 3 files changed, 8 insertions(+) diff --git a/src/avr/adc.c b/src/avr/adc.c index 99fd063f6..e94dfbc57 100644 --- a/src/avr/adc.c +++ b/src/avr/adc.c @@ -4,6 +4,7 @@ // // This file may be distributed under the terms of the GNU GPLv3 license. +#include // ADCSRA #include "autoconf.h" // CONFIG_MACH_atmega644p #include "command.h" // shutdown #include "gpio.h" // gpio_adc_read diff --git a/src/avr/main.c b/src/avr/main.c index 0523af411..b0d299dac 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -12,6 +12,12 @@ #include "irq.h" // irq_enable #include "sched.h" // sched_main +// Newer avr-libc headers expose the stack pointer as SP instead of the +// older AVR_STACK_POINTER_REG alias used by Klipper. +#ifndef AVR_STACK_POINTER_REG +#define AVR_STACK_POINTER_REG SP +#endif + DECL_CONSTANT_STR("MCU", CONFIG_MCU); diff --git a/src/avr/spi.c b/src/avr/spi.c index 55eb1f58c..d8acd45da 100644 --- a/src/avr/spi.c +++ b/src/avr/spi.c @@ -4,6 +4,7 @@ // // This file may be distributed under the terms of the GNU GPLv3 license. +#include // SPCR #include "autoconf.h" // CONFIG_MACH_atmega644p #include "command.h" // shutdown #include "gpio.h" // spi_setup