mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Merge remote-tracking branch 'upstream/master' into blackbox-flash
This commit is contained in:
commit
f6c9f7cc4a
16 changed files with 457 additions and 115 deletions
|
@ -98,6 +98,7 @@ static void cliProfile(char *cmdline);
|
|||
static void cliRateProfile(char *cmdline);
|
||||
static void cliReboot(void);
|
||||
static void cliSave(char *cmdline);
|
||||
static void cliServo(char *cmdline);
|
||||
static void cliSet(char *cmdline);
|
||||
static void cliGet(char *cmdline);
|
||||
static void cliStatus(char *cmdline);
|
||||
|
@ -212,6 +213,9 @@ const clicmd_t cmdTable[] = {
|
|||
{ "profile", "index (0 to 2)", cliProfile },
|
||||
{ "rateprofile", "index (0 to 2)", cliRateProfile },
|
||||
{ "save", "save and reboot", cliSave },
|
||||
#ifndef CJMCU
|
||||
{ "servo", "servo config", cliServo },
|
||||
#endif
|
||||
{ "set", "name=value or blank or * for list", cliSet },
|
||||
{ "status", "show system status", cliStatus },
|
||||
{ "version", "", cliVersion },
|
||||
|
@ -492,14 +496,18 @@ static char *processChannelRangeArgs(char *ptr, channelRange_t *range, uint8_t *
|
|||
return ptr;
|
||||
}
|
||||
|
||||
// Check if a string's length is zero
|
||||
static bool isEmpty(const char *string)
|
||||
{
|
||||
return *string == '\0';
|
||||
}
|
||||
|
||||
static void cliAux(char *cmdline)
|
||||
{
|
||||
int i, val = 0;
|
||||
uint8_t len;
|
||||
char *ptr;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
// print out aux channel settings
|
||||
for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i];
|
||||
|
@ -548,11 +556,9 @@ static void cliAux(char *cmdline)
|
|||
static void cliAdjustmentRange(char *cmdline)
|
||||
{
|
||||
int i, val = 0;
|
||||
uint8_t len;
|
||||
char *ptr;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
// print out adjustment ranges channel settings
|
||||
for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) {
|
||||
adjustmentRange_t *ar = ¤tProfile->adjustmentRanges[i];
|
||||
|
@ -627,9 +633,7 @@ static void cliCMix(char *cmdline)
|
|||
float mixsum[3];
|
||||
char *ptr;
|
||||
|
||||
len = strlen(cmdline);
|
||||
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
cliPrint("Custom mixer: \r\nMotor\tThr\tRoll\tPitch\tYaw\r\n");
|
||||
for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
|
||||
if (masterConfig.customMixer[i].throttle == 0.0f)
|
||||
|
@ -713,12 +717,10 @@ static void cliCMix(char *cmdline)
|
|||
static void cliLed(char *cmdline)
|
||||
{
|
||||
int i;
|
||||
uint8_t len;
|
||||
char *ptr;
|
||||
char ledConfigBuffer[20];
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) {
|
||||
generateLedConfig(i, ledConfigBuffer, sizeof(ledConfigBuffer));
|
||||
printf("led %u %s\r\n", i, ledConfigBuffer);
|
||||
|
@ -729,7 +731,7 @@ static void cliLed(char *cmdline)
|
|||
if (i < MAX_LED_STRIP_LENGTH) {
|
||||
ptr = strchr(cmdline, ' ');
|
||||
if (!parseLedStripConfig(i, ++ptr)) {
|
||||
printf("Parse error\r\n", MAX_LED_STRIP_LENGTH);
|
||||
cliPrint("Parse error\r\n");
|
||||
}
|
||||
} else {
|
||||
printf("Invalid led index: must be < %u\r\n", MAX_LED_STRIP_LENGTH);
|
||||
|
@ -740,11 +742,9 @@ static void cliLed(char *cmdline)
|
|||
static void cliColor(char *cmdline)
|
||||
{
|
||||
int i;
|
||||
uint8_t len;
|
||||
char *ptr;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
printf("color %u %d,%u,%u\r\n", i, masterConfig.colors[i].h, masterConfig.colors[i].s, masterConfig.colors[i].v);
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ static void cliColor(char *cmdline)
|
|||
if (i < CONFIGURABLE_COLOR_COUNT) {
|
||||
ptr = strchr(cmdline, ' ');
|
||||
if (!parseColor(i, ++ptr)) {
|
||||
printf("Parse error\r\n", CONFIGURABLE_COLOR_COUNT);
|
||||
cliPrint("Parse error\r\n");
|
||||
}
|
||||
} else {
|
||||
printf("Invalid color index: must be < %u\r\n", CONFIGURABLE_COLOR_COUNT);
|
||||
|
@ -763,6 +763,78 @@ static void cliColor(char *cmdline)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void cliServo(char *cmdline)
|
||||
{
|
||||
#ifdef CJMCU
|
||||
UNUSED(cmdline);
|
||||
#else
|
||||
enum { SERVO_ARGUMENT_COUNT = 6 };
|
||||
int16_t arguments[SERVO_ARGUMENT_COUNT];
|
||||
|
||||
servoParam_t *servo;
|
||||
|
||||
int i;
|
||||
char *ptr;
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
// print out servo settings
|
||||
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
servo = ¤tProfile->servoConf[i];
|
||||
|
||||
printf("servo %u %d %d %d %d %d\r\n",
|
||||
i,
|
||||
servo->min,
|
||||
servo->max,
|
||||
servo->middle,
|
||||
servo->rate,
|
||||
servo->forwardFromChannel
|
||||
);
|
||||
}
|
||||
} else {
|
||||
int validArgumentCount = 0;
|
||||
|
||||
ptr = cmdline;
|
||||
|
||||
// Command line is integers (possibly negative) separated by spaces, no other characters allowed.
|
||||
|
||||
// If command line doesn't fit the format, don't modify the config
|
||||
while (*ptr) {
|
||||
if (*ptr == '-' || (*ptr >= '0' && *ptr <= '9')) {
|
||||
if (validArgumentCount >= SERVO_ARGUMENT_COUNT) {
|
||||
cliPrint("Parse error\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
arguments[validArgumentCount++] = atoi(ptr);
|
||||
|
||||
do {
|
||||
ptr++;
|
||||
} while (*ptr >= '0' && *ptr <= '9');
|
||||
} else if (*ptr == ' ') {
|
||||
ptr++;
|
||||
} else {
|
||||
cliPrint("Parse error\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check we got the right number of args and the servo index is correct (don't validate the other values)
|
||||
if (validArgumentCount != SERVO_ARGUMENT_COUNT || arguments[0] < 0 || arguments[0] >= MAX_SUPPORTED_SERVOS) {
|
||||
cliPrint("Parse error\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
servo = ¤tProfile->servoConf[arguments[0]];
|
||||
|
||||
servo->min = arguments[1];
|
||||
servo->max = arguments[2];
|
||||
servo->middle = arguments[3];
|
||||
servo->rate = arguments[4];
|
||||
servo->forwardFromChannel = arguments[5];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_FLASHFS
|
||||
|
||||
static void cliFlashInfo(char *cmdline)
|
||||
|
@ -898,11 +970,11 @@ static void cliDump(char *cmdline)
|
|||
|
||||
if (dumpMask & DUMP_MASTER) {
|
||||
|
||||
printf("\r\n# version\r\n");
|
||||
cliPrint("\r\n# version\r\n");
|
||||
cliVersion(NULL);
|
||||
|
||||
printf("\r\n# dump master\r\n");
|
||||
printf("\r\n# mixer\r\n");
|
||||
cliPrint("\r\n# dump master\r\n");
|
||||
cliPrint("\r\n# mixer\r\n");
|
||||
|
||||
#ifndef USE_QUAD_MIXER_ONLY
|
||||
printf("mixer %s\r\n", mixerNames[masterConfig.mixerMode - 1]);
|
||||
|
@ -917,23 +989,23 @@ static void cliDump(char *cmdline)
|
|||
yaw = masterConfig.customMixer[i].yaw;
|
||||
printf("cmix %d", i + 1);
|
||||
if (thr < 0)
|
||||
printf(" ");
|
||||
cliWrite(' ');
|
||||
printf("%s", ftoa(thr, buf));
|
||||
if (roll < 0)
|
||||
printf(" ");
|
||||
cliWrite(' ');
|
||||
printf("%s", ftoa(roll, buf));
|
||||
if (pitch < 0)
|
||||
printf(" ");
|
||||
cliWrite(' ');
|
||||
printf("%s", ftoa(pitch, buf));
|
||||
if (yaw < 0)
|
||||
printf(" ");
|
||||
cliWrite(' ');
|
||||
printf("%s\r\n", ftoa(yaw, buf));
|
||||
}
|
||||
printf("cmix %d 0 0 0 0\r\n", i + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\r\n\r\n# feature\r\n");
|
||||
cliPrint("\r\n\r\n# feature\r\n");
|
||||
|
||||
mask = featureMask();
|
||||
for (i = 0; ; i++) { // disable all feature first
|
||||
|
@ -948,7 +1020,7 @@ static void cliDump(char *cmdline)
|
|||
printf("feature %s\r\n", featureNames[i]);
|
||||
}
|
||||
|
||||
printf("\r\n\r\n# map\r\n");
|
||||
cliPrint("\r\n\r\n# map\r\n");
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[masterConfig.rxConfig.rcmap[i]] = rcChannelLetters[i];
|
||||
|
@ -956,10 +1028,10 @@ static void cliDump(char *cmdline)
|
|||
printf("map %s\r\n", buf);
|
||||
|
||||
#ifdef LED_STRIP
|
||||
printf("\r\n\r\n# led\r\n");
|
||||
cliPrint("\r\n\r\n# led\r\n");
|
||||
cliLed("");
|
||||
|
||||
printf("\r\n\r\n# color\r\n");
|
||||
cliPrint("\r\n\r\n# color\r\n");
|
||||
cliColor("");
|
||||
#endif
|
||||
printSectionBreak();
|
||||
|
@ -967,28 +1039,32 @@ static void cliDump(char *cmdline)
|
|||
}
|
||||
|
||||
if (dumpMask & DUMP_PROFILE) {
|
||||
printf("\r\n# dump profile\r\n");
|
||||
cliPrint("\r\n# dump profile\r\n");
|
||||
|
||||
printf("\r\n# profile\r\n");
|
||||
cliPrint("\r\n# profile\r\n");
|
||||
cliProfile("");
|
||||
|
||||
printf("\r\n# aux\r\n");
|
||||
cliPrint("\r\n# aux\r\n");
|
||||
|
||||
cliAux("");
|
||||
|
||||
printf("\r\n# adjrange\r\n");
|
||||
cliPrint("\r\n# adjrange\r\n");
|
||||
|
||||
cliAdjustmentRange("");
|
||||
|
||||
cliPrint("\r\n# servo\r\n");
|
||||
|
||||
cliServo("");
|
||||
|
||||
printSectionBreak();
|
||||
|
||||
dumpValues(PROFILE_VALUE);
|
||||
}
|
||||
|
||||
if (dumpMask & DUMP_CONTROL_RATE_PROFILE) {
|
||||
printf("\r\n# dump rates\r\n");
|
||||
cliPrint("\r\n# dump rates\r\n");
|
||||
|
||||
printf("\r\n# rateprofile\r\n");
|
||||
cliPrint("\r\n# rateprofile\r\n");
|
||||
cliRateProfile("");
|
||||
|
||||
printSectionBreak();
|
||||
|
@ -1185,12 +1261,11 @@ static void cliMotor(char *cmdline)
|
|||
{
|
||||
int motor_index = 0;
|
||||
int motor_value = 0;
|
||||
int len, index = 0;
|
||||
int index = 0;
|
||||
char *pch = NULL;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
printf("Usage:\r\nmotor index [value] - show [or set] motor value\r\n");
|
||||
if (isEmpty(cmdline)) {
|
||||
cliPrint("Usage:\r\nmotor index [value] - show [or set] motor value\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1219,7 +1294,7 @@ static void cliMotor(char *cmdline)
|
|||
}
|
||||
|
||||
if (motor_value < PWM_RANGE_MIN || motor_value > PWM_RANGE_MAX) {
|
||||
printf("Invalid motor value, 1000..2000\r\n");
|
||||
cliPrint("Invalid motor value, 1000..2000\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1229,11 +1304,9 @@ static void cliMotor(char *cmdline)
|
|||
|
||||
static void cliProfile(char *cmdline)
|
||||
{
|
||||
uint8_t len;
|
||||
int i;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
printf("profile %d\r\n", getCurrentProfile());
|
||||
return;
|
||||
} else {
|
||||
|
@ -1249,11 +1322,9 @@ static void cliProfile(char *cmdline)
|
|||
|
||||
static void cliRateProfile(char *cmdline)
|
||||
{
|
||||
uint8_t len;
|
||||
int i;
|
||||
|
||||
len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
if (isEmpty(cmdline)) {
|
||||
printf("rateprofile %d\r\n", getCurrentControlRateProfile());
|
||||
return;
|
||||
} else {
|
||||
|
@ -1447,7 +1518,7 @@ static void cliGet(char *cmdline)
|
|||
val = &valueTable[i];
|
||||
printf("%s = ", valueTable[i].name);
|
||||
cliPrintVar(val, 0);
|
||||
printf("\r\n");
|
||||
cliPrint("\r\n");
|
||||
|
||||
matchedCommands++;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#define USABLE_TIMER_CHANNEL_COUNT 11
|
||||
|
||||
// MPU 9150 INT connected to PA15, pulled up to VCC by 10K Resistor, contains MPU6050 and AK8975 in single component.
|
||||
// Using MPU6050 for the moment.
|
||||
#define GYRO
|
||||
#define USE_GYRO_MPU6050
|
||||
|
||||
|
@ -39,11 +39,13 @@
|
|||
|
||||
#define ACC_MPU6050_ALIGN CW270_DEG
|
||||
|
||||
// No baro support.
|
||||
//#define BARO
|
||||
//#define USE_BARO_MS5611
|
||||
|
||||
#define MAG
|
||||
#define USE_MAG_AK8975
|
||||
// No mag support for now (option to use MPU9150 in the future).
|
||||
//#define MAG
|
||||
//#define USE_MAG_AK8975
|
||||
|
||||
#define MAG_AK8975_ALIGN CW0_DEG_FLIP
|
||||
|
||||
|
@ -51,9 +53,9 @@
|
|||
#define LED1
|
||||
|
||||
#define USE_VCP
|
||||
#define USE_USART1 // Conn 1 - TX (PB6) RX PB7 (AF7)
|
||||
#define USE_USART2 // Input - RX (PA3)
|
||||
#define USE_USART3 // Servo out - 10/RX (PB11) 11/TX (PB10)
|
||||
#define USE_USART1 // Not connected - TX (PB6) RX PB7 (AF7)
|
||||
#define USE_USART2 // Receiver - RX (PA3)
|
||||
#define USE_USART3 // Not connected - 10/RX (PB11) 11/TX (PB10)
|
||||
#define SERIAL_PORT_COUNT 4
|
||||
|
||||
#define UART1_TX_PIN GPIO_Pin_6 // PB6
|
||||
|
@ -63,14 +65,13 @@
|
|||
#define UART1_TX_PINSOURCE GPIO_PinSource6
|
||||
#define UART1_RX_PINSOURCE GPIO_PinSource7
|
||||
|
||||
#define UART2_TX_PIN GPIO_Pin_2 // PA2 - Clashes with PWM6 input.
|
||||
#define UART2_TX_PIN GPIO_Pin_2 // PA2
|
||||
#define UART2_RX_PIN GPIO_Pin_3 // PA3
|
||||
#define UART2_GPIO GPIOA
|
||||
#define UART2_GPIO_AF GPIO_AF_7
|
||||
#define UART2_TX_PINSOURCE GPIO_PinSource2
|
||||
#define UART2_RX_PINSOURCE GPIO_PinSource3
|
||||
|
||||
// Note: PA5 and PA0 are N/C on the sparky - potentially use for ADC or LED STRIP?
|
||||
|
||||
#define USE_I2C
|
||||
#define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4)
|
||||
|
@ -89,53 +90,20 @@
|
|||
#define BLACKBOX
|
||||
#define SERIAL_RX
|
||||
#define GPS
|
||||
#define DISPLAY
|
||||
|
||||
#define LED_STRIP
|
||||
#if 1
|
||||
// LED strip configuration using PWM motor output pin 5.
|
||||
#define LED_STRIP_TIMER TIM16
|
||||
|
||||
#define USE_LED_STRIP_ON_DMA1_CHANNEL3
|
||||
#define WS2811_GPIO GPIOA
|
||||
#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
|
||||
#define WS2811_GPIO_AF GPIO_AF_1
|
||||
#define WS2811_PIN GPIO_Pin_6 // TIM16_CH1
|
||||
#define WS2811_PIN_SOURCE GPIO_PinSource6
|
||||
#define WS2811_TIMER TIM16
|
||||
#define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16
|
||||
#define WS2811_DMA_CHANNEL DMA1_Channel3
|
||||
#define WS2811_IRQ DMA1_Channel3_IRQn
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// Alternate LED strip pin
|
||||
// FIXME DMA IRQ Transfer Complete is never called because the TIM17_DMA_RMP needs to be set in SYSCFG_CFGR1
|
||||
#define LED_STRIP_TIMER TIM17
|
||||
|
||||
#define USE_LED_STRIP_ON_DMA1_CHANNEL7
|
||||
#define WS2811_GPIO GPIOA
|
||||
#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
|
||||
#define WS2811_GPIO_AF GPIO_AF_1
|
||||
#define WS2811_PIN GPIO_Pin_7 // TIM17_CH1
|
||||
#define WS2811_PIN_SOURCE GPIO_PinSource7
|
||||
#define WS2811_TIMER TIM17
|
||||
#define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM17
|
||||
#define WS2811_DMA_CHANNEL DMA1_Channel7
|
||||
#define WS2811_IRQ DMA1_Channel7_IRQn
|
||||
#endif
|
||||
//#define DISPLAY
|
||||
#define AUTOTUNE
|
||||
|
||||
|
||||
#define SPEKTRUM_BIND
|
||||
// USART2, PA3
|
||||
#define BIND_PORT GPIOA
|
||||
#define BIND_PIN Pin_3
|
||||
#define BIND_PORT GPIOA
|
||||
#define BIND_PIN Pin_3
|
||||
|
||||
// alternative defaults for AlienWii32 F3 target
|
||||
#define ALIENWII32
|
||||
#define HARDWARE_BIND_PLUG
|
||||
|
||||
// Hardware bind plug at PB12 (Pin 25)
|
||||
#define BINDPLUG_PORT GPIOB
|
||||
#define BINDPLUG_PIN Pin_12
|
||||
|
||||
// alternative defaults for AlienWii32 F3 target
|
||||
#define ALIENWII32
|
||||
#define BRUSHED_MOTORS
|
||||
#define HARDWARE_BIND_PLUG
|
||||
|
|
|
@ -163,8 +163,8 @@
|
|||
#ifdef ALIENWII32
|
||||
#undef TARGET_BOARD_IDENTIFIER
|
||||
#define TARGET_BOARD_IDENTIFIER "AWF1" // AlienWii32 F1.
|
||||
#define BRUSHED_MOTORS
|
||||
#define HARDWARE_BIND_PLUG
|
||||
|
||||
// Hardware bind plug at PB5 (Pin 41)
|
||||
#define BINDPLUG_PORT GPIOB
|
||||
#define BINDPLUG_PIN Pin_5
|
||||
|
|
|
@ -39,6 +39,14 @@ TEST(BatteryTest, BatteryADCToVoltage)
|
|||
|
||||
batteryConfig_t batteryConfig;
|
||||
|
||||
// batteryInit() reads a bunch of fields including vbatscale, so set up the config with useful initial values:
|
||||
memset(&batteryConfig, 0, sizeof(batteryConfig));
|
||||
|
||||
batteryConfig.vbatmaxcellvoltage = 43;
|
||||
batteryConfig.vbatmincellvoltage = 33;
|
||||
batteryConfig.vbatwarningcellvoltage = 35;
|
||||
batteryConfig.vbatscale = VBAT_SCALE_DEFAULT;
|
||||
|
||||
batteryInit(&batteryConfig);
|
||||
|
||||
batteryAdcToVoltageExpectation_t batteryAdcToVoltageExpectations[] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue