refactoring: time to unify digital pin API
This commit is contained in:
parent
6bcf7a438d
commit
b6b8c001cd
|
@ -23,23 +23,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.
|
||||
int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
|
||||
void 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 -1;
|
||||
return;
|
||||
|
||||
ioportid_t port = getHwPort(msg, brainPin);
|
||||
if (port == NULL)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
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 -1;
|
||||
return;
|
||||
}
|
||||
|
||||
ioline_t line = PAL_LINE(port, index);
|
||||
|
@ -48,8 +48,6 @@ int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palca
|
|||
|
||||
/* mark used */
|
||||
ext_used |= PAL_PORT_BIT(index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void efiExtiDisablePin(brain_pin_e brainPin)
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
#include "digital_input.h"
|
||||
|
||||
#if HAL_USE_PAL
|
||||
int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
|
||||
void 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 */
|
||||
|
|
Loading…
Reference in New Issue