1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Changed disable beeper method.

Fix indentation level to 4.
Removed CLI support for 1wire pass through
This commit is contained in:
4712betaflight 2015-11-30 00:42:57 +01:00 committed by borisbstyle
parent f68add5d4d
commit 5f1540dbcb
11 changed files with 118 additions and 214 deletions

View file

@ -16,6 +16,7 @@
*
* Ported from https://github.com/4712/BLHeliSuite/blob/master/Interfaces/Arduino1Wire/Source/Arduino1Wire_C/Arduino1Wire.c
* by Nathan Tsoi <nathan@vertile.com>
* Several updates by 4712 in order to optimize interaction with BLHeliSuite
*/
#include <stdbool.h>
@ -29,66 +30,12 @@
#include "drivers/light_led.h"
#include "drivers/system.h"
#include "io/serial_1wire.h"
#include "io/beeper.h"
#include "drivers/pwm_mapping.h"
#include "flight/mixer.h"
/*
const escHardware_t escHardware[ESC_COUNT] = {
// Figure out esc clocks and pins, extrapolated from timer.c
// Periphs could be pulled progmatically... but I'll leave that for another exercise
#if defined(STM32F3DISCOVERY) && !(defined(CHEBUZZF3))
{ GPIOD, 12 },
{ GPIOD, 13 },
{ GPIOD, 14 },
{ GPIOD, 15 },
{ GPIOA, 1 },
{ GPIOA, 2 }
#elif defined(CJMCU) || defined(EUSTM32F103RC) || defined(NAZE) || defined(OLIMEXINO) || defined(PORT103R)
{ GPIOA, 8 },
{ GPIOA, 11 },
{ GPIOB, 6 },
{ GPIOB, 7 },
{ GPIOB, 8 },
{ GPIOB, 9 }
#elif CC3D
{ GPIOB, 9 },
{ GPIOB, 8 },
{ GPIOB, 7 },
{ GPIOA, 8 },
{ GPIOB, 4 },
{ GPIOA, 2 }
#elif SPRACINGF3
{ GPIOA, 6 },
{ GPIOA, 7 },
{ GPIOA, 11 },
{ GPIOA, 12 },
{ GPIOB, 8 },
{ GPIOB, 9 },
{ GPIOA, 2 },
{ GPIOA, 3 }
#elif MOTOLAB
{ GPIOA, 4 },
{ GPIOA, 6 },
{ GPIOB, 0 },
{ GPIOB, 1 },
{ GPIOA, 1 },
{ GPIOA, 2 },
{ GPIOA, 3 },
{ GPIOA, 8 }
#elif SPARKY
{ GPIOB, 15 },
{ GPIOB, 14 },
{ GPIOA, 8 },
{ GPIOB, 0 },
{ GPIOA, 6 },
{ GPIOA, 2 }
#endif
};
*/
uint8_t escCount; // we detect the hardware dynamically
static escHardware_t escHardware[MAX_PWM_MOTORS];
static void gpio_set_mode(GPIO_TypeDef* gpio, uint16_t pin, GPIO_Mode mode) {
@ -99,7 +46,6 @@ static void gpio_set_mode(GPIO_TypeDef* gpio, uint16_t pin, GPIO_Mode mode) {
gpioInit(gpio, &cfg);
}
static uint32_t GetPinPos(uint32_t pin) {
uint32_t pinPos;
for (pinPos = 0; pinPos < 16; pinPos++) {
@ -112,7 +58,6 @@ static uint32_t GetPinPos(uint32_t pin) {
return 0;
}
void usb1WireInitialize()
{
escCount = 0;
@ -129,11 +74,6 @@ void usb1WireInitialize()
}
}
}
#ifdef BEEPER
// fix for buzzer often starts beeping continuously when the ESCs are read
// switch beeper off until reboot
gpio_set_mode(BEEP_GPIO, BEEP_PIN, Mode_IN_FLOATING); // set input no pull up or down
#endif
}
#ifdef STM32F10X
@ -190,7 +130,6 @@ static void gpioSetOne(uint32_t escIndex, GPIO_Mode mode) {
#define ESC_OUTPUT(escIndex) gpioSetOne(escIndex, Mode_Out_PP)
#endif
#define RX_LED_OFF LED0_OFF
#define RX_LED_ON LED0_ON
#define TX_LED_OFF LED1_OFF
@ -200,16 +139,22 @@ static void gpioSetOne(uint32_t escIndex, GPIO_Mode mode) {
// RX line control when data should be read or written from the single line
void usb1WirePassthrough(uint8_t escIndex)
{
#ifdef BEEPER
// fix for buzzer often starts beeping continuously when the ESCs are read
// switch beeper silent here
beeperSilence();
#endif
// disable all interrupts
__disable_irq();
// prepare MSP UART port for direct pin access
// reset all the pins
GPIO_ResetBits(S1W_RX_GPIO, S1W_RX_PIN);
GPIO_ResetBits(S1W_TX_GPIO, S1W_TX_PIN);
// configure gpio
gpio_set_mode(S1W_RX_GPIO, S1W_RX_PIN, Mode_IPU);
gpio_set_mode(S1W_TX_GPIO, S1W_TX_PIN, Mode_Out_PP);
// hey user, turn on your ESC now
#ifdef STM32F10X
// reset our gpio register pointers and bitmask values
@ -268,5 +213,4 @@ void usb1WirePassthrough(uint8_t escIndex)
__enable_irq();
return;
}
#endif

View file

@ -51,7 +51,6 @@
#include "io/gimbal.h"
#include "io/rc_controls.h"
#include "io/serial.h"
#include "io/serial_1wire.h"
#include "io/ledstrip.h"
#include "io/flashfs.h"
#include "io/beeper.h"
@ -149,10 +148,6 @@ static void cliFlashRead(char *cmdline);
#endif
#endif
#ifdef USE_SERIAL_1WIRE_CLI
static void cliUSB1Wire(char *cmdline);
#endif
// buffer
static char cliBuffer[48];
static uint32_t bufferIndex = 0;
@ -229,9 +224,6 @@ typedef struct {
// should be sorted a..z for bsearch()
const clicmd_t cmdTable[] = {
#ifdef USE_SERIAL_1WIRE_CLI
CLI_COMMAND_DEF("1wire", "1-wire interface to escs", "<esc index>", cliUSB1Wire),
#endif
CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL, cliAdjustmentRange),
CLI_COMMAND_DEF("aux", "configure modes", NULL, cliAux),
#ifdef LED_STRIP
@ -2326,30 +2318,6 @@ static void cliStatus(char *cmdline)
printf("Cycle Time: %d, I2C Errors: %d, config size: %d\r\n", cycleTime, i2cErrorCounter, sizeof(master_t));
}
#ifdef USE_SERIAL_1WIRE_CLI
static void cliUSB1Wire(char *cmdline)
{
if (isEmpty(cmdline)) {
cliPrint("Please specify a ouput channel. e.g. `1wire 2` to connect to motor 2\r\n");
return;
} else {
usb1WireInitialize(); // init ESC outputs and get escCount value
int i;
i = atoi(cmdline);
if (i >= 0 && i <= escCount) {
printf("Switching to BlHeli mode on motor port %d\r\n", i);
// motor 1 => index 0
usb1WirePassthrough(i-1);
}
else {
printf("Invalid motor port, valid range: 1 to %d\r\n", escCount);
// cliReboot();
}
}
}
#endif
static void cliVersion(char *cmdline)
{
UNUSED(cmdline);

View file

@ -129,7 +129,6 @@
#define USE_CLI
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
// FlexPort (pin 21/22, TX/RX respectively):
// Note, FlexPort has 10k pullups on both TX and RX

View file

@ -172,7 +172,6 @@
#define BIND_PIN Pin_11
#define USE_SERIAL_1WIRE
#define ESC_COUNT 8
#define S1W_TX_GPIO GPIOA
#define S1W_TX_PIN GPIO_Pin_9
#define S1W_RX_GPIO GPIOA

View file

@ -187,7 +187,6 @@
#define BIND_PIN Pin_4
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
#define S1W_TX_GPIO GPIOB
#define S1W_TX_PIN GPIO_Pin_6

View file

@ -187,7 +187,6 @@
#define BIND_PIN Pin_3
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
// STM32F103CBT6-LQFP48 Pin30 (PA9) TX - PC3 connects to onboard CP2102 RX
#define S1W_TX_GPIO GPIOA

View file

@ -164,7 +164,6 @@
#define BIND_PIN Pin_11
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
#define S1W_TX_GPIO GPIOA
#define S1W_TX_PIN GPIO_Pin_9

View file

@ -162,7 +162,6 @@
#endif
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
#define S1W_TX_GPIO GPIOB
#define S1W_TX_PIN GPIO_Pin_6

View file

@ -172,7 +172,6 @@
#define BIND_PIN Pin_11
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
#define S1W_TX_GPIO GPIOA
#define S1W_TX_PIN GPIO_Pin_9

View file

@ -100,7 +100,6 @@
#define USE_CLI
#define USE_SERIAL_1WIRE
#define USE_SERIAL_1WIRE_CLI
// STM32F3DISCOVERY TX - PD5 connects to UART RX
#define S1W_TX_GPIO GPIOD