Migrate to FreeRTOS

This commit is contained in:
Allen Hill
2026-09-22 20:34:38 -07:00
parent 5b9cb1da8b
commit 90e54b0896
20 changed files with 637 additions and 428 deletions
-32
View File
@@ -1,32 +0,0 @@
// Copyright (C) 2026 Allen Hill <allenofthehills@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
// CDChanger periodic-timer HAL: the ~1 Hz tick that drives the CD changer's
// status updates. The timer hardware is target-specific; the CD changer owns
// what a tick means (see cdchanger.cc). The device polls cdtimer_pending() and
// clears the tick with cdtimer_clear().
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
// One-time hardware bring-up. Leaves the tick disabled.
void cdtimer_init(void *ptr, void(clbk)(void *), bool(isplay)(void *));
// Reset the count so the next tick is ~1 s out, and enable the tick.
void cdtimer_reset(void);
// Restore / disable the ~1 Hz tick.
void cdtimer_restore(void);
void cdtimer_disable(void);
extern volatile bool cdtimer_pending_flag;
static inline bool cdtimer_pending() { return cdtimer_pending_flag; }
static inline void cdtimer_clear() { cdtimer_pending_flag = false; }
#ifdef __cplusplus
}
#endif
+8 -10
View File
@@ -7,6 +7,8 @@
#include <stdint.h>
#include "FreeRTOS.h" // IWYU pragma: export
#include "avclan.h"
#ifdef __cplusplus
@@ -30,21 +32,16 @@ void phy_mute(bool mute);
// Non-mutating (e.g. theoretically const qualified/-able)
bool phy_is_muted(void);
// Withhold acknowledgement. Unlike mute this leaves TX alone: a deaf device
// can still manipulate the bus/send frames, it just never responds (e.g. ACK,
// etc). An empty implementation is sufficient for synchronous ports.
// Do not respond to or log incoming frames. Can still send frames.
void phy_deafen(bool deaf);
// True when there is a frame to read. This may reflect current bus state (e.g.
// a frame can be synchronously read from the bus) or indicate that a buffered
// frame is available to "read".
bool phy_frame_pending(void);
// Blocks until a frame is ready
void phy_wait_frame(TickType_t xTicksToWait);
// Bus-transaction guard: quiesce the other async sources (e.g. interrupts)
// so that bus read/send timing isn't disturbed. Re-enable relevant async
// sources with `phy_guard_leave`.
// - May be a no-op on a target where contention isn't a concern.
// - May acquire a hardware lock to prevent concurrent use
// - May be a no-op on a target where concurrency/preemption isn't a concern.
void phy_guard_enter(void);
void phy_guard_leave(void);
@@ -67,8 +64,9 @@ void phy_guard_leave(void);
*
* `expect_ack` indicates whether the recipient should be ACK'ing; false for
* broadcast frames which don't have a single recipient.
*
*/
// Returns NO_FRAME when there is no frame to read.
Read phy_read_header(bool *is_unicast);
Read phy_read_controller_addr(uint16_t *addr);
Read phy_read_peripheral_addr(uint16_t *addr);
+2 -2
View File
@@ -12,8 +12,8 @@ extern "C" {
// Generic stdio interface initialization. All user I/O goes through <stdio.h>
// functions. Assumptions/invariants:
// - stdin MUST be non-blocking (ie. a libc read yields EOF immediately when no
// input is buffered). Necessary to avoid stalling the REPL poll loop.
// - A libc read of stdin blocks the calling task (not the CPU) until at least
// one byte is available.
// - stdout is *raw*. There is no '\n' -> "\r\n" translation. The port does not
// change a bare LF or a binary frame payload. Writes through
// <stdio.h> and writes through stdio_write_nonblock() must reach the same