Assorted todos (#2762)

* gpiochip todos

* fuel computer

* this was already done
This commit is contained in:
Matthew Kennedy 2021-05-30 16:23:29 -07:00 committed by GitHub
parent f51dd36622
commit e68d920a9b
5 changed files with 22 additions and 40 deletions

View File

@ -21,7 +21,6 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const
FuelComputer::FuelComputer(const ValueProvider3D& lambdaTable) : m_lambdaTable(&lambdaTable) {} FuelComputer::FuelComputer(const ValueProvider3D& lambdaTable) : m_lambdaTable(&lambdaTable) {}
float FuelComputer::getStoichiometricRatio() const { float FuelComputer::getStoichiometricRatio() const {
// TODO: vary this with ethanol content/configured setting/whatever
float primary = (float)CONFIG(stoichRatioPrimary) / PACK_MULT_AFR_CFG; float primary = (float)CONFIG(stoichRatioPrimary) / PACK_MULT_AFR_CFG;
// Config compatibility: this field may be zero on ECUs with old defaults // Config compatibility: this field may be zero on ECUs with old defaults

View File

@ -20,8 +20,8 @@ constexpr float convertToGramsPerSecond(float ccPerMinute) {
expected<float> InjectorModel::getAbsoluteRailPressure() const { expected<float> InjectorModel::getAbsoluteRailPressure() const {
switch (CONFIG(injectorCompensationMode)) { switch (CONFIG(injectorCompensationMode)) {
case ICM_FixedRailPressure: case ICM_FixedRailPressure:
// TODO: should this add baro pressure instead of 1atm? // Add barometric pressure, as "fixed" really means "fixed pressure above atmosphere"
return (CONFIG(fuelReferencePressure) + 101.325f); return CONFIG(fuelReferencePressure) + Sensor::get(SensorType::BarometricPressure).value_or(101.325f);
case ICM_SensedRailPressure: case ICM_SensedRailPressure:
if (!Sensor::hasSensor(SensorType::FuelPressureInjector)) { if (!Sensor::hasSensor(SensorType::FuelPressureInjector)) {
firmwareError(OBD_PCM_Processor_Fault, "Fuel pressure compensation is set to use a pressure sensor, but none is configured."); firmwareError(OBD_PCM_Processor_Fault, "Fuel pressure compensation is set to use a pressure sensor, but none is configured.");

View File

@ -133,8 +133,6 @@ static int mc33972_spi_w(mc33972_priv *chip, uint32_t tx)
/* Slave Select assertion. */ /* Slave Select assertion. */
spiSelect(spi); spiSelect(spi);
/* Atomic transfer operations. */ /* Atomic transfer operations. */
/* TODO: check why spiExchange transfers invalid data on STM32F7xx, DMA issue? */
//spiExchange(spi, 3, txb, rxb);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
rxb[i] = spiPolledExchange(spi, txb[i]); rxb[i] = spiPolledExchange(spi, txb[i]);
/* Slave Select de-assertion. */ /* Slave Select de-assertion. */
@ -156,15 +154,7 @@ static int mc33972_spi_w(mc33972_priv *chip, uint32_t tx)
static int mc33972_update_status(mc33972_priv *chip) static int mc33972_update_status(mc33972_priv *chip)
{ {
int ret; return mc33972_spi_w(chip, CMD_STATUS);
/* TODO: lock? */
ret = mc33972_spi_w(chip, CMD_STATUS);
/* TODO: unlock? */
return ret;
} }
static int mc33972_update_pullups(mc33972_priv *chip) static int mc33972_update_pullups(mc33972_priv *chip)

View File

@ -137,8 +137,6 @@ static int tle6240_spi_rw(tle6240_priv *chip, uint16_t tx, uint16_t *rx)
/* Slave Select assertion. */ /* Slave Select assertion. */
spiSelect(spi); spiSelect(spi);
/* Atomic transfer operations. */ /* Atomic transfer operations. */
/* TODO: check why spiExchange transfers invalid data on STM32F7xx, DMA issue? */
//spiExchange(spi, 2, &tx, &rxb);
rxb = spiPolledExchange(spi, tx); rxb = spiPolledExchange(spi, tx);
/* Slave Select de-assertion. */ /* Slave Select de-assertion. */
spiUnselect(spi); spiUnselect(spi);
@ -162,8 +160,6 @@ static int tle6240_update_output_and_diag(tle6240_priv *chip)
int ret; int ret;
uint16_t out_data; uint16_t out_data;
/* TODO: lock? */
/* atomic */ /* atomic */
/* set value only for non-direct driven pins */ /* set value only for non-direct driven pins */
out_data = chip->o_state & (~chip->o_direct_mask); out_data = chip->o_state & (~chip->o_direct_mask);
@ -185,8 +181,6 @@ static int tle6240_update_output_and_diag(tle6240_priv *chip)
chip->diag_8_reguested = true; chip->diag_8_reguested = true;
} }
/* TODO: unlock? */
return ret; return ret;
} }
@ -387,12 +381,15 @@ static int tle6240_writePad(void *data, unsigned int pin, int value)
chip = (tle6240_priv *)data; chip = (tle6240_priv *)data;
/* TODO: lock */ {
if (value) chibios_rt::CriticalSectionLocker csl;
chip->o_state |= (1 << pin);
else if (value)
chip->o_state &= ~(1 << pin); chip->o_state |= (1 << pin);
/* TODO: unlock */ else
chip->o_state &= ~(1 << pin);
}
/* direct driven? */ /* direct driven? */
if (chip->o_direct_mask & (1 << pin)) { if (chip->o_direct_mask & (1 << pin)) {
int n = (pin < 8) ? pin : (pin - 4); int n = (pin < 8) ? pin : (pin - 4);

View File

@ -427,8 +427,6 @@ static int tle8888_update_output(tle8888_priv *chip)
int i; int i;
int ret; int ret;
/* TODO: lock? */
uint8_t briconfig0 = 0; uint8_t briconfig0 = 0;
/* calculate briconfig0 */ /* calculate briconfig0 */
@ -466,8 +464,6 @@ static int tle8888_update_output(tle8888_priv *chip)
}; };
ret = tle8888_spi_rw_array(chip, tx, NULL, ARRAY_SIZE(tx)); ret = tle8888_spi_rw_array(chip, tx, NULL, ARRAY_SIZE(tx));
/* TODO: unlock? */
if (ret == 0) { if (ret == 0) {
/* atomic */ /* atomic */
chip->o_data_cached = o_data; chip->o_data_cached = o_data;
@ -499,9 +495,7 @@ static int tle8888_update_status_and_diag(tle8888_priv *chip)
}; };
uint16_t rx[ARRAY_SIZE(tx)]; uint16_t rx[ARRAY_SIZE(tx)];
/* TODO: lock? */
ret = tle8888_spi_rw_array(chip, tx, rx, ARRAY_SIZE(tx)); ret = tle8888_spi_rw_array(chip, tx, rx, ARRAY_SIZE(tx));
/* TODO: unlock? */
if (ret == 0) { if (ret == 0) {
/* the address and content of the selected register is transmitted with the /* the address and content of the selected register is transmitted with the
@ -680,9 +674,8 @@ static int tle8888_chip_init(tle8888_priv *chip)
/* enable outputs */ /* enable outputs */
CMD_OE_SET CMD_OE_SET
}; };
/* TODO: lock? */
ret = tle8888_spi_rw_array(chip, tx, NULL, ARRAY_SIZE(tx)); ret = tle8888_spi_rw_array(chip, tx, NULL, ARRAY_SIZE(tx));
/* TODO: unlock? */
if (ret == 0) { if (ret == 0) {
const tle8888_config *cfg = chip->cfg; const tle8888_config *cfg = chip->cfg;
@ -940,13 +933,16 @@ static int tle8888_writePad(void *data, unsigned int pin, int value) {
tle8888_priv *chip = (tle8888_priv *)data; tle8888_priv *chip = (tle8888_priv *)data;
/* TODO: lock */ {
if (value) { chibios_rt::CriticalSectionLocker csl;
chip->o_state |= (1 << pin);
} else { if (value) {
chip->o_state &= ~(1 << pin); chip->o_state |= (1 << pin);
} else {
chip->o_state &= ~(1 << pin);
}
} }
/* TODO: unlock */
/* direct driven? */ /* direct driven? */
if (chip->o_direct_mask & (1 << pin)) { if (chip->o_direct_mask & (1 << pin)) {
return tle8888_update_direct_output(chip, pin, value); return tle8888_update_direct_output(chip, pin, value);