feat(pm5): hf tune --rgb / lf tune --rgb - antenna RGB as a tuning meter

Adds an opt-in `--rgb` flag to the continuous `hf tune` / `lf tune` commands that
mirrors the antenna tuning level on the PM5 antenna RGB LED: blue = low, green =
mid, red = high, tracking the on-screen bar so you can find coupling (e.g. an
implant) by feel without watching the screen.

The colour is computed client-side from the same per-iteration voltage / running
peak the bar uses (so it matches the bar and auto-scales), and pushed to the
device via a new dumb CMD_PM5_RGB_SET {r,g,b}. That command is handled (#ifdef
PM5) by a dedicated AT32 RGB HAL module, common_arm/rgb/{rgb_apis.h,
rgb_hw_at32.c} (RgbLedSet(), I2C controller @ 0x48), wired into the armsrc
Makefile/CMake as SRC_RGB for PM5 only - so no other platform is affected and no
hardware code lands in shared files.
This commit is contained in:
Nemanja Nedeljkovic authored and Philippe Teuwen committed 2026-08-20 11:55:55 +02:00
1 parent ad4a94b1a5
commit 6507b8f36b
12 files changed
+142 -2

No files matched your search

+2 -2
View File
@@ -43,12 +43,12 @@ OBJDIR = obj
INCLUDE = -I../include -I../common_arm -I../common_fpga -I../common -I.
INCLUDE += -I../common_arm/flash_code -I../common_arm/flash_data -I../common_arm/fpga -I../common_arm/gpio
INCLUDE += -I../common_arm/rssi -I../common_arm/sys -I../common_arm/ticks -I../common_arm/usb -I../common_arm/wdt
INCLUDE += -I../common_arm/rssi -I../common_arm/rgb -I../common_arm/sys -I../common_arm/ticks -I../common_arm/usb -I../common_arm/wdt
# Also search prerequisites in the common directory (for usb.c), the fpga directory (for fpga.bit), and the lz4 directory
VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/lz4 ../fpga ../armsrc/Standalone ../common/hitag2
VPATH += ../common_arm/flash_code ../common_arm/flash_data ../common_arm/fpga ../common_arm/gpio
VPATH += ../common_arm/rssi ../common_arm/sys ../common_arm/ticks ../common_arm/usb ../common_arm/wdt
VPATH += ../common_arm/rssi ../common_arm/rgb ../common_arm/sys ../common_arm/ticks ../common_arm/usb ../common_arm/wdt
INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h
+15
View File
@@ -0,0 +1,15 @@
#ifndef RGB_APIS_H_
#define RGB_APIS_H_
#include "common.h"
//-----------------------------------------------------------------------------
// Antenna RGB LED control.
//
// Only implemented on platforms that actually have an RGB LED (currently PM5,
// driven by an I2C RGB controller). Other platforms don't build this module, so
// callers must guard usage accordingly (e.g. the CMD_PM5_RGB_SET handler).
//-----------------------------------------------------------------------------
void RgbLedSet(uint8_t r, uint8_t g, uint8_t b);
#endif // RGB_APIS_H_
+22
View File
@@ -0,0 +1,22 @@
#include "rgb_apis.h"
#include "i2c.h" // RGB LED is driven over I2C
#include "ticks_apis.h" // I2C timing needs ticks running
// PM5 antenna RGB LED, driven by an I2C RGB controller (7-bit address 0x48).
// Register map (from the QC/bring-up code):
// 0x02 = index (which LED)
// 0x01 = count (number of LEDs on the string; must be set or nothing lights)
// 0x03 = data (3 bytes RGB888 per LED)
#define RGB_I2C_ADDR (0x48 << 1) // 8-bit address form expected by the I2C_* API
#define RGB_REG_COUNT 0x01
#define RGB_REG_INDEX 0x02
#define RGB_REG_DATA 0x03
void RgbLedSet(uint8_t r, uint8_t g, uint8_t b) {
uint8_t rgb[3] = { r, g, b };
StartTicks();
I2C_init(true);
I2C_WriteByte(0, RGB_REG_INDEX, RGB_I2C_ADDR); // address LED index 0
I2C_WriteByte(1, RGB_REG_COUNT, RGB_I2C_ADDR); // 1 LED on the string
I2C_BufferWrite(rgb, sizeof(rgb), RGB_REG_DATA, RGB_I2C_ADDR);
}