Reverted to original CPLD data

This commit is contained in:
furrtek 2017-01-29 06:50:48 +00:00
parent 17451d840a
commit 693a2533b5
19 changed files with 86 additions and 138 deletions

View file

@ -28,7 +28,7 @@ set(CHIBIOS_PORTAPACK ${PROJECT_SOURCE_DIR}/chibios-portapack)
set(HACKRF_FIRMWARE_FILENAME hackrf_one_usb_ram.dfu) set(HACKRF_FIRMWARE_FILENAME hackrf_one_usb_ram.dfu)
set(HACKRF_FIRMWARE_IMAGE ${PROJECT_SOURCE_DIR}/${HACKRF_FIRMWARE_FILENAME}) set(HACKRF_FIRMWARE_IMAGE ${PROJECT_SOURCE_DIR}/${HACKRF_FIRMWARE_FILENAME})
set(HACKRF_CPLD_SVF_FILENAME hackrf_cpld_portapack.svf) set(HACKRF_CPLD_SVF_FILENAME hackrf_cpld_default.svf)
set(HACKRF_CPLD_SVF_PATH ${PROJECT_SOURCE_DIR}/${HACKRF_CPLD_SVF_FILENAME}) set(HACKRF_CPLD_SVF_PATH ${PROJECT_SOURCE_DIR}/${HACKRF_CPLD_SVF_FILENAME})
set(EXTRACT_CPLD_DATA ${PROJECT_SOURCE_DIR}/tools/extract_cpld_data.py) set(EXTRACT_CPLD_DATA ${PROJECT_SOURCE_DIR}/tools/extract_cpld_data.py)

View file

@ -23,8 +23,11 @@
// Color bitmaps generated with: // Color bitmaps generated with:
// Gimp image > indexed colors (16), then "xxd -i *.bmp" // Gimp image > indexed colors (16), then "xxd -i *.bmp"
//BUG: Distorted audio in WFM receiver
//BUG: (fixed ?) Bad console scroll init //BUG: (fixed ?) Bad console scroll init
//BUG: POCSAG misses alphanum messages, cuts them off sometimes //BUG: POCSAG misses alphanum messages, cuts them off sometimes
//BUG: Check AFSK transmit end, skips last bits ?
//BUG: RDS doesn't stop baseband when stopping tx ?
//TEST: Imperial in whipcalc //TEST: Imperial in whipcalc
//TEST: Numbers //TEST: Numbers
@ -37,10 +40,6 @@
//TODO: IQ replay //TODO: IQ replay
//TODO: Wav visualizer //TODO: Wav visualizer
//BUG: POCSAG RX sometimes misses the first codeword after SYNC
//BUG: Check AFSK transmit end, skips last bits ?
//BUG: RDS doesn't stop baseband when stopping tx ?
//TODO: File browser ? //TODO: File browser ?
//TODO: Mousejack ? //TODO: Mousejack ?
//TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere) //TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)

View file

@ -30,27 +30,6 @@
#include "max2837.hpp" #include "max2837.hpp"
#include "volume.hpp" #include "volume.hpp"
struct BasebandConfiguration {
int32_t mode;
uint32_t sampling_rate;
size_t decimation_factor;
constexpr BasebandConfiguration(
int32_t mode,
uint32_t sampling_rate,
size_t decimation_factor = 1
) : mode { mode },
sampling_rate { sampling_rate },
decimation_factor { decimation_factor }
{
}
constexpr BasebandConfiguration(
) : BasebandConfiguration { -1, 0, 1 }
{
}
};
class ReceiverModel { class ReceiverModel {
public: public:
enum class Mode { enum class Mode {

View file

@ -112,8 +112,10 @@ void TransmitterModel::enable() {
signal_token_tick_second = rtc_time::signal_tick_second += [this]() { signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
this->on_tick_second(); this->on_tick_second();
}; };
if (portapack::persistent_memory::stealth_mode()) if (portapack::persistent_memory::stealth_mode()) {
EventDispatcher::set_display_sleep(true); DisplaySleepMessage message;
EventDispatcher::send_message(message);
}
} }
void TransmitterModel::disable() { void TransmitterModel::disable() {

View file

@ -64,7 +64,7 @@ void BHTView::start_tx() {
generate_message(); generate_message();
transmitter_model.set_tuning_frequency(bht_freqs[options_freq.selected_index()]); transmitter_model.set_tuning_frequency(bht_freqs[options_freq.selected_index()]);
transmitter_model.set_sampling_rate(1536000U); transmitter_model.set_sampling_rate(1536000);
transmitter_model.set_rf_amp(true); transmitter_model.set_rf_amp(true);
transmitter_model.set_lna(40); transmitter_model.set_lna(40);
transmitter_model.set_vga(40); transmitter_model.set_vga(40);
@ -78,7 +78,7 @@ void BHTView::start_tx() {
} }
audio::set_rate(audio::Rate::Hz_24000); audio::set_rate(audio::Rate::Hz_24000);
baseband::set_tones_data(field_bw.value() * 20, CCIR_SILENCE, 20, false, checkbox_speaker.value()); baseband::set_tones_data(field_bw.value(), CCIR_SILENCE, 20, false, checkbox_speaker.value());
} }
void BHTView::on_tx_progress(const int progress, const bool done) { void BHTView::on_tx_progress(const int progress, const bool done) {

View file

@ -137,7 +137,7 @@ void NuoptixView::transmit(bool setup) {
shared_memory.bb_data.tones_data.silence = NUOPTIX_TONE_LENGTH; // 49ms tone, 49ms space shared_memory.bb_data.tones_data.silence = NUOPTIX_TONE_LENGTH; // 49ms tone, 49ms space
audio::set_rate(audio::Rate::Hz_24000); audio::set_rate(audio::Rate::Hz_24000);
baseband::set_tones_data(number_bw.value() * 500, 0, 6 * 2, true, true); baseband::set_tones_data(number_bw.value(), 0, 6 * 2, true, true);
timecode++; timecode++;
} }

View file

@ -97,14 +97,14 @@ private:
NumberField number_bw { NumberField number_bw {
{ 13 * 8, 4 }, { 13 * 8, 4 },
3, 2,
{1, 150}, {1, 99},
1, 1,
' ' ' '
}; };
Text text_kHz { Text text_kHz {
{ 16 * 8, 4, 3 * 8, 16 }, { 15 * 8, 4, 3 * 8, 16 },
"kHz" "kHz"
}; };

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *

View file

@ -36,9 +36,7 @@
class AudioOutput { class AudioOutput {
public: public:
void configure( void configure(const bool do_proc);
const bool do_proc
);
void configure( void configure(
const iir_biquad_config_t& hpf_config, const iir_biquad_config_t& hpf_config,

View file

@ -115,9 +115,16 @@ static void dma_error() {
void init() { void init() {
gpdma_channel_sgpio.set_handlers(transfer_complete, dma_error); gpdma_channel_sgpio.set_handlers(transfer_complete, dma_error);
#if defined(PORTAPACK_BASEBAND_DMA_NO_SYNC)
// LPC_GPDMA->SYNC |= (1 << gpdma_src_peripheral); /* Disable synchronization logic to improve(?) DMA response time.
// LPC_GPDMA->SYNC |= (1 << gpdma_dest_peripheral); * SGPIO (peripheral) must be on same clock as GPDMA peripheral.
* SGPIO runs from BASE_PERIPH_CLK, which is set to PLL1 in normal
* operation, same as the M4 and M0 cores. Memory, of course, is
* running from the same clock as the cores.
*/
LPC_GPDMA->SYNC |= (1 << gpdma_src_peripheral);
LPC_GPDMA->SYNC |= (1 << gpdma_dest_peripheral);
#endif
} }
void configure( void configure(
@ -149,7 +156,7 @@ void disable() {
gpdma_channel_sgpio.disable(); gpdma_channel_sgpio.disable();
} }
/*baseband::buffer_t wait_for_buffer() { baseband::buffer_t wait_for_buffer() {
const auto next_index = thread_wait.sleep(); const auto next_index = thread_wait.sleep();
if( next_index >= 0 ) { if( next_index >= 0 ) {
@ -161,28 +168,6 @@ void disable() {
} else { } else {
return { }; return { };
} }
}*/
baseband::buffer_t wait_for_rx_buffer() {
const auto next_index = thread_wait.sleep();
if( next_index >= 0 ) {
const size_t free_index = (next_index + transfers_per_buffer - 2) & transfers_mask;
return { reinterpret_cast<sample_t*>(lli_loop[free_index].destaddr), transfer_samples };
} else {
return { };
}
}
baseband::buffer_t wait_for_tx_buffer() {
const auto next_index = thread_wait.sleep();
if( next_index >= 0 ) {
const size_t free_index = (next_index + transfers_per_buffer - 2) & transfers_mask;
return { reinterpret_cast<sample_t*>(lli_loop[free_index].srcaddr), transfer_samples };
} else {
return { };
}
} }
} /* namespace dma */ } /* namespace dma */

View file

@ -42,8 +42,7 @@ bool is_enabled();
void disable(); void disable();
baseband::buffer_t wait_for_rx_buffer(); baseband::buffer_t wait_for_buffer();
baseband::buffer_t wait_for_tx_buffer();
} /* namespace dma */ } /* namespace dma */
} /* namespace baseband */ } /* namespace baseband */

View file

@ -47,7 +47,7 @@ BasebandThread::BasebandThread(
uint32_t sampling_rate, uint32_t sampling_rate,
BasebandProcessor* const baseband_processor, BasebandProcessor* const baseband_processor,
const tprio_t priority, const tprio_t priority,
const baseband::Direction direction baseband::Direction direction
) : baseband_processor { baseband_processor }, ) : baseband_processor { baseband_processor },
_direction { direction }, _direction { direction },
sampling_rate { sampling_rate } sampling_rate { sampling_rate }
@ -79,10 +79,9 @@ void BasebandThread::run() {
baseband::dma::enable(direction()); baseband::dma::enable(direction());
baseband_sgpio.streaming_enable(); baseband_sgpio.streaming_enable();
if (_direction == baseband::Direction::Transmit) {
while( !chThdShouldTerminate() ) { while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here: // TODO: Place correct sampling rate into buffer returned here:
const baseband::buffer_t buffer_tmp = baseband::dma::wait_for_tx_buffer(); const auto buffer_tmp = baseband::dma::wait_for_buffer();
if( buffer_tmp ) { if( buffer_tmp ) {
buffer_c8_t buffer { buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate buffer_tmp.p, buffer_tmp.count, sampling_rate
@ -93,21 +92,6 @@ void BasebandThread::run() {
} }
} }
} }
} else {
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const baseband::buffer_t buffer_tmp = baseband::dma::wait_for_rx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
}
}
}
i2s::i2s0::tx_mute(); i2s::i2s0::tx_mute();
baseband::dma::disable(); baseband::dma::disable();

View file

@ -51,10 +51,10 @@ public:
private: private:
static Thread* thread; static Thread* thread;
baseband::Direction _direction;
BasebandProcessor* baseband_processor { nullptr }; BasebandProcessor* baseband_processor { nullptr };
uint32_t sampling_rate; baseband::Direction _direction { baseband::Direction::Receive };
uint32_t sampling_rate { 0 };
void run() override; void run() override;
}; };

View file

@ -37,27 +37,27 @@ private:
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
uint32_t afsk_samples_per_bit; uint32_t afsk_samples_per_bit { 0 };
uint32_t afsk_phase_inc_mark; uint32_t afsk_phase_inc_mark { 0 };
uint32_t afsk_phase_inc_space; uint32_t afsk_phase_inc_space { 0 };
uint8_t afsk_repeat; uint8_t afsk_repeat { 0 };
uint32_t afsk_bw; uint32_t afsk_bw { 0 };
uint8_t afsk_format; uint8_t afsk_format { 0 };
uint8_t repeat_counter = 0; uint8_t repeat_counter { 0 };
int8_t re, im; int8_t re { 0 }, im { 0 };
uint8_t s = 0; uint8_t s { 0 };
uint8_t bit_pos = 0; uint8_t bit_pos { 0 };
uint16_t byte_pos = 0; uint16_t byte_pos { 0 };
char cur_byte = 0; char cur_byte { 0 };
char ext_byte = 0; char ext_byte { 0 };
uint16_t gbyte; uint16_t gbyte { 0 };
uint8_t cur_bit = 0; uint8_t cur_bit { 0 };
uint32_t sample_count; uint32_t sample_count { 0 };
uint32_t tone_phase, phase, sphase; uint32_t tone_phase { 0 }, phase { 0 }, sphase { 0 };
int32_t tone_sample, sig, frq; int32_t tone_sample { 0 }, sig { 0 }, frq { 0 };
TXDoneMessage message; TXDoneMessage message { };
}; };
#endif #endif

View file

@ -82,11 +82,11 @@ void TonesProcessor::execute(const buffer_c8_t& buffer) {
tone_sample = 0; tone_sample = 0;
} else { } else {
if (!dual_tone) { if (!dual_tone) {
tone_sample = (sine_table_i8[(tone_a_phase & 0x03FC0000) >> 18]); tone_sample = (sine_table_i8[(tone_a_phase & 0x03FC0000U) >> 18]);
tone_a_phase += tone_a_delta; tone_a_phase += tone_a_delta;
} else { } else {
tone_sample = sine_table_i8[(tone_a_phase & 0x03FC0000) >> 18] >> 1; tone_sample = sine_table_i8[(tone_a_phase & 0x03FC0000U) >> 18] >> 1;
tone_sample += sine_table_i8[(tone_b_phase & 0x03FC0000) >> 18] >> 1; tone_sample += sine_table_i8[(tone_b_phase & 0x03FC0000U) >> 18] >> 1;
tone_a_phase += tone_a_delta; tone_a_phase += tone_a_delta;
tone_b_phase += tone_b_delta; tone_b_phase += tone_b_delta;
@ -97,23 +97,23 @@ void TonesProcessor::execute(const buffer_c8_t& buffer) {
delta = tone_sample * fm_delta; delta = tone_sample * fm_delta;
phase += delta; phase += delta;
sphase = phase + (64 << 18); sphase = phase + (64 << 24);
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]); re = (sine_table_i8[(sphase & 0xFF000000U) >> 24]);
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]); im = (sine_table_i8[(phase & 0xFF000000U) >> 24]);
} }
// Headphone output sample generation: 1536000/24000 = 64 // Headphone output sample generation: 1536000/24000 = 64
if (audio_out) { if (audio_out) {
if (!as) { if (!as) {
as = 64; // 63 ? as = 64;
audio_buffer.p[ai++] = tone_sample * 128; audio_buffer.p[ai++] = tone_sample * 128;
} else { } else {
as--; as--;
} }
} }
buffer.p[i] = {(int8_t)re, (int8_t)im}; buffer.p[i] = {re, im};
} }
if (audio_out) audio_output.write(audio_buffer); if (audio_out) audio_output.write(audio_buffer);
@ -128,7 +128,7 @@ void TonesProcessor::on_message(const Message* const p) {
tone_durations[c] = shared_memory.bb_data.tones_data.tone_defs[c].duration; tone_durations[c] = shared_memory.bb_data.tones_data.tone_defs[c].duration;
} }
message_length = message.tone_count; message_length = message.tone_count;
fm_delta = message.fm_delta; fm_delta = message.fm_delta * 32768;
audio_out = message.audio_out; audio_out = message.audio_out;
dual_tone = message.dual_tone; dual_tone = message.dual_tone;

View file

@ -39,7 +39,7 @@ private:
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
std::array<int16_t, 32> audio; // 2048/64 std::array<int16_t, 32> audio { }; // 2048/64
const buffer_s16_t audio_buffer { const buffer_s16_t audio_buffer {
(int16_t*)audio.data(), (int16_t*)audio.data(),
sizeof(audio) / sizeof(int16_t) sizeof(audio) / sizeof(int16_t)
@ -48,22 +48,22 @@ private:
uint32_t tone_deltas[32]; uint32_t tone_deltas[32];
uint32_t tone_durations[32]; uint32_t tone_durations[32];
bool audio_out; bool audio_out { false };
bool dual_tone; bool dual_tone { false };
uint32_t fm_delta; uint32_t fm_delta { 0 };
uint32_t tone_a_phase, tone_b_phase; uint32_t tone_a_phase { 0 }, tone_b_phase { 0 };
uint32_t tone_a_delta, tone_b_delta; uint32_t tone_a_delta { 0 }, tone_b_delta { 0 };
uint8_t digit_pos; uint8_t digit_pos { 0 };
uint8_t digit; uint8_t digit { 0 };
uint32_t silence_count, sample_count; uint32_t silence_count { 0 }, sample_count { 0 };
uint32_t message_length; uint32_t message_length { 0 };
uint32_t phase, sphase; uint32_t phase { 0 }, sphase { 0 };
int32_t tone_sample, delta; int32_t tone_sample { 0 }, delta { 0 };
int8_t re, im; int8_t re { 0 }, im { 0 };
uint8_t as, ai; uint8_t as { 0 }, ai { 0 };
TXDoneMessage txdone_message; TXDoneMessage txdone_message { };
AudioOutput audio_output; AudioOutput audio_output { };
}; };
#endif #endif

0
firmware/hackrf_cpld_portapack.svf Executable file → Normal file
View file

View file

@ -339,3 +339,4 @@ type_name = '::cpld::xilinx::XC2C64A::verify_blocks_t'
HeaderGen(header_includes, namespaces, type_name, variable_name).to_file(args.header_file_path) HeaderGen(header_includes, namespaces, type_name, variable_name).to_file(args.header_file_path)
DataGen(data_includes, namespaces, type_name, variable_name, verify).to_file(args.data_file_path) DataGen(data_includes, namespaces, type_name, variable_name, verify).to_file(args.data_file_path)