mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-10-29 05:30:32 +00:00
Finalize C <=> C++ interface
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2026 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Clock setup + GPIO/pin configuration. Call once, first thing at startup
|
||||
// (before any peripheral init).
|
||||
void board_init(void);
|
||||
|
||||
// Globally enable interrupts. Call after all peripherals are initialized.
|
||||
void board_enable_interrupts(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2026 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Media-control HAL: emulate head-unit button presses to the audio source. This
|
||||
// is device functionality (see CDChanger), so this contract is consumed only by
|
||||
// the device implementation, not the app.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avclan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
using MediaAction = avclan::MediaAction;
|
||||
extern "C" {
|
||||
#else
|
||||
typedef enum MediaAction MediaAction;
|
||||
#endif
|
||||
|
||||
// One-time hardware bring-up for the media driver.
|
||||
void media_init(void);
|
||||
|
||||
// Emulate a media function (button press) on the source device.
|
||||
void media_action(MediaAction fn);
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool media_mic_toggle(void);
|
||||
bool media_busy(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
// copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||
// copyright (C) 2007 Louis Frigon
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avclan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
using Read = avclan::detail::Error::Read;
|
||||
using Bit = avclan::detail::Bit;
|
||||
extern "C" {
|
||||
#else
|
||||
typedef enum Read Read;
|
||||
typedef enum Bit Bit;
|
||||
#endif
|
||||
|
||||
// One-time bring-up of the bus hardware. Leaves the bus idle and TX unmuted.
|
||||
void phy_init(void);
|
||||
|
||||
// Mute/unmute device TX. "Muted" means we still listen, we just don't ACK or
|
||||
// transmit.
|
||||
void phy_mute(bool mute);
|
||||
bool phy_is_muted(void);
|
||||
|
||||
// True when there is activity on the bus (something is driving it).
|
||||
bool phy_active(void);
|
||||
|
||||
// Bus-transaction guard: quiesce the target's other async sources around a bus
|
||||
// read/send so framing isn't disturbed, then restore them. May be a no-op on a
|
||||
// target without such contention.
|
||||
void phy_guard_enter(void);
|
||||
void phy_guard_leave(void);
|
||||
|
||||
// Start-bit handling, factored out of read/sendframe so the framing layer holds
|
||||
// no bus-timing or hardware-recovery logic.
|
||||
// - phy_read_startbit waits for and validates an incoming start bit, doing
|
||||
// any target-specific bus recovery; see avclan::detail::Error::Read.
|
||||
// - phy_send_startbit acquires the bus and emits a start bit; returns false
|
||||
// if the bus was busy.
|
||||
Read phy_read_startbit(void);
|
||||
bool phy_send_startbit(void);
|
||||
|
||||
// Per-symbol I/O. The send* helpers return the even parity of the bits sent;
|
||||
// the read* helpers return the even parity of the bits read. The _u8/_u16
|
||||
// suffixes name the source-operand width; `len` is how many bits (<= width).
|
||||
void phy_send_bit(Bit bit);
|
||||
void phy_send_ack(void);
|
||||
uint8_t phy_read_ack(void);
|
||||
|
||||
Bit phy_send_bits_u8(const uint8_t *bits, int8_t len);
|
||||
Bit phy_send_bits_u16(const uint16_t *bits, int8_t len);
|
||||
Bit phy_send_byte(const uint8_t *byte);
|
||||
|
||||
uint8_t phy_read_bits_u8(uint8_t *bits, uint8_t len);
|
||||
uint8_t phy_read_bits_u16(uint16_t *bits, int8_t len);
|
||||
uint8_t phy_read_byte(uint8_t *byte);
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Sample and dump bus bit timing over the serial link (REPL `M`).
|
||||
void phy_measure(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user