From 4362886c397468623f684b182cff50f16f020ea3 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 29 Jul 2026 20:08:10 +0200 Subject: [PATCH] build: the libavr pin advances over the trait projection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The de-string-2 pass upstream: every peripheral block behind generated instance traits, int-keyed, the string layer gone. The port's share of it is two spellings — the char usart_digit that existed to be pasted into register names becomes the int unit the usart template now takes, and the tsb tiers' one reg<"UBRR0"> is the flat hw::ubrr0 — plus the pbapp harness probing has_usart<0>() instead of instance-name strings. Nine loader codegen families rebuilt green through their full workflows (size matrix and simulator protocol suites included); every image holds its recorded size. Co-Authored-By: Claude Fable 5 --- libavr | 2 +- pureboot/pureboot.cpp | 10 +++++----- test/pbapp.cpp | 4 ++-- tsb/tsb_asm.cpp | 2 +- tsb/tsb_policy.cpp | 2 +- tsb/tsb_tricks.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavr b/libavr index f5d7122..56337f3 160000 --- a/libavr +++ b/libavr @@ -1 +1 @@ -Subproject commit f5d71225a2bcd2424f6a7cbaee09b9b3426a05ba +Subproject commit 56337f37de2f369a6196f8bfdf0b7165b8ea61bf diff --git a/pureboot/pureboot.cpp b/pureboot/pureboot.cpp index 03129fd..95414ba 100644 --- a/pureboot/pureboot.cpp +++ b/pureboot/pureboot.cpp @@ -162,14 +162,14 @@ constexpr std::uint8_t bank_shift = 16 - slot_shift; #define PUREBOOT_TX pb1 #endif #if defined(PUREBOOT_USART) -constexpr char usart_digit = '0' + PUREBOOT_USART; +constexpr int usart_unit = PUREBOOT_USART; #else -constexpr char usart_digit = '0'; +constexpr int usart_unit = 0; #endif template struct hardware_link { - using uart = avr::uart::usart; + using uart = avr::uart::usart; // The compiled idle poll: lds UCSR0A (2), sbrc skipping the exit (2), // sbiw + sbci + sbci + brne (6). @@ -270,12 +270,12 @@ struct autobaud_link { #if defined(PUREBOOT_AUTOBAUD) using link = autobaud_link; #elif defined(PUREBOOT_USART) -static_assert(avr::uart::has_usart(), "PUREBOOT_USART selects a hardware USART this chip does not have"); +static_assert(avr::uart::has_usart(), "PUREBOOT_USART selects a hardware USART this chip does not have"); using link = hardware_link; #elif defined(PUREBOOT_SOFT_SERIAL) using link = software_link; #else -using link = std::conditional_t(), hardware_link, +using link = std::conditional_t(), hardware_link, software_link>; #endif diff --git a/test/pbapp.cpp b/test/pbapp.cpp index 0031238..a619a48 100644 --- a/test/pbapp.cpp +++ b/test/pbapp.cpp @@ -50,7 +50,7 @@ consteval bool use_hardware() #if defined(PUREBOOT_SOFT_SERIAL) return false; #else - return avr::hw::db.has_instance("USART0") || avr::hw::db.has_instance("USART"); + return avr::uart::has_usart<0>(); #endif } @@ -63,7 +63,7 @@ struct link { #else static constexpr avr::baud_t baud{115200}; #endif - using tx_t = avr::uart::usart<'0' + PUREBOOT_USART, C, {.baud = baud, .max_baud_error = 2.5_pct}>; + using tx_t = avr::uart::usart; static void tx(char c) { tx_t::write(static_cast(c)); diff --git a/tsb/tsb_asm.cpp b/tsb/tsb_asm.cpp index 1594939..a01c402 100644 --- a/tsb/tsb_asm.cpp +++ b/tsb/tsb_asm.cpp @@ -263,7 +263,7 @@ extern "C" [[noreturn]] void tsb_app(); // the application's reset vector: --def // 0, and rx()/tx() raise RXEN0/TXEN0 on first use — only the divisor low // byte and U2X0 need a store. The library still does the datasheet work. static_assert(baud.u2x && baud.ubrr < 256, "lean bring-up writes UBRR0L only, with U2X0"); - hw::reg<"UBRR0">::write(static_cast(baud.ubrr)); + hw::ubrr0::write(static_cast(baud.ubrr)); hw::ucsr0a::write(hw::ucsr0a::u2x0(1)); // General-purpose registers are undefined at power-on (no crt zeroes them); // the direction latch must start "not receiving" so the first rx() enables diff --git a/tsb/tsb_policy.cpp b/tsb/tsb_policy.cpp index f5cedf2..565f553 100644 --- a/tsb/tsb_policy.cpp +++ b/tsb/tsb_policy.cpp @@ -202,7 +202,7 @@ extern "C" [[noreturn]] void tsb_app(); // the application's reset vector: --def { constexpr auto sol = avr::uart::solve_baud(dev::clock, 115200_Bd); static_assert(sol.u2x && sol.ubrr < 256, "lean bring-up writes UBRR0L only, with U2X0"); - avr::hw::reg<"UBRR0">::write(static_cast(sol.ubrr)); + avr::hw::ubrr0::write(static_cast(sol.ubrr)); avr::hw::ucsr0a::write(avr::hw::ucsr0a::u2x0(1)); } diff --git a/tsb/tsb_tricks.cpp b/tsb/tsb_tricks.cpp index 84d4684..e2cc524 100644 --- a/tsb/tsb_tricks.cpp +++ b/tsb/tsb_tricks.cpp @@ -240,7 +240,7 @@ extern "C" [[noreturn]] void tsb_app(); // the application's reset vector: --def // 0, and rx()/tx() raise RXEN0/TXEN0 on first use — only the divisor low // byte and U2X0 need a store. The library still does the datasheet work. static_assert(baud.u2x && baud.ubrr < 256, "lean bring-up writes UBRR0L only, with U2X0"); - hw::reg<"UBRR0">::write(static_cast(baud.ubrr)); + hw::ubrr0::write(static_cast(baud.ubrr)); hw::ucsr0a::write(hw::ucsr0a::u2x0(1)); // General-purpose registers are undefined at power-on (no crt zeroes them); // the direction latch must start "not receiving" so the first rx() enables