Some fixes prior to board pull request (#2291)

* ChibiOS: add support for STM32F765

This chip is used on Subaru EG33 p'n'p RusEFI board from Dron_Gus

* drivers: gpio: mc33810: commulative update

- use BIT macro
- fix wake-up method
- fix order of arguments in _add function

* port: stm32f4/7: detectCanDevice check for enabled interfaces only

* ADC: fix internal array size

internalAdcIndexByHardwareIndex should be EFI_ADC_LAST_CHANNEL size
couse adc_channel_e is used as index

* status LEDs: support status LEDs that driven by low level
This commit is contained in:
Andrey G 2021-02-06 20:22:57 +03:00 committed by GitHub
parent 6e217c92fa
commit 3166076839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 19 deletions

@ -1 +1 @@
Subproject commit 0b4897475aceea4ae791f104297d334911a5adf7
Subproject commit eaff869a3afdd8ca6600a337df0df362ccf8b60a

View File

@ -87,6 +87,7 @@
#define BOARD_TLE6240_COUNT 0
#define BOARD_MC33972_COUNT 0
#define BOARD_TLE8888_COUNT 0
#define BOARD_MC33810_COUNT 0
/**
* if you have a 60-2 trigger, or if you just want better performance, you

View File

@ -102,6 +102,16 @@ extern int icuFallingCallbackCounter;
extern WaveChart waveChart;
#endif /* EFI_ENGINE_SNIFFER */
extern pin_output_mode_e DEFAULT_OUTPUT;
extern pin_output_mode_e INVERTED_OUTPUT;
#ifndef LED_WARNING_BRAIN_PIN_MODE
#define LED_WARNING_BRAIN_PIN_MODE DEFAULT_OUTPUT
#endif
#ifndef LED_RUNING_BRAIN_PIN_MODE
#define LED_RUNING_BRAIN_PIN_MODE DEFAULT_OUTPUT
#endif
int warningEnabled = true;
extern int maxTriggerReentraint;
@ -321,8 +331,8 @@ static void initStatusLeds(void) {
enginePins.communicationLedPin.initPin("led: comm status", engineConfiguration->communicationLedPin);
// checkEnginePin is already initialized by the time we get here
enginePins.warningLedPin.initPin("led: warning status", engineConfiguration->warningLedPin);
enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin);
enginePins.warningLedPin.initPin("led: warning status", engineConfiguration->warningLedPin, &LED_WARNING_BRAIN_PIN_MODE);
enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin, &LED_RUNING_BRAIN_PIN_MODE);
}
#if EFI_PROD_CODE

View File

@ -72,6 +72,7 @@ extern uint8_t criticalErrorLedState;
/**
* low-level function is used here to reduce stack usage
*/
#define ON_CRITICAL_ERROR() \
palWritePad(criticalErrorLedPort, criticalErrorLedPin, criticalErrorLedState); \
turnAllPinsOff(); \

View File

@ -34,7 +34,7 @@ extern WaveChart waveChart;
EnginePins enginePins;
static Logging* logger;
static pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT;
pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT;
pin_output_mode_e INVERTED_OUTPUT = OM_INVERTED;
static const char *sparkNames[] = { "Coil 1", "Coil 2", "Coil 3", "Coil 4", "Coil 5", "Coil 6", "Coil 7", "Coil 8",

View File

@ -24,7 +24,7 @@ public:
void enableChannel(adc_channel_e hwChannelIndex);
void enableChannelAndPin(const char *msg, adc_channel_e hwChannelIndex);
adc_channel_e getAdcHardwareIndexByInternalIndex(int index) const;
int internalAdcIndexByHardwareIndex[ADC_MAX_CHANNELS_COUNT + 4];
int internalAdcIndexByHardwareIndex[EFI_ADC_LAST_CHANNEL];
bool isHwUsed(adc_channel_e hwChannel) const;
int size() const;
void init(void);

View File

@ -303,7 +303,7 @@ static int mc33810_chip_init(struct mc33810_priv *chip)
ret = -1;
goto err_gpios;
}
if (rx & (1 << 14)) {
if (rx & BIT(14)) {
//print(DRIVER_NAME " spi COR status\n");
ret = -3;
goto err_gpios;
@ -345,15 +345,18 @@ static int mc33810_wake_driver(struct mc33810_priv *chip)
{
(void)chip;
if (isIsrContext()) {
// this is for normal runtime
syssts_s sts = chSysGetStatusAndLockX();
/* Entering a reentrant critical zone.*/
syssts_t sts = chSysGetStatusAndLockX();
chSemSignalI(&mc33810_wake);
chSysRestoreStatusX(sts);
} else {
// this is for start-up to not hang up
chSemSignal(&mc33810_wake);
if (!port_is_isr_context()) {
/**
* chSemSignalI above requires rescheduling
* interrupt handlers have implicit rescheduling
*/
chSchRescheduleS();
}
/* Leaving the critical zone.*/
chSysRestoreStatusX(sts);
return 0;
}
@ -417,12 +420,12 @@ int mc33810_writePad(void *data, unsigned int pin, int value)
/* TODO: lock */
if (value)
chip->o_state |= (1 << pin);
chip->o_state |= BIT(pin);
else
chip->o_state &= ~(1 << pin);
chip->o_state &= ~BIT(pin);
/* TODO: unlock */
/* direct driven? */
if (chip->o_direct_mask & (1 << pin)) {
if (chip->o_direct_mask & BIT(pin)) {
/* TODO: ensure that output driver enabled */
if (value)
palSetPort(chip->cfg->direct_io[pin].port,
@ -523,7 +526,7 @@ struct gpiochip_ops mc33810_ops = {
* @details Checks for valid config
*/
int mc33810_add(unsigned int index, const struct mc33810_config *cfg, brain_pin_e base)
int mc33810_add(brain_pin_e base, unsigned int index, const struct mc33810_config *cfg)
{
int i;
int ret;
@ -551,7 +554,7 @@ int mc33810_add(unsigned int index, const struct mc33810_config *cfg, brain_pin_
chip->drv_state = MC33810_WAIT_INIT;
for (i = 0; i < MC33810_DIRECT_OUTPUTS; i++) {
if (cfg->direct_io[i].port != 0)
chip->o_direct_mask |= (1 << i);
chip->o_direct_mask |= BIT(i);
}
/* GPGD mode is not supported yet, ignition mode does not support spi on/off commands

View File

@ -373,10 +373,14 @@ bool isValidCanRxPin(brain_pin_e pin) {
}
CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) {
#if STM32_CAN_USE_CAN1
if (isValidCan1RxPin(pinRx) && isValidCan1TxPin(pinTx))
return &CAND1;
#endif
#if STM32_CAN_USE_CAN2
if (isValidCan2RxPin(pinRx) && isValidCan2TxPin(pinTx))
return &CAND2;
#endif
return NULL;
}

View File

@ -366,10 +366,14 @@ bool isValidCanRxPin(brain_pin_e pin) {
}
CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) {
#if STM32_CAN_USE_CAN1
if (isValidCan1RxPin(pinRx) && isValidCan1TxPin(pinTx))
return &CAND1;
#endif
#if STM32_CAN_USE_CAN2
if (isValidCan2RxPin(pinRx) && isValidCan2TxPin(pinTx))
return &CAND2;
#endif
return NULL;
}