Minor fixes (#1442)
* exti trigger: mark pins used, handle errors * MC33810 add to smart gpios
This commit is contained in:
parent
a0efd3ad68
commit
2e9cff8596
|
@ -70,6 +70,9 @@
|
|||
#define BOARD_TLE8888_COUNT 0
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_MC33810_COUNT
|
||||
#define BOARD_MC33810_COUNT 0
|
||||
#endif
|
||||
|
||||
#undef EFI_CONSOLE_TX_BRAIN_PIN
|
||||
#define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_0
|
||||
|
|
|
@ -146,6 +146,10 @@
|
|||
#define BOARD_TLE8888_COUNT 1
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_MC33810_COUNT
|
||||
#define BOARD_MC33810_COUNT 0
|
||||
#endif
|
||||
|
||||
#define EFI_ANALOG_SENSORS TRUE
|
||||
|
||||
#ifndef EFI_MAX_31855
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
#define BOARD_TLE8888_COUNT 1
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_MC33810_COUNT
|
||||
#define BOARD_MC33810_COUNT 0
|
||||
#endif
|
||||
|
||||
#undef EFI_CAN_SUPPORT
|
||||
#define EFI_CAN_SUPPORT TRUE
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "digital_input_exti.h"
|
||||
#include "efi_gpio.h"
|
||||
#include "error_handling.h"
|
||||
#include "pin_repository.h"
|
||||
|
||||
/**
|
||||
* EXTI is a funny thing: you can only use same pin on one port. For example, you can use
|
||||
|
@ -23,23 +24,23 @@
|
|||
static ioportmask_t ext_used = 0;
|
||||
|
||||
// EXT is not able to give you the front direction but you could read the pin in the callback.
|
||||
void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
|
||||
int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
|
||||
|
||||
/* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL
|
||||
* and we will fail on next check */
|
||||
if (brainPin == GPIO_UNASSIGNED)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
ioportid_t port = getHwPort(msg, brainPin);
|
||||
if (port == NULL)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
int index = getHwPin(msg, brainPin);
|
||||
|
||||
/* is this index already used? */
|
||||
if (ext_used & PAL_PORT_BIT(index)) {
|
||||
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ioline_t line = PAL_LINE(port, index);
|
||||
|
@ -48,6 +49,9 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palc
|
|||
|
||||
/* mark used */
|
||||
ext_used |= PAL_PORT_BIT(index);
|
||||
brain_pin_markUsed(brainPin, msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void efiExtiDisablePin(brain_pin_e brainPin)
|
||||
|
@ -73,6 +77,7 @@ void efiExtiDisablePin(brain_pin_e brainPin)
|
|||
|
||||
/* mark unused */
|
||||
ext_used &= ~PAL_PORT_BIT(index);
|
||||
brain_pin_markUnused(brainPin);
|
||||
}
|
||||
|
||||
#endif /* HAL_USE_PAL && EFI_PROD_CODE */
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
#include "digital_input.h"
|
||||
|
||||
#if HAL_USE_PAL
|
||||
void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
|
||||
int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
|
||||
void efiExtiDisablePin(brain_pin_e brainPin);
|
||||
#endif /* HAL_USE_PAL */
|
||||
|
|
|
@ -221,7 +221,6 @@ void stopDigitalCapture(const char *msg, brain_pin_e brainPin) {
|
|||
if (brainPin == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
brain_pin_markUnused(brainPin);
|
||||
|
||||
ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
|
||||
if (driver == NULL) {
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
#include "drivers/gpio/tle6240.h"
|
||||
#include "drivers/gpio/mc33972.h"
|
||||
#include "drivers/gpio/tle8888.h"
|
||||
#define BOARD_EXT_PINREPOPINS (BOARD_TLE6240_COUNT * TLE6240_OUTPUTS + BOARD_MC33972_COUNT * MC33972_INPUTS + BOARD_TLE8888_COUNT * TLE8888_OUTPUTS)
|
||||
#define BOARD_EXT_PINREPOPINS \
|
||||
(BOARD_TLE6240_COUNT * TLE6240_OUTPUTS + \
|
||||
BOARD_MC33972_COUNT * MC33972_INPUTS + \
|
||||
BOARD_TLE8888_COUNT * TLE8888_OUTPUTS + \
|
||||
BOARD_MC33810_COUNT * MC33810_OUTPUTS)
|
||||
|
||||
#else /* EFI_PROD_CODE */
|
||||
#define BOARD_EXT_PINREPOPINS 0
|
||||
|
@ -21,7 +25,11 @@
|
|||
#if EFI_UNIT_TEST
|
||||
#define BOARD_EXT_GPIOCHIPS 3
|
||||
#else
|
||||
#define BOARD_EXT_GPIOCHIPS (BOARD_TLE6240_COUNT + BOARD_MC33972_COUNT + BOARD_TLE8888_COUNT)
|
||||
#define BOARD_EXT_GPIOCHIPS \
|
||||
(BOARD_TLE6240_COUNT + \
|
||||
BOARD_MC33972_COUNT + \
|
||||
BOARD_TLE8888_COUNT + \
|
||||
BOARD_MC33810_COUNT)
|
||||
#endif
|
||||
|
||||
void initSmartGpio(void);
|
||||
|
|
|
@ -76,6 +76,7 @@ static void cam_callback(void *arg) {
|
|||
/*==========================================================================*/
|
||||
|
||||
int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
||||
int ret;
|
||||
brain_pin_e brainPin = isTriggerShaft ? CONFIG(triggerInputPins)[index] : engineConfiguration->camInputs[index];
|
||||
|
||||
scheduleMsg(logger, "extiTriggerTurnOnInputPin %s %s", msg, hwPortname(brainPin));
|
||||
|
@ -83,8 +84,10 @@ int extiTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
|
|||
/* TODO:
|
||||
* * do not set to both edges if we need only one
|
||||
* * simplify callback in case of one edge */
|
||||
ioline_t pal_line = PAL_LINE(getHwPort("trg", brainPin), getHwPin("trg", brainPin));
|
||||
efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isTriggerShaft ? shaft_callback : cam_callback, (void *)pal_line);
|
||||
ioline_t pal_line = PAL_LINE(getHwPort(msg, brainPin), getHwPin(msg, brainPin));
|
||||
ret = efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isTriggerShaft ? shaft_callback : cam_callback, (void *)pal_line);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue