mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 23:47:45 +00:00
OOK transmit is mostly working, bit durations are wrong
Simplified messages carrying data (uses shared_memory instead) Added SymField widget (bitfield, symbol field...) Added some space for baseband code BMP palette loading bugfix
This commit is contained in:
@@ -326,19 +326,26 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PSPE wideband_spectrum)
|
||||
|
||||
### Jammer
|
||||
### OOK
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_jammer.cpp
|
||||
proc_ook.cpp
|
||||
)
|
||||
DeclareTargets(PJAM jammer)
|
||||
DeclareTargets(POOK ook)
|
||||
|
||||
### Jammer
|
||||
|
||||
#set(MODE_CPPSRC
|
||||
# proc_jammer.cpp
|
||||
#)
|
||||
#DeclareTargets(PJAM jammer)
|
||||
|
||||
### Audio transmit
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_audiotx.cpp
|
||||
)
|
||||
DeclareTargets(PATX audio_tx)
|
||||
#set(MODE_CPPSRC
|
||||
# proc_audiotx.cpp
|
||||
#)
|
||||
#DeclareTargets(PATX audio_tx)
|
||||
|
||||
### AFSK
|
||||
|
||||
@@ -349,17 +356,17 @@ DeclareTargets(PAFS afsk)
|
||||
|
||||
### Epar
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_epar.cpp
|
||||
)
|
||||
DeclareTargets(PEPR epar)
|
||||
#set(MODE_CPPSRC
|
||||
# proc_epar.cpp
|
||||
#)
|
||||
#DeclareTargets(PEPR epar)
|
||||
|
||||
### Play audio
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_playaudio.cpp
|
||||
)
|
||||
DeclareTargets(PPAU play_audio)
|
||||
#set(MODE_CPPSRC
|
||||
# proc_playaudio.cpp
|
||||
#)
|
||||
#DeclareTargets(PPAU play_audio)
|
||||
|
||||
### Xylos
|
||||
|
||||
@@ -375,13 +382,6 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PRDS rds)
|
||||
|
||||
### OOK
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_ook.cpp
|
||||
)
|
||||
DeclareTargets(POOK ook)
|
||||
|
||||
### HackRF "factory" firmware
|
||||
|
||||
add_custom_command(
|
||||
|
@@ -34,14 +34,15 @@ void AFSKProcessor::execute(const buffer_c8_t& buffer) {
|
||||
if (!configured) return;
|
||||
|
||||
for (size_t i = 0; i<buffer.count; i++) {
|
||||
|
||||
|
||||
// Tone synthesis at 2.28M/10 = 228kHz
|
||||
if (!s) {
|
||||
s = 10 - 1;
|
||||
if (s >= (5 - 1)) {
|
||||
s = 0;
|
||||
|
||||
if (sample_count >= afsk_samples_per_bit) {
|
||||
if (configured) {
|
||||
cur_byte = message_data[byte_pos];
|
||||
ext_byte = message_data[byte_pos + 1];
|
||||
cur_byte = shared_memory.tx_data[byte_pos];
|
||||
ext_byte = shared_memory.tx_data[byte_pos + 1];
|
||||
|
||||
if (!(cur_byte | ext_byte)) {
|
||||
// End of data
|
||||
@@ -49,8 +50,8 @@ void AFSKProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// Repeat
|
||||
bit_pos = 0;
|
||||
byte_pos = 0;
|
||||
cur_byte = message_data[0];
|
||||
ext_byte = message_data[1];
|
||||
cur_byte = shared_memory.tx_data[0];
|
||||
ext_byte = shared_memory.tx_data[1];
|
||||
message.n = repeat_counter + 1;
|
||||
shared_memory.application_queue.push(message);
|
||||
repeat_counter++;
|
||||
@@ -98,6 +99,8 @@ void AFSKProcessor::execute(const buffer_c8_t& buffer) {
|
||||
} else {
|
||||
s--;
|
||||
}
|
||||
|
||||
//tone_phase += 432759; // 1981Hz
|
||||
|
||||
tone_sample = (sine_table_i8[(tone_phase & 0x03FC0000) >> 18]);
|
||||
|
||||
@@ -120,13 +123,12 @@ void AFSKProcessor::on_message(const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const AFSKConfigureMessage*>(p);
|
||||
|
||||
if (message.id == Message::ID::AFSKConfigure) {
|
||||
memcpy(message_data, message.message_data, 512);
|
||||
afsk_samples_per_bit = message.afsk_samples_per_bit;
|
||||
afsk_phase_inc_mark = message.afsk_phase_inc_mark;
|
||||
afsk_phase_inc_space = message.afsk_phase_inc_space;
|
||||
afsk_repeat = message.afsk_repeat - 1;
|
||||
afsk_bw = message.afsk_bw;
|
||||
afsk_format = message.afsk_format;
|
||||
afsk_samples_per_bit = message.samples_per_bit;
|
||||
afsk_phase_inc_mark = message.phase_inc_mark;
|
||||
afsk_phase_inc_space = message.phase_inc_space;
|
||||
afsk_repeat = message.repeat - 1;
|
||||
afsk_bw = message.bw;
|
||||
afsk_format = message.format;
|
||||
|
||||
s = 0;
|
||||
sample_count = afsk_samples_per_bit;
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
private:
|
||||
bool configured = false;
|
||||
|
||||
BasebandThread baseband_thread { 2280000, 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_phase_inc_mark;
|
||||
@@ -43,7 +43,6 @@ private:
|
||||
uint8_t afsk_repeat;
|
||||
uint32_t afsk_bw;
|
||||
uint8_t afsk_format;
|
||||
char message_data[512];
|
||||
|
||||
uint8_t repeat_counter = 0;
|
||||
int8_t re, im;
|
||||
|
@@ -35,31 +35,38 @@ void OOKProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
for (size_t i = 0; i<buffer.count; i++) {
|
||||
|
||||
// Synthesis at 2.28M/2 = 1.14MHz
|
||||
// Synthesis at 2.28M/10 = 228kHz
|
||||
if (!s) {
|
||||
s = 2 - 1;
|
||||
s = 10 - 1;
|
||||
if (sample_count >= samples_per_bit) {
|
||||
if (configured) {
|
||||
cur_bit = (bitstream[bit_pos >> 3] << (bit_pos & 7)) & 0x80;
|
||||
|
||||
bit_pos++;
|
||||
|
||||
if (bit_pos >= stream_size) {
|
||||
if (bit_pos >= length) {
|
||||
// End of data
|
||||
if (repeat_counter < repeat) {
|
||||
// Repeat
|
||||
bit_pos = 0;
|
||||
cur_bit = bitstream[0] & 0x80;
|
||||
message.n = repeat_counter + 1;
|
||||
shared_memory.application_queue.push(message);
|
||||
repeat_counter++;
|
||||
} else {
|
||||
// Stop
|
||||
if (pause_counter == 0) {
|
||||
pause_counter = pause;
|
||||
cur_bit = 0;
|
||||
message.n = 0;
|
||||
shared_memory.application_queue.push(message);
|
||||
configured = false;
|
||||
} else if (pause_counter == 1) {
|
||||
if (repeat_counter < repeat) {
|
||||
// Repeat
|
||||
bit_pos = 0;
|
||||
cur_bit = shared_memory.tx_data[0] & 0x80;
|
||||
message.n = repeat_counter + 1;
|
||||
shared_memory.application_queue.push(message);
|
||||
repeat_counter++;
|
||||
} else {
|
||||
// Stop
|
||||
cur_bit = 0;
|
||||
message.n = 0;
|
||||
shared_memory.application_queue.push(message);
|
||||
configured = false;
|
||||
}
|
||||
pause_counter = 0;
|
||||
} else {
|
||||
pause_counter--;
|
||||
}
|
||||
} else {
|
||||
cur_bit = (shared_memory.tx_data[bit_pos >> 3] << (bit_pos & 7)) & 0x80;
|
||||
bit_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,13 +78,17 @@ void OOKProcessor::execute(const buffer_c8_t& buffer) {
|
||||
s--;
|
||||
}
|
||||
|
||||
if (cur_bit) phase += 100; // ?
|
||||
|
||||
sphase = phase + (64 << 18);
|
||||
if (cur_bit) {
|
||||
phase = (phase + 200); // What ?
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
|
||||
} else {
|
||||
re = 0;
|
||||
im = 0;
|
||||
}
|
||||
|
||||
buffer.p[i] = {(int8_t)re, (int8_t)im};
|
||||
}
|
||||
}
|
||||
@@ -86,12 +97,12 @@ void OOKProcessor::on_message(const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const OOKConfigureMessage*>(p);
|
||||
|
||||
if (message.id == Message::ID::OOKConfigure) {
|
||||
//memcpy(bitstream, message.ook_bitstream, 64);
|
||||
|
||||
samples_per_bit = message.samples_per_bit;
|
||||
stream_size = message.stream_length;
|
||||
repeat = message.repeat - 1;
|
||||
length = message.stream_length - 1;
|
||||
pause = message.pause_symbols + 1;
|
||||
|
||||
pause_counter = 0;
|
||||
s = 0;
|
||||
sample_count = samples_per_bit;
|
||||
repeat_counter = 0;
|
||||
|
@@ -39,17 +39,17 @@ private:
|
||||
|
||||
uint32_t samples_per_bit;
|
||||
uint8_t repeat;
|
||||
char bitstream[64];
|
||||
uint32_t length;
|
||||
uint32_t pause;
|
||||
|
||||
uint32_t pause_counter = 0;
|
||||
uint8_t repeat_counter = 0;
|
||||
int8_t re, im;
|
||||
uint8_t s = 0;
|
||||
|
||||
uint16_t bit_pos = 0;
|
||||
uint8_t cur_bit = 0;
|
||||
uint32_t sample_count;
|
||||
uint32_t stream_size;
|
||||
uint32_t phase, sphase;
|
||||
uint32_t tone_phase, phase, sphase;
|
||||
int32_t tone_sample, sig, frq;
|
||||
|
||||
TXDoneMessage message;
|
||||
|
@@ -43,13 +43,13 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// Just occupy channel with carrier
|
||||
if (sample_count >= CCIR_SILENCE) {
|
||||
silence = false;
|
||||
sample_count = CCIR_TONELENGTH;
|
||||
sample_count = samples_per_tone;
|
||||
} else {
|
||||
sample_count++;
|
||||
}
|
||||
} else {
|
||||
if (sample_count >= CCIR_TONELENGTH) {
|
||||
digit = xylosdata[byte_pos++];
|
||||
if (sample_count >= samples_per_tone) {
|
||||
digit = shared_memory.tx_data[byte_pos++];
|
||||
if ((digit == 0xFF) || (byte_pos >= 21)) {
|
||||
configured = false;
|
||||
message.n = 25; // End of message code
|
||||
@@ -103,12 +103,12 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
|
||||
}
|
||||
|
||||
void XylosProcessor::on_message(const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const XylosConfigureMessage*>(p);
|
||||
if (message.id == Message::ID::XylosConfigure) {
|
||||
memcpy(xylosdata, message.ccir_message, 21);
|
||||
const auto message = *reinterpret_cast<const CCIRConfigureMessage*>(p);
|
||||
if (message.id == Message::ID::CCIRConfigure) {
|
||||
byte_pos = 0;
|
||||
digit = 0;
|
||||
sample_count = CCIR_TONELENGTH;
|
||||
samples_per_tone = message.samples_per_tone;
|
||||
sample_count = samples_per_tone;
|
||||
as = 0;
|
||||
silence = true;
|
||||
configured = true;
|
||||
|
@@ -28,7 +28,6 @@
|
||||
|
||||
//#include "audio_output.hpp"
|
||||
|
||||
#define CCIR_TONELENGTH (15360*2)-1 // 1536000/10/10
|
||||
#define CCIR_PHASEINC (436.91/2) // (65536*1024)/1536000*10
|
||||
#define CCIR_SILENCE (122880)-1 // 400ms
|
||||
|
||||
@@ -62,12 +61,12 @@ private:
|
||||
(uint32_t)(1055*CCIR_PHASEINC)
|
||||
};
|
||||
|
||||
char xylosdata[21];
|
||||
uint32_t samples_per_tone;
|
||||
int8_t re, im;
|
||||
uint8_t s, as = 0, ai;
|
||||
uint8_t byte_pos = 0;
|
||||
uint8_t digit = 0;
|
||||
uint32_t sample_count = CCIR_TONELENGTH;
|
||||
uint32_t sample_count = 0;
|
||||
uint32_t tone_phase, phase, sphase;
|
||||
int32_t tone_sample, frq;
|
||||
bool silence = true;
|
||||
|
Reference in New Issue
Block a user