mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 12:58:00 +00:00
Started work on ADS-B TX baseband processor
This commit is contained in:
@@ -342,10 +342,10 @@ DeclareTargets(POOK ook)
|
||||
|
||||
### Jammer
|
||||
|
||||
#set(MODE_CPPSRC
|
||||
# proc_jammer.cpp
|
||||
#)
|
||||
#DeclareTargets(PJAM jammer)
|
||||
set(MODE_CPPSRC
|
||||
proc_jammer.cpp
|
||||
)
|
||||
DeclareTargets(PJAM jammer)
|
||||
|
||||
### Audio transmit
|
||||
|
||||
@@ -389,6 +389,13 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PRDS rds)
|
||||
|
||||
### ADS-B TX
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_adsbtx.cpp
|
||||
)
|
||||
DeclareTargets(PADS ads)
|
||||
|
||||
### HackRF "factory" firmware
|
||||
|
||||
add_custom_command(
|
||||
|
BIN
firmware/baseband/baseband_ads.img
Normal file
BIN
firmware/baseband/baseband_ads.img
Normal file
Binary file not shown.
103
firmware/baseband/proc_adsbtx.cpp
Normal file
103
firmware/baseband/proc_adsbtx.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "proc_adsbtx.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
void ADSBTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
// This is called at 2M/2048 = 977Hz
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
// Synthesis at 2M
|
||||
/*if (preamble == true) {
|
||||
if (bit_pos >= 16) {
|
||||
bit_pos = 0;
|
||||
preamble = false;
|
||||
bit_part = 0;
|
||||
} else {
|
||||
cur_bit = (preamble_parts << bit_pos) >> 15;
|
||||
bit_pos++;
|
||||
}
|
||||
}*/
|
||||
//if (preamble == false) {
|
||||
if (!bit_part) {
|
||||
if (bit_pos >= 112) {
|
||||
// Stop
|
||||
cur_bit = 0;
|
||||
} else {
|
||||
cur_bit = shared_memory.tx_data[bit_pos];
|
||||
bit_pos++;
|
||||
bit_part = 1;
|
||||
}
|
||||
} else {
|
||||
bit_part = 0;
|
||||
cur_bit ^= 1;
|
||||
}
|
||||
//}
|
||||
|
||||
// 8D48: 10001101 01001000
|
||||
// 1001010110100110 0110010110010101
|
||||
|
||||
if (cur_bit) {
|
||||
phase = (phase + 0x1FE0000); // What ?
|
||||
sphase = phase + (64 << 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};
|
||||
}
|
||||
|
||||
// TEST
|
||||
message.n = 200;
|
||||
shared_memory.application_queue.push(message);
|
||||
configured = false;
|
||||
}
|
||||
|
||||
void ADSBTXProcessor::on_message(const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const ADSBConfigureMessage*>(p);
|
||||
|
||||
if (message.id == Message::ID::ADSBConfigure) {
|
||||
bit_pos = 0;
|
||||
cur_bit = 0;
|
||||
preamble = true;
|
||||
configured = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<ADSBTXProcessor>() };
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
}
|
52
firmware/baseband/proc_adsbtx.hpp
Normal file
52
firmware/baseband/proc_adsbtx.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROC_ADSBTX_H__
|
||||
#define __PROC_ADSBTX_H__
|
||||
|
||||
#include "baseband_processor.hpp"
|
||||
#include "baseband_thread.hpp"
|
||||
|
||||
class ADSBTXProcessor : public BasebandProcessor {
|
||||
public:
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const p) override;
|
||||
|
||||
private:
|
||||
bool configured = false;
|
||||
|
||||
BasebandThread baseband_thread { 2000000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; // 2280000
|
||||
|
||||
const uint16_t preamble_parts = 0b1010000101000000;
|
||||
uint8_t bit_part;
|
||||
bool preamble;
|
||||
int8_t re, im;
|
||||
uint16_t bit_pos = 0;
|
||||
uint8_t cur_bit = 0;
|
||||
uint32_t phase, sphase;
|
||||
int32_t sig, frq;
|
||||
|
||||
TXDoneMessage message;
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -21,7 +22,7 @@
|
||||
|
||||
#include "proc_jammer.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "sine_table.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -29,6 +30,9 @@
|
||||
#define POLY_MASK_32 0xB4BCD35C
|
||||
|
||||
void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
for (size_t i = 0; i<buffer.count; i++) {
|
||||
|
||||
if (s >= 10000) { //shared_memory.jammer_ranges[ir].duration
|
||||
@@ -66,21 +70,68 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
}
|
||||
|
||||
aphase += 8830;
|
||||
sample = sine_table_f32[(aphase & 0x03FF0000)>>18]*256;
|
||||
sample = sine_table_i8[(sphase & 0x03FC0000) >> 18];
|
||||
|
||||
//FM
|
||||
frq = sample * jammer_bw; // Bandwidth
|
||||
// FM
|
||||
frq = sample * jammer_bw;
|
||||
|
||||
phase = (phase + frq);
|
||||
sphase = phase + (256<<16);
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = sine_table_f32[(sphase & 0x03FF0000)>>18]*127;
|
||||
im = sine_table_f32[(phase & 0x03FF0000)>>18]*127;
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
|
||||
|
||||
buffer.p[i] = {(int8_t)re,(int8_t)im};
|
||||
buffer.p[i] = {(int8_t)re, (int8_t)im};
|
||||
}
|
||||
};
|
||||
|
||||
void JammerProcessor::on_message(const Message* const msg) {
|
||||
/*const auto message = *reinterpret_cast<const DTMFTXConfigMessage*>(msg);
|
||||
|
||||
if (message.id == Message::ID::DTMFTXConfig) {
|
||||
|
||||
// Translate DTMF message to index in DTMF frequencies table
|
||||
tone_ptr = &shared_memory.tx_data[0];
|
||||
for (;;) {
|
||||
tone_code = *tone_ptr;
|
||||
if (tone_code == 0xFF)
|
||||
break; // End of message
|
||||
else if (tone_code <= 9)
|
||||
// That's already fine bro.
|
||||
*tone_ptr = tone_code;
|
||||
else if (tone_code == 'A')
|
||||
*tone_ptr = 10;
|
||||
else if (tone_code == 'B')
|
||||
*tone_ptr = 11;
|
||||
else if (tone_code == 'C')
|
||||
*tone_ptr = 12;
|
||||
else if (tone_code == 'D')
|
||||
*tone_ptr = 13;
|
||||
else if (tone_code == '#')
|
||||
*tone_ptr = 14;
|
||||
else if (tone_code == '*')
|
||||
*tone_ptr = 15;
|
||||
else {
|
||||
*tone_ptr = 0xFF; // Invalid character, stop here
|
||||
}
|
||||
tone_ptr++;
|
||||
}
|
||||
|
||||
// 1<<18 = 262144
|
||||
// m = (262144 * a) / 1536000
|
||||
// a = 262144 / 1536000 (*1000 = 171)
|
||||
bw = 171 * (message.bw);
|
||||
tone_length = message.tone_length * 154; // 153.6
|
||||
pause_length = message.pause_length * 154; // 153.6
|
||||
as = 0;
|
||||
tone = false;
|
||||
timer = 0;
|
||||
tone_idx = 0;
|
||||
|
||||
configured = true;
|
||||
}*/
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<JammerProcessor>() };
|
||||
event_dispatcher.run();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
@@ -28,8 +29,14 @@
|
||||
class JammerProcessor : public BasebandProcessor {
|
||||
public:
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const msg) override;
|
||||
|
||||
private:
|
||||
bool configured = false;
|
||||
|
||||
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
int32_t lfsr32 = 0xABCDE;
|
||||
uint32_t s;
|
||||
int8_t r, ir, re, im;
|
||||
|
Reference in New Issue
Block a user