mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-06 17:03:17 +00:00
Prep for C++ port
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
// (phy / frame / protocol / cdchanger). This is a leaf header: it must not
|
||||
// include any other project header.
|
||||
|
||||
#ifndef AVCLAN_DEFS_H
|
||||
#define AVCLAN_DEFS_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -157,5 +156,3 @@ typedef enum : uint8_t {
|
||||
sBUSY,
|
||||
sMUTED,
|
||||
} avclan_senderr_t;
|
||||
|
||||
#endif // AVCLAN_DEFS_H
|
||||
|
||||
@@ -29,17 +29,22 @@
|
||||
No acknowledge bits are sent for broadcast frames.
|
||||
*/
|
||||
|
||||
#ifndef AVCLAN_FRAME_H
|
||||
#define AVCLAN_FRAME_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avclan_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
avclan_readerr_t AVCLAN_readframe(AVCLAN_frame_t *frame, log_t print);
|
||||
avclan_senderr_t AVCLAN_sendframe(const AVCLAN_frame_t *frame, log_t print);
|
||||
void AVCLAN_printframe(const AVCLAN_frame_t *frame, bool binary);
|
||||
uint8_t AVCLAN_parseframe(const uint8_t *bytes, uint8_t len,
|
||||
AVCLAN_frame_t *frame);
|
||||
|
||||
#endif // AVCLAN_FRAME_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef AVCLAN_PHY_H
|
||||
#define AVCLAN_PHY_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avclan_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// One-time bring-up of the bus hardware. Leaves the bus idle and TX unmuted.
|
||||
void AVCLAN_busInit(void);
|
||||
|
||||
@@ -69,4 +72,6 @@ uint8_t AVCLAN_readbyte(uint8_t *byte);
|
||||
void AVCLan_Measure(void);
|
||||
#endif
|
||||
|
||||
#endif // AVCLAN_PHY_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
// generic peripheral-level handling with CD-changer device-specific handling;
|
||||
// the device-specific cases will later migrate into cdchanger.
|
||||
|
||||
#ifndef AVCLAN_PROTOCOL_H
|
||||
#define AVCLAN_PROTOCOL_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avclan_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// Message state machine
|
||||
// - r_Nothing (0x00) means don't send current message
|
||||
// - r_Handled means send current message and stop/finished state machine
|
||||
@@ -37,4 +40,6 @@ typedef struct RFrame_struct {
|
||||
response_t AVCLAN_handleframe(const AVCLAN_frame_t *in, AVCLAN_frame_t *out);
|
||||
RFrame_t *AVCLAN_statemachine(RFrame_t *resp);
|
||||
|
||||
#endif // AVCLAN_PROTOCOL_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
// Umbrella header for the avclan library. Consumers (e.g. the app in
|
||||
// src/sniffer.c) include this single header to pull in the whole AVC-LAN stack.
|
||||
|
||||
#ifndef __AVCLANDRV_H
|
||||
#define __AVCLANDRV_H
|
||||
#pragma once
|
||||
|
||||
#include "avclan_defs.h"
|
||||
#include "avclan_frame.h"
|
||||
@@ -16,5 +15,3 @@
|
||||
#include "cdchanger.h"
|
||||
#include "mediacontrol.h"
|
||||
#include "statustimer.h"
|
||||
|
||||
#endif // __AVCLANDRV_H
|
||||
|
||||
@@ -8,13 +8,16 @@
|
||||
// logic; it commands the mediacontrol and statustimer drivers rather than
|
||||
// touching their hardware directly.
|
||||
|
||||
#ifndef CDCHANGER_H
|
||||
#define CDCHANGER_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avclan_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum : uint8_t {
|
||||
cd_OPEN = 0x01,
|
||||
cd_ERR1 = 0x02,
|
||||
@@ -77,4 +80,6 @@ void serializeCDStatus(uint8_t *dst);
|
||||
AVCLAN_frame_t *AVCLAN_getStatusFrame();
|
||||
void AVCLAN_generateStatus(AVCLAN_frame_t *status, bool is_unicast, devices to);
|
||||
|
||||
#endif // CDCHANGER_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
// Media-control: route/handle head-unit button presses to the audio source.
|
||||
|
||||
#ifndef MEDIACONTROL_H
|
||||
#define MEDIACONTROL_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -15,6 +14,10 @@ typedef enum : uint8_t {
|
||||
MEDIA_SKIP_BACKWARD,
|
||||
} AVCLAN_media_fn_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// One-time hardware bring-up for the media driver.
|
||||
void mediacontrol_init();
|
||||
|
||||
@@ -26,4 +29,6 @@ bool AVCLAN_micToggle();
|
||||
bool AVCLAN_isMediaFunctioning();
|
||||
#endif
|
||||
|
||||
#endif // MEDIACONTROL_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
// polls statustimer_tickPending() and clears the tick with
|
||||
// statustimer_clearTick()
|
||||
|
||||
#ifndef STATUSTIMER_H
|
||||
#define STATUSTIMER_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// One-time hardware bring-up. Leaves the tick disabled.
|
||||
void statustimer_init(void);
|
||||
@@ -23,4 +26,6 @@ extern volatile bool tick_pending;
|
||||
static inline bool statustimer_tickPending() { return tick_pending; }
|
||||
static inline void statustimer_clearTick() { tick_pending = false; }
|
||||
|
||||
#endif // STATUSTIMER_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
// transaction guard (phy_avr.c's AVCLAN_stopEvent). Not part of the public
|
||||
// mediacontrol.h interface.
|
||||
|
||||
#ifndef MEDIA_AVR_H
|
||||
#define MEDIA_AVR_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Keep the TCA0 press waveform roughly in sync while a bus transaction has
|
||||
// masked interrupts (runs the OVF ISR body early if an overflow is imminent).
|
||||
@@ -14,4 +17,6 @@
|
||||
// ATOMIC_BLOCK).
|
||||
void mediacontrol_syncDuringMask();
|
||||
|
||||
#endif // MEDIA_AVR_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef TIMING_AVR_H
|
||||
#define TIMING_AVR_H
|
||||
#pragma once
|
||||
|
||||
// AVR ATtiny3216 timing parameters. Derives F_CPU (needed by avr-libc, e.g.
|
||||
// util/delay.h) and the bus-timer (TCB) tick period from the CMake-provided
|
||||
@@ -65,5 +64,3 @@
|
||||
#define TICK_US (TCB_TICK / 1000.0)
|
||||
|
||||
#include "timing.h"
|
||||
|
||||
#endif // TIMING_AVR_H
|
||||
|
||||
+1
-4
@@ -1,8 +1,7 @@
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef _TIMING_HPP_
|
||||
#define _TIMING_HPP_
|
||||
#pragma once
|
||||
|
||||
// Physical AVC-LAN bit-phase durations, in microseconds. These are protocol
|
||||
// facts (the bus spec), independent of any particular hardware. The active
|
||||
@@ -31,5 +30,3 @@
|
||||
#define AVCLAN_READBIT_THRESHOLD (26.0 / TICK_US)
|
||||
|
||||
#define AVCLAN_BIT_LENGTH_MAX (39.1 / TICK_US)
|
||||
|
||||
#endif
|
||||
|
||||
+8
-3
@@ -1,8 +1,11 @@
|
||||
// Copyright (C) 2026 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Clock setup + GPIO/pin configuration. Call once, first thing at startup
|
||||
// (before any peripheral init).
|
||||
@@ -11,4 +14,6 @@ void board_init(void);
|
||||
// Globally enable interrupts. Call after all peripherals are initialized.
|
||||
void board_interruptsEnable(void);
|
||||
|
||||
#endif // BOARD_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+8
-3
@@ -3,11 +3,14 @@
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef __COM232_H
|
||||
#define __COM232_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void RS232_Init(void);
|
||||
|
||||
// Receive path. The RX ring is private to the driver; the app polls hasChar()
|
||||
@@ -28,4 +31,6 @@ void RS232_PrintHex(uint16_t x);
|
||||
void RS232_PrintDec(uint8_t Data);
|
||||
void RS232_PrintDec2(uint8_t Data);
|
||||
|
||||
#endif // __COM232_H
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct Queue_struct {
|
||||
uint8_t write;
|
||||
uint8_t read;
|
||||
@@ -20,3 +24,7 @@ static inline void incrementRead(Queue_t *q) { q->read++; }
|
||||
uint8_t pushQueue(Queue_t *q, void *x);
|
||||
void *peekQueue(const Queue_t *q);
|
||||
void *popQueue(Queue_t *q);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user