From 24c4a25b2d86b654af8b72571d0d2f5157bf1a3c Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Tue, 26 Dec 2023 11:12:31 +0100 Subject: [PATCH] Made "static" all the variables local to each translation unit --- openrtx/include/core/state.h | 4 ++-- openrtx/src/core/state.c | 8 ++++--- openrtx/src/rtx/rtx.cpp | 20 ++++++++---------- platform/drivers/ADC/ADC1_MDx.c | 2 +- platform/drivers/ADC/ADC1_Mod17.c | 2 +- platform/drivers/audio/stm32_adc.cpp | 2 +- platform/drivers/baseband/radio_GDx.cpp | 16 +++++++------- platform/drivers/baseband/radio_MD3x0.cpp | 18 ++++++++-------- platform/drivers/baseband/radio_Mod17.cpp | 4 ++-- platform/drivers/baseband/radio_UV3x0.cpp | 22 ++++++++++---------- platform/drivers/baseband/radio_ttwrplus.cpp | 10 ++++----- platform/drivers/display/display_libSDL.c | 4 ++-- 12 files changed, 56 insertions(+), 56 deletions(-) diff --git a/openrtx/include/core/state.h b/openrtx/include/core/state.h index 0ae5bde2..d29a66e0 100644 --- a/openrtx/include/core/state.h +++ b/openrtx/include/core/state.h @@ -64,8 +64,8 @@ typedef struct } state_t; -extern uint32_t freq_steps[]; -extern size_t n_freq_steps; +extern const uint32_t freq_steps[]; +extern const size_t n_freq_steps; enum TunerMode { diff --git a/openrtx/src/core/state.c b/openrtx/src/core/state.c index 5fa09b27..4404d94a 100644 --- a/openrtx/src/core/state.c +++ b/openrtx/src/core/state.c @@ -32,11 +32,13 @@ state_t state; pthread_mutex_t state_mutex; -long long int lastUpdate = 0; +static long long int lastUpdate = 0; // Commonly used frequency steps, expressed in Hz -uint32_t freq_steps[] = { 1000, 5000, 6250, 10000, 12500, 15000, 20000, 25000, 50000, 100000 }; -size_t n_freq_steps = sizeof(freq_steps) / sizeof(freq_steps[0]); +const uint32_t freq_steps[] = { 1000, 5000, 6250, 10000, 12500, 15000, + 20000, 25000, 50000, 100000 }; +const size_t n_freq_steps = sizeof(freq_steps) / sizeof(freq_steps[0]); + void state_init() { diff --git a/openrtx/src/rtx/rtx.cpp b/openrtx/src/rtx/rtx.cpp index c4546c04..2db32a99 100644 --- a/openrtx/src/rtx/rtx.cpp +++ b/openrtx/src/rtx/rtx.cpp @@ -24,18 +24,16 @@ #include #include -pthread_mutex_t *cfgMutex; // Mutex for incoming config messages +static pthread_mutex_t *cfgMutex; // Mutex for incoming config messages +static const rtxStatus_t *newCnf; // Pointer for incoming config messages +static rtxStatus_t rtxStatus; // RTX driver status +static float rssi; // Current RSSI in dBm +static bool reinitFilter; // Flag for RSSI filter re-initialisation -const rtxStatus_t *newCnf; // Pointer for incoming config messages -rtxStatus_t rtxStatus; // RTX driver status - -float rssi; // Current RSSI in dBm -bool reinitFilter; // Flag for RSSI filter re-initialisation - -OpMode *currMode; // Pointer to currently active opMode handler -OpMode noMode; // Empty opMode handler for opmode::NONE -OpMode_FM fmMode; // FM mode handler -OpMode_M17 m17Mode; // M17 mode handler +static OpMode *currMode; // Pointer to currently active opMode handler +static OpMode noMode; // Empty opMode handler for opmode::NONE +static OpMode_FM fmMode; // FM mode handler +static OpMode_M17 m17Mode; // M17 mode handler void rtx_init(pthread_mutex_t *m) { diff --git a/platform/drivers/ADC/ADC1_MDx.c b/platform/drivers/ADC/ADC1_MDx.c index 6ff35c36..c3456a2a 100644 --- a/platform/drivers/ADC/ADC1_MDx.c +++ b/platform/drivers/ADC/ADC1_MDx.c @@ -22,7 +22,7 @@ #include #include "ADC1_MDx.h" -pthread_mutex_t adcMutex; +static pthread_mutex_t adcMutex; void adc1_init() { diff --git a/platform/drivers/ADC/ADC1_Mod17.c b/platform/drivers/ADC/ADC1_Mod17.c index 6f843af4..d1e6d7d8 100644 --- a/platform/drivers/ADC/ADC1_Mod17.c +++ b/platform/drivers/ADC/ADC1_Mod17.c @@ -22,7 +22,7 @@ #include #include "ADC1_Mod17.h" -pthread_mutex_t adcMutex; +static pthread_mutex_t adcMutex; void adc1_init() { diff --git a/platform/drivers/audio/stm32_adc.cpp b/platform/drivers/audio/stm32_adc.cpp index d5920b42..6f4a6a0a 100644 --- a/platform/drivers/audio/stm32_adc.cpp +++ b/platform/drivers/audio/stm32_adc.cpp @@ -40,7 +40,7 @@ StreamHandler Dma2_Stream0_hdl = Dma2_Stream0::init(10, DataSize::_16BIT, false) StreamHandler Dma2_Stream1_hdl = Dma2_Stream1::init(10, DataSize::_16BIT, false); StreamHandler Dma2_Stream2_hdl = Dma2_Stream2::init(10, DataSize::_16BIT, false); -struct streamCtx *AdcContext[3]; +static struct streamCtx *AdcContext[3]; static constexpr AdcPeriph periph[] = { diff --git a/platform/drivers/baseband/radio_GDx.cpp b/platform/drivers/baseband/radio_GDx.cpp index 65fa30b5..caed49d1 100644 --- a/platform/drivers/baseband/radio_GDx.cpp +++ b/platform/drivers/baseband/radio_GDx.cpp @@ -29,17 +29,17 @@ #include "HR_C6000.h" #include "AT1846S.h" -const rtxStatus_t *config; // Pointer to data structure with radio configuration +static const rtxStatus_t *config; // Pointer to data structure with radio configuration -static gdxCalibration_t calData; // Calibration data -Band currRxBand = BND_NONE; // Current band for RX -Band currTxBand = BND_NONE; // Current band for TX -uint16_t apcVoltage = 0; // APC voltage for TX output power control +static gdxCalibration_t calData; // Calibration data +static Band currRxBand = BND_NONE; // Current band for RX +static Band currTxBand = BND_NONE; // Current band for TX +static uint16_t apcVoltage = 0; // APC voltage for TX output power control -enum opstatus radioStatus; // Current operating status +static enum opstatus radioStatus; // Current operating status -HR_C6000& C6000 = HR_C6000::instance(); // HR_C5000 driver -AT1846S& at1846s = AT1846S::instance(); // AT1846S driver +static HR_C6000& C6000 = HR_C6000::instance(); // HR_C5000 driver +static AT1846S& at1846s = AT1846S::instance(); // AT1846S driver void radio_init(const rtxStatus_t *rtxState) { diff --git a/platform/drivers/baseband/radio_MD3x0.cpp b/platform/drivers/baseband/radio_MD3x0.cpp index 73602a66..a3a1671a 100644 --- a/platform/drivers/baseband/radio_MD3x0.cpp +++ b/platform/drivers/baseband/radio_MD3x0.cpp @@ -30,19 +30,19 @@ #include "HR_C5000.h" #include "SKY72310.h" -static const freq_t IF_FREQ = 49950000; // Intermediate frequency: 49.95MHz +static const freq_t IF_FREQ = 49950000; // Intermediate frequency: 49.95MHz -const rtxStatus_t *config; // Pointer to data structure with radio configuration +static const rtxStatus_t *config; // Pointer to data structure with radio configuration -static md3x0Calib_t calData; // Calibration data -bool isVhfBand = false; // True if rtx stage is for VHF band -uint8_t vtune_rx = 0; // Tuning voltage for RX input filter -uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power -uint8_t txpwr_hi = 0; // APC voltage for TX output power control, high power +static md3x0Calib_t calData; // Calibration data +static bool isVhfBand = false; // True if rtx stage is for VHF band +static uint8_t vtune_rx = 0; // Tuning voltage for RX input filter +static uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power +static uint8_t txpwr_hi = 0; // APC voltage for TX output power control, high power -enum opstatus radioStatus; // Current operating status +static enum opstatus radioStatus; // Current operating status -HR_C5000& C5000 = HR_C5000::instance(); // HR_C5000 driver +static HR_C5000& C5000 = HR_C5000::instance(); // HR_C5000 driver /* * Parameters for RSSI voltage (mV) to input power (dBm) conversion. diff --git a/platform/drivers/baseband/radio_Mod17.cpp b/platform/drivers/baseband/radio_Mod17.cpp index f51b0cee..486f0f19 100644 --- a/platform/drivers/baseband/radio_Mod17.cpp +++ b/platform/drivers/baseband/radio_Mod17.cpp @@ -25,8 +25,8 @@ #include #include "../audio/MAX9814.h" -enum opstatus radioStatus; // Current operating status -extern mod17Calib_t mod17CalData; // Calibration data +static enum opstatus radioStatus; // Current operating status +extern mod17Calib_t mod17CalData; // Calibration data void radio_init(const rtxStatus_t *rtxState) diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index f6302ea4..f077abe4 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -31,20 +31,20 @@ #include "AT1846S.h" -const rtxStatus_t *config; // Pointer to data structure with radio configuration +static const rtxStatus_t *config; // Pointer to data structure with radio configuration -static mduv3x0Calib_t calData; // Calibration data -Band currRxBand = BND_NONE; // Current band for RX -Band currTxBand = BND_NONE; // Current band for TX -uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power -uint8_t txpwr_hi = 0; // APC voltage for TX output power control, high power -uint8_t rxModBias = 0; // VCXO bias for RX -uint8_t txModBias = 0; // VCXO bias for TX +static mduv3x0Calib_t calData; // Calibration data +static Band currRxBand = BND_NONE; // Current band for RX +static Band currTxBand = BND_NONE; // Current band for TX +static uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power +static uint8_t txpwr_hi = 0; // APC voltage for TX output power control, high power +static uint8_t rxModBias = 0; // VCXO bias for RX +static uint8_t txModBias = 0; // VCXO bias for TX -enum opstatus radioStatus; // Current operating status +static enum opstatus radioStatus; // Current operating status -HR_C6000& C6000 = HR_C6000::instance(); // HR_C5000 driver -AT1846S& at1846s = AT1846S::instance(); // AT1846S driver +static HR_C6000& C6000 = HR_C6000::instance(); // HR_C5000 driver +static AT1846S& at1846s = AT1846S::instance(); // AT1846S driver void radio_init(const rtxStatus_t *rtxState) { diff --git a/platform/drivers/baseband/radio_ttwrplus.cpp b/platform/drivers/baseband/radio_ttwrplus.cpp index 1bef6aab..96442300 100644 --- a/platform/drivers/baseband/radio_ttwrplus.cpp +++ b/platform/drivers/baseband/radio_ttwrplus.cpp @@ -25,13 +25,13 @@ #include "AT1846S.h" #include "SA8x8.h" -const rtxStatus_t *config; // Pointer to data structure with radio configuration +static const rtxStatus_t *config; // Pointer to data structure with radio configuration -Band currRxBand = BND_NONE; // Current band for RX -Band currTxBand = BND_NONE; // Current band for TX -enum opstatus radioStatus; // Current operating status +static Band currRxBand = BND_NONE; // Current band for RX +static Band currTxBand = BND_NONE; // Current band for TX +static enum opstatus radioStatus; // Current operating status -AT1846S& at1846s = AT1846S::instance(); // AT1846S driver +static AT1846S& at1846s = AT1846S::instance(); // AT1846S driver void radio_init(const rtxStatus_t *rtxState) diff --git a/platform/drivers/display/display_libSDL.c b/platform/drivers/display/display_libSDL.c index 397f289a..4548467c 100644 --- a/platform/drivers/display/display_libSDL.c +++ b/platform/drivers/display/display_libSDL.c @@ -32,8 +32,8 @@ #include #include -void *frameBuffer = NULL; /* Pointer to framebuffer */ -bool inProgress; /* Flag to signal when rendering is in progress */ +static void *frameBuffer = NULL; /* Pointer to framebuffer */ +static bool inProgress; /* Flag to signal when rendering is in progress */ /* * SDL main loop syncronization