forked from ashtuchkin/vive-diy-position-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new platform: Particle Photon board.
- Loading branch information
1 parent
57c29cb
commit 1671118
Showing
69 changed files
with
1,366 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ | |
|
||
# CMake build | ||
build/* | ||
|
||
# External lib files | ||
libs/particle-firmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
set(CMAKE_DISABLE_SOURCE_CHANGES ON) | ||
#set(CMAKE_VERBOSE_MAKEFILE TRUE) | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
set(SOURCE_FILES | ||
src/cycle_phase_classifier.cpp | ||
src/data_frame_decoder.cpp | ||
src/formatters.cpp | ||
src/geometry.cpp | ||
src/input.cpp | ||
src/mavlink.cpp | ||
src/pulse_processor.cpp | ||
src/primitives/string_utils.cpp | ||
) | ||
|
||
set(PLATFORM_SPECIFIC_SOURCE_FILES | ||
src/main.cpp | ||
src/settings.cpp | ||
src/debug_node.cpp | ||
src/input_cmp.cpp | ||
src/led_state.cpp | ||
src/outputs.cpp | ||
src/platform.cpp | ||
src/vive_sensors_pipeline.cpp | ||
src/primitives/timestamp.cpp | ||
) | ||
|
||
set(TEST_SOURCE_FILES | ||
test/main_test.cpp | ||
test/platform_mocks.cpp | ||
test/test_pulse_processor.cpp | ||
) | ||
|
||
if (NOT TEST_MODE) | ||
set(CMAKE_TOOLCHAIN_FILE "teensy-arm.toolchain.cmake") | ||
|
||
if (${PLATFORM} MATCHES "Teensy") | ||
set(CMAKE_TOOLCHAIN_FILE "platform-teensy/teensy-arm.toolchain.cmake") | ||
project(vive-diy-position-sensor) | ||
add_subdirectory(platform-teensy) | ||
add_subdirectory(src) | ||
|
||
add_executable(vive-diy-position-sensor "${SOURCE_FILES}" "${PLATFORM_SPECIFIC_SOURCE_FILES}") | ||
add_firmware_targets(vive-diy-position-sensor) | ||
|
||
import_cmsis_dsp_library(vive-diy-position-sensor) | ||
import_arduino_library(vive-diy-position-sensor mavlink_v2) | ||
elseif (${PLATFORM} MATCHES "Particle") | ||
set(CMAKE_TOOLCHAIN_FILE "platform-particle/stm32f2xx.toolchain.cmake") | ||
project(vive-diy-position-sensor) | ||
add_subdirectory(platform-particle) | ||
add_subdirectory(src) | ||
|
||
else() | ||
elseif (${PLATFORM} MATCHES "Host_Test") | ||
# Need to define project at the top level to be able to call ctest from build directory | ||
set(CMAKE_TOOLCHAIN_FILE "test/32bit.toolchain.cmake") | ||
project(vive-diy-position-sensor) | ||
include(CTest) | ||
add_subdirectory(test) | ||
add_subdirectory(src) | ||
|
||
# Compile 32 bit code | ||
add_compile_options("-m32") | ||
link_libraries("-m32") | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options("-Wno-deprecated-register" "-Wno-unknown-attributes") | ||
endif() | ||
|
||
# Compile CMSIS as a library. | ||
set(CMSIS_ROOT "${CMAKE_SOURCE_DIR}/libs/CMSIS/CMSIS" CACHE PATH "Path to the CMSIS root directory") | ||
file(GLOB_RECURSE CMSIS_CORE_FILES "${CMSIS_ROOT}/DSP_Lib/Source/*_f32.c") | ||
add_library(CMSIS "${CMSIS_CORE_FILES}" "${CMSIS_ROOT}/DSP_Lib/Source/CommonTables/arm_common_tables.c") | ||
target_compile_definitions(CMSIS PUBLIC "-DARM_MATH_CM4") | ||
link_libraries(CMSIS) | ||
else() | ||
message(FATAL_ERROR "Please provide PLATFORM env variable") | ||
|
||
# We have only one test executable | ||
add_definitions("-DNEW_H") # Don't include new.h header as it defines non-standard operator new(). | ||
include_directories("libs/Catch" "libs/CMSIS/CMSIS/Include" "libs/cores/teensy3" "libs/mavlink_v2" "src") | ||
add_executable(main-test "${TEST_SOURCE_FILES}" "${SOURCE_FILES}") | ||
add_test(main-test main-test) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
// Class to help with (almost) compile-time class registration. | ||
// To use, add static instance of this class to the class that needs registering and provide creation | ||
// function. Then, you'll be able to iterate over all creation functions. | ||
template<typename T> | ||
struct StaticRegistrar { | ||
StaticRegistrar(const T &val) | ||
: val_(val) { | ||
next_ = instance; | ||
instance = this; | ||
} | ||
struct iterator { | ||
const T &operator*() const { return cur->val_; } | ||
iterator &operator++() { cur = cur->next_; return *this; } | ||
bool operator!=(const iterator &it) const { return cur != it.cur; } | ||
friend StaticRegistrar; | ||
protected: | ||
iterator(const StaticRegistrar *val): cur(val) {} | ||
private: | ||
const StaticRegistrar *cur; | ||
}; | ||
struct iteration_range { | ||
iterator begin() { return instance; } | ||
iterator end() { return nullptr; } | ||
}; | ||
static iteration_range iterate() { return {}; } | ||
|
||
private: | ||
const T val_; | ||
StaticRegistrar *next_; | ||
static StaticRegistrar *instance; | ||
}; | ||
|
||
template<typename T> | ||
StaticRegistrar<T> *StaticRegistrar<T>::instance = nullptr; |
File renamed without changes.
Oops, something went wrong.