chore(tx15): avoid hardcoding magic numbers (#6586)
This commit is contained in:
@@ -144,15 +144,15 @@ int bsp_io_init()
|
|||||||
_expanders_reset();
|
_expanders_reset();
|
||||||
|
|
||||||
// configure expander 1
|
// configure expander 1
|
||||||
_init_io_expander(&_io_fs_switches, EXP_1_MASK);
|
_init_io_expander(&_io_fs_switches, IO_EXPANDER1_MASK);
|
||||||
if (pca95xx_init(&_io_fs_switches.exp, IO_EXPANDER_I2C_BUS, 0x74) < 0) {
|
if (pca95xx_init(&_io_fs_switches.exp, IO_EXPANDER_I2C_BUS, IO_EXPANDER1_I2C_ADDR) < 0) {
|
||||||
TRACE("EXP1 INIT ERROR");
|
TRACE("EXP1 INIT ERROR");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure expander 2
|
// configure expander 2
|
||||||
_init_io_expander(&_io_switches, EXP_2_MASK);
|
_init_io_expander(&_io_switches, IO_EXPANDER2_MASK);
|
||||||
if (pca95xx_init(&_io_switches.exp, IO_EXPANDER_I2C_BUS, 0x75) < 0) {
|
if (pca95xx_init(&_io_switches.exp, IO_EXPANDER_I2C_BUS, IO_EXPANDER2_I2C_ADDR) < 0) {
|
||||||
TRACE("EXP2 INIT ERROR");
|
TRACE("EXP2 INIT ERROR");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
#include "drivers/pca95xx.h"
|
#include "drivers/pca95xx.h"
|
||||||
#include "hal/switch_driver.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)
|
// Port expander 2 (0x75)
|
||||||
#define BSP_TR1U PCA95XX_PIN_13
|
#define BSP_TR1U PCA95XX_PIN_13
|
||||||
@@ -50,5 +52,5 @@ uint16_t bsp_input_get();
|
|||||||
struct stm32_switch_t;
|
struct stm32_switch_t;
|
||||||
|
|
||||||
//TODO compute from json
|
//TODO compute from json
|
||||||
constexpr uint32_t EXP_1_MASK = 0xFF3F;
|
constexpr uint32_t IO_EXPANDER1_MASK = 0xFF3F;
|
||||||
constexpr uint32_t EXP_2_MASK = 0xFFF8;
|
constexpr uint32_t IO_EXPANDER2_MASK = 0xFFF8;
|
||||||
|
|||||||
Reference in New Issue
Block a user