chore(tx15): avoid hardcoding magic numbers (#6586)

This commit is contained in:
3djc
2025-09-17 11:52:51 +10:00
committed by GitHub
parent 3d3378ed98
commit 39f0ace8ad
2 changed files with 9 additions and 7 deletions
+4 -4
View File
@@ -144,15 +144,15 @@ int bsp_io_init()
_expanders_reset();
// configure expander 1
_init_io_expander(&_io_fs_switches, EXP_1_MASK);
if (pca95xx_init(&_io_fs_switches.exp, IO_EXPANDER_I2C_BUS, 0x74) < 0) {
_init_io_expander(&_io_fs_switches, IO_EXPANDER1_MASK);
if (pca95xx_init(&_io_fs_switches.exp, IO_EXPANDER_I2C_BUS, IO_EXPANDER1_I2C_ADDR) < 0) {
TRACE("EXP1 INIT ERROR");
return -1;
}
// configure expander 2
_init_io_expander(&_io_switches, EXP_2_MASK);
if (pca95xx_init(&_io_switches.exp, IO_EXPANDER_I2C_BUS, 0x75) < 0) {
_init_io_expander(&_io_switches, IO_EXPANDER2_MASK);
if (pca95xx_init(&_io_switches.exp, IO_EXPANDER_I2C_BUS, IO_EXPANDER2_I2C_ADDR) < 0) {
TRACE("EXP2 INIT ERROR");
return -1;
}
+5 -3
View File
@@ -24,7 +24,9 @@
#include "drivers/pca95xx.h"
#include "hal/switch_driver.h"
#define IO_EXPANDER_I2C_BUS I2C_Bus_1
#define IO_EXPANDER_I2C_BUS I2C_Bus_1
#define IO_EXPANDER1_I2C_ADDR 0x74
#define IO_EXPANDER2_I2C_ADDR 0x75
// Port expander 2 (0x75)
#define BSP_TR1U PCA95XX_PIN_13
@@ -50,5 +52,5 @@ uint16_t bsp_input_get();
struct stm32_switch_t;
//TODO compute from json
constexpr uint32_t EXP_1_MASK = 0xFF3F;
constexpr uint32_t EXP_2_MASK = 0xFFF8;
constexpr uint32_t IO_EXPANDER1_MASK = 0xFF3F;
constexpr uint32_t IO_EXPANDER2_MASK = 0xFFF8;