Smart gpios (#752)

* efi_gpio: update cached pin value for ext gpios to

* tle6240: update and fix

* gpiochips_init should be called after all gpio chips are added

or we can lost calls to _init of chips

* smart_gpio.c: fix for tle6240 and mc33972

now config structs are not const. waste of ram...
This commit is contained in:
dron0gus 2019-04-14 02:32:46 +03:00 committed by rusefi
parent b04b1ce5c4
commit 76cc822b1e
4 changed files with 22 additions and 8 deletions

View File

@ -316,6 +316,8 @@ void OutputPin::setValue(int logicValue) {
} else {
/* external pin */
gpiochips_writePad(this->brainPin, logicValue);
/* TODO: check return value */
currentLogicValue = logicValue;
}
#else
if (port != GPIO_NULL) {

View File

@ -24,6 +24,7 @@
#include "gpio/gpio_ext.h"
#include "gpio/tle6240.h"
#include "pin_repository.h"
#include "rfiutil.h"
#if (BOARD_TLE6240_COUNT > 0)
@ -312,7 +313,17 @@ static int tle6240_wake_driver(struct tle6240_priv *chip)
{
(void)chip;
chSemSignal(&tle6240_wake);
if (isIsrContext()) {
// this is for normal runtime
int wasLocked = lockAnyContext();
chSemSignalI(&tle6240_wake);
if (!wasLocked) {
unlockAnyContext();
}
} else {
// this is for start-up to not hang up
chSemSignal(&tle6240_wake);
}
return 0;
}

View File

@ -215,11 +215,6 @@ void initPinRepository(void) {
initialized = true;
#if (BOARD_EXT_GPIOCHIPS > 0)
/* external chip init */
gpiochips_init();
#endif
addConsoleAction("pins", reportPins);
}

View File

@ -11,6 +11,7 @@
#include "smart_gpio.h"
#include "efi_gpio.h"
#include "engine_configuration.h"
#include "hardware.h"
#include "gpio_ext.h"
#include "drivers/gpio/tle6240.h"
#include "drivers/gpio/mc33972.h"
@ -19,7 +20,7 @@
EXTERN_CONFIG;
#if (BOARD_TLE6240_COUNT > 0)
const struct tle6240_config tle6240 = {
struct tle6240_config tle6240 = {
.spi_bus = NULL /* TODO software lookup &SPID4 */,
.spi_config = {
.circular = false,
@ -58,7 +59,7 @@ const struct tle6240_config tle6240 = {
#endif /* (BOARD_TLE6240_COUNT > 0) */
#if (BOARD_MC33972_COUNT > 0)
const struct mc33972_config mc33972 = {
struct mc33972_config mc33972 = {
.spi_bus = NULL /* TODO software lookup &SPID4 */,
.spi_config = {
.circular = false,
@ -107,6 +108,11 @@ void initSmartGpio() {
initTle8888(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* (BOARD_TLE6240_COUNT > 0) */
#if (BOARD_EXT_GPIOCHIPS > 0)
/* external chip init */
gpiochips_init();
#endif
}
#endif /* EFI_PROD_CODE */