mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +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 "boardalignment.h"
|
||||
#include "battery.h"
|
||||
#include "math.h"
|
||||
|
||||
#ifdef FY90Q
|
||||
// FY90Q
|
||||
#include "drivers/accgyro_fy90q.h"
|
||||
#include "drivers/adc_common.h"
|
||||
#include "drivers/adc_fy90q.h"
|
||||
#include "drivers/bus_i2c.h"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "stdbool.h"
|
||||
#include "stdint.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -11,6 +13,12 @@
|
|||
#include "battery.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
|
||||
#error Motor configuration mismatch
|
||||
#endif
|
||||
|
@ -18,3 +26,34 @@
|
|||
#if MAX_SERVOS != MAX_SUPPORTED_SERVOS
|
||||
#error Servo configuration mismatch
|
||||
#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
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#define USE_LAME_PRINTF
|
||||
#define PRINTF_LONG_SUPPORT
|
||||
#define REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||
#define REQUIRE_PRINTF_LONG_SUPPORT
|
||||
#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);
|
||||
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 "telemetry_common.h"
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
core_t core;
|
||||
|
||||
extern rcReadRawDataPtr rcReadRawFunc;
|
||||
|
@ -11,23 +13,6 @@ extern rcReadRawDataPtr rcReadRawFunc;
|
|||
// receiver read function
|
||||
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)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -38,9 +23,7 @@ int main(void)
|
|||
serialPort_t* loopbackPort2 = NULL;
|
||||
#endif
|
||||
systemInit();
|
||||
#ifdef USE_LAME_PRINTF
|
||||
init_printf(NULL, _putc);
|
||||
#endif
|
||||
initPrintfSupport();
|
||||
|
||||
checkFirstTime(false);
|
||||
readEEPROM();
|
||||
|
|
18
src/printf.c
18
src/printf.c
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "build_config.h"
|
||||
|
@ -41,12 +40,12 @@
|
|||
|
||||
#include "printf.h"
|
||||
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
#include "typeconversion.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_LAME_PRINTF
|
||||
#ifdef REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||
|
||||
typedef void (*putcf) (void *, char);
|
||||
static putcf stdout_putf;
|
||||
|
@ -76,7 +75,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
|||
putf(putp, ch);
|
||||
else {
|
||||
char lz = 0;
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
char lng = 0;
|
||||
#endif
|
||||
int w = 0;
|
||||
|
@ -88,7 +87,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
|||
if (ch >= '0' && ch <= '9') {
|
||||
ch = a2i(ch, &fmt, 10, &w);
|
||||
}
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
if (ch == 'l') {
|
||||
ch = *(fmt++);
|
||||
lng = 1;
|
||||
|
@ -98,7 +97,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
|||
case 0:
|
||||
goto abort;
|
||||
case 'u':{
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 10, 0, bf);
|
||||
else
|
||||
|
@ -108,7 +107,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
|||
break;
|
||||
}
|
||||
case 'd':{
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
li2a(va_arg(va, unsigned long int), bf);
|
||||
else
|
||||
|
@ -119,7 +118,7 @@ void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
|||
}
|
||||
case 'x':
|
||||
case 'X':
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 16, (ch == 'X'), bf);
|
||||
else
|
||||
|
@ -171,4 +170,5 @@ void tfp_sprintf(char *s, char *fmt, ...)
|
|||
putcp(&s, 0);
|
||||
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
|
||||
static const char * const featureNames[] = {
|
||||
"PPM", "VBAT", "INFLIGHT_ACC_CAL", "SERIALRX", "MOTOR_STOP",
|
||||
"SERVO_TILT",
|
||||
#ifndef FY90Q
|
||||
"SOFTSERIAL",
|
||||
#endif
|
||||
"LED_RING", "GPS",
|
||||
"SERVO_TILT", "SOFTSERIAL", "LED_RING", "GPS",
|
||||
"FAILSAFE", "SONAR", "TELEMETRY", "POWERMETER", "VARIO", "3D",
|
||||
NULL
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue