From d9bac8da6126b30e4c59c895fde0ece54686cb39 Mon Sep 17 00:00:00 2001 From: roman Date: Sun, 10 Dec 2023 21:33:38 +0300 Subject: [PATCH] Pre-merge commit. --- CMakeLists.txt | 2 +- TxChannel/TxChannel.c | 13 +---------- WSPRbeacon/WSPRbeacon.c | 2 +- core1.c | 5 ++-- defines.h | 2 +- main.c | 51 +++++++++++++++++++++++++++++++++-------- pico-hf-oscillator | 2 +- 7 files changed, 48 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d947d8..07d7074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ project(pico-wspr-tx C CXX ASM) pico_sdk_init() add_executable(pico-wspr-tx) -pico_generate_pio_header(pico-wspr-tx ${CMAKE_CURRENT_LIST_DIR}/pico-hf-oscillator/piodco/dco.pio) +pico_generate_pio_header(pico-wspr-tx ${CMAKE_CURRENT_LIST_DIR}/pico-hf-oscillator/piodco/dco2.pio) target_sources(pico-wspr-tx PUBLIC ${CMAKE_CURRENT_LIST_DIR}/pico-hf-oscillator/lib/assert.c diff --git a/TxChannel/TxChannel.c b/TxChannel/TxChannel.c index c35b607..cb9422a 100644 --- a/TxChannel/TxChannel.c +++ b/TxChannel/TxChannel.c @@ -113,7 +113,7 @@ TxChannelContext *TxChannelInit(const uint32_t bit_period_us, uint8_t timer_alar /// @return A count of bytes. uint8_t TxChannelPending(TxChannelContext *pctx) { - return 256 + pctx->_ix_input - pctx->_ix_output; + return 256L + (int)pctx->_ix_input - (int)pctx->_ix_output; } /// @brief Push a number of bytes to the output FIFO. @@ -154,14 +154,3 @@ void TxChannelClear(TxChannelContext *pctx) { pctx->_ix_input = pctx->_ix_output = 0; } -/* -void TxChannelStart(TxChannelContext *pctx) -{ - pctx->_b_allowtx = YES; -} - -void TxChannelStop(TxChannelContext *pctx) -{ - pctx->_b_allowtx = NO; -} -*/ diff --git a/WSPRbeacon/WSPRbeacon.c b/WSPRbeacon/WSPRbeacon.c index 9fb00fc..bcaac6b 100644 --- a/WSPRbeacon/WSPRbeacon.c +++ b/WSPRbeacon/WSPRbeacon.c @@ -113,7 +113,7 @@ int WSPRbeaconSendPacket(const WSPRbeaconContext *pctx) { assert_(pctx); assert_(pctx->_pTX); - assert_(pctx->_pTX->_u32_dialfreqhz > 1100 * kHz); + assert_(pctx->_pTX->_u32_dialfreqhz > 500 * kHz); TxChannelClear(pctx->_pTX); diff --git a/core1.c b/core1.c index ea14363..d107e45 100644 --- a/core1.c +++ b/core1.c @@ -65,7 +65,6 @@ void Core1Entry() assert_(pWSPR); const uint32_t clkhz = PLL_SYS_MHZ * MHz; - const uint32_t freq_hz = pWSPR->_pTX->_u32_dialfreqhz; PioDco *p = pWSPR->_pTX->_p_oscillator; assert_(p); @@ -74,8 +73,8 @@ void Core1Entry() assert_(0 == PioDCOInit(p, pWSPR->_pTX->_i_tx_gpio, clkhz)); /* Set initial freq. */ - assert_(0 == PioDCOSetFreq(p, freq_hz, 0U)); + assert_(0 == PioDCOSetFreq(p, pWSPR->_pTX->_u32_dialfreqhz, 0U)); /* Run the main DCO algorithm. It spins forever. */ - PioDCOWorker(p); + PioDCOWorker2(p); } diff --git a/defines.h b/defines.h index 6fd0a4a..b942064 100644 --- a/defines.h +++ b/defines.h @@ -52,7 +52,7 @@ #ifndef DEFINESWSPR_H #define DEFINESWSPR_H -//#define DEBUG +#define DEBUG #ifdef DEBUG #define DEBUGPRINTF(x) StampPrintf(x); diff --git a/main.c b/main.c index 864cf31..13baee9 100644 --- a/main.c +++ b/main.c @@ -66,6 +66,13 @@ #include #include +#define CONFIG_GPS_SOLUTION_IS_MANDATORY NO +#define CONFIG_GPS_RELY_ON_PAST_SOLUTION NO +#define CONFIG_SCHEDULE_SKIP_SLOT_COUNT 5 +#define CONFIG_WSPR_DIAL_FREQUENCY 24926000UL // 28126000UL //7040000UL +#define CONFIG_CALLSIGN "R2BDY" +#define CONFIG_LOCATOR4 "KO85" + WSPRbeaconContext *pWSPR; int main() @@ -81,21 +88,20 @@ int main() StampPrintf("WSPR beacon init..."); WSPRbeaconContext *pWB = WSPRbeaconInit( - "R2BDY", /* the Callsign. */ - "KO85", /* the default QTH locator if GPS isn't used. */ - 16, /* Tx power, dbm. */ + CONFIG_CALLSIGN,/* the Callsign. */ + CONFIG_LOCATOR4,/* the default QTH locator if GPS isn't used. */ + 12, /* Tx power, dbm. */ &DCO, /* the PioDCO object. */ - 7040000UL, /* the dial frequency. */ + CONFIG_WSPR_DIAL_FREQUENCY, 55UL, /* the carrier freq. shift relative to dial freq. */ RFOUT_PIN /* RF output GPIO pin. */ ); assert_(pWB); pWSPR = pWB; - pWB->_txSched._u8_tx_GPS_mandatory = YES; /* Send WSPR signals only when GPS solution is active. */ - pWB->_txSched._u8_tx_GPS_past_time = YES; /* ?relying on GPS solution in the past. */ - pWB->_txSched._u8_tx_slot_skip = 5; /* 1 slot tx, 1 slot idle, etc. */ - //pWB->_txSched._u8_tx_heating_pause_min = 1; /* Give 1 minute pre-heating ere first transmition. */ + pWB->_txSched._u8_tx_GPS_mandatory = CONFIG_GPS_SOLUTION_IS_MANDATORY; + pWB->_txSched._u8_tx_GPS_past_time = CONFIG_GPS_RELY_ON_PAST_SOLUTION; + pWB->_txSched._u8_tx_slot_skip = CONFIG_SCHEDULE_SKIP_SLOT_COUNT; multicore_launch_core1(Core1Entry); StampPrintf("RF oscillator started."); @@ -106,6 +112,7 @@ int main() int tick = 0; for(;;) { + /* if(WSPRbeaconIsGPSsolutionActive(pWB)) { const char *pgps_qth = WSPRbeaconGetLastQTHLocator(pWB); @@ -115,8 +122,32 @@ int main() pWB->_pu8_locator[5] = 0x00; } } - - WSPRbeaconTxScheduler(pWB, YES); + */ + + if(pWB->_txSched._u8_tx_GPS_mandatory) + { + WSPRbeaconTxScheduler(pWB, YES); + } + else + { + StampPrintf("Omitting GPS solution, start tx now."); + PioDCOStart(pWB->_pTX->_p_oscillator); + WSPRbeaconCreatePacket(pWB); + sleep_ms(100); + WSPRbeaconSendPacket(pWB); + StampPrintf("The system will be halted when tx is completed."); + for(;;) + { + if(!TxChannelPending(pWB->_pTX)) + { + PioDCOStop(pWB->_pTX->_p_oscillator); + StampPrintf("System halted."); + } + gpio_put(PICO_DEFAULT_LED_PIN, 1); + sleep_ms(500); + gpio_put(PICO_DEFAULT_LED_PIN, 0); + } + } gpio_put(PICO_DEFAULT_LED_PIN, 1); sleep_ms(100); diff --git a/pico-hf-oscillator b/pico-hf-oscillator index 01dbdef..9fbd9fa 160000 --- a/pico-hf-oscillator +++ b/pico-hf-oscillator @@ -1 +1 @@ -Subproject commit 01dbdefbaf1964246bfb66383ceeccea63aa6c60 +Subproject commit 9fbd9fa407423c89af9c4878340e71446c948f66