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