Skip to content

Commit

Permalink
It works. Eureka. The standard WSJT-X software has received the signa…
Browse files Browse the repository at this point in the history
…l emmited by pico's GP6 leg! No additional hw.
  • Loading branch information
RPiks committed Nov 16, 2023
1 parent 78a9431 commit 5d1e1b6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 13 deletions.
16 changes: 15 additions & 1 deletion TxChannel/TxChannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void __not_in_flash_func (TxChannelISR)(void)
if(n2send)
{
PioDCOSetFreq(pDCO, spTX->_u32_dialfreqhz,
byte * FREQ_STEP_MILLIHERTZ);
(uint32_t)byte * WSPR_FREQ_STEP_MILHZ);
}

spTX->_tm_future_call += spTX->_bit_period_us;
Expand Down Expand Up @@ -104,11 +104,19 @@ TxChannelContext *TxChannelInit(const uint32_t bit_period_us, uint8_t timer_alar
return p;
}

/// @brief Gets a count of bytes to send.
/// @param pctx Context.
/// @return A count of bytes.
uint8_t TxChannelPending(TxChannelContext *pctx)
{
return 256 + pctx->_ix_input - pctx->_ix_output;
}

/// @brief Push a number of bytes to the output FIFO.
/// @param pctx Context.
/// @param psrc Ptr to buffer to send.
/// @param n A count of bytes to send.
/// @return A count of bytes has been sent (might be lower than n).
int TxChannelPush(TxChannelContext *pctx, uint8_t *psrc, int n)
{
uint8_t *pdst = pctx->_pbyte_buffer;
Expand All @@ -120,6 +128,10 @@ int TxChannelPush(TxChannelContext *pctx, uint8_t *psrc, int n)
return n;
}

/// @brief Retrieves a next byte from FIFO.
/// @param pctx Context.
/// @param pdst Ptr to write a byte.
/// @return 1 if a byte has been retrived, or 0.
int TxChannelPop(TxChannelContext *pctx, uint8_t *pdst)
{
if(pctx->_ix_input != pctx->_ix_output)
Expand All @@ -132,6 +144,8 @@ int TxChannelPop(TxChannelContext *pctx, uint8_t *pdst)
return 0;
}

/// @brief Clears FIFO completely. Sets write&read indexes to 0.
/// @param pctx Context.
void TxChannelClear(TxChannelContext *pctx)
{
pctx->_ix_input = pctx->_ix_output = 0;
Expand Down
2 changes: 0 additions & 2 deletions TxChannel/TxChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
#include "../pico-hf-oscillator/lib/assert.h"
#include <piodco.h>

#define FREQ_STEP_MILLIHERTZ 1465

typedef struct
{
uint64_t _tm_future_call;
Expand Down
19 changes: 19 additions & 0 deletions WSPRbeacon/WSPRbeacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

#include <WSPRutility.h>

/// @brief Initializes a new WSPR beacon context.
/// @param pcallsign HAM radio callsign, 12 chr max.
/// @param pgridsquare Maidenhead locator, 7 chr max.
/// @param txpow_dbm TX power, db`mW.
/// @param pdco Ptr to working DCO.
/// @return the context.
WSPRbeaconContext *WSPRbeaconInit(const char *pcallsign, const char *pgridsquare, int txpow_dbm,
PioDco *pdco)
{
Expand All @@ -20,19 +26,30 @@ WSPRbeaconContext *WSPRbeaconInit(const char *pcallsign, const char *pgridsquare
return p;
}

/// @brief Sets dial (baseband minima) freq.
/// @param pctx Context.
/// @param freq_hz the freq., Hz.
void WSPRbeaconSetDialFreq(WSPRbeaconContext *pctx, uint32_t freq_hz)
{
assert_(pctx);
pctx->_pTX->_u32_dialfreqhz = freq_hz;
}

/// @brief Constructs a new WSPR packet using the data available.
/// @param pctx Context
/// @return 0 if OK.
int WSPRbeaconCreatePacket(WSPRbeaconContext *pctx)
{
assert_(pctx);

wspr_encode(pctx->_pu8_callsign, pctx->_pu8_locator, pctx->_u8_txpower, pctx->_pu8_outbuf);

return 0;
}

/// @brief Sends a prepared WSPR packet using TxChannel.
/// @param pctx Context.
/// @return 0, if OK.
int WSPRbeaconSendPacket(const WSPRbeaconContext *pctx)
{
assert_(pctx);
Expand All @@ -41,4 +58,6 @@ int WSPRbeaconSendPacket(const WSPRbeaconContext *pctx)

memcpy(pctx->_pTX->_pbyte_buffer, pctx->_pu8_outbuf, WSPR_SYMBOL_COUNT);
pctx->_pTX->_ix_input += WSPR_SYMBOL_COUNT;

return 0;
}
3 changes: 1 addition & 2 deletions core1.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

extern PioDco DCO;

/* This is the code of dedicated core.
We deal with extremely precise real-time task. */
/// @brief The code of dedicated core' program running HF oscillator.
void Core1Entry()
{
const uint32_t clkhz = PLL_SYS_MHZ * MHz;
Expand Down
12 changes: 6 additions & 6 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

/* Performing the square by ASM. */
#define iSquare32ASM(x) (iMUL32ASM((x), (x)))

/* Hardware defs. */
/* Hardware defs. */
#define kHz 1000UL
#define MHz 1000000UL
#define PLL_SYS_MHZ 270UL

/* WSPR defs. */
#define WSPR_DIAL_FREQ_HZ 7040000UL
#define WSPR_SHIFT_FREQ_HZ 88UL
/* WSPR defs. */
#define WSPR_DIAL_FREQ_HZ 7040000UL
#define WSPR_SHIFT_FREQ_HZ 50UL
//#define WSPR_FREQ_STEP_MILHZ 1465UL
#define WSPR_FREQ_STEP_MILHZ 2930UL

#endif
1 change: 1 addition & 0 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "defines.h"

/// @brief Initializes Pi pico low level hardware.
void InitPicoHW(void)
{
gpio_init(PICO_DEFAULT_LED_PIN);
Expand Down
8 changes: 6 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main()
InitPicoHW();

DEBUGPRINTF("WSPR beacon init...");
WSPRbeaconContext *pWB = WSPRbeaconInit("R2BDY/QRPX", "KO85", 6, &DCO);
WSPRbeaconContext *pWB = WSPRbeaconInit("R2BDY", "KO85", 6, &DCO);
WSPRbeaconSetDialFreq(pWB, WSPR_DIAL_FREQ_HZ + WSPR_SHIFT_FREQ_HZ);
DEBUGPRINTF("OK");

Expand All @@ -99,9 +99,13 @@ int main()
}
}

/// @brief Frequency shift keying modulator wrapper.
/// @param frq_step_millihz Shift step, milliHertz.
/// @param shift_index Shift index, [0..3] for WSPR.
/// @return 0 if OK.
int FSK4mod(uint32_t frq_step_millihz, uint8_t shift_index)
{
PioDCOSetFreq(&DCO, WSPR_DIAL_FREQ_HZ + WSPR_SHIFT_FREQ_HZ,
frq_step_millihz * shift_index);
frq_step_millihz * (uint32_t)shift_index);
return 0;
}

0 comments on commit 5d1e1b6

Please sign in to comment.