mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-19 22:24:02 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aee54e5b2d | |||
| e33e697cca | |||
| d7d27d99e7 | |||
| 78d3480b68 | |||
| 70b42f4a56 |
+17
-1
@@ -1 +1,17 @@
|
||||
Please check [Intended-Use-and-Legality](https://github.com/portapack-mayhem/mayhem-firmware/wiki/)
|
||||
# Security Policy
|
||||
|
||||
## Scope and Threat Model
|
||||
This repository hosts the codebase for an embedded system designed for security research. Because the system operates primarily offline, traditional network-based vulnerabilities are generally not applicable. However, we still welcome and review security reports concerning the code within this repository.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
If you discover a vulnerability within this tool itself, please submit a report. Please be aware that the maintainers do not promise assistance with obtaining CVE IDs or managing formal security advisories.
|
||||
|
||||
## Out of Scope
|
||||
* **Vulnerabilities found *using* this tool:** Please do not submit reports here for vulnerabilities you have discovered in other systems or targets using this tool. This channel is strictly for reporting vulnerabilities found *in* the tool itself.
|
||||
* **Other Repositories:** For security issues concerning related tools, such as MayhemHub, please submit your reports directly to their respective repositories.
|
||||
|
||||
## Research Attribution
|
||||
If you utilize this tool to successfully discover vulnerabilities in external systems, we would greatly appreciate it if you credit or mention our project in your published research or write-ups.
|
||||
|
||||
## Legal and Security Disclaimer
|
||||
For comprehensive guidelines regarding the legal and secure usage of this tool, as well as our full liability disclaimer, please refer to: [Intended-Use-and-Legality](https://github.com/portapack-mayhem/mayhem-firmware/wiki/). Users are expected to comply with all applicable laws and regulations when using this software and/or hardware.
|
||||
|
||||
@@ -419,10 +419,10 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) {
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_modulation_changed(ReceiverModel::Mode modulation) {
|
||||
baseband::spectrum_streaming_stop();
|
||||
waterfall.stop();
|
||||
update_modulation(modulation);
|
||||
on_show_options_modulation();
|
||||
baseband::spectrum_streaming_start();
|
||||
waterfall.start();
|
||||
}
|
||||
|
||||
void AnalogAudioView::remove_options_widget() {
|
||||
|
||||
+12
-14
@@ -3,13 +3,11 @@
|
||||
/*
|
||||
* FPV RX — how frequency search and lock work
|
||||
*
|
||||
* 1. Power metric: We use channelized power (baseband IQ magnitude² in the
|
||||
* capture bandwidth), not raw RF RSSI. Stats come from ChannelStatsCollector
|
||||
* over filtered IQ, so we see power in the tuned channel, not wideband.
|
||||
* 1. Power metric: We use channelized power that portapack RSSI algo included.
|
||||
*
|
||||
* 2. Scanning: We step through FPV bands/channels (A/B/E/F/R, 8 ch each). When
|
||||
* power on the current channel exceeds the detect threshold, we enter
|
||||
* "Candidate" and run verification — we do not lock on a single peak.
|
||||
* "Candidate" and run verification - with some edge detecting algo.
|
||||
*
|
||||
* 3. Verification (making sure the drone is on that freq):
|
||||
* - Multiple samples: verify_hits / verify_misses over several updates.
|
||||
@@ -177,7 +175,7 @@ void FpvDetectView::reset_detector(bool retune_current) {
|
||||
}
|
||||
}
|
||||
|
||||
bool FpvDetectView::is_possible_analog_carrier(const ChannelStatistics& statistics) const {
|
||||
bool FpvDetectView::is_possible_freq_spike(const ChannelStatistics& statistics) const {
|
||||
return statistics.max_db >= detect_threshold_db();
|
||||
}
|
||||
|
||||
@@ -392,17 +390,17 @@ void FpvDetectView::update_state_badge() {
|
||||
text_state.set("SCANNING");
|
||||
break;
|
||||
case DetectState::Candidate:
|
||||
text_state.set("VERIFY FPV");
|
||||
text_state.set("CHECKING");
|
||||
break;
|
||||
case DetectState::Locked:
|
||||
text_state.set("DRONE FOUND");
|
||||
text_state.set("FREQ FOUND");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FpvDetectView::update_confidence_text() {
|
||||
char buf[16];
|
||||
std::snprintf(buf, sizeof(buf), "Conf %u%%", static_cast<unsigned>(candidate_confidence_));
|
||||
std::snprintf(buf, sizeof(buf), "Posi %u%%", static_cast<unsigned>(candidate_confidence_));
|
||||
text_confidence.set(buf);
|
||||
}
|
||||
|
||||
@@ -412,21 +410,21 @@ void FpvDetectView::update_status_text() {
|
||||
switch (detect_state_) {
|
||||
case DetectState::Scanning:
|
||||
if (band_mode < FPV_NUM_BANDS) {
|
||||
std::snprintf(buf, sizeof(buf), "Scanning band %c for analog FPV", band_labels[band_mode]);
|
||||
std::snprintf(buf, sizeof(buf), "Scanning band %c", band_labels[band_mode]);
|
||||
} else {
|
||||
std::snprintf(buf, sizeof(buf), "Scanning all FPV bands");
|
||||
std::snprintf(buf, sizeof(buf), "Scanning all from list");
|
||||
}
|
||||
break;
|
||||
|
||||
case DetectState::Candidate:
|
||||
std::snprintf(buf, sizeof(buf), "VERIFYING %c%d %ld MHz",
|
||||
std::snprintf(buf, sizeof(buf), "CHKING %c%d %ld MHz",
|
||||
band_labels[candidate_band_],
|
||||
static_cast<int>(candidate_ch_ + 1),
|
||||
static_cast<long>(fpv_frequencies[candidate_band_][candidate_ch_] / 1000000LL));
|
||||
break;
|
||||
|
||||
case DetectState::Locked:
|
||||
std::snprintf(buf, sizeof(buf), "!!! DRONE FOUND !!! %c%d %ld",
|
||||
std::snprintf(buf, sizeof(buf), "FREQ FOUND %c%d %ld",
|
||||
band_labels[candidate_band_],
|
||||
static_cast<int>(candidate_ch_ + 1),
|
||||
static_cast<long>(fpv_frequencies[candidate_band_][candidate_ch_] / 1000000LL));
|
||||
@@ -453,7 +451,7 @@ void FpvDetectView::update_detail_text() {
|
||||
break;
|
||||
|
||||
case DetectState::Locked:
|
||||
std::snprintf(buf, sizeof(buf), "LOCKED %c%d conf %u%% hold %u",
|
||||
std::snprintf(buf, sizeof(buf), "LOCKED %c%d posi %u%% hold %u",
|
||||
band_labels[candidate_band_],
|
||||
static_cast<int>(candidate_ch_ + 1),
|
||||
static_cast<unsigned>(candidate_confidence_),
|
||||
@@ -605,7 +603,7 @@ void FpvDetectView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
|
||||
switch (detect_state_) {
|
||||
case DetectState::Scanning:
|
||||
if (is_possible_analog_carrier(statistics)) {
|
||||
if (is_possible_freq_spike(statistics)) {
|
||||
enter_candidate(statistics);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -72,7 +72,7 @@ class FpvDetectView : public View {
|
||||
void step_scan();
|
||||
void reset_detector(bool retune_current);
|
||||
|
||||
bool is_possible_analog_carrier(const ChannelStatistics& statistics) const;
|
||||
bool is_possible_freq_spike(const ChannelStatistics& statistics) const;
|
||||
void enter_candidate(const ChannelStatistics& statistics);
|
||||
void evaluate_candidate_sample(const ChannelStatistics& statistics);
|
||||
void enter_lock();
|
||||
@@ -162,7 +162,7 @@ class FpvDetectView : public View {
|
||||
Text text_freq{{UI_POS_X_RIGHT(20), UI_POS_Y(1), UI_POS_WIDTH(20), UI_POS_DEFAULT_HEIGHT}, ""};
|
||||
|
||||
Text text_state{{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(12), UI_POS_DEFAULT_HEIGHT}, "SCANNING"};
|
||||
Text text_confidence{{UI_POS_X(12), UI_POS_Y(2), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT}, "Conf 0%"};
|
||||
Text text_confidence{{UI_POS_X(12), UI_POS_Y(2), UI_POS_WIDTH(8), UI_POS_DEFAULT_HEIGHT}, "Posi 0%"};
|
||||
Text text_detect_label{{UI_POS_X_RIGHT(10), UI_POS_Y(2), UI_POS_WIDTH(5), UI_POS_DEFAULT_HEIGHT}, "Thr>"};
|
||||
|
||||
NumberField field_detect_threshold{
|
||||
@@ -176,8 +176,8 @@ class FpvDetectView : public View {
|
||||
Text freq_stats_rssi{{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(15), UI_POS_DEFAULT_HEIGHT}, "RSSI 0/0/0"};
|
||||
Text freq_stats_db{{UI_POS_X_RIGHT(14), UI_POS_Y(3), UI_POS_WIDTH(14), UI_POS_DEFAULT_HEIGHT}, "PWR -120 dB"};
|
||||
|
||||
Text text_status{{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH(30), UI_POS_DEFAULT_HEIGHT}, "SCANNING FOR ANALOG FPV"};
|
||||
Text text_detail{{UI_POS_X(0), UI_POS_Y(5), UI_POS_WIDTH(30), UI_POS_DEFAULT_HEIGHT}, "Waiting for FPV-like carrier"};
|
||||
Text text_status{{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH(30), UI_POS_DEFAULT_HEIGHT}, "SCANNING FOR FREQS"};
|
||||
Text text_detail{{UI_POS_X(0), UI_POS_Y(5), UI_POS_WIDTH(30), UI_POS_DEFAULT_HEIGHT}, "Waiting for FPV FREQ"};
|
||||
|
||||
RSSIGraph rssi_graph{{UI_POS_X(0), UI_POS_Y(6), UI_POS_WIDTH_REMAINING(5), UI_POS_HEIGHT_REMAINING(7)}};
|
||||
RSSI rssi{{UI_POS_X_RIGHT(5), UI_POS_Y(6), UI_POS_WIDTH(5), UI_POS_HEIGHT_REMAINING(7)}};
|
||||
|
||||
+75
-42
@@ -27,6 +27,9 @@ MorseRadiotxView::MorseRadiotxView(ui::NavigationView& nav)
|
||||
&chk_trans,
|
||||
&bandwidth,
|
||||
&chk_callsgn,
|
||||
&chk_loop,
|
||||
&wait_time,
|
||||
&progressbar,
|
||||
&txt_last,
|
||||
&console_text,
|
||||
&btn_clear,
|
||||
@@ -69,6 +72,7 @@ MorseRadiotxView::MorseRadiotxView(ui::NavigationView& nav)
|
||||
options_mode.set_selected_index(current_mode, true);
|
||||
tone_.set_value(tone, true);
|
||||
wpm_.set_value(wpm, true);
|
||||
wait_time.set_value(1, true);
|
||||
bandwidth.set_value(band, true);
|
||||
|
||||
btn_ptt.on_select = [this](Button&) {
|
||||
@@ -156,6 +160,14 @@ MorseRadiotxView::MorseRadiotxView(ui::NavigationView& nav)
|
||||
transmitter_model.set_target_frequency(f);
|
||||
};
|
||||
};
|
||||
|
||||
chk_trans.on_select = [this](Checkbox&, bool v) {
|
||||
if (v) chk_loop.set_value(false);
|
||||
};
|
||||
|
||||
chk_loop.on_select = [this](Checkbox&, bool v) {
|
||||
if (v) chk_trans.set_value(false);
|
||||
};
|
||||
}
|
||||
|
||||
MorseRadiotxView::~MorseRadiotxView() {
|
||||
@@ -197,19 +209,15 @@ MorseRadiotxView::MorseTimings MorseRadiotxView::calculate_morse_timings(uint32_
|
||||
|
||||
void MorseRadiotxView::transmit_morse_message() {
|
||||
std::string full_message = "";
|
||||
// cal sign
|
||||
if (chk_callsgn.value() && !call_sign.empty()) {
|
||||
full_message = call_sign;
|
||||
if (!chk_trans.value() && !msg_buffer.empty()) {
|
||||
full_message += " " + msg_buffer;
|
||||
}
|
||||
} else {
|
||||
if (!chk_trans.value()) full_message = msg_buffer;
|
||||
}
|
||||
|
||||
if (full_message.empty() && !chk_trans.value()) {
|
||||
if (chk_trans.value()) {
|
||||
ptt_button_visibility(false);
|
||||
return;
|
||||
} else {
|
||||
full_message = msg_buffer;
|
||||
if (chk_callsgn.value() && !call_sign.empty()) { // call sign
|
||||
full_message += " " + call_sign;
|
||||
}
|
||||
}
|
||||
|
||||
// enable transmit
|
||||
@@ -219,46 +227,63 @@ void MorseRadiotxView::transmit_morse_message() {
|
||||
ui_toggle();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < full_message.length(); i++) {
|
||||
if (chThdShouldTerminate()) break;
|
||||
uint8_t loop_seconds = static_cast<uint8_t>(wait_time.value());
|
||||
progressbar.set_max(loop_seconds * 2);
|
||||
|
||||
char c = full_message[i];
|
||||
do {
|
||||
for (size_t i = 0; i < full_message.length(); i++) {
|
||||
if (chThdShouldTerminate()) break;
|
||||
|
||||
std::string s_char(1, c);
|
||||
// space
|
||||
if (c == ' ') {
|
||||
console_text.write(" ");
|
||||
chThdSleepMilliseconds(current_timings.word_gap);
|
||||
continue;
|
||||
}
|
||||
char c = full_message[i];
|
||||
|
||||
const char* pattern = morse_decoder_.get_morse_pattern(c);
|
||||
std::string s_char(1, c);
|
||||
// space
|
||||
if (c == ' ') {
|
||||
console_text.write(" ");
|
||||
chThdSleepMilliseconds(current_timings.word_gap);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pattern != nullptr) {
|
||||
txt_last.set(pattern);
|
||||
const char* pattern = morse_decoder_.get_morse_pattern(c);
|
||||
|
||||
// write blue char to console
|
||||
console_text.write(STR_COLOR_BLUE + s_char);
|
||||
if (pattern != nullptr) {
|
||||
txt_last.set(pattern);
|
||||
|
||||
// Morze (dih/dah) send
|
||||
for (int j = 0; pattern[j] != '\0'; j++) {
|
||||
baseband::set_morsetx_key(true);
|
||||
if (pattern[j] == '.') {
|
||||
chThdSleepMilliseconds(current_timings.dot_ms);
|
||||
} else if (pattern[j] == '-') {
|
||||
chThdSleepMilliseconds(current_timings.dash_ms);
|
||||
// write blue char to console
|
||||
console_text.write(STR_COLOR_BLUE + s_char);
|
||||
|
||||
// Morze (dih/dah) send
|
||||
for (int j = 0; pattern[j] != '\0'; j++) {
|
||||
baseband::set_morsetx_key(true);
|
||||
if (pattern[j] == '.') {
|
||||
chThdSleepMilliseconds(current_timings.dot_ms);
|
||||
} else if (pattern[j] == '-') {
|
||||
chThdSleepMilliseconds(current_timings.dash_ms);
|
||||
}
|
||||
if (chThdShouldTerminate()) break;
|
||||
// pause between signs
|
||||
baseband::set_morsetx_key(false);
|
||||
chThdSleepMilliseconds(current_timings.symbol_gap);
|
||||
}
|
||||
if (chThdShouldTerminate()) break;
|
||||
// pause between signs
|
||||
baseband::set_morsetx_key(false);
|
||||
chThdSleepMilliseconds(current_timings.symbol_gap);
|
||||
}
|
||||
if (chThdShouldTerminate()) break;
|
||||
if (current_timings.char_gap > current_timings.symbol_gap) {
|
||||
chThdSleepMilliseconds(current_timings.char_gap - current_timings.symbol_gap);
|
||||
if (current_timings.char_gap > current_timings.symbol_gap) {
|
||||
chThdSleepMilliseconds(current_timings.char_gap - current_timings.symbol_gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chThdShouldTerminate()) break;
|
||||
if (chk_loop.value()) {
|
||||
console_text.write(" ");
|
||||
for (uint8_t s = 0; s < (loop_seconds * 2); s++) {
|
||||
if (chThdShouldTerminate()) break;
|
||||
progressbar.set_value(s + 1);
|
||||
if (!chk_loop.value()) break;
|
||||
chThdSleepMilliseconds(500);
|
||||
}
|
||||
progressbar.set_value(0);
|
||||
}
|
||||
if (!chk_loop.value()) break;
|
||||
} while (chk_loop.value() && !chThdShouldTerminate());
|
||||
|
||||
if (chk_trans.value()) ptt_button_visibility(false);
|
||||
baseband::set_morsetx_key(false);
|
||||
@@ -356,13 +381,17 @@ void MorseRadiotxView::ui_toggle() {
|
||||
wpm_.set_style(Theme::getInstance()->fg_dark);
|
||||
wpm_.set_focusable(false);
|
||||
btn_message.set_style(Theme::getInstance()->fg_dark);
|
||||
btn_message.set_focusable(false);
|
||||
btn_calls.set_style(Theme::getInstance()->fg_dark);
|
||||
btn_calls.set_focusable(false);
|
||||
chk_trans.set_style(Theme::getInstance()->fg_dark);
|
||||
chk_trans.set_focusable(false);
|
||||
bandwidth.set_style(Theme::getInstance()->fg_dark);
|
||||
bandwidth.set_focusable(false);
|
||||
chk_callsgn.set_style(Theme::getInstance()->fg_dark);
|
||||
chk_callsgn.set_focusable(false);
|
||||
wait_time.set_style(Theme::getInstance()->fg_dark);
|
||||
wait_time.set_focusable(false);
|
||||
bandwidth.set_style(Theme::getInstance()->fg_dark);
|
||||
bandwidth.set_focusable(false);
|
||||
|
||||
} else {
|
||||
options_mode.set_style(Theme::getInstance()->bg_darker);
|
||||
@@ -370,11 +399,15 @@ void MorseRadiotxView::ui_toggle() {
|
||||
wpm_.set_style(Theme::getInstance()->bg_darker);
|
||||
wpm_.set_focusable(true);
|
||||
btn_message.set_style(Theme::getInstance()->bg_darker);
|
||||
btn_message.set_focusable(true);
|
||||
btn_calls.set_style(Theme::getInstance()->bg_darker);
|
||||
btn_calls.set_focusable(true);
|
||||
chk_trans.set_style(Theme::getInstance()->bg_darker);
|
||||
chk_trans.set_focusable(true);
|
||||
chk_callsgn.set_style(Theme::getInstance()->bg_darker);
|
||||
chk_callsgn.set_focusable(true);
|
||||
wait_time.set_style(Theme::getInstance()->bg_darker);
|
||||
wait_time.set_focusable(true);
|
||||
ptt_button_visibility(true);
|
||||
tone_.set_style(Theme::getInstance()->bg_darker);
|
||||
tone_.set_focusable(true);
|
||||
|
||||
@@ -118,15 +118,20 @@ class MorseRadiotxView : public ui::View {
|
||||
{{"AM", 0}, {"FM", 1}, {"DSB", 2}, {"USB", 3}, {"LSB", 4}}};
|
||||
NumberField tone_{{UI_POS_X(14), UI_POS_Y(0)}, 4, {400, 1400}, 10, ' ', true};
|
||||
NumberField wpm_{{UI_POS_X(25), UI_POS_Y(0)}, 2, {10, 45}, 1, ' ', true};
|
||||
FloatField bandwidth{{UI_POS_X(20), UI_POS_Y(3)}, 4, {1.0, 16.0}, 0.1, ' ', true, 1};
|
||||
NumberField wait_time{{UI_POS_X(10), UI_POS_Y(4)}, 3, {1, 99}, 1, ' ', true}; // wait between tx-es in loop mode (sec)
|
||||
FloatField bandwidth{{UI_POS_X(6), UI_POS_Y(5)}, 4, {1.0, 16.0}, 0.1, ' ', true, 1};
|
||||
|
||||
ProgressBar progressbar{
|
||||
{UI_POS_X(0), UI_POS_Y(6), screen_width, 16}};
|
||||
|
||||
ui::Text txt_msg{{UI_POS_X(0), UI_POS_Y(1), UI_POS_MAXWIDTH, UI_POS_HEIGHT(1)}, "[" + msg_buffer + "] "};
|
||||
ui::Button btn_message{{UI_POS_X(0), UI_POS_Y(2), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)}, "Message"};
|
||||
ui::Button btn_calls{{UI_POS_X(0), UI_POS_Y(4), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)}, (call_sign.empty()) ? "call sign?" : call_sign};
|
||||
ui::Button btn_calls{{UI_POS_X(0), UI_POS_Y(3), UI_POS_WIDTH(11), UI_POS_HEIGHT(1)}, (call_sign.empty()) ? "call sign?" : call_sign};
|
||||
Checkbox chk_trans{{UI_POS_X(14), UI_POS_Y(2)}, 13, "Manual trans.", true};
|
||||
Checkbox chk_callsgn{{UI_POS_X(14), UI_POS_Y(4)}, 13, "Call sign", true};
|
||||
ui::Text txt_last{{UI_POS_X(10), UI_POS_Y(5), UI_POS_WIDTH_REMAINING(10), UI_POS_HEIGHT(1)}, ""};
|
||||
ui::Console console_text{{UI_POS_X(0), UI_POS_Y(7), UI_POS_MAXWIDTH, UI_POS_HEIGHT_REMAINING(14)}};
|
||||
Checkbox chk_callsgn{{UI_POS_X(14), UI_POS_Y(3)}, 9, "Call sign", true};
|
||||
Checkbox chk_loop{{UI_POS_X(14), UI_POS_Y(4)}, 4, "loop", true};
|
||||
ui::Text txt_last{{UI_POS_X(10), UI_POS_Y(7), UI_POS_WIDTH_REMAINING(10), UI_POS_HEIGHT(1)}, ""};
|
||||
ui::Console console_text{{UI_POS_X(0), UI_POS_Y(9), UI_POS_MAXWIDTH, UI_POS_HEIGHT_REMAINING(14)}};
|
||||
ui::Button btn_clear{{UI_POS_X(0), UI_POS_Y_BOTTOM(5), UI_POS_WIDTH(5), UI_POS_HEIGHT(1)}, "CLR"};
|
||||
ui::Button btn_ptt{{UI_POS_X_CENTER(12), UI_POS_Y_BOTTOM(7), UI_POS_WIDTH(12), UI_POS_HEIGHT(3)}, "PTT"};
|
||||
|
||||
@@ -135,10 +140,11 @@ class MorseRadiotxView : public ui::View {
|
||||
{{UI_POS_X(9), UI_POS_Y(0)}, "Tone:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(18), UI_POS_Y(0)}, "Hz", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(21), UI_POS_Y(0)}, "WPM:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(14), UI_POS_Y(3)}, "BandW:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(24), UI_POS_Y(3)}, "kHz", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(5)}, "Last seq:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(6)}, "Sent Message:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(5)}, "BandW:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(10), UI_POS_Y(5)}, "kHz", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(4)}, "Wait time: ", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(7)}, "Last seq:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X(0), UI_POS_Y(8)}, "Sent Message:", Theme::getInstance()->fg_light->foreground},
|
||||
{{UI_POS_X_RIGHT(7), UI_POS_Y_BOTTOM(5)}, "Vol.:", Theme::getInstance()->fg_light->foreground},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "gpio_lpc.h"
|
||||
#include "gpio.h"
|
||||
|
||||
typedef enum {
|
||||
LED1 = 0,
|
||||
@@ -8,7 +9,7 @@ typedef enum {
|
||||
} led_t;
|
||||
|
||||
/* GPIO Output PinMux */
|
||||
static struct gpio_t gpio_led[] = {
|
||||
static struct gpio gpio_led[] = {
|
||||
GPIO(2, 1),
|
||||
GPIO(2, 2),
|
||||
GPIO(2, 8),
|
||||
|
||||
@@ -361,6 +361,8 @@ void WaterfallView::stop() {
|
||||
baseband::spectrum_streaming_stop();
|
||||
running_ = false;
|
||||
}
|
||||
this->channel_fifo = nullptr;
|
||||
this->audio_spectrum_data = nullptr;
|
||||
}
|
||||
|
||||
void WaterfallView::show_audio_spectrum_view(const bool show) {
|
||||
|
||||
@@ -173,12 +173,16 @@ class WaterfallView : public View {
|
||||
MessageHandlerRegistration message_handler_channel_spectrum_config{
|
||||
Message::ID::ChannelSpectrumConfig,
|
||||
[this](const Message* const p) {
|
||||
if (!running_)
|
||||
return;
|
||||
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
|
||||
this->channel_fifo = message.fifo;
|
||||
}};
|
||||
MessageHandlerRegistration message_handler_audio_spectrum{
|
||||
Message::ID::AudioSpectrum,
|
||||
[this](const Message* const p) {
|
||||
if (!running_)
|
||||
return;
|
||||
const auto message = *reinterpret_cast<const AudioSpectrumMessage*>(p);
|
||||
this->audio_spectrum_data = message.data;
|
||||
this->audio_spectrum_update = true;
|
||||
@@ -186,6 +190,8 @@ class WaterfallView : public View {
|
||||
MessageHandlerRegistration message_handler_frame_sync{
|
||||
Message::ID::DisplayFrameSync,
|
||||
[this](const Message* const) {
|
||||
if (!running_)
|
||||
return;
|
||||
if (this->channel_fifo) {
|
||||
ChannelSpectrum channel_spectrum;
|
||||
while (channel_fifo->out(channel_spectrum)) {
|
||||
|
||||
@@ -746,6 +746,8 @@ set(MODE_CPPSRC
|
||||
${HACKRF_PATH}/firmware/common/usb_request.c
|
||||
${HACKRF_PATH}/firmware/common/usb_standard_request.c
|
||||
${HACKRF_PATH}/firmware/common/platform_detect.c
|
||||
${HACKRF_PATH}/firmware/common/platform_gpio.c
|
||||
${HACKRF_PATH}/firmware/common/platform_scu.c
|
||||
${HACKRF_PATH}/firmware/common/gpio_lpc.c
|
||||
${HACKRF_PATH}/firmware/common/firmware_info.c
|
||||
${HACKRF_PATH}/firmware/common/si5351c.c
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
#include "i2c_lpc.h"
|
||||
#include "cpld_jtag.h"
|
||||
#include "platform_detect.h"
|
||||
#include "platform_gpio.h"
|
||||
#include "platform_scu.h"
|
||||
#include "fixed_point.h"
|
||||
#include "clkin.h"
|
||||
#include <libopencm3/lpc43xx/cgu.h>
|
||||
#include <libopencm3/lpc43xx/ccu.h>
|
||||
@@ -48,7 +51,7 @@
|
||||
#include "gpio_lpc.h"
|
||||
|
||||
/* GPIO Output PinMux */
|
||||
static struct gpio_t gpio_led[] = {
|
||||
static struct gpio gpio_led[] = {
|
||||
GPIO(2, 1),
|
||||
GPIO(2, 2),
|
||||
GPIO(2, 8),
|
||||
@@ -58,90 +61,89 @@ static struct gpio_t gpio_led[] = {
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
static struct gpio_t gpio_1v8_enable = GPIO(3, 6);
|
||||
static struct gpio gpio_1v8_enable = GPIO(3, 6);
|
||||
|
||||
/* MAX283x GPIO (XCVR_CTL) PinMux */
|
||||
static struct gpio_t gpio_max283x_select = GPIO(0, 15);
|
||||
static struct gpio gpio_max283x_select = GPIO(0, 15);
|
||||
|
||||
/* MAX5864 SPI chip select (AD_CS) GPIO PinMux */
|
||||
static struct gpio_t gpio_max5864_select = GPIO(2, 7);
|
||||
static struct gpio gpio_max5864_select = GPIO(2, 7);
|
||||
|
||||
/* RFFC5071 GPIO serial interface PinMux */
|
||||
// #ifdef RAD1O
|
||||
// static struct gpio_t gpio_rffc5072_select = GPIO(2, 13);
|
||||
// static struct gpio_t gpio_rffc5072_clock = GPIO(5, 6);
|
||||
// static struct gpio_t gpio_rffc5072_data = GPIO(3, 3);
|
||||
// static struct gpio_t gpio_rffc5072_reset = GPIO(2, 14);
|
||||
// static struct gpio gpio_rffc5072_select = GPIO(2, 13);
|
||||
// static struct gpio gpio_rffc5072_clock = GPIO(5, 6);
|
||||
// static struct gpio gpio_rffc5072_data = GPIO(3, 3);
|
||||
// static struct gpio gpio_rffc5072_reset = GPIO(2, 14);
|
||||
// #endif
|
||||
|
||||
/* RF supply (VAA) control */
|
||||
#ifdef HACKRF_ONE
|
||||
static struct gpio_t gpio_vaa_disable = GPIO(2, 9);
|
||||
static struct gpio gpio_vaa_disable = GPIO(2, 9);
|
||||
#endif
|
||||
#ifdef RAD1O
|
||||
static struct gpio_t gpio_vaa_enable = GPIO(2, 9);
|
||||
static struct gpio gpio_vaa_enable = GPIO(2, 9);
|
||||
#endif
|
||||
|
||||
static struct gpio_t gpio_w25q80bv_hold = GPIO(1, 14);
|
||||
static struct gpio_t gpio_w25q80bv_wp = GPIO(1, 15);
|
||||
static struct gpio_t gpio_w25q80bv_select = GPIO(5, 11);
|
||||
static struct gpio gpio_w25q80bv_hold = GPIO(1, 14);
|
||||
static struct gpio gpio_w25q80bv_wp = GPIO(1, 15);
|
||||
|
||||
/* RF switch control */
|
||||
#ifdef HACKRF_ONE
|
||||
static struct gpio_t gpio_hp = GPIO(2, 0);
|
||||
static struct gpio_t gpio_lp = GPIO(2, 10);
|
||||
static struct gpio_t gpio_tx_mix_bp = GPIO(2, 11);
|
||||
static struct gpio_t gpio_no_mix_bypass = GPIO(1, 0);
|
||||
static struct gpio_t gpio_rx_mix_bp = GPIO(2, 12);
|
||||
static struct gpio_t gpio_tx_amp = GPIO(2, 15);
|
||||
static struct gpio_t gpio_tx = GPIO(5, 15);
|
||||
static struct gpio_t gpio_mix_bypass = GPIO(5, 16);
|
||||
static struct gpio_t gpio_rx = GPIO(5, 5);
|
||||
static struct gpio_t gpio_no_tx_amp_pwr = GPIO(3, 5);
|
||||
static struct gpio_t gpio_amp_bypass = GPIO(0, 14);
|
||||
static struct gpio_t gpio_rx_amp = GPIO(1, 11);
|
||||
static struct gpio_t gpio_no_rx_amp_pwr = GPIO(1, 12);
|
||||
static struct gpio gpio_hp = GPIO(2, 0);
|
||||
static struct gpio gpio_lp = GPIO(2, 10);
|
||||
static struct gpio gpio_tx_mix_bp = GPIO(2, 11);
|
||||
static struct gpio gpio_no_mix_bypass = GPIO(1, 0);
|
||||
static struct gpio gpio_rx_mix_bp = GPIO(2, 12);
|
||||
static struct gpio gpio_tx_amp = GPIO(2, 15);
|
||||
static struct gpio gpio_tx = GPIO(5, 15);
|
||||
static struct gpio gpio_mix_bypass = GPIO(5, 16);
|
||||
static struct gpio gpio_rx = GPIO(5, 5);
|
||||
static struct gpio gpio_no_tx_amp_pwr = GPIO(3, 5);
|
||||
static struct gpio gpio_amp_bypass = GPIO(0, 14);
|
||||
static struct gpio gpio_rx_amp = GPIO(1, 11);
|
||||
static struct gpio gpio_no_rx_amp_pwr = GPIO(1, 12);
|
||||
#endif
|
||||
#ifdef RAD1O
|
||||
static struct gpio_t gpio_tx_rx_n = GPIO(1, 11);
|
||||
static struct gpio_t gpio_tx_rx = GPIO(0, 14);
|
||||
static struct gpio_t gpio_by_mix = GPIO(1, 12);
|
||||
static struct gpio_t gpio_by_mix_n = GPIO(2, 10);
|
||||
static struct gpio_t gpio_by_amp = GPIO(1, 0);
|
||||
static struct gpio_t gpio_by_amp_n = GPIO(5, 5);
|
||||
static struct gpio_t gpio_mixer_en = GPIO(5, 16);
|
||||
static struct gpio_t gpio_low_high_filt = GPIO(2, 11);
|
||||
static struct gpio_t gpio_low_high_filt_n = GPIO(2, 12);
|
||||
static struct gpio_t gpio_tx_amp = GPIO(2, 15);
|
||||
static struct gpio_t gpio_rx_lna = GPIO(5, 15);
|
||||
static struct gpio gpio_tx_rx_n = GPIO(1, 11);
|
||||
static struct gpio gpio_tx_rx = GPIO(0, 14);
|
||||
static struct gpio gpio_by_mix = GPIO(1, 12);
|
||||
static struct gpio gpio_by_mix_n = GPIO(2, 10);
|
||||
static struct gpio gpio_by_amp = GPIO(1, 0);
|
||||
static struct gpio gpio_by_amp_n = GPIO(5, 5);
|
||||
static struct gpio gpio_mixer_en = GPIO(5, 16);
|
||||
static struct gpio gpio_low_high_filt = GPIO(2, 11);
|
||||
static struct gpio gpio_low_high_filt_n = GPIO(2, 12);
|
||||
static struct gpio gpio_tx_amp = GPIO(2, 15);
|
||||
static struct gpio gpio_rx_lna = GPIO(5, 15);
|
||||
#endif
|
||||
|
||||
/* CPLD JTAG interface GPIO pins */
|
||||
static struct gpio_t gpio_cpld_tdo = GPIO(5, 18);
|
||||
static struct gpio_t gpio_cpld_tck = GPIO(3, 0);
|
||||
static struct gpio gpio_cpld_tdo = GPIO(5, 18);
|
||||
static struct gpio gpio_cpld_tck = GPIO(3, 0);
|
||||
#if (defined HACKRF_ONE || defined RAD1O)
|
||||
static struct gpio_t gpio_cpld_tms = GPIO(3, 4);
|
||||
static struct gpio_t gpio_cpld_tdi = GPIO(3, 1);
|
||||
static struct gpio gpio_cpld_tms = GPIO(3, 4);
|
||||
static struct gpio gpio_cpld_tdi = GPIO(3, 1);
|
||||
#else
|
||||
static struct gpio_t gpio_cpld_tms = GPIO(3, 1);
|
||||
static struct gpio_t gpio_cpld_tdi = GPIO(3, 4);
|
||||
static struct gpio gpio_cpld_tms = GPIO(3, 1);
|
||||
static struct gpio gpio_cpld_tdi = GPIO(3, 4);
|
||||
#endif
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
static struct gpio_t gpio_cpld_pp_tms = GPIO(1, 1);
|
||||
static struct gpio_t gpio_cpld_pp_tdo = GPIO(1, 8);
|
||||
static struct gpio gpio_cpld_pp_tms = GPIO(1, 1);
|
||||
static struct gpio gpio_cpld_pp_tdo = GPIO(1, 8);
|
||||
#endif
|
||||
|
||||
/* other CPLD interface GPIO pins */
|
||||
static struct gpio_t gpio_hw_sync_enable = GPIO(5, 12);
|
||||
static struct gpio_t gpio_q_invert = GPIO(0, 13);
|
||||
static struct gpio gpio_hw_sync_enable = GPIO(5, 12);
|
||||
static struct gpio gpio_q_invert = GPIO(0, 13);
|
||||
|
||||
/* HackRF One r9 */
|
||||
#ifdef HACKRF_ONE
|
||||
static struct gpio_t gpio_h1r9_rx = GPIO(0, 7);
|
||||
static struct gpio_t gpio_h1r9_1v8_enable = GPIO(2, 9);
|
||||
static struct gpio_t gpio_h1r9_vaa_disable = GPIO(3, 6);
|
||||
static struct gpio_t gpio_h1r9_hw_sync_enable = GPIO(5, 5);
|
||||
static struct gpio gpio_h1r9_rx = GPIO(0, 7);
|
||||
static struct gpio gpio_h1r9_1v8_enable = GPIO(2, 9);
|
||||
static struct gpio gpio_h1r9_vaa_disable = GPIO(3, 6);
|
||||
static struct gpio gpio_h1r9_hw_sync_enable = GPIO(5, 5);
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
@@ -216,11 +218,10 @@ max5864_driver_t max5864 = {
|
||||
.target_init = max5864_target_init,
|
||||
};
|
||||
|
||||
const ssp_config_t ssp_config_w25q80bv = {
|
||||
ssp_config_t ssp_config_w25q80bv = {
|
||||
.data_bits = SSP_DATA_8BITS,
|
||||
.serial_clock_rate = 2,
|
||||
.clock_prescale_rate = 2,
|
||||
.gpio_select = &gpio_w25q80bv_select,
|
||||
};
|
||||
|
||||
spi_bus_t spi_bus_ssp0 = {
|
||||
@@ -431,96 +432,105 @@ bool sample_rate_frac_set(uint32_t rate_num, uint32_t rate_denom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sample_rate_set(const uint32_t sample_rate_hz) {
|
||||
uint32_t p1 = 4608;
|
||||
uint32_t p2 = 0;
|
||||
uint32_t p3 = 0;
|
||||
/*
|
||||
* Configure clock generator to produce sample clock in units of 1/(2**24) Hz.
|
||||
* Can be called with program=false for a dry run that returns the resultant
|
||||
* frequency without actually configuring the clock generator.
|
||||
*/
|
||||
fp_40_24_t sample_rate_set(const fp_40_24_t sample_rate, const bool program) {
|
||||
const fp_40_24_t vco = 800 * FP_ONE_MHZ;
|
||||
uint64_t p1, p2, p3;
|
||||
uint64_t n, d, q;
|
||||
fp_40_24_t remainder, resultant_rate;
|
||||
|
||||
switch (sample_rate_hz) {
|
||||
case 8000000:
|
||||
p1 = SI_INTDIV(50); // 800MHz / 50 = 16 MHz (SGPIO), 8 MHz (codec)
|
||||
break;
|
||||
fp_40_24_t rate = sample_rate * 2;
|
||||
|
||||
case 9216000:
|
||||
// 43.40277777777778: a = 43; b = 29; c = 72
|
||||
p1 = 5043;
|
||||
p2 = 40;
|
||||
p3 = 72;
|
||||
break;
|
||||
p1 = ((128 * vco) / rate) - 512;
|
||||
if (vco % rate) {
|
||||
n = (128 * vco) - (rate * (p1 + 512));
|
||||
d = rate / FP_ONE_HZ;
|
||||
n += (d / 2);
|
||||
p2 = n / d;
|
||||
p3 = 1 << 24;
|
||||
|
||||
case 10000000:
|
||||
p1 = SI_INTDIV(40); // 800MHz / 40 = 20 MHz (SGPIO), 10 MHz (codec)
|
||||
break;
|
||||
unsigned int shift = p2 ? __builtin_ctzll(p2) : 24;
|
||||
p2 >>= shift;
|
||||
p3 >>= shift;
|
||||
|
||||
case 12288000:
|
||||
// 32.552083333333336: a = 32; b = 159; c = 288
|
||||
p1 = 3654;
|
||||
p2 = 192;
|
||||
p3 = 288;
|
||||
break;
|
||||
const uint64_t p3_max = 0xfffff;
|
||||
if (p3 > p3_max) {
|
||||
p2 *= p3_max;
|
||||
p2 += (p3 / 2);
|
||||
p2 /= p3;
|
||||
p3 = p3_max;
|
||||
}
|
||||
|
||||
case 12500000:
|
||||
p1 = SI_INTDIV(32); // 800MHz / 32 = 25 MHz (SGPIO), 12.5 MHz (codec)
|
||||
break;
|
||||
if (p2 >= p3) {
|
||||
p1++;
|
||||
p2 = 0;
|
||||
}
|
||||
} else {
|
||||
p2 = 0;
|
||||
}
|
||||
|
||||
case 16000000:
|
||||
p1 = SI_INTDIV(25); // 800MHz / 25 = 32 MHz (SGPIO), 16 MHz (codec)
|
||||
break;
|
||||
if (p1 > 0x3fe00) {
|
||||
p1 = 0x3fe00;
|
||||
p2 = 0;
|
||||
}
|
||||
|
||||
case 18432000:
|
||||
// 21.70138888889: a = 21; b = 101; c = 144
|
||||
p1 = 2265;
|
||||
p2 = 112;
|
||||
p3 = 144;
|
||||
break;
|
||||
if (p2 == 0) {
|
||||
p3 = 1;
|
||||
n = (vco * 128);
|
||||
d = (p1 + 512);
|
||||
n += (d / 2);
|
||||
resultant_rate = n / d;
|
||||
} else {
|
||||
const uint64_t vco_hz = vco / FP_ONE_HZ;
|
||||
n = p3 * vco_hz * 128;
|
||||
d = p3 * (p1 + 512) + p2;
|
||||
const uint64_t rate_hz = n / d;
|
||||
remainder = (n - (d * rate_hz)) * FP_ONE_HZ;
|
||||
remainder += (d / 2);
|
||||
q = remainder / d;
|
||||
resultant_rate = (rate_hz * FP_ONE_HZ) + q;
|
||||
}
|
||||
|
||||
case 20000000:
|
||||
p1 = SI_INTDIV(20); // 800MHz / 20 = 40 MHz (SGPIO), 20 MHz (codec)
|
||||
break;
|
||||
resultant_rate = (resultant_rate + 1) / 2;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (!program) {
|
||||
return resultant_rate;
|
||||
}
|
||||
|
||||
bool streaming = sgpio_cpld_stream_is_enabled(&sgpio_config);
|
||||
|
||||
if (streaming) {
|
||||
sgpio_cpld_stream_disable(&sgpio_config);
|
||||
}
|
||||
|
||||
if (p1 & 0x1 || p2) {
|
||||
si5351c_set_int_mode(&clock_gen, 0, 0);
|
||||
} else {
|
||||
si5351c_set_int_mode(&clock_gen, 0, 1);
|
||||
}
|
||||
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
/*
|
||||
* On HackRF One r9 all sample clocks are externally derived
|
||||
* from MS1/CLK1 operating at twice the sample rate.
|
||||
*/
|
||||
si5351c_configure_multisynth(&clock_gen, 1, p1, p2, p3, 0);
|
||||
} else {
|
||||
/*
|
||||
* On other platforms the clock generator produces three
|
||||
* different sample clocks, all derived from multisynth 0.
|
||||
*/
|
||||
/* MS0/CLK0 is the source for the MAX5864/CPLD (CODEC_CLK). */
|
||||
si5351c_configure_multisynth(&clock_gen, 0, p1, p2, p3, 1);
|
||||
|
||||
/* MS0/CLK1 is the source for the CPLD (CODEC_X2_CLK). */
|
||||
si5351c_configure_multisynth(
|
||||
&clock_gen,
|
||||
1,
|
||||
p1,
|
||||
0,
|
||||
1,
|
||||
0); // p1 doesn't matter
|
||||
|
||||
/* MS0/CLK2 is the source for SGPIO (CODEC_X2_CLK) */
|
||||
si5351c_configure_multisynth(
|
||||
&clock_gen,
|
||||
2,
|
||||
p1,
|
||||
0,
|
||||
1,
|
||||
0); // p1 doesn't matter
|
||||
si5351c_configure_multisynth(&clock_gen, 1, 0, 0, 0, 0);
|
||||
si5351c_configure_multisynth(&clock_gen, 2, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
if (streaming) {
|
||||
sgpio_cpld_stream_enable(&sgpio_config);
|
||||
}
|
||||
|
||||
return resultant_rate;
|
||||
}
|
||||
|
||||
bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz) {
|
||||
uint32_t bandwidth_hz_real;
|
||||
bandwidth_hz_real = max283x_set_lpf_bandwidth(&max283x, bandwidth_hz);
|
||||
bandwidth_hz_real = max283x_set_lpf_bandwidth(&max283x, MAX283x_MODE_RX, bandwidth_hz);
|
||||
|
||||
if (bandwidth_hz_real) {
|
||||
hackrf_ui()->set_filter_bw(bandwidth_hz_real);
|
||||
@@ -615,8 +625,8 @@ void cpu_clock_init(void) {
|
||||
si5351c_power_down_all_clocks(&clock_gen);
|
||||
si5351c_set_crystal_configuration(&clock_gen);
|
||||
si5351c_enable_xo_and_ms_fanout(&clock_gen);
|
||||
si5351c_configure_pll_sources(&clock_gen);
|
||||
si5351c_configure_pll_multisynth(&clock_gen);
|
||||
si5351c_configure_pll_sources(&clock_gen, PLL_SOURCE_XTAL);
|
||||
si5351c_configure_pll_multisynth(&clock_gen, PLL_SOURCE_XTAL);
|
||||
|
||||
/*
|
||||
* Clocks on HackRF One r9:
|
||||
@@ -667,7 +677,7 @@ void cpu_clock_init(void) {
|
||||
/* MS7/CLK7 is unused. */
|
||||
|
||||
/* Set to 10 MHz, the common rate between Jawbreaker and HackRF One. */
|
||||
sample_rate_set(10000000);
|
||||
sample_rate_set(10000000 * (fp_40_24_t)FP_ONE_HZ, true);
|
||||
|
||||
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_XTAL);
|
||||
// soft reset
|
||||
@@ -854,6 +864,8 @@ void ssp1_set_mode_max5864(void) {
|
||||
}
|
||||
|
||||
void pin_setup(void) {
|
||||
const platform_scu_t* scu = platform_scu();
|
||||
|
||||
/* Configure all GPIO as Input (safe state) */
|
||||
// gpio_init();
|
||||
|
||||
@@ -872,26 +884,26 @@ void pin_setup(void) {
|
||||
* LPC43xx pull-up and pull-down resistors are approximately 53K.
|
||||
*/
|
||||
#ifdef HACKRF_ONE
|
||||
scu_pinmux(SCU_PINMUX_PP_TMS, SCU_GPIO_PUP | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_PP_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_PP_TMS, SCU_GPIO_PUP | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_PP_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
#endif
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(SCU_PINMUX_CPLD_TCK, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_CPLD_TMS, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_CPLD_TDI, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_CPLD_TDO, SCU_GPIO_PDN | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(scu->PINMUX_CPLD_TCK, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
|
||||
/* Configure SCU Pin Mux as GPIO */
|
||||
scu_pinmux(SCU_PINMUX_LED1, SCU_GPIO_NOPULL);
|
||||
scu_pinmux(SCU_PINMUX_LED2, SCU_GPIO_NOPULL);
|
||||
scu_pinmux(SCU_PINMUX_LED3, SCU_GPIO_NOPULL);
|
||||
scu_pinmux(scu->PINMUX_LED1, SCU_GPIO_NOPULL);
|
||||
scu_pinmux(scu->PINMUX_LED2, SCU_GPIO_NOPULL);
|
||||
scu_pinmux(scu->PINMUX_LED3, SCU_GPIO_NOPULL);
|
||||
#ifdef RAD1O
|
||||
scu_pinmux(SCU_PINMUX_LED4, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
scu_pinmux(scu->PINMUX_LED4, SCU_GPIO_NOPULL | SCU_CONF_FUNCTION4);
|
||||
#endif
|
||||
|
||||
/* Configure USB indicators */
|
||||
#ifdef JAWBREAKER
|
||||
scu_pinmux(SCU_PINMUX_USB_LED0, SCU_CONF_FUNCTION3);
|
||||
scu_pinmux(SCU_PINMUX_USB_LED1, SCU_CONF_FUNCTION3);
|
||||
scu_pinmux(scu->PINMUX_USB_LED0, SCU_CONF_FUNCTION3);
|
||||
scu_pinmux(scu->PINMUX_USB_LED1, SCU_CONF_FUNCTION3);
|
||||
#endif
|
||||
|
||||
gpio_output(&gpio_led[0]);
|
||||
@@ -905,11 +917,11 @@ void pin_setup(void) {
|
||||
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
|
||||
#ifdef HACKRF_ONE
|
||||
gpio_output(&gpio_h1r9_1v8_enable);
|
||||
scu_pinmux(SCU_H1R9_EN1V8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->H1R9_EN1V8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||
#endif
|
||||
} else {
|
||||
gpio_output(&gpio_1v8_enable);
|
||||
scu_pinmux(SCU_PINMUX_EN1V8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_EN1V8, SCU_GPIO_FAST | SCU_CONF_FUNCTION0);
|
||||
}
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
@@ -935,8 +947,8 @@ void pin_setup(void) {
|
||||
scu_pinmux(CLK0, SCU_CLK_IN | SCU_CONF_FUNCTION7);
|
||||
scu_pinmux(CLK2, SCU_CLK_IN | SCU_CONF_FUNCTION7);
|
||||
|
||||
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
scu_pinmux(scu->PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -956,7 +968,7 @@ void pin_setup(void) {
|
||||
rf_path_pin_setup(&rf_path);
|
||||
|
||||
/* Configure external clock in */
|
||||
scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
|
||||
scu_pinmux(scu->PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
|
||||
|
||||
sgpio_configure_pin_functions(&sgpio_config);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "scsi.h"
|
||||
#include "diskio.h"
|
||||
#include "gpio_lpc.h"
|
||||
#include <libopencm3/lpc43xx/scu.h>
|
||||
#include <libopencm3/lpc43xx/rgu.h>
|
||||
#include <libopencm3/lpc43xx/wwdt.h>
|
||||
@@ -286,7 +287,7 @@ void scsi_command(msd_cbw_t* msd_cbw_data) {
|
||||
|
||||
case SCSI_CMD_START_STOP_UNIT:
|
||||
SCU_SFSP2_8 = (SCU_SFSP2_8 & ~(7)) | 4;
|
||||
struct gpio_t dfu = GPIO(5, 7);
|
||||
struct gpio dfu = GPIO(5, 7);
|
||||
gpio_output(&dfu);
|
||||
gpio_clear(&dfu);
|
||||
|
||||
|
||||
+1
-1
Submodule hackrf updated: 38e082b939...442d95e23d
Reference in New Issue
Block a user