exti refactoring
This commit is contained in:
parent
28d58c41eb
commit
ae3ec77677
|
@ -139,7 +139,7 @@ static uint32_t getExtMode(ioportid_t port) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void applyPin(brain_pin_e pin) {
|
static void enableExti(brain_pin_e pin, extcallback_t cb) {
|
||||||
if (pin == GPIO_UNASSIGNED)
|
if (pin == GPIO_UNASSIGNED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -147,14 +147,14 @@ static void applyPin(brain_pin_e pin) {
|
||||||
ioportid_t port = getHwPort("joy", pin);
|
ioportid_t port = getHwPort("joy", pin);
|
||||||
|
|
||||||
extcfg.channels[index].mode = EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | getExtMode(port);
|
extcfg.channels[index].mode = EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | getExtMode(port);
|
||||||
extcfg.channels[index].cb = extCallback;
|
extcfg.channels[index].cb = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isJoystickEnabled() {
|
static bool isJoystickEnabled() {
|
||||||
return boardConfiguration->joystickCenterPin != GPIO_UNASSIGNED ||
|
return boardConfiguration->joystickCenterPin != GPIO_UNASSIGNED ||
|
||||||
boardConfiguration->joystickAPin != GPIO_UNASSIGNED ||
|
boardConfiguration->joystickAPin != GPIO_UNASSIGNED ||
|
||||||
boardConfiguration->joystickBPin != GPIO_UNASSIGNED ||
|
// not used so far boardConfiguration->joystickBPin != GPIO_UNASSIGNED ||
|
||||||
boardConfiguration->joystickCPin != GPIO_UNASSIGNED ||
|
// not used so far boardConfiguration->joystickCPin != GPIO_UNASSIGNED ||
|
||||||
boardConfiguration->joystickDPin != GPIO_UNASSIGNED;
|
boardConfiguration->joystickDPin != GPIO_UNASSIGNED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,16 +163,16 @@ void initJoystick(Logging *shared) {
|
||||||
return;
|
return;
|
||||||
sharedLogger = shared;
|
sharedLogger = shared;
|
||||||
|
|
||||||
applyPin(boardConfiguration->joystickCenterPin);
|
enableExti(boardConfiguration->joystickCenterPin, extCallback);
|
||||||
applyPin(boardConfiguration->joystickAPin);
|
enableExti(boardConfiguration->joystickAPin, extCallback);
|
||||||
applyPin(boardConfiguration->joystickBPin);
|
// not used so far applyPin(boardConfiguration->joystickBPin);
|
||||||
applyPin(boardConfiguration->joystickCPin);
|
// not used so far applyPin(boardConfiguration->joystickCPin);
|
||||||
applyPin(boardConfiguration->joystickDPin);
|
enableExti(boardConfiguration->joystickDPin, extCallback);
|
||||||
|
|
||||||
efiSetPadMode("joy center", boardConfiguration->joystickCenterPin, PAL_MODE_INPUT_PULLUP);
|
efiSetPadMode("joy center", boardConfiguration->joystickCenterPin, PAL_MODE_INPUT_PULLUP);
|
||||||
efiSetPadMode("joy A", boardConfiguration->joystickAPin, PAL_MODE_INPUT_PULLUP);
|
efiSetPadMode("joy A", boardConfiguration->joystickAPin, PAL_MODE_INPUT_PULLUP);
|
||||||
efiSetPadMode("joy B", boardConfiguration->joystickBPin, PAL_MODE_INPUT_PULLUP);
|
// not used so far efiSetPadMode("joy B", boardConfiguration->joystickBPin, PAL_MODE_INPUT_PULLUP);
|
||||||
efiSetPadMode("joy C", boardConfiguration->joystickCPin, PAL_MODE_INPUT_PULLUP);
|
// not used so far efiSetPadMode("joy C", boardConfiguration->joystickCPin, PAL_MODE_INPUT_PULLUP);
|
||||||
efiSetPadMode("joy D", boardConfiguration->joystickDPin, PAL_MODE_INPUT_PULLUP);
|
efiSetPadMode("joy D", boardConfiguration->joystickDPin, PAL_MODE_INPUT_PULLUP);
|
||||||
|
|
||||||
addConsoleAction("joystickinfo", joystickInfo);
|
addConsoleAction("joystickinfo", joystickInfo);
|
||||||
|
|
Loading…
Reference in New Issue