mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 00:05:28 +03:00
Normalize all the line endings
This commit is contained in:
parent
4237370b60
commit
d60183d91d
396 changed files with 158300 additions and 158300 deletions
|
@ -1,174 +1,174 @@
|
|||
# A sample Makefile for building Google Test and using it in user
|
||||
# tests. Please tweak it to suit your environment and project. You
|
||||
# may want to move it to your project's root directory.
|
||||
#
|
||||
# SYNOPSIS:
|
||||
#
|
||||
# make [all] - makes everything.
|
||||
# make TARGET - makes the given target.
|
||||
# make clean - removes all files generated by make.
|
||||
|
||||
# Please tweak the following variable definitions as needed by your
|
||||
# project, except GTEST_HEADERS, which you can use in your own targets
|
||||
# but shouldn't modify.
|
||||
|
||||
# Points to the root of Google Test, relative to where this file is.
|
||||
# Remember to tweak this if you move this file.
|
||||
GTEST_DIR = ../../lib/test/gtest
|
||||
|
||||
# Where to find user code.
|
||||
USER_DIR = ../main
|
||||
TEST_DIR = unit
|
||||
USER_INCLUDE_DIR = $(USER_DIR)
|
||||
|
||||
OBJECT_DIR = ../../obj/test
|
||||
|
||||
# Flags passed to the preprocessor.
|
||||
# Set Google Test's header directory as a system directory, such that
|
||||
# the compiler doesn't generate warnings in Google Test headers.
|
||||
CPPFLAGS += -isystem $(GTEST_DIR)/inc
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += -g -Wall -Wextra -pthread -ggdb -O0
|
||||
|
||||
# All tests produced by this Makefile. Remember to add new tests you
|
||||
# created to the list.
|
||||
TESTS = \
|
||||
battery_unittest \
|
||||
flight_imu_unittest \
|
||||
gps_conversion_unittest \
|
||||
telemetry_hott_unittest \
|
||||
rc_controls_unittest \
|
||||
ledstrip_unittest
|
||||
|
||||
# All Google Test headers. Usually you shouldn't change this
|
||||
# definition.
|
||||
GTEST_HEADERS = $(GTEST_DIR)/inc/gtest/*.h
|
||||
|
||||
# House-keeping build targets.
|
||||
|
||||
all : $(TESTS)
|
||||
|
||||
clean :
|
||||
rm -rf $(TESTS) $(OBJECT_DIR)
|
||||
|
||||
# Builds gtest.a and gtest_main.a.
|
||||
|
||||
# Usually you shouldn't tweak such internal variables, indicated by a
|
||||
# trailing _.
|
||||
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/inc/gtest/*.h $(GTEST_HEADERS)
|
||||
|
||||
# For simplicity and to avoid depending on Google Test's
|
||||
# implementation details, the dependencies specified below are
|
||||
# conservative and not optimized. This is fine as Google Test
|
||||
# compiles fast and for ordinary users its source rarely changes.
|
||||
$(OBJECT_DIR)/gtest-all.o : $(GTEST_SRCS_)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
|
||||
$(GTEST_DIR)/src/gtest-all.cc -o $@
|
||||
|
||||
$(OBJECT_DIR)/gtest_main.o : $(GTEST_SRCS_)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
|
||||
$(GTEST_DIR)/src/gtest_main.cc -o $@
|
||||
|
||||
$(OBJECT_DIR)/gtest.a : $(OBJECT_DIR)/gtest-all.o
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
$(OBJECT_DIR)/gtest_main.a : $(OBJECT_DIR)/gtest-all.o $(OBJECT_DIR)/gtest_main.o
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
# Builds a sample test. A test should link with either gtest.a or
|
||||
# gtest_main.a, depending on whether it defines its own main()
|
||||
# function.
|
||||
|
||||
# includes in test dir must override includes in user dir
|
||||
TEST_INCLUDE_DIRS := $(TEST_DIR) \
|
||||
$(USER_INCLUDE_DIR)
|
||||
|
||||
|
||||
TEST_CFLAGS = $(addprefix -I,$(TEST_INCLUDE_DIRS))
|
||||
|
||||
|
||||
$(OBJECT_DIR)/sensors/battery.o : $(USER_DIR)/sensors/battery.c $(USER_DIR)/sensors/battery.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/sensors/battery.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/battery_unittest.o : $(TEST_DIR)/battery_unittest.cc \
|
||||
$(USER_DIR)/sensors/battery.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/battery_unittest.cc -o $@
|
||||
|
||||
battery_unittest : $(OBJECT_DIR)/sensors/battery.o $(OBJECT_DIR)/battery_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/flight/imu.o : $(USER_DIR)/flight/imu.c $(USER_DIR)/flight/imu.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/flight/imu.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/flight_imu_unittest.o : $(TEST_DIR)/flight_imu_unittest.cc \
|
||||
$(USER_DIR)/flight/imu.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/flight_imu_unittest.cc -o $@
|
||||
|
||||
flight_imu_unittest : $(OBJECT_DIR)/flight/imu.o $(OBJECT_DIR)/flight_imu_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
$(OBJECT_DIR)/flight/gps_conversion.o : $(USER_DIR)/flight/gps_conversion.c $(USER_DIR)/flight/gps_conversion.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/flight/gps_conversion.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/gps_conversion_unittest.o : $(TEST_DIR)/gps_conversion_unittest.cc \
|
||||
$(USER_DIR)/flight/gps_conversion.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/gps_conversion_unittest.cc -o $@
|
||||
|
||||
gps_conversion_unittest : $(OBJECT_DIR)/flight/gps_conversion.o $(OBJECT_DIR)/gps_conversion_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/telemetry/hott.o : $(USER_DIR)/telemetry/hott.c $(USER_DIR)/telemetry/hott.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/telemetry/hott.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/telemetry_hott_unittest.o : $(TEST_DIR)/telemetry_hott_unittest.cc \
|
||||
$(USER_DIR)/telemetry/hott.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/telemetry_hott_unittest.cc -o $@
|
||||
|
||||
telemetry_hott_unittest :$(OBJECT_DIR)/telemetry/hott.o $(OBJECT_DIR)/telemetry_hott_unittest.o $(OBJECT_DIR)/flight/gps_conversion.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/io/rc_controls.o : $(USER_DIR)/io/rc_controls.c $(USER_DIR)/io/rc_controls.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/io/rc_controls.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/rc_controls_unittest.o : $(TEST_DIR)/rc_controls_unittest.cc \
|
||||
$(USER_DIR)/io/rc_controls.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/rc_controls_unittest.cc -o $@
|
||||
|
||||
rc_controls_unittest :$(OBJECT_DIR)/io/rc_controls.o $(OBJECT_DIR)/rc_controls_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
$(OBJECT_DIR)/io/ledstrip.o : $(USER_DIR)/io/ledstrip.c $(USER_DIR)/io/ledstrip.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/io/ledstrip.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/ledstrip_unittest.o : $(TEST_DIR)/ledstrip_unittest.cc \
|
||||
$(USER_DIR)/io/ledstrip.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/ledstrip_unittest.cc -o $@
|
||||
|
||||
ledstrip_unittest :$(OBJECT_DIR)/io/ledstrip.o $(OBJECT_DIR)/ledstrip_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
# A sample Makefile for building Google Test and using it in user
|
||||
# tests. Please tweak it to suit your environment and project. You
|
||||
# may want to move it to your project's root directory.
|
||||
#
|
||||
# SYNOPSIS:
|
||||
#
|
||||
# make [all] - makes everything.
|
||||
# make TARGET - makes the given target.
|
||||
# make clean - removes all files generated by make.
|
||||
|
||||
# Please tweak the following variable definitions as needed by your
|
||||
# project, except GTEST_HEADERS, which you can use in your own targets
|
||||
# but shouldn't modify.
|
||||
|
||||
# Points to the root of Google Test, relative to where this file is.
|
||||
# Remember to tweak this if you move this file.
|
||||
GTEST_DIR = ../../lib/test/gtest
|
||||
|
||||
# Where to find user code.
|
||||
USER_DIR = ../main
|
||||
TEST_DIR = unit
|
||||
USER_INCLUDE_DIR = $(USER_DIR)
|
||||
|
||||
OBJECT_DIR = ../../obj/test
|
||||
|
||||
# Flags passed to the preprocessor.
|
||||
# Set Google Test's header directory as a system directory, such that
|
||||
# the compiler doesn't generate warnings in Google Test headers.
|
||||
CPPFLAGS += -isystem $(GTEST_DIR)/inc
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += -g -Wall -Wextra -pthread -ggdb -O0
|
||||
|
||||
# All tests produced by this Makefile. Remember to add new tests you
|
||||
# created to the list.
|
||||
TESTS = \
|
||||
battery_unittest \
|
||||
flight_imu_unittest \
|
||||
gps_conversion_unittest \
|
||||
telemetry_hott_unittest \
|
||||
rc_controls_unittest \
|
||||
ledstrip_unittest
|
||||
|
||||
# All Google Test headers. Usually you shouldn't change this
|
||||
# definition.
|
||||
GTEST_HEADERS = $(GTEST_DIR)/inc/gtest/*.h
|
||||
|
||||
# House-keeping build targets.
|
||||
|
||||
all : $(TESTS)
|
||||
|
||||
clean :
|
||||
rm -rf $(TESTS) $(OBJECT_DIR)
|
||||
|
||||
# Builds gtest.a and gtest_main.a.
|
||||
|
||||
# Usually you shouldn't tweak such internal variables, indicated by a
|
||||
# trailing _.
|
||||
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/inc/gtest/*.h $(GTEST_HEADERS)
|
||||
|
||||
# For simplicity and to avoid depending on Google Test's
|
||||
# implementation details, the dependencies specified below are
|
||||
# conservative and not optimized. This is fine as Google Test
|
||||
# compiles fast and for ordinary users its source rarely changes.
|
||||
$(OBJECT_DIR)/gtest-all.o : $(GTEST_SRCS_)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
|
||||
$(GTEST_DIR)/src/gtest-all.cc -o $@
|
||||
|
||||
$(OBJECT_DIR)/gtest_main.o : $(GTEST_SRCS_)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
|
||||
$(GTEST_DIR)/src/gtest_main.cc -o $@
|
||||
|
||||
$(OBJECT_DIR)/gtest.a : $(OBJECT_DIR)/gtest-all.o
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
$(OBJECT_DIR)/gtest_main.a : $(OBJECT_DIR)/gtest-all.o $(OBJECT_DIR)/gtest_main.o
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
# Builds a sample test. A test should link with either gtest.a or
|
||||
# gtest_main.a, depending on whether it defines its own main()
|
||||
# function.
|
||||
|
||||
# includes in test dir must override includes in user dir
|
||||
TEST_INCLUDE_DIRS := $(TEST_DIR) \
|
||||
$(USER_INCLUDE_DIR)
|
||||
|
||||
|
||||
TEST_CFLAGS = $(addprefix -I,$(TEST_INCLUDE_DIRS))
|
||||
|
||||
|
||||
$(OBJECT_DIR)/sensors/battery.o : $(USER_DIR)/sensors/battery.c $(USER_DIR)/sensors/battery.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/sensors/battery.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/battery_unittest.o : $(TEST_DIR)/battery_unittest.cc \
|
||||
$(USER_DIR)/sensors/battery.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/battery_unittest.cc -o $@
|
||||
|
||||
battery_unittest : $(OBJECT_DIR)/sensors/battery.o $(OBJECT_DIR)/battery_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/flight/imu.o : $(USER_DIR)/flight/imu.c $(USER_DIR)/flight/imu.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/flight/imu.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/flight_imu_unittest.o : $(TEST_DIR)/flight_imu_unittest.cc \
|
||||
$(USER_DIR)/flight/imu.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/flight_imu_unittest.cc -o $@
|
||||
|
||||
flight_imu_unittest : $(OBJECT_DIR)/flight/imu.o $(OBJECT_DIR)/flight_imu_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
$(OBJECT_DIR)/flight/gps_conversion.o : $(USER_DIR)/flight/gps_conversion.c $(USER_DIR)/flight/gps_conversion.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/flight/gps_conversion.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/gps_conversion_unittest.o : $(TEST_DIR)/gps_conversion_unittest.cc \
|
||||
$(USER_DIR)/flight/gps_conversion.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/gps_conversion_unittest.cc -o $@
|
||||
|
||||
gps_conversion_unittest : $(OBJECT_DIR)/flight/gps_conversion.o $(OBJECT_DIR)/gps_conversion_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/telemetry/hott.o : $(USER_DIR)/telemetry/hott.c $(USER_DIR)/telemetry/hott.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/telemetry/hott.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/telemetry_hott_unittest.o : $(TEST_DIR)/telemetry_hott_unittest.cc \
|
||||
$(USER_DIR)/telemetry/hott.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/telemetry_hott_unittest.cc -o $@
|
||||
|
||||
telemetry_hott_unittest :$(OBJECT_DIR)/telemetry/hott.o $(OBJECT_DIR)/telemetry_hott_unittest.o $(OBJECT_DIR)/flight/gps_conversion.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
||||
$(OBJECT_DIR)/io/rc_controls.o : $(USER_DIR)/io/rc_controls.c $(USER_DIR)/io/rc_controls.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/io/rc_controls.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/rc_controls_unittest.o : $(TEST_DIR)/rc_controls_unittest.cc \
|
||||
$(USER_DIR)/io/rc_controls.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/rc_controls_unittest.cc -o $@
|
||||
|
||||
rc_controls_unittest :$(OBJECT_DIR)/io/rc_controls.o $(OBJECT_DIR)/rc_controls_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
$(OBJECT_DIR)/io/ledstrip.o : $(USER_DIR)/io/ledstrip.c $(USER_DIR)/io/ledstrip.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(USER_DIR)/io/ledstrip.c -o $@
|
||||
|
||||
$(OBJECT_DIR)/ledstrip_unittest.o : $(TEST_DIR)/ledstrip_unittest.cc \
|
||||
$(USER_DIR)/io/ledstrip.h $(GTEST_HEADERS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(TEST_CFLAGS) -c $(TEST_DIR)/ledstrip_unittest.cc -o $@
|
||||
|
||||
ledstrip_unittest :$(OBJECT_DIR)/io/ledstrip.o $(OBJECT_DIR)/ledstrip_unittest.o $(OBJECT_DIR)/gtest_main.a
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $(OBJECT_DIR)/$@
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
typedef struct batteryAdcToVoltageExpectation_s {
|
||||
uint16_t adcReading;
|
||||
uint16_t expectedVoltageInDeciVoltSteps;
|
||||
} batteryAdcToVoltageExpectation_t;
|
||||
|
||||
#define ELEVEN_TO_ONE_VOLTAGE_DIVIDER 110 // (10k:1k) * 10 for 0.1V
|
||||
|
||||
TEST(BatteryTest, BatteryADCToVoltage)
|
||||
{
|
||||
// given
|
||||
|
||||
batteryConfig_t batteryConfig;
|
||||
batteryConfig.vbatscale = ELEVEN_TO_ONE_VOLTAGE_DIVIDER;
|
||||
|
||||
batteryInit(&batteryConfig);
|
||||
|
||||
batteryAdcToVoltageExpectation_t batteryAdcToVoltageExpectations[] = {
|
||||
{1420, 125},
|
||||
{1430, 126},
|
||||
{1440, 127},
|
||||
{1890, 167},
|
||||
{1900, 168},
|
||||
{1910, 169}
|
||||
};
|
||||
uint8_t testIterationCount = sizeof(batteryAdcToVoltageExpectations) / sizeof(batteryAdcToVoltageExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
batteryAdcToVoltageExpectation_t *batteryAdcToVoltageExpectation = &batteryAdcToVoltageExpectations[index];
|
||||
printf("adcReading: %d\n", batteryAdcToVoltageExpectation->adcReading);
|
||||
|
||||
uint16_t pointOneVoltSteps = batteryAdcToVoltage(batteryAdcToVoltageExpectation->adcReading);
|
||||
|
||||
EXPECT_EQ(pointOneVoltSteps, batteryAdcToVoltageExpectation->expectedVoltageInDeciVoltSteps);
|
||||
}
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
||||
uint16_t adcGetChannel(uint8_t channel)
|
||||
{
|
||||
UNUSED(channel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void delay(uint32_t ms)
|
||||
{
|
||||
UNUSED(ms);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
typedef struct batteryAdcToVoltageExpectation_s {
|
||||
uint16_t adcReading;
|
||||
uint16_t expectedVoltageInDeciVoltSteps;
|
||||
} batteryAdcToVoltageExpectation_t;
|
||||
|
||||
#define ELEVEN_TO_ONE_VOLTAGE_DIVIDER 110 // (10k:1k) * 10 for 0.1V
|
||||
|
||||
TEST(BatteryTest, BatteryADCToVoltage)
|
||||
{
|
||||
// given
|
||||
|
||||
batteryConfig_t batteryConfig;
|
||||
batteryConfig.vbatscale = ELEVEN_TO_ONE_VOLTAGE_DIVIDER;
|
||||
|
||||
batteryInit(&batteryConfig);
|
||||
|
||||
batteryAdcToVoltageExpectation_t batteryAdcToVoltageExpectations[] = {
|
||||
{1420, 125},
|
||||
{1430, 126},
|
||||
{1440, 127},
|
||||
{1890, 167},
|
||||
{1900, 168},
|
||||
{1910, 169}
|
||||
};
|
||||
uint8_t testIterationCount = sizeof(batteryAdcToVoltageExpectations) / sizeof(batteryAdcToVoltageExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
batteryAdcToVoltageExpectation_t *batteryAdcToVoltageExpectation = &batteryAdcToVoltageExpectations[index];
|
||||
printf("adcReading: %d\n", batteryAdcToVoltageExpectation->adcReading);
|
||||
|
||||
uint16_t pointOneVoltSteps = batteryAdcToVoltage(batteryAdcToVoltageExpectation->adcReading);
|
||||
|
||||
EXPECT_EQ(pointOneVoltSteps, batteryAdcToVoltageExpectation->expectedVoltageInDeciVoltSteps);
|
||||
}
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
||||
uint16_t adcGetChannel(uint8_t channel)
|
||||
{
|
||||
UNUSED(channel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void delay(uint32_t ms)
|
||||
{
|
||||
UNUSED(ms);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,120 +1,120 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define BARO
|
||||
|
||||
#include "common/axis.h"
|
||||
#include "flight/flight.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "drivers/accgyro.h"
|
||||
#include "sensors/gyro.h"
|
||||
#include "sensors/compass.h"
|
||||
#include "sensors/acceleration.h"
|
||||
#include "sensors/barometer.h"
|
||||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
#include "flight/mixer.h"
|
||||
#include "flight/imu.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define DOWNWARDS_THRUST true
|
||||
#define UPWARDS_THRUST false
|
||||
|
||||
|
||||
bool isThrustFacingDownwards(rollAndPitchInclination_t *inclinations);
|
||||
|
||||
typedef struct inclinationExpectation_s {
|
||||
rollAndPitchInclination_t inclination;
|
||||
bool expectDownwardsThrust;
|
||||
} inclinationExpectation_t;
|
||||
|
||||
TEST(FlightImuTest, IsThrustFacingDownwards)
|
||||
{
|
||||
// given
|
||||
|
||||
inclinationExpectation_t inclinationExpectations[] = {
|
||||
{ { 0, 0 }, DOWNWARDS_THRUST },
|
||||
{ { 799, 799 }, DOWNWARDS_THRUST },
|
||||
{ { 800, 799 }, UPWARDS_THRUST },
|
||||
{ { 799, 800 }, UPWARDS_THRUST },
|
||||
{ { 800, 800 }, UPWARDS_THRUST },
|
||||
{ { 801, 801 }, UPWARDS_THRUST },
|
||||
{ { -799, -799 }, DOWNWARDS_THRUST },
|
||||
{ { -800, -799 }, UPWARDS_THRUST },
|
||||
{ { -799, -800 }, UPWARDS_THRUST },
|
||||
{ { -800, -800 }, UPWARDS_THRUST },
|
||||
{ { -801, -801 }, UPWARDS_THRUST }
|
||||
};
|
||||
uint8_t testIterationCount = sizeof(inclinationExpectations) / sizeof(inclinationExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
inclinationExpectation_t *angleInclinationExpectation = &inclinationExpectations[index];
|
||||
printf("iteration: %d\n", index);
|
||||
bool result = isThrustFacingDownwards(&angleInclinationExpectation->inclination);
|
||||
EXPECT_EQ(angleInclinationExpectation->expectDownwardsThrust, result);
|
||||
}
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
||||
uint16_t acc_1G;
|
||||
int16_t heading;
|
||||
gyro_t gyro;
|
||||
int16_t magADC[XYZ_AXIS_COUNT];
|
||||
int32_t BaroAlt;
|
||||
int16_t debug[4];
|
||||
|
||||
uint8_t stateFlags;
|
||||
uint16_t flightModeFlags;
|
||||
uint8_t armingFlags;
|
||||
|
||||
int32_t sonarAlt;
|
||||
|
||||
|
||||
void gyroGetADC(void) {};
|
||||
bool sensors(uint32_t mask)
|
||||
{
|
||||
UNUSED(mask);
|
||||
return false;
|
||||
};
|
||||
void updateAccelerationReadings(rollAndPitchTrims_t *rollAndPitchTrims)
|
||||
{
|
||||
UNUSED(rollAndPitchTrims);
|
||||
}
|
||||
|
||||
uint32_t micros(void) { return 0; }
|
||||
bool isBaroCalibrationComplete(void) { return true; }
|
||||
void performBaroCalibrationCycle(void) {}
|
||||
int32_t baroCalculateAltitude(void) { return 0; }
|
||||
int constrain(int amt, int low, int high)
|
||||
{
|
||||
UNUSED(amt);
|
||||
UNUSED(low);
|
||||
UNUSED(high);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define BARO
|
||||
|
||||
#include "common/axis.h"
|
||||
#include "flight/flight.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "drivers/accgyro.h"
|
||||
#include "sensors/gyro.h"
|
||||
#include "sensors/compass.h"
|
||||
#include "sensors/acceleration.h"
|
||||
#include "sensors/barometer.h"
|
||||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
#include "flight/mixer.h"
|
||||
#include "flight/imu.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define DOWNWARDS_THRUST true
|
||||
#define UPWARDS_THRUST false
|
||||
|
||||
|
||||
bool isThrustFacingDownwards(rollAndPitchInclination_t *inclinations);
|
||||
|
||||
typedef struct inclinationExpectation_s {
|
||||
rollAndPitchInclination_t inclination;
|
||||
bool expectDownwardsThrust;
|
||||
} inclinationExpectation_t;
|
||||
|
||||
TEST(FlightImuTest, IsThrustFacingDownwards)
|
||||
{
|
||||
// given
|
||||
|
||||
inclinationExpectation_t inclinationExpectations[] = {
|
||||
{ { 0, 0 }, DOWNWARDS_THRUST },
|
||||
{ { 799, 799 }, DOWNWARDS_THRUST },
|
||||
{ { 800, 799 }, UPWARDS_THRUST },
|
||||
{ { 799, 800 }, UPWARDS_THRUST },
|
||||
{ { 800, 800 }, UPWARDS_THRUST },
|
||||
{ { 801, 801 }, UPWARDS_THRUST },
|
||||
{ { -799, -799 }, DOWNWARDS_THRUST },
|
||||
{ { -800, -799 }, UPWARDS_THRUST },
|
||||
{ { -799, -800 }, UPWARDS_THRUST },
|
||||
{ { -800, -800 }, UPWARDS_THRUST },
|
||||
{ { -801, -801 }, UPWARDS_THRUST }
|
||||
};
|
||||
uint8_t testIterationCount = sizeof(inclinationExpectations) / sizeof(inclinationExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
inclinationExpectation_t *angleInclinationExpectation = &inclinationExpectations[index];
|
||||
printf("iteration: %d\n", index);
|
||||
bool result = isThrustFacingDownwards(&angleInclinationExpectation->inclination);
|
||||
EXPECT_EQ(angleInclinationExpectation->expectDownwardsThrust, result);
|
||||
}
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
||||
uint16_t acc_1G;
|
||||
int16_t heading;
|
||||
gyro_t gyro;
|
||||
int16_t magADC[XYZ_AXIS_COUNT];
|
||||
int32_t BaroAlt;
|
||||
int16_t debug[4];
|
||||
|
||||
uint8_t stateFlags;
|
||||
uint16_t flightModeFlags;
|
||||
uint8_t armingFlags;
|
||||
|
||||
int32_t sonarAlt;
|
||||
|
||||
|
||||
void gyroGetADC(void) {};
|
||||
bool sensors(uint32_t mask)
|
||||
{
|
||||
UNUSED(mask);
|
||||
return false;
|
||||
};
|
||||
void updateAccelerationReadings(rollAndPitchTrims_t *rollAndPitchTrims)
|
||||
{
|
||||
UNUSED(rollAndPitchTrims);
|
||||
}
|
||||
|
||||
uint32_t micros(void) { return 0; }
|
||||
bool isBaroCalibrationComplete(void) { return true; }
|
||||
void performBaroCalibrationCycle(void) {}
|
||||
int32_t baroCalculateAltitude(void) { return 0; }
|
||||
int constrain(int amt, int low, int high)
|
||||
{
|
||||
UNUSED(amt);
|
||||
UNUSED(low);
|
||||
UNUSED(high);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include "flight/gps_conversion.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// See http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
|
||||
|
||||
TEST(GpsConversionTest, GPSCoordToDegrees_BadString)
|
||||
{
|
||||
// expect
|
||||
uint32_t result = GPS_coord_to_degrees("diediedie");
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
typedef struct gpsConversionExpectation_s {
|
||||
char *coord;
|
||||
uint32_t degrees;
|
||||
} gpsConversionExpectation_t;
|
||||
|
||||
TEST(GpsConversionTest, GPSCoordToDegrees_NMEA_Values)
|
||||
{
|
||||
const gpsConversionExpectation_t gpsConversionExpectations[] = {
|
||||
{"0.0", 0},
|
||||
{"000.0", 0},
|
||||
{"00000.0000", 0},
|
||||
{"0.0001", 16}, // smallest value
|
||||
{"25599.9999", 2566666650UL}, // largest value
|
||||
{"25599.99999", 2566666650UL}, // too many fractional digits
|
||||
{"25699.9999", 16666650UL}, // overflowed without detection
|
||||
{"5128.3727", 514728783UL},
|
||||
{"5321.6802", 533613366UL},
|
||||
{"00630.3372", 65056200UL},
|
||||
};
|
||||
|
||||
// expect
|
||||
|
||||
uint8_t testIterationCount = sizeof(gpsConversionExpectations) / sizeof(gpsConversionExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
const gpsConversionExpectation_t *expectation = &gpsConversionExpectations[index];
|
||||
printf("iteration: %d\n", index);
|
||||
|
||||
uint32_t result = GPS_coord_to_degrees(expectation->coord);
|
||||
EXPECT_EQ(result, expectation->degrees);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include "flight/gps_conversion.h"
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// See http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
|
||||
|
||||
TEST(GpsConversionTest, GPSCoordToDegrees_BadString)
|
||||
{
|
||||
// expect
|
||||
uint32_t result = GPS_coord_to_degrees("diediedie");
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
|
||||
typedef struct gpsConversionExpectation_s {
|
||||
char *coord;
|
||||
uint32_t degrees;
|
||||
} gpsConversionExpectation_t;
|
||||
|
||||
TEST(GpsConversionTest, GPSCoordToDegrees_NMEA_Values)
|
||||
{
|
||||
const gpsConversionExpectation_t gpsConversionExpectations[] = {
|
||||
{"0.0", 0},
|
||||
{"000.0", 0},
|
||||
{"00000.0000", 0},
|
||||
{"0.0001", 16}, // smallest value
|
||||
{"25599.9999", 2566666650UL}, // largest value
|
||||
{"25599.99999", 2566666650UL}, // too many fractional digits
|
||||
{"25699.9999", 16666650UL}, // overflowed without detection
|
||||
{"5128.3727", 514728783UL},
|
||||
{"5321.6802", 533613366UL},
|
||||
{"00630.3372", 65056200UL},
|
||||
};
|
||||
|
||||
// expect
|
||||
|
||||
uint8_t testIterationCount = sizeof(gpsConversionExpectations) / sizeof(gpsConversionExpectation_t);
|
||||
|
||||
// expect
|
||||
|
||||
for (uint8_t index = 0; index < testIterationCount; index ++) {
|
||||
const gpsConversionExpectation_t *expectation = &gpsConversionExpectations[index];
|
||||
printf("iteration: %d\n", index);
|
||||
|
||||
uint32_t result = GPS_coord_to_degrees(expectation->coord);
|
||||
EXPECT_EQ(result, expectation->degrees);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BARO
|
||||
#define GPS
|
||||
#define TELEMETRY
|
||||
#define LED_STRIP
|
||||
|
||||
#define SERIAL_PORT_COUNT 4
|
||||
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BARO
|
||||
#define GPS
|
||||
#define TELEMETRY
|
||||
#define LED_STRIP
|
||||
|
||||
#define SERIAL_PORT_COUNT 4
|
||||
|
||||
|
|
|
@ -1,222 +1,222 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
#include "io/serial.h"
|
||||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
|
||||
#include "flight/flight.h"
|
||||
#include "io/gps.h"
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
#include "telemetry/hott.h"
|
||||
|
||||
#include "flight/gps_conversion.h"
|
||||
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
void addGPSCoordinates(HOTT_GPS_MSG_t *hottGPSMessage, int32_t latitude, int32_t longitude);
|
||||
|
||||
// See http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
|
||||
|
||||
HOTT_GPS_MSG_t hottGPSMessage;
|
||||
|
||||
HOTT_GPS_MSG_t *getGPSMessageForTest(void)
|
||||
{
|
||||
memset(&hottGPSMessage, 0, sizeof(hottGPSMessage));
|
||||
return &hottGPSMessage;
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates1)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
// Mayrhofen, Austria
|
||||
uint32_t longitude = GPS_coord_to_degrees("4710.5186");
|
||||
uint32_t latitude = GPS_coord_to_degrees("1151.4252");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, latitude, longitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L, 1151);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L), 4251);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L, 4710);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), 5186);
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates2)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
// Hampstead Heath, London
|
||||
// 51.563886, -0.159960
|
||||
uint32_t longitude = GPS_coord_to_degrees("5156.3886");
|
||||
uint32_t latitude = -GPS_coord_to_degrees("015.9960");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, longitude, latitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L, 5156);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L, 3886);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 1);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L), -15);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), -9960);
|
||||
}
|
||||
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates3)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
int32_t longitude = -GPS_coord_to_degrees("17999.9999");
|
||||
int32_t latitude = GPS_coord_to_degrees("8999.9999");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, longitude, latitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 1);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L), -18039);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L), -9999);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 0);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L), 9039);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), 9999);
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, PrepareGPSMessage_Altitude1m)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
stateFlags = GPS_FIX;
|
||||
uint16_t altitudeInMeters = 1;
|
||||
GPS_altitude = altitudeInMeters * (1 / 0.1f); // 1 = 0.1m
|
||||
|
||||
// when
|
||||
hottPrepareGPSResponse(hottGPSMessage);
|
||||
|
||||
// then
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->altitude_H << 8 | hottGPSMessage->altitude_L), 1 + HOTT_GPS_ALTITUDE_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
// STUBS
|
||||
|
||||
int16_t debug[4];
|
||||
|
||||
uint8_t stateFlags;
|
||||
|
||||
|
||||
uint8_t GPS_numSat;
|
||||
int32_t GPS_coord[2];
|
||||
uint16_t GPS_speed; // speed in 0.1m/s
|
||||
uint16_t GPS_distanceToHome; // distance to home point in meters
|
||||
uint16_t GPS_altitude; // altitude in 0.1m
|
||||
uint8_t vbat;
|
||||
int16_t GPS_directionToHome; // direction to home or hol point in degrees
|
||||
|
||||
uint32_t micros(void) { return 0; }
|
||||
|
||||
uint8_t serialTotalBytesWaiting(serialPort_t *instance) {
|
||||
UNUSED(instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t serialRead(serialPort_t *instance) {
|
||||
UNUSED(instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void serialWrite(serialPort_t *instance, uint8_t ch) {
|
||||
UNUSED(instance);
|
||||
UNUSED(ch);
|
||||
}
|
||||
|
||||
void serialSetMode(serialPort_t *instance, portMode_t mode) {
|
||||
UNUSED(instance);
|
||||
UNUSED(mode);
|
||||
}
|
||||
|
||||
void serialSetBaudRate(serialPort_t *instance, uint32_t baudRate) {
|
||||
UNUSED(instance);
|
||||
UNUSED(baudRate);
|
||||
}
|
||||
|
||||
void beginSerialPortFunction(serialPort_t *port, serialPortFunction_e function) {
|
||||
UNUSED(port);
|
||||
UNUSED(function);
|
||||
}
|
||||
|
||||
void endSerialPortFunction(serialPort_t *port, serialPortFunction_e function) {
|
||||
UNUSED(port);
|
||||
UNUSED(function);
|
||||
}
|
||||
|
||||
serialPort_t *openSerialPort(serialPortFunction_e functionMask, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, serialInversion_e inversion) {
|
||||
UNUSED(functionMask);
|
||||
UNUSED(baudRate);
|
||||
UNUSED(callback);
|
||||
UNUSED(mode);
|
||||
UNUSED(inversion);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
serialPort_t *findOpenSerialPort(uint16_t functionMask) {
|
||||
UNUSED(functionMask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool sensors(uint32_t mask) {
|
||||
UNUSED(mask);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
#include "io/serial.h"
|
||||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
|
||||
#include "flight/flight.h"
|
||||
#include "io/gps.h"
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
#include "telemetry/hott.h"
|
||||
|
||||
#include "flight/gps_conversion.h"
|
||||
|
||||
|
||||
#include "unittest_macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
void addGPSCoordinates(HOTT_GPS_MSG_t *hottGPSMessage, int32_t latitude, int32_t longitude);
|
||||
|
||||
// See http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
|
||||
|
||||
HOTT_GPS_MSG_t hottGPSMessage;
|
||||
|
||||
HOTT_GPS_MSG_t *getGPSMessageForTest(void)
|
||||
{
|
||||
memset(&hottGPSMessage, 0, sizeof(hottGPSMessage));
|
||||
return &hottGPSMessage;
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates1)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
// Mayrhofen, Austria
|
||||
uint32_t longitude = GPS_coord_to_degrees("4710.5186");
|
||||
uint32_t latitude = GPS_coord_to_degrees("1151.4252");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, latitude, longitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L, 1151);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L), 4251);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L, 4710);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), 5186);
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates2)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
// Hampstead Heath, London
|
||||
// 51.563886, -0.159960
|
||||
uint32_t longitude = GPS_coord_to_degrees("5156.3886");
|
||||
uint32_t latitude = -GPS_coord_to_degrees("015.9960");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, longitude, latitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 0);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L, 5156);
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L, 3886);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 1);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L), -15);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), -9960);
|
||||
}
|
||||
|
||||
|
||||
TEST(TelemetryHottTest, UpdateGPSCoordinates3)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
int32_t longitude = -GPS_coord_to_degrees("17999.9999");
|
||||
int32_t latitude = GPS_coord_to_degrees("8999.9999");
|
||||
|
||||
// when
|
||||
addGPSCoordinates(hottGPSMessage, longitude, latitude);
|
||||
|
||||
// then
|
||||
EXPECT_EQ(hottGPSMessage->pos_NS, 1);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_dm_H << 8 | hottGPSMessage->pos_NS_dm_L), -18039);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_NS_sec_H << 8 | hottGPSMessage->pos_NS_sec_L), -9999);
|
||||
|
||||
EXPECT_EQ(hottGPSMessage->pos_EW, 0);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_dm_H << 8 | hottGPSMessage->pos_EW_dm_L), 9039);
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->pos_EW_sec_H << 8 | hottGPSMessage->pos_EW_sec_L), 9999);
|
||||
}
|
||||
|
||||
TEST(TelemetryHottTest, PrepareGPSMessage_Altitude1m)
|
||||
{
|
||||
// given
|
||||
HOTT_GPS_MSG_t *hottGPSMessage = getGPSMessageForTest();
|
||||
|
||||
stateFlags = GPS_FIX;
|
||||
uint16_t altitudeInMeters = 1;
|
||||
GPS_altitude = altitudeInMeters * (1 / 0.1f); // 1 = 0.1m
|
||||
|
||||
// when
|
||||
hottPrepareGPSResponse(hottGPSMessage);
|
||||
|
||||
// then
|
||||
EXPECT_EQ((int16_t)(hottGPSMessage->altitude_H << 8 | hottGPSMessage->altitude_L), 1 + HOTT_GPS_ALTITUDE_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
// STUBS
|
||||
|
||||
int16_t debug[4];
|
||||
|
||||
uint8_t stateFlags;
|
||||
|
||||
|
||||
uint8_t GPS_numSat;
|
||||
int32_t GPS_coord[2];
|
||||
uint16_t GPS_speed; // speed in 0.1m/s
|
||||
uint16_t GPS_distanceToHome; // distance to home point in meters
|
||||
uint16_t GPS_altitude; // altitude in 0.1m
|
||||
uint8_t vbat;
|
||||
int16_t GPS_directionToHome; // direction to home or hol point in degrees
|
||||
|
||||
uint32_t micros(void) { return 0; }
|
||||
|
||||
uint8_t serialTotalBytesWaiting(serialPort_t *instance) {
|
||||
UNUSED(instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t serialRead(serialPort_t *instance) {
|
||||
UNUSED(instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void serialWrite(serialPort_t *instance, uint8_t ch) {
|
||||
UNUSED(instance);
|
||||
UNUSED(ch);
|
||||
}
|
||||
|
||||
void serialSetMode(serialPort_t *instance, portMode_t mode) {
|
||||
UNUSED(instance);
|
||||
UNUSED(mode);
|
||||
}
|
||||
|
||||
void serialSetBaudRate(serialPort_t *instance, uint32_t baudRate) {
|
||||
UNUSED(instance);
|
||||
UNUSED(baudRate);
|
||||
}
|
||||
|
||||
void beginSerialPortFunction(serialPort_t *port, serialPortFunction_e function) {
|
||||
UNUSED(port);
|
||||
UNUSED(function);
|
||||
}
|
||||
|
||||
void endSerialPortFunction(serialPort_t *port, serialPortFunction_e function) {
|
||||
UNUSED(port);
|
||||
UNUSED(function);
|
||||
}
|
||||
|
||||
serialPort_t *openSerialPort(serialPortFunction_e functionMask, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, serialInversion_e inversion) {
|
||||
UNUSED(functionMask);
|
||||
UNUSED(baudRate);
|
||||
UNUSED(callback);
|
||||
UNUSED(mode);
|
||||
UNUSED(inversion);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
serialPort_t *findOpenSerialPort(uint16_t functionMask) {
|
||||
UNUSED(functionMask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool sensors(uint32_t mask) {
|
||||
UNUSED(mask);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue