first commit
This commit is contained in:
+1108
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* cw_decoder.h
|
||||
*
|
||||
* Created on: 07.09.2017
|
||||
* Author: danilo
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_CW_CW_DECODER_H_
|
||||
#define AUDIO_CW_CW_DECODER_H_
|
||||
|
||||
#define CW_DECODER_BLOCKSIZE_MIN 8
|
||||
#define CW_DECODER_BLOCKSIZE_MAX 128
|
||||
#define CW_DECODER_BLOCKSIZE_DEFAULT 88
|
||||
|
||||
#define CW_DECODER_THRESH_MIN 1000
|
||||
#define CW_DECODER_THRESH_MAX 50000
|
||||
#define CW_DECODER_THRESH_DEFAULT 32000
|
||||
|
||||
#define CW_DECODER_FLAGS_DEFAULT (0b110001) // NOISECANCEL_ENABLE, SNAP_ENABLE, SHOW_CW_LED
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float32_t sampling_freq;
|
||||
float32_t target_freq;
|
||||
// float32_t speed;
|
||||
uint8_t speed;
|
||||
// uint8_t average;
|
||||
uint32_t thresh;
|
||||
uint8_t blocksize;
|
||||
|
||||
// uint8_t AGC_enable;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t noisecancel_enable:1;
|
||||
uint16_t spikecancel:2;
|
||||
#define CW_SPIKECANCEL_MODE_OFF 0
|
||||
#define CW_SPIKECANCEL_MODE_SPIKE 1
|
||||
#define CW_SPIKECANCEL_MODE_SHORT 2
|
||||
uint16_t use_3_goertzels:1;
|
||||
uint16_t snap_enable:1;
|
||||
uint16_t show_CW_LED:1; // menu choice whether the user wants the CW LED indicator to be working or not
|
||||
};
|
||||
uint16_t flags;
|
||||
};
|
||||
} cw_config_t;
|
||||
|
||||
extern cw_config_t cw_decoder_config;
|
||||
|
||||
|
||||
void CwDecode_RxProcessor(float32_t * const src, int16_t blockSize);
|
||||
void CwDecode_Filter_Set(void);
|
||||
//void CW_Decoder_WPM_display_erase(void);
|
||||
void CwDecoder_WpmDisplayUpdate(bool force_update);
|
||||
void CwDecoder_WpmDisplayClearOrPrepare(bool prepare);
|
||||
|
||||
#endif /* AUDIO_CW_CW_DECODER_H_ */
|
||||
+1100
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; coding: utf-8 -*- */
|
||||
/************************************************************************************
|
||||
** **
|
||||
** mcHF QRP Transceiver **
|
||||
** K Atanassov - M0NKA 2014 **
|
||||
** **
|
||||
**---------------------------------------------------------------------------------**
|
||||
** **
|
||||
** File name: **
|
||||
** Description: **
|
||||
** Last Modified: **
|
||||
** Licence: GNU GPLv3 **
|
||||
************************************************************************************/
|
||||
#ifndef __CW_GEN_H
|
||||
#define __CW_GEN_H
|
||||
|
||||
#include "arm_math.h"
|
||||
|
||||
void CwGen_Init(void);
|
||||
|
||||
void CwGen_PrepareTx(void);
|
||||
void CwGen_SetSpeed(void);
|
||||
|
||||
bool CwGen_Process( float32_t *i_buffer, float32_t *q_buffer, uint32_t size );
|
||||
|
||||
// As showed tests calling them (CwGen_DahIRQ & CwGen_DitIRQ) is matter only for Ultimatic mode.
|
||||
// After change code to work in this mode w/o them, these extra dependencies with low-level layers could be removed.
|
||||
void CwGen_DahIRQ(void);
|
||||
void CwGen_DitIRQ(void);
|
||||
|
||||
uint8_t CwGen_CharacterIdFunc( uint32_t );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,146 @@
|
||||
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; coding: utf-8 -*- */
|
||||
/************************************************************************************
|
||||
** **
|
||||
** UHSDR **
|
||||
** a powerful firmware for STM32 based SDR transceivers **
|
||||
** **
|
||||
**--------------------------------------------------------------------------------**
|
||||
** **
|
||||
** Description: Please provide one **
|
||||
** Licence: GNU GPLv3 **
|
||||
************************************************************************************/
|
||||
#include <assert.h>
|
||||
#include "ui_driver.h" // for pushing into UI buffer
|
||||
#include "uhsdr_digi_buffer.h"
|
||||
|
||||
#define DIGIMODES_TX_BUFFER_SIZE 128
|
||||
|
||||
static __IO uint8_t digimodes_tx_buffer[DIGIMODES_TX_BUFFER_SIZE];
|
||||
static __IO int32_t digimodes_tx_buffer_head = 0;
|
||||
static __IO int32_t digimodes_tx_tail = 0;
|
||||
static __IO uint32_t active_consumer = 0;
|
||||
|
||||
// keeps prev consumer to restore it by calling DigiModes_Restore_BufferConsumer();
|
||||
static __IO uint32_t prev_consumer = CW;
|
||||
|
||||
void DigiModes_Restore_BufferConsumer()
|
||||
{
|
||||
active_consumer = prev_consumer;
|
||||
}
|
||||
|
||||
/*
|
||||
* The UI consumer has higher priority to protect it by changing modes.
|
||||
* UI should release buffer by calling DigiModes_Restore_BufferConsumer()
|
||||
*/
|
||||
digi_buff_consumer_t DigiModes_Set_BufferConsumer( digi_buff_consumer_t consumer )
|
||||
{
|
||||
assert((consumer & RTTY) || (consumer & BPSK) || (consumer & CW) || (consumer & UI));
|
||||
if ( active_consumer == UI ) // <- UI has higher priority
|
||||
{
|
||||
prev_consumer = consumer; // in case we change mode
|
||||
return prev_consumer;
|
||||
}
|
||||
prev_consumer = active_consumer;
|
||||
active_consumer = consumer;
|
||||
return prev_consumer;
|
||||
}
|
||||
|
||||
uint8_t DigiModes_TxBufferHasData()
|
||||
{
|
||||
int32_t len = digimodes_tx_buffer_head - digimodes_tx_tail;
|
||||
return len < 0 ? ( len + DIGIMODES_TX_BUFFER_SIZE ) : len;
|
||||
}
|
||||
|
||||
bool DigiModes_TxBufferRemove( uint8_t* c_ptr, digi_buff_consumer_t consumer )
|
||||
{
|
||||
assert( c_ptr );
|
||||
assert((consumer & RTTY) || (consumer & BPSK) || (consumer & CW) || (consumer & UI));
|
||||
|
||||
bool retval = false;
|
||||
|
||||
if ( consumer == active_consumer && digimodes_tx_buffer_head != digimodes_tx_tail)
|
||||
{
|
||||
*c_ptr = digimodes_tx_buffer[digimodes_tx_tail];
|
||||
digimodes_tx_tail = (digimodes_tx_tail + 1) % DIGIMODES_TX_BUFFER_SIZE;
|
||||
|
||||
// push removed char to UI buffer to display it on the screen.
|
||||
// characters for UI and CW prints when they add to digi_buffer
|
||||
if ( active_consumer == RTTY || active_consumer == BPSK )
|
||||
{
|
||||
UiDriver_TextMsgPutChar( *c_ptr );
|
||||
}
|
||||
retval = true;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* no room left in the buffer returns 0 */
|
||||
int32_t DigiModes_TxBufferPutChar( uint8_t c, digi_buff_consumer_t source )
|
||||
{
|
||||
assert((source & CW) || (source & KeyBoard) || (source & UI));
|
||||
|
||||
int32_t ret = 0;
|
||||
/*
|
||||
* In case when source and consumer are equal we just
|
||||
* print on the screen without putting into digi_buffer
|
||||
* to prevent from infinite loop
|
||||
* ( CW working as a source and receiver at the same time )
|
||||
*/
|
||||
if ( active_consumer == source )
|
||||
{
|
||||
if(!(ts.dmod_mode == DEMOD_CW && !ts.cw_decoder_enable))
|
||||
{
|
||||
UiDriver_TextMsgPutChar( c );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t next_head = (digimodes_tx_buffer_head + 1) % DIGIMODES_TX_BUFFER_SIZE;
|
||||
if (next_head != digimodes_tx_tail)
|
||||
{
|
||||
/* there is room */
|
||||
digimodes_tx_buffer[digimodes_tx_buffer_head] = c;
|
||||
digimodes_tx_buffer_head = next_head;
|
||||
/*
|
||||
* If the consumer is UI we print on the screen
|
||||
* right the way on the inputing text into buffer
|
||||
*/
|
||||
if ( active_consumer == UI )
|
||||
{
|
||||
if(!(ts.dmod_mode == DEMOD_CW && !ts.cw_decoder_enable))
|
||||
{
|
||||
UiDriver_TextMsgPutChar( c );
|
||||
}
|
||||
}
|
||||
ret ++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DigiModes_TxBufferPutSign( const char* s, digi_buff_consumer_t source )
|
||||
{
|
||||
assert( s );
|
||||
assert((source & CW) || (source & KeyBoard));
|
||||
|
||||
DigiModes_TxBufferPutChar( '<', source );
|
||||
DigiModes_TxBufferPutChar( s[0], source );
|
||||
DigiModes_TxBufferPutChar( s[1], source );
|
||||
DigiModes_TxBufferPutChar( '>', source );
|
||||
}
|
||||
|
||||
void DigiModes_TxBufferReset()
|
||||
{
|
||||
digimodes_tx_tail = digimodes_tx_buffer_head;
|
||||
}
|
||||
|
||||
#if defined(_UNIT_TEST_)
|
||||
uint32_t DigiModes_TxBufferGetCurrentConsumer( void )
|
||||
{
|
||||
return active_consumer;
|
||||
}
|
||||
uint32_t DigiModes_TxBufferGetPrevConsumer( void )
|
||||
{
|
||||
return prev_consumer;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; coding: utf-8 -*- */
|
||||
/************************************************************************************
|
||||
** **
|
||||
** UHSDR **
|
||||
** a powerful firmware for STM32 based SDR transceivers **
|
||||
** **
|
||||
**--------------------------------------------------------------------------------**
|
||||
** **
|
||||
** Description: Please provide one **
|
||||
** Licence: GNU GPLv3 **
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __UHSDR_DIGI_BUFFER_H
|
||||
#define __UHSDR_DIGI_BUFFER_H
|
||||
|
||||
#include "uhsdr_types.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RTTY = 1,
|
||||
BPSK = 2,
|
||||
CW = 4,
|
||||
UI = 8,
|
||||
KeyBoard = 16, // <- keyboard should be used as a source only
|
||||
} digi_buff_consumer_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t DigiModes_TxBufferHasData(void);
|
||||
|
||||
/*
|
||||
* The Digi buffer has multi consumers, some of them trying to get an entry
|
||||
* from the buffer at the same time.
|
||||
* to organize it, the allowed consumer for buffer should be set before using it.
|
||||
*
|
||||
* @return - previous consumer
|
||||
*/
|
||||
digi_buff_consumer_t DigiModes_Set_BufferConsumer( digi_buff_consumer_t consumer );
|
||||
void DigiModes_Restore_BufferConsumer(void);
|
||||
|
||||
/*
|
||||
* @return - true if element was removed from buffer and available in c_ptr
|
||||
* false if there is no elements in buffer or this consumer not
|
||||
* allowed to remove elements from buffer.
|
||||
*/
|
||||
bool DigiModes_TxBufferRemove( uint8_t* c_ptr, digi_buff_consumer_t consumer );
|
||||
|
||||
int32_t DigiModes_TxBufferPutChar( uint8_t c, digi_buff_consumer_t source );
|
||||
void DigiModes_TxBufferPutSign( const char* s, digi_buff_consumer_t source );
|
||||
|
||||
void DigiModes_TxBufferReset( );
|
||||
|
||||
#if defined(_UNIT_TEST_)
|
||||
uint32_t DigiModes_TxBufferGetCurrentConsumer( void );
|
||||
uint32_t DigiModes_TxBufferGetPrevConsumer( void );
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // __UHSDR_DIGI_BUFFER_H
|
||||
Reference in New Issue
Block a user