efiExtiEnablePin: return status to caller

This commit is contained in:
Andrey Gusakov 2024-03-05 23:30:08 +03:00 committed by rusefillc
parent a3ca49566e
commit f4cd6de86d
2 changed files with 17 additions and 12 deletions

View File

@ -35,24 +35,24 @@ struct ExtiChannel
static ExtiChannel channels[16]; static ExtiChannel channels[16];
// EXT is not able to give you the front direction but you could read the pin in the callback. // 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, ExtiCallback cb, void *cb_data) { int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, ExtiCallback cb, void *cb_data) {
/* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL /* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL
* and we will fail on next check */ * and we will fail on next check */
if (!isBrainPinValid(brainPin)) { if (!isBrainPinValid(brainPin)) {
return; return -1;
} }
criticalAssertVoid(msg, "efiExtiEnablePin msg must not be null"); criticalAssert(msg, "efiExtiEnablePin msg must not be null", -1);
ioportid_t port = getHwPort(msg, brainPin); ioportid_t port = getHwPort(msg, brainPin);
if (port == NULL) { if (port == NULL) {
return; return -1;
} }
bool wasUsed = brain_pin_markUsed(brainPin, msg); bool wasUsed = brain_pin_markUsed(brainPin, msg);
if (wasUsed) { if (wasUsed) {
// error condition we shall bail // error condition we shall bail
return; return -1;
} }
int index = getHwPin(msg, brainPin); int index = getHwPin(msg, brainPin);
@ -66,7 +66,7 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti
hwPortname(brainPin), hwPortname(brainPin),
index, index,
channel.Name); channel.Name);
return; return -1;
} }
channel.Callback = cb; channel.Callback = cb;
@ -75,6 +75,8 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti
ioline_t line = PAL_LINE(port, index); ioline_t line = PAL_LINE(port, index);
palEnableLineEvent(line, mode); palEnableLineEvent(line, mode);
return 0;
} }
void efiExtiDisablePin(brain_pin_e brainPin) void efiExtiDisablePin(brain_pin_e brainPin)
@ -256,7 +258,10 @@ void efiExtiInit() {
criticalError("exti not supported"); criticalError("exti not supported");
} }
void efiExtiEnablePin(const char *, brain_pin_e, uint32_t, ExtiCallback, void *) { } int efiExtiEnablePin(const char *, brain_pin_e, uint32_t, ExtiCallback, void *)
{
return 0;
}
void efiExtiDisablePin(brain_pin_e) { } void efiExtiDisablePin(brain_pin_e) { }
uint8_t getExtiOverflowCounter() { uint8_t getExtiOverflowCounter() {

View File

@ -12,7 +12,7 @@
using ExtiCallback = void(*)(void*, efitick_t); using ExtiCallback = void(*)(void*, efitick_t);
void efiExtiInit(); void efiExtiInit();
void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, ExtiCallback cb, void *cb_data); int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, ExtiCallback cb, void *cb_data);
void efiExtiDisablePin(brain_pin_e brainPin); void efiExtiDisablePin(brain_pin_e brainPin);
uint8_t getExtiOverflowCounter(); uint8_t getExtiOverflowCounter();
#endif /* HAL_USE_PAL */ #endif /* HAL_USE_PAL */