Praline rssi (#3127)

This commit is contained in:
Pezsma
2026-04-07 19:42:21 +02:00
committed by GitHub
parent d5f94398ce
commit 5deeaed5f0
7 changed files with 69 additions and 252 deletions
-25
View File
@@ -102,31 +102,6 @@ void BasebandThread::run() {
buffer_c8_t buffer{
buffer_tmp.p, buffer_tmp.count, sampling_rate_};
#ifdef PRALINE
/*
* Software RSSI: Copy 8 I/Q samples spread across buffer.
*
* Just pack and copy - no computation here.
* rssi_thread does __SMUAD power and rssi calculation.
* 8 samples avoids zero-crossing artifacts.
*/
if (direction_ == baseband::Direction::Receive && buffer_tmp.count >= 32) {
const size_t step = buffer_tmp.count / 8;
for (size_t i = 0; i < 8; i++) {
const size_t idx = i * step + (step / 2);
const auto sample = buffer_tmp.p[idx];
// Pack into 32 bits: Q in high 16 bits, I in low 16 bits, the safe approach:
// 1. Cast to uint16_t to capture the raw 16-bit pattern (e.g., -1 becomes 0xFFFF)
// 2. OR them together. The uint16_t will be promoted to uint32_t cleanly.
// This is accomplished with the specific hardware instruction designed
// for this __PKHBT (Pack Halfword Bottom Top).
shared_memory.software_rssi_iq[i] = __PKHBT(sample.real(), sample.imag(), 16);
}
}
#endif
if (shared_memory.request_m4_performance_counter == 0x02) {
uint8_t max = shared_memory.m4_performance_counter;
for (size_t i = 0; i < buffer_tmp.count; i++) {