build: the libavr pin advances past phase 6
The renames land (interrupt_guard, consume_reset_cause, set_duty), the sampler binds its input in the new converter shape (the input pack plus in<>::start() as free-running's one kick), and the console states .allow_baud_error = true for the 115200-at-16-MHz this board has always spoken - the receiver-tolerance table libavr now enforces is stricter than the rate's own +2.1 %. The loader probe reads through avr::flash_load instead of raw pgmspace, the terminal's line buffer is std::array with backspace and delete named, the tree is reformatted under InsertBraces, and the sources are ASCII. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <libavr/libavr.hpp>
|
||||
|
||||
// The board composition: every peripheral of the fan controller in one
|
||||
// place. ATmega328P at 16 MHz — thermistor divider on ADC0 (PC0), fan on
|
||||
// place. ATmega328P at 16 MHz - thermistor divider on ADC0 (PC0), fan on
|
||||
// OC0B (PD5) at 50 kHz, console on the hardware UART.
|
||||
namespace app {
|
||||
|
||||
@@ -20,7 +20,7 @@ class uptime {
|
||||
|
||||
static std::uint64_t millis()
|
||||
{
|
||||
avr::irq::atomic_guard lock;
|
||||
avr::irq::interrupt_guard lock;
|
||||
return ms;
|
||||
}
|
||||
};
|
||||
@@ -35,25 +35,29 @@ class sampler {
|
||||
static constexpr std::uint16_t samples = 1000;
|
||||
|
||||
public:
|
||||
using input = dev::adc<{.input = avr::adc::input_pin(0),
|
||||
.trigger = avr::adc::trigger::free_running,
|
||||
.on_conversion = [](std::uint16_t value) {
|
||||
sum = sum + value;
|
||||
count = count + 1;
|
||||
if (count >= samples) {
|
||||
window = static_cast<std::uint16_t>(sum / samples);
|
||||
sum = 0;
|
||||
count = 0;
|
||||
ready = true;
|
||||
}
|
||||
}}>;
|
||||
using input = dev::adc<{.trigger = avr::adc::trigger::free_running,
|
||||
.on_conversion =
|
||||
[](std::uint16_t value) {
|
||||
sum = sum + value;
|
||||
count = count + 1;
|
||||
if (count >= samples) {
|
||||
window = static_cast<std::uint16_t>(sum / samples);
|
||||
sum = 0;
|
||||
count = 0;
|
||||
ready = true;
|
||||
}
|
||||
}},
|
||||
avr::adc::input<avr::adc::input_pin(0)>>;
|
||||
// The bound input, whose start() is free-running's one kick.
|
||||
using thermistor = input::in<avr::adc::input_pin(0)>;
|
||||
|
||||
// The finished average (raw 10-bit), once per window.
|
||||
static bool take(std::uint16_t &value)
|
||||
{
|
||||
avr::irq::atomic_guard lock;
|
||||
if (!ready)
|
||||
avr::irq::interrupt_guard lock;
|
||||
if (!ready) {
|
||||
return false;
|
||||
}
|
||||
value = window;
|
||||
ready = false;
|
||||
return true;
|
||||
@@ -62,7 +66,10 @@ class sampler {
|
||||
|
||||
using fan = dev::pwm<avr::pd5, {.frequency = 50_kHz}>;
|
||||
|
||||
using serial_t = dev::uart0<{.baud = 115200_Bd, .rx_buffer = 32, .max_baud_error = 2.5_pct}>;
|
||||
// 115200 at 16 MHz lands +2.1 % off, past the receiver-tolerance table the
|
||||
// solver holds rates to - the rate this board has always spoken, so the
|
||||
// override states that it is meant.
|
||||
using serial_t = dev::uart0<{.baud = 115200_Bd, .rx_buffer = 32, .allow_baud_error = true}>;
|
||||
inline constexpr serial_t serial{};
|
||||
|
||||
} // namespace app
|
||||
|
||||
Reference in New Issue
Block a user