diff --git a/src/avclan/avclan_defs.h b/src/avclan/avclan_defs.h index b632f0c..029993a 100644 --- a/src/avclan/avclan_defs.h +++ b/src/avclan/avclan_defs.h @@ -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 @@ -157,5 +156,3 @@ typedef enum : uint8_t { sBUSY, sMUTED, } avclan_senderr_t; - -#endif // AVCLAN_DEFS_H diff --git a/src/avclan/avclan_frame.h b/src/avclan/avclan_frame.h index b67b1fd..708ce08 100644 --- a/src/avclan/avclan_frame.h +++ b/src/avclan/avclan_frame.h @@ -29,17 +29,22 @@ No acknowledge bits are sent for broadcast frames. */ -#ifndef AVCLAN_FRAME_H -#define AVCLAN_FRAME_H +#pragma once #include #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 diff --git a/src/avclan/avclan_phy.h b/src/avclan/avclan_phy.h index 7c061c2..7864b9c 100644 --- a/src/avclan/avclan_phy.h +++ b/src/avclan/avclan_phy.h @@ -3,13 +3,16 @@ // Copyright (C) 2015 Allen Hill // SPDX-License-Identifier: GPL-3.0-or-later -#ifndef AVCLAN_PHY_H -#define AVCLAN_PHY_H +#pragma once #include #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 diff --git a/src/avclan/avclan_protocol.h b/src/avclan/avclan_protocol.h index 2e1b9c1..f8fc066 100644 --- a/src/avclan/avclan_protocol.h +++ b/src/avclan/avclan_protocol.h @@ -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 #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 diff --git a/src/avclan/avclandrv.h b/src/avclan/avclandrv.h index 8ab8491..dc4c137 100644 --- a/src/avclan/avclandrv.h +++ b/src/avclan/avclandrv.h @@ -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 diff --git a/src/avclan/cdchanger.h b/src/avclan/cdchanger.h index 5e42b37..ee722d6 100644 --- a/src/avclan/cdchanger.h +++ b/src/avclan/cdchanger.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 #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 diff --git a/src/avclan/mediacontrol.h b/src/avclan/mediacontrol.h index 7e813f8..9d2d44d 100644 --- a/src/avclan/mediacontrol.h +++ b/src/avclan/mediacontrol.h @@ -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 @@ -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 diff --git a/src/avclan/statustimer.h b/src/avclan/statustimer.h index d0a2de6..ec615d3 100644 --- a/src/avclan/statustimer.h +++ b/src/avclan/statustimer.h @@ -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 diff --git a/src/avclan/target/avr-attiny3216/media_avr.h b/src/avclan/target/avr-attiny3216/media_avr.h index 64a7046..14cdebd 100644 --- a/src/avclan/target/avr-attiny3216/media_avr.h +++ b/src/avclan/target/avr-attiny3216/media_avr.h @@ -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 diff --git a/src/avclan/target/avr-attiny3216/timing_avr.h b/src/avclan/target/avr-attiny3216/timing_avr.h index 0a6a770..37424cb 100644 --- a/src/avclan/target/avr-attiny3216/timing_avr.h +++ b/src/avclan/target/avr-attiny3216/timing_avr.h @@ -1,8 +1,7 @@ // Copyright (C) 2015 Allen Hill // 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 diff --git a/src/avclan/timing.h b/src/avclan/timing.h index 88df522..111137a 100644 --- a/src/avclan/timing.h +++ b/src/avclan/timing.h @@ -1,8 +1,7 @@ // Copyright (C) 2015 Allen Hill // 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 diff --git a/src/board.h b/src/board.h index c9d8cda..1ae956e 100644 --- a/src/board.h +++ b/src/board.h @@ -1,8 +1,11 @@ // Copyright (C) 2026 Allen Hill // 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 diff --git a/src/com232.h b/src/com232.h index f90068d..ee1b3b6 100644 --- a/src/com232.h +++ b/src/com232.h @@ -3,11 +3,14 @@ // Copyright (C) 2015 Allen Hill // SPDX-License-Identifier: GPL-3.0-or-later -#ifndef __COM232_H -#define __COM232_H +#pragma once #include +#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 diff --git a/src/queue.h b/src/queue.h index a24c3ae..afe04c3 100644 --- a/src/queue.h +++ b/src/queue.h @@ -5,6 +5,10 @@ #include +#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