Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jacob.eva 2024-09-11 20:50:41 +01:00
commit 1a91fa60d8
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E
3 changed files with 29 additions and 45 deletions

View File

@ -78,6 +78,7 @@
bool pmu_ready = false;
bool promisc = false;
bool implicit = false;
volatile bool packet_ready = false;
uint8_t implicit_l = 0;
uint8_t op_mode = MODE_HOST;

View File

@ -96,10 +96,11 @@ extern RadioInterface* interface_obj[];
// which one is high. We can then use the index of this pin in the 2D array to
// signal the correct interface to the main loop
void ISR_VECT onDio0Rise() {
BaseType_t int_status = taskENTER_CRITICAL_FROM_ISR();
for (int i = 0; i < INTERFACE_COUNT; i++) {
if (digitalRead(interface_pins[i][5]) == HIGH) {
if (interface_obj[i]->getPacketValidity()) {
fifo_push(&packet_rdy_interfaces, i);
interface_obj[i]->handleDio0Rise();
}
if (interfaces[i] == SX128X) {
// On the SX1280, there is a bug which can cause the busy line
@ -111,6 +112,7 @@ void ISR_VECT onDio0Rise() {
}
}
}
taskEXIT_CRITICAL_FROM_ISR(int_status);
}
sx126x::sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen) :
@ -2621,11 +2623,11 @@ void sx128x::updateBitrate() {
_csma_slot_ms = 10;
float target_preamble_symbols;
if (_bitrate <= LORA_FAST_BITRATE_THRESHOLD) {
//if (_bitrate <= LORA_FAST_BITRATE_THRESHOLD) {
target_preamble_symbols = (LORA_PREAMBLE_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
} else {
target_preamble_symbols = (LORA_PREAMBLE_FAST_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
}
//} else {
/*target_preamble_symbols = (LORA_PREAMBLE_FAST_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
}*/
if (target_preamble_symbols < LORA_PREAMBLE_SYMBOLS_MIN) {
target_preamble_symbols = LORA_PREAMBLE_SYMBOLS_MIN;
} else {

View File

@ -324,6 +324,7 @@ inline void kiss_write_packet(int index) {
}
serial_write(FEND);
read_len = 0;
packet_ready = false;
}
inline void getPacketData(RadioInterface* radio, uint16_t len) {
@ -362,7 +363,7 @@ void receive_callback(uint8_t index, int packet_size) {
getPacketData(selected_radio, packet_size);
seq = SEQ_UNSET;
ready = true;
packet_ready = true;
} else if (isSplitPacket(header) && seq != sequence) {
// This split packet does not carry the
@ -387,7 +388,7 @@ void receive_callback(uint8_t index, int packet_size) {
}
getPacketData(selected_radio, packet_size);
ready = true;
packet_ready = true;
}
} else {
// In promiscuous mode, raw packets are
@ -395,26 +396,9 @@ void receive_callback(uint8_t index, int packet_size) {
read_len = 0;
getPacketData(selected_radio, packet_size);
ready = true;
packet_ready = true;
}
if (ready) {
#if MCU_VARIANT == MCU_ESP32
portENTER_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portENTER_CRITICAL();
#endif
last_rssi = selected_radio->packetRssi();
last_snr_raw = selected_radio->packetSnrRaw();
#if MCU_VARIANT == MCU_ESP32
portEXIT_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portEXIT_CRITICAL();
#endif
kiss_indicate_stat_rssi();
kiss_indicate_stat_snr();
kiss_write_packet(index);
}
last_rx = millis();
}
@ -1190,7 +1174,23 @@ void validate_status() {
}
void loop() {
packet_poll();
if (packet_ready) {
#if MCU_VARIANT == MCU_ESP32
portENTER_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portENTER_CRITICAL();
#endif
last_rssi = selected_radio->packetRssi();
last_snr_raw = selected_radio->packetSnrRaw();
#if MCU_VARIANT == MCU_ESP32
portEXIT_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portEXIT_CRITICAL();
#endif
kiss_indicate_stat_rssi();
kiss_indicate_stat_snr();
kiss_write_packet(1);
}
bool ready = false;
for (int i = 0; i < INTERFACE_COUNT; i++) {
@ -1327,25 +1327,6 @@ void poll_buffers() {
process_serial();
}
void packet_poll() {
// If we have received a packet on an interface which needs to be processed
while (!fifo_isempty(&packet_rdy_interfaces)) {
#if MCU_VARIANT == MCU_ESP32
portENTER_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portENTER_CRITICAL();
#endif
uint8_t packet_int = fifo_pop(&packet_rdy_interfaces);
#if MCU_VARIANT == MCU_ESP32
portEXIT_CRITICAL(&update_lock);
#elif MCU_VARIANT == MCU_NRF52
portEXIT_CRITICAL();
#endif
selected_radio = interface_obj[packet_int];
selected_radio->handleDio0Rise();
}
}
volatile bool serial_polling = false;
void serial_poll() {
serial_polling = true;