mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Fixing FY90Q build. Cleanup of printf support and initialisation.
Remove duplicate inclusion of math.h in board.h.
This commit is contained in:
parent
89612bd881
commit
7e45a0c7e6
9 changed files with 61 additions and 41 deletions
|
@ -28,10 +28,10 @@
|
||||||
#include "drivers/sound_beeper.h"
|
#include "drivers/sound_beeper.h"
|
||||||
#include "boardalignment.h"
|
#include "boardalignment.h"
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
#ifdef FY90Q
|
#ifdef FY90Q
|
||||||
// FY90Q
|
// FY90Q
|
||||||
|
#include "drivers/accgyro_fy90q.h"
|
||||||
#include "drivers/adc_common.h"
|
#include "drivers/adc_common.h"
|
||||||
#include "drivers/adc_fy90q.h"
|
#include "drivers/adc_fy90q.h"
|
||||||
#include "drivers/bus_i2c.h"
|
#include "drivers/bus_i2c.h"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "stdbool.h"
|
#include "stdbool.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
#include "stdlib.h"
|
||||||
|
#include "stdarg.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -11,6 +13,12 @@
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "drivers/serial_common.h"
|
||||||
|
#include "runtime_config.h"
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
|
#include "build_config.h"
|
||||||
|
|
||||||
#if MAX_MOTORS != MAX_SUPPORTED_MOTORS
|
#if MAX_MOTORS != MAX_SUPPORTED_MOTORS
|
||||||
#error Motor configuration mismatch
|
#error Motor configuration mismatch
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,3 +26,34 @@
|
||||||
#if MAX_SERVOS != MAX_SUPPORTED_SERVOS
|
#if MAX_SERVOS != MAX_SUPPORTED_SERVOS
|
||||||
#error Servo configuration mismatch
|
#error Servo configuration mismatch
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||||
|
|
||||||
|
// gcc/GNU version
|
||||||
|
static void _putc(void *p, char c)
|
||||||
|
{
|
||||||
|
serialWrite(core.mainport, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initPrintfSupport(void)
|
||||||
|
{
|
||||||
|
init_printf(NULL, _putc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// keil/armcc version
|
||||||
|
int fputc(int c, FILE *f)
|
||||||
|
{
|
||||||
|
// let DMA catch up a bit when using set or dump, we're too fast.
|
||||||
|
while (!isSerialTransmitBufferEmpty(core.mainport));
|
||||||
|
serialWrite(core.mainport, c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initPrintfSupport(void)
|
||||||
|
{
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
//#define SOFT_I2C // enable to test software i2c
|
//#define SOFT_I2C // enable to test software i2c
|
||||||
|
|
||||||
#ifndef __CC_ARM
|
#ifndef __CC_ARM
|
||||||
#define USE_LAME_PRINTF
|
#define REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||||
#define PRINTF_LONG_SUPPORT
|
#define REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void initPrintfSupport(void);
|
||||||
|
|
3
src/drivers/accgyro_fy90q.h
Normal file
3
src/drivers/accgyro_fy90q.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void adcSensorInit(sensor_t *acc, sensor_t *gyro);
|
|
@ -10,6 +10,3 @@ typedef struct drv_adc_config_t {
|
||||||
|
|
||||||
void adcInit(drv_adc_config_t *init);
|
void adcInit(drv_adc_config_t *init);
|
||||||
uint16_t adcGetChannel(uint8_t channel);
|
uint16_t adcGetChannel(uint8_t channel);
|
||||||
#ifdef FY90Q
|
|
||||||
void adcSensorInit(sensor_t *acc, sensor_t *gyro);
|
|
||||||
#endif
|
|
||||||
|
|
23
src/main.c
23
src/main.c
|
@ -4,6 +4,8 @@
|
||||||
#include "rx.h"
|
#include "rx.h"
|
||||||
#include "telemetry_common.h"
|
#include "telemetry_common.h"
|
||||||
|
|
||||||
|
#include "build_config.h"
|
||||||
|
|
||||||
core_t core;
|
core_t core;
|
||||||
|
|
||||||
extern rcReadRawDataPtr rcReadRawFunc;
|
extern rcReadRawDataPtr rcReadRawFunc;
|
||||||
|
@ -11,23 +13,6 @@ extern rcReadRawDataPtr rcReadRawFunc;
|
||||||
// receiver read function
|
// receiver read function
|
||||||
extern uint16_t pwmReadRawRC(uint8_t chan);
|
extern uint16_t pwmReadRawRC(uint8_t chan);
|
||||||
|
|
||||||
#ifdef USE_LAME_PRINTF
|
|
||||||
// gcc/GNU version
|
|
||||||
static void _putc(void *p, char c)
|
|
||||||
{
|
|
||||||
serialWrite(core.mainport, c);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// keil/armcc version
|
|
||||||
int fputc(int c, FILE *f)
|
|
||||||
{
|
|
||||||
// let DMA catch up a bit when using set or dump, we're too fast.
|
|
||||||
while (!isSerialTransmitBufferEmpty(core.mainport));
|
|
||||||
serialWrite(core.mainport, c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
@ -38,9 +23,7 @@ int main(void)
|
||||||
serialPort_t* loopbackPort2 = NULL;
|
serialPort_t* loopbackPort2 = NULL;
|
||||||
#endif
|
#endif
|
||||||
systemInit();
|
systemInit();
|
||||||
#ifdef USE_LAME_PRINTF
|
initPrintfSupport();
|
||||||
init_printf(NULL, _putc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
checkFirstTime(false);
|
checkFirstTime(false);
|
||||||
readEEPROM();
|
readEEPROM();
|
||||||
|
|
18
src/printf.c
18
src/printf.c
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "build_config.h"
|
#include "build_config.h"
|
||||||
|
@ -41,12 +40,12 @@
|
||||||
|
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
#include "typeconversion.h"
|
#include "typeconversion.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_LAME_PRINTF
|
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||||
|
|
||||||
typedef void (*putcf) (void *, char);
|
typedef void (*putcf) (void *, char);
|
||||||
static putcf stdout_putf;
|
static putcf stdout_putf;
|
||||||
|
@ -76,7 +75,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
||||||
putf(putp, ch);
|
putf(putp, ch);
|
||||||
else {
|
else {
|
||||||
char lz = 0;
|
char lz = 0;
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
char lng = 0;
|
char lng = 0;
|
||||||
#endif
|
#endif
|
||||||
int w = 0;
|
int w = 0;
|
||||||
|
@ -88,7 +87,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
||||||
if (ch >= '0' && ch <= '9') {
|
if (ch >= '0' && ch <= '9') {
|
||||||
ch = a2i(ch, &fmt, 10, &w);
|
ch = a2i(ch, &fmt, 10, &w);
|
||||||
}
|
}
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
if (ch == 'l') {
|
if (ch == 'l') {
|
||||||
ch = *(fmt++);
|
ch = *(fmt++);
|
||||||
lng = 1;
|
lng = 1;
|
||||||
|
@ -98,7 +97,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
||||||
case 0:
|
case 0:
|
||||||
goto abort;
|
goto abort;
|
||||||
case 'u':{
|
case 'u':{
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
if (lng)
|
if (lng)
|
||||||
uli2a(va_arg(va, unsigned long int), 10, 0, bf);
|
uli2a(va_arg(va, unsigned long int), 10, 0, bf);
|
||||||
else
|
else
|
||||||
|
@ -108,7 +107,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd':{
|
case 'd':{
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
if (lng)
|
if (lng)
|
||||||
li2a(va_arg(va, unsigned long int), bf);
|
li2a(va_arg(va, unsigned long int), bf);
|
||||||
else
|
else
|
||||||
|
@ -119,7 +118,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
||||||
}
|
}
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
if (lng)
|
if (lng)
|
||||||
uli2a(va_arg(va, unsigned long int), 16, (ch == 'X'), bf);
|
uli2a(va_arg(va, unsigned long int), 16, (ch == 'X'), bf);
|
||||||
else
|
else
|
||||||
|
@ -171,4 +170,5 @@ void tfp_sprintf(char *s, char *fmt, ...)
|
||||||
putcp(&s, 0);
|
putcp(&s, 0);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
#endif /* USE_LAME_PRINTF */
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -61,11 +61,7 @@ static const char * const mixerNames[] = {
|
||||||
// sync this with AvailableFeatures enum from board.h
|
// sync this with AvailableFeatures enum from board.h
|
||||||
static const char * const featureNames[] = {
|
static const char * const featureNames[] = {
|
||||||
"PPM", "VBAT", "INFLIGHT_ACC_CAL", "SERIALRX", "MOTOR_STOP",
|
"PPM", "VBAT", "INFLIGHT_ACC_CAL", "SERIALRX", "MOTOR_STOP",
|
||||||
"SERVO_TILT",
|
"SERVO_TILT", "SOFTSERIAL", "LED_RING", "GPS",
|
||||||
#ifndef FY90Q
|
|
||||||
"SOFTSERIAL",
|
|
||||||
#endif
|
|
||||||
"LED_RING", "GPS",
|
|
||||||
"FAILSAFE", "SONAR", "TELEMETRY", "POWERMETER", "VARIO", "3D",
|
"FAILSAFE", "SONAR", "TELEMETRY", "POWERMETER", "VARIO", "3D",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "build_config.h"
|
#include "build_config.h"
|
||||||
|
|
||||||
#ifdef PRINTF_LONG_SUPPORT
|
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
|
|
||||||
void uli2a(unsigned long int num, unsigned int base, int uc, char *bf)
|
void uli2a(unsigned long int num, unsigned int base, int uc, char *bf)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue