Change button code For SPRACINGF3MINI and OMNIBUS targets to new IO

This commit is contained in:
Michael Jakob 2016-12-09 19:56:28 +01:00
parent 590b01a77e
commit fcb3ebf066
3 changed files with 12 additions and 23 deletions

View File

@ -35,7 +35,6 @@
#include "drivers/sensor.h"
#include "drivers/system.h"
#include "drivers/dma.h"
#include "drivers/gpio.h"
#include "drivers/io.h"
#include "drivers/light_led.h"
#include "drivers/sound_beeper.h"
@ -188,28 +187,22 @@ void init(void)
#endif
#if defined(BUTTONS)
gpio_config_t buttonAGpioConfig = {
BUTTON_A_PIN,
Mode_IPU,
Speed_2MHz
};
gpioInit(BUTTON_A_PORT, &buttonAGpioConfig);
IO_t buttonAPin = IOGetByTag(IO_TAG(BUTTON_A_PIN));
IOInit(buttonAPin, OWNER_SYSTEM, 0);
IOConfigGPIO(buttonAPin, IOCFG_IPU);
gpio_config_t buttonBGpioConfig = {
BUTTON_B_PIN,
Mode_IPU,
Speed_2MHz
};
gpioInit(BUTTON_B_PORT, &buttonBGpioConfig);
IO_t buttonBPin = IOGetByTag(IO_TAG(BUTTON_B_PIN));
IOInit(buttonBPin, OWNER_SYSTEM, 0);
IOConfigGPIO(buttonBPin, IOCFG_IPU);
// Check status of bind plug and exit if not active
delayMicroseconds(10); // allow GPIO configuration to settle
delayMicroseconds(10); // allow configuration to settle
if (!isMPUSoftReset()) {
uint8_t secondsRemaining = 5;
bool bothButtonsHeld;
do {
bothButtonsHeld = !digitalIn(BUTTON_A_PORT, BUTTON_A_PIN) && !digitalIn(BUTTON_B_PORT, BUTTON_B_PIN);
bothButtonsHeld = !IORead(buttonAPin) && !IORead(buttonBPin);
if (bothButtonsHeld) {
if (--secondsRemaining == 0) {
resetEEPROM();

View File

@ -171,10 +171,8 @@
#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_CURRENT_METER | FEATURE_BLACKBOX)
#define BUTTONS
#define BUTTON_A_PORT GPIOB
#define BUTTON_A_PIN Pin_1
#define BUTTON_B_PORT GPIOB
#define BUTTON_B_PIN Pin_0
#define BUTTON_A_PIN PB1
#define BUTTON_B_PIN PB0
#define AVOID_UART3_FOR_PWM_PPM

View File

@ -147,10 +147,8 @@
#define DEFAULT_FEATURES FEATURE_BLACKBOX
#define BUTTONS
#define BUTTON_A_PORT GPIOB
#define BUTTON_A_PIN Pin_1
#define BUTTON_B_PORT GPIOB
#define BUTTON_B_PIN Pin_0
#define BUTTON_A_PIN PB1
#define BUTTON_B_PIN PB0
#define SPEKTRUM_BIND
// USART3,