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

@@ -93,7 +93,7 @@ void AudioOutput::on_block(
}
} else
audio_present = true;
fill_audio_buffer(audio, audio_present);
}

View File

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

View File

@@ -115,9 +115,16 @@ static void dma_error() {
void init() {
gpdma_channel_sgpio.set_handlers(transfer_complete, dma_error);
// LPC_GPDMA->SYNC |= (1 << gpdma_src_peripheral);
// LPC_GPDMA->SYNC |= (1 << gpdma_dest_peripheral);
#if defined(PORTAPACK_BASEBAND_DMA_NO_SYNC)
/* Disable synchronization logic to improve(?) DMA response time.
* 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(
@@ -149,7 +156,7 @@ void disable() {
gpdma_channel_sgpio.disable();
}
/*baseband::buffer_t wait_for_buffer() {
baseband::buffer_t wait_for_buffer() {
const auto next_index = thread_wait.sleep();
if( next_index >= 0 ) {
@@ -161,28 +168,6 @@ void disable() {
} else {
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 */

View File

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

View File

@@ -47,7 +47,7 @@ BasebandThread::BasebandThread(
uint32_t sampling_rate,
BasebandProcessor* const baseband_processor,
const tprio_t priority,
const baseband::Direction direction
baseband::Direction direction
) : baseband_processor { baseband_processor },
_direction { direction },
sampling_rate { sampling_rate }
@@ -78,33 +78,17 @@ void BasebandThread::run() {
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.streaming_enable();
if (_direction == baseband::Direction::Transmit) {
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const baseband::buffer_t buffer_tmp = baseband::dma::wait_for_tx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
}
}
} 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
};
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const auto buffer_tmp = baseband::dma::wait_for_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
}
}

View File

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

View File

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

View File

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

View File

@@ -39,7 +39,7 @@ private:
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 {
(int16_t*)audio.data(),
sizeof(audio) / sizeof(int16_t)
@@ -48,22 +48,22 @@ private:
uint32_t tone_deltas[32];
uint32_t tone_durations[32];
bool audio_out;
bool dual_tone;
uint32_t fm_delta;
uint32_t tone_a_phase, tone_b_phase;
uint32_t tone_a_delta, tone_b_delta;
uint8_t digit_pos;
uint8_t digit;
uint32_t silence_count, sample_count;
uint32_t message_length;
uint32_t phase, sphase;
int32_t tone_sample, delta;
int8_t re, im;
uint8_t as, ai;
bool audio_out { false };
bool dual_tone { false };
uint32_t fm_delta { 0 };
uint32_t tone_a_phase { 0 }, tone_b_phase { 0 };
uint32_t tone_a_delta { 0 }, tone_b_delta { 0 };
uint8_t digit_pos { 0 };
uint8_t digit { 0 };
uint32_t silence_count { 0 }, sample_count { 0 };
uint32_t message_length { 0 };
uint32_t phase { 0 }, sphase { 0 };
int32_t tone_sample { 0 }, delta { 0 };
int8_t re { 0 }, im { 0 };
uint8_t as { 0 }, ai { 0 };
TXDoneMessage txdone_message;
AudioOutput audio_output;
TXDoneMessage txdone_message { };
AudioOutput audio_output { };
};
#endif