board: aplhax-silver: read board revsion from PCA9555
This commit is contained in:
parent
8af5f51fc7
commit
25c1d5e1ad
|
@ -1,10 +1,13 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "hellen_meta.h"
|
#include "hellen_meta.h"
|
||||||
|
#include "i2c_bb.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "hellen_leds_100.cpp"
|
#include "hellen_leds_100.cpp"
|
||||||
#include "smart_gpio.h"
|
#include "smart_gpio.h"
|
||||||
#include "drivers/gpio/tle9104.h"
|
#include "drivers/gpio/tle9104.h"
|
||||||
|
|
||||||
|
#define PCA9555_I2C_ADDR 0x20
|
||||||
|
|
||||||
static OutputPin alphaTempPullUp;
|
static OutputPin alphaTempPullUp;
|
||||||
|
|
||||||
static void setInjectorPins() {
|
static void setInjectorPins() {
|
||||||
|
@ -35,6 +38,44 @@ static void setupDefaultSensorInputs() {
|
||||||
engineConfiguration->iat.adcChannel = MM100_IN_IAT_ANALOG;
|
engineConfiguration->iat.adcChannel = MM100_IN_IAT_ANALOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t getBoardRevision() {
|
||||||
|
static bool isFirstInvocation = true;
|
||||||
|
static uint32_t variant;
|
||||||
|
|
||||||
|
if (isFirstInvocation) {
|
||||||
|
BitbangI2c m_i2c;
|
||||||
|
const uint8_t set_out[3] = {0x06, 0xff, 0xff};
|
||||||
|
const uint8_t read_inputs_cmd[1] = {0x00};
|
||||||
|
uint8_t rx[2] = {0xff, 0xff};
|
||||||
|
|
||||||
|
//same pins as for LPS25
|
||||||
|
m_i2c.init(Gpio::B10, Gpio::B11);
|
||||||
|
|
||||||
|
// configuration registers:
|
||||||
|
// after reset all IO pins should be configured as output, so ttis step can be skipped
|
||||||
|
m_i2c.write(PCA9555_I2C_ADDR, set_out, sizeof(set_out));
|
||||||
|
|
||||||
|
// read registers 0 and 1: Input port registers
|
||||||
|
m_i2c.writeRead(PCA9555_I2C_ADDR, read_inputs_cmd, sizeof(read_inputs_cmd), rx, sizeof(rx));
|
||||||
|
|
||||||
|
variant = (rx[1] << 8) | (rx[0] << 0);
|
||||||
|
|
||||||
|
efiPrintf("Board variant 0x%04x\n", (unsigned int)variant);
|
||||||
|
|
||||||
|
isFirstInvocation = false;
|
||||||
|
|
||||||
|
// release gpios for LPS25 driver
|
||||||
|
m_i2c.deinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hackHellenBoardId(int /* detectedId */) {
|
||||||
|
return getBoardRevision();
|
||||||
|
}
|
||||||
|
|
||||||
void setBoardConfigOverrides() {
|
void setBoardConfigOverrides() {
|
||||||
/* Force PWR_EN as TLE9104s are powered from +5VA */
|
/* Force PWR_EN as TLE9104s are powered from +5VA */
|
||||||
setHellenMegaEnPin();
|
setHellenMegaEnPin();
|
||||||
|
|
Loading…
Reference in New Issue