Saved working stuff

This commit is contained in:
Richard Koeppe 2024-05-16 00:40:22 +02:00
parent 2d22ccd2d6
commit a02331451d
54 changed files with 3452 additions and 13 deletions

File diff suppressed because one or more lines are too long

33
INS-VN-200/.metadata/.log Normal file
View File

@ -0,0 +1,33 @@
!SESSION 2024-05-14 17:34:55.537 -----------------------------------------------
eclipse.buildId=Version 1.15.1
java.version=17.0.8.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments: -os linux -ws gtk -arch x86_64
!ENTRY com.st.stm32cube.ide.mcu.informationcenter 4 4 2024-05-14 17:35:17.896
!MESSAGE CubeMX plugin appears to be active, Log4j initialization might be too late.
!ENTRY com.st.stm32cube.ide.mcu.informationcenter 1 1 2024-05-14 17:35:17.897
!MESSAGE Log4j2 initialized with config file /home/richard/Uni/FaSTTUBe/INS-VN-200/INS-VN-200/.metadata/.log4j2.xml
!ENTRY com.st.stm32cube.ide.mcu.ide 1 1 2024-05-14 17:35:21.128
!MESSAGE Started RMI Server, listening on port 41337
!SESSION 2024-05-14 21:44:50.912 -----------------------------------------------
eclipse.buildId=Version 1.15.1
java.version=17.0.8.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments: -os linux -ws gtk -arch x86_64
!ENTRY com.st.stm32cube.ide.mcu.informationcenter 4 4 2024-05-14 21:45:12.764
!MESSAGE CubeMX plugin appears to be active, Log4j initialization might be too late.
!ENTRY com.st.stm32cube.ide.mcu.informationcenter 1 1 2024-05-14 21:45:12.765
!MESSAGE Log4j2 initialized with config file /home/richard/Uni/FaSTTUBe/INS-VN-200/INS-VN-200/.metadata/.log4j2.xml
!ENTRY com.st.stm32cube.ide.mcu.ide 1 1 2024-05-14 21:45:17.715
!MESSAGE Started RMI Server, listening on port 41337
!ENTRY org.eclipse.cdt.core 1 0 2024-05-14 21:47:28.105
!MESSAGE Indexed 'IMU' (24 sources, 85 headers) in 3.52 sec: 5,590 declarations; 32,972 references; 0 unresolved inclusions; 1 syntax errors; 2 unresolved names (0.0052%)

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info">
<ThresholdFilter level="INFO"/>
<Appenders>
<RollingFile name="DEBUGFILE" fileName="/home/richard/Uni/FaSTTUBe/INS-VN-200/INS-VN-200/.metadata/.ide.log" filePattern="/home/richard/Uni/FaSTTUBe/INS-VN-200/INS-VN-200/.metadata/.ide.log-%d{yyyy-MM-dd}.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%p] %c{1}:%L - %m%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="50MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="DEBUGFILE" />
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,2 @@
*** SESSION May 14, 2024 17:35:16.569 ------------------------------------------
*** SESSION May 14, 2024 21:45:11.451 ------------------------------------------

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.cdt.internal.ui.MakeView">
</section>
</section>

View File

@ -0,0 +1,2 @@
DC22A860405A8BF2F2C095E5B6529F12=0FE3A692F5297FEB83FC6C4A28927594
eclipse.preferences.version=1

View File

@ -0,0 +1,3 @@
DeviceConfigurationTool.AskToSwitchToCubeMxPerspective=false
DeviceConfigurationTool.SwitchToCubeMxPerspective=true
eclipse.preferences.version=1

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
project_presentation/setHierarchicalMode=false

View File

@ -0,0 +1,16 @@
eclipse.preferences.version=1
indexer/indexAllFiles=true
indexer/indexAllHeaderVersions=false
indexer/indexImportLocation=.settings/cdt-index.zip
indexer/indexOnOpen=false
indexer/indexUnusedHeadersWithAlternateLang=false
indexer/indexUnusedHeadersWithDefaultLang=true
indexer/indexerId=org.eclipse.cdt.core.fastIndexer
indexer/preferenceScope=1
indexer/skipFilesLargerThanMB=8
indexer/skipImplicitReferences=false
indexer/skipIncludedFilesLargerThanMB=16
indexer/skipMacroReferences=false
indexer/skipReferences=false
indexer/skipTypeReferences=false
indexer/useHeuristicIncludeResolution=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.cdt.debug.core.cDebug.default_source_containers=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<sourceLookupDirector>\n <sourceContainers duplicates\="false">\n <container memento\="AbsolutePath" typeId\="org.eclipse.cdt.debug.core.containerType.absolutePath"/>\n <container memento\="programRelativePath" typeId\="org.eclipse.cdt.debug.core.containerType.programRelativePath"/>\n <container memento\="&lt;?xml version\=&quot;1.0&quot; encoding\=&quot;UTF-8&quot; standalone\=&quot;no&quot;?&gt;&\#10;&lt;project referencedProjects\=&quot;true&quot;/&gt;&\#10;" typeId\="org.eclipse.cdt.debug.core.containerType.project"/>\n </sourceContainers>\n</sourceLookupDirector>\n

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
properties/IMU.null.1964711832/com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1460140893=com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1589171082\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1048577547\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1551551058\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.737716598\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.33774739\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.246252337\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.283410503\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1745432042\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1074164272\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1460140893\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.364964272\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.1346820652\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.415890173\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.524669138\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.2008473311\=rebuildState\\\=true\\n\n
properties/IMU.null.1964711832/com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.490558341=com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.57215345\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.1009691226\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.69412876\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1782852981\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1286545839\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1219404507\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1297701503\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1433280110\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.172178142\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.777284667\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1599578858\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.867413867\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.222865914\=rebuildState\\\=true\\n\ncom.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.841352617\=rebuildState\\\=true\\n\n

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
spelling_locale_initialized=true
useAnnotationsPrefPage=true
useQuickDiffPrefPage=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
version=1

View File

@ -0,0 +1,5 @@
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug,;org.eclipse.cdt.cdi.launch.localCLaunch,run,;
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug,;
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug,;
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.remoteApplicationLaunchType=org.eclipse.rse.remotecdt.dsf.debug,debug,;
eclipse.preferences.version=1

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<launchPerspectives/>\n

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
platformState=1715035914223
quickStart=false
tipsAndTricks=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ui.navigator.ProjectExplorer.filterActivation=\:org.eclipse.ui.navigator.resources.filters.startsWithDot\:org.eclipse.cdt.ui.navigator.filters.AnonymousStructFilter\:org.eclipse.cdt.ui.navigator.filters.AbsentTranslationUnitFilter\:org.eclipse.ui.navigator.resources.nested.HideTopLevelProjectIfNested\:org.eclipse.ui.navigator.resources.nested.HideFolderWhenProjectIsShownAsNested\:org.eclipse.cdt.ui.navigator.filters.ForwardDeclarationFilter\:

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
showIntro=false

View File

@ -0,0 +1,12 @@
//org.eclipse.ui.commands/state/com.st.stm32cube.ide.mcu.buildanalyzer.showstate/org.eclipse.ui.commands.radioState=human
//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false
eclipse.preferences.version=1
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=41,41,41
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=43,44,45
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=204,204,204
org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=41,41,41
org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=43,44,45
org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=221,221,221
org.eclipse.ui.workbench.INACTIVE_TAB_BG_END=49,53,56
org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=59,64,66
org.eclipse.ui.workbench.INACTIVE_TAB_TEXT_COLOR=187,187,187

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
processedSchemes=,eclipse+command,eclipse+mpc

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ExternalProjectImportWizard">
<item key="WizardProjectsImportPage.STORE_NESTED_PROJECTS" value="true"/>
</section>
<section name="SmartImportWizard">
<item key="SmartImportRootWizardPage.STORE_HIDE_ALREADY_OPEN" value="false"/>
<item key="SmartImportRootWizardPage.STORE_CLOSE_IMPORTED" value="false"/>
<item key="SmartImportRootWizardPage.STORE_NESTED_PROJECTS" value="true"/>
<item key="SmartImportRootWizardPage.STORE_CONFIGURE_NATURES" value="true"/>
<list key="org.eclipse.ui.internal.wizards.datatransfer.SmartImportRootWizardPage.knownSources">
<item value="/home/richard/Uni/FaSTTUBe/INS-VN-200/INS-VN-200"/>
</list>
</section>
</section>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ImportExportAction">
</section>
</section>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1715700917883_0" label="Window Working Set" name="Aggregate for window 1715700917883"/>
</workingSetManager>

View File

@ -0,0 +1,3 @@
#Tue May 14 21:45:09 CEST 2024
org.eclipse.core.runtime=2
org.eclipse.platform=4.30.0.v20231201-0110

View File

@ -15,6 +15,8 @@ set(CPU_PARAMETERS
set(STARTUP_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/Core/Startup/startup_stm32f302cbtx.s)
set(MCU_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/STM32F302CBTX_FLASH.ld)
find_package(vn-interface)
# ##############################################################################
set(EXECUTABLE ${CMAKE_PROJECT_NAME})
enable_language(C CXX ASM)
@ -39,6 +41,7 @@ set(PROJECT_INCLUDE_DIRECTORIES
# Sources
file(GLOB_RECURSE STM32CUBEMX_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/Core/*.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/*.c)
file(GLOB_RECURSE PROJECT_SOURCES FOLLOW_SYMLINKS
${PROJECT_DIR}/*.cpp
@ -60,6 +63,8 @@ target_include_directories(${EXECUTABLE} PRIVATE
${CUBEMX_INCLUDE_DIRECTORIES}
${PROJECT_INCLUDE_DIRECTORIES})
target_link_libraries(${EXECUTABLE} PRIVATE vn-interface::vn-interface)
# Compiler and linker options
target_compile_options(${EXECUTABLE} PRIVATE
${CPU_PARAMETERS}
@ -69,9 +74,8 @@ target_compile_options(${EXECUTABLE} PRIVATE
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-volatile
-Wold-style-cast
-Wuseless-cast
-Wsuggest-override>
-Wsuggest-override
-Wno-missing-field-initializers>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0>)

View File

@ -0,0 +1,22 @@
#include "Converter.h"
HAL_StatusTypeDef ftcan_init(CAN_HandleTypeDef *handle) {
HAL_StatusTypeDef status = HAL_CAN_ActivateNotification(handle, CAN_IT_RX_FIFO0_MSG_PENDING);
if (status != HAL_OK) {
return status;
}
return HAL_CAN_Start(handle);
}
HAL_StatusTypeDef ftcan_transmit(CAN_HandleTypeDef *handle, uint16_t id, const uint8_t *data, size_t datalen) {
static CAN_TxHeaderTypeDef header;
header.StdId = id;
header.IDE = CAN_ID_STD;
header.RTR = CAN_RTR_DATA;
header.DLC = datalen;
uint32_t mailbox;
return HAL_CAN_AddTxMessage(handle, &header, data, &mailbox);
}
uint16_t derived_t::size() { return 0; };

View File

@ -0,0 +1,21 @@
#include <stm32f302xc.h>
#include <stm32f3xx_hal.h>
#include <stm32f3xx_hal_conf.h>
struct base_t {
int i = 0;
base_t(){};
virtual uint16_t size() = 0;
};
struct derived_t : public base_t {
uint16_t size() override;
};
HAL_StatusTypeDef ftcan_init(CAN_HandleTypeDef *hcan);
HAL_StatusTypeDef ftcan_transmit(CAN_HandleTypeDef *hcan, uint16_t id, const uint8_t *data, size_t datalen);
HAL_StatusTypeDef spi_init(SPI_HandleTypeDef *hspi);
HAL_StatusTypeDef spi_receive(SPI_HandleTypeDef *hspi, uint8_t group);

View File

@ -27,11 +27,13 @@ extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include "stm32f3xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdint.h>
#include <stm32f302xc.h>
#include <stm32f3xx_hal.h>
#include <stm32f3xx_hal_conf.h>
/* USER CODE END Includes */

View File

@ -19,10 +19,11 @@
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "Converter/Converter.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "Converter/Converter.h"
// #include "Converter/vn200.h"
#include <vn-interface/vn200.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@ -60,7 +61,7 @@ static void MX_SPI1_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
// using namespace VN200;
/* USER CODE END 0 */
/**
@ -69,7 +70,7 @@ static void MX_SPI1_Init(void);
*/
int main(void) {
/* USER CODE BEGIN 1 */
// const unsigned char payload_group_1[16] = payload_lengths[0];
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
@ -95,13 +96,41 @@ int main(void) {
MX_SPI1_Init();
/* USER CODE BEGIN 2 */
ftcan_init(&hcan);
uint16_t can_id = 0x12; /*TODO*/
uint8_t data[8] = {0}; /*TODO*/
// uint8_t size_accel = VN200::SPI::BinaryGroups::Group1::payload_sizes[VN200::SPI::BinaryGroups::Group1::Accel];
// Attempt for custom binary group
// VN200::SPI::configuration_t config;
// config.AsyncMode = 0;
// config.RateDivisor = 4;
// config.setBinaryGroups({VN200::SPI::BinaryGroups::Group1::BitOffset});
// config.setOutputFields(VN200::SPI::BinaryGroups::Group1::BitOffset,
// {VN200::SPI::BinaryGroups::Group1::OutputFields::Accel, VN200::SPI::BinaryGroups::Group1::OutputFields::Imu});
// VN200::SPI::pkg_request_write_t<VN200::SPI::configuration_t> pkg_request_write_config;
// pkg_request_write_config.header.pkg.ID = 75; /* REGISTER ID FOR FIRST OUTPUT REGISTER */
// pkg_request_write_config.payload = config;
// HAL_SPI_Transmit(&hspi1, pkg_request_write_config.to_array(), pkg_request_write_config.size(), 100);
VN200::SPI::pkg_request_read_t package_request_read_imu(VN200::SPI::IMU::ID);
VN200::SPI::pkg_response_t<VN200::SPI::IMU::imu_t> package_response_read_imu;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* Request the data from the slave device */
HAL_SPI_Transmit(&hspi1, reinterpret_cast<uint8_t *>(&package_request_read_imu), sizeof(package_request_read_imu), 100);
/* Receive the response from the slave device */
HAL_SPI_Receive(&hspi1, reinterpret_cast<uint8_t *>(&package_response_read_imu), sizeof(package_response_read_imu), 100);
/* TODO: Parse it into CAN frame */
/* Send the can frame */
ftcan_transmit(&hcan, can_id, data, sizeof(data));
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
@ -128,8 +157,7 @@ void SystemClock_Config(void) {
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

View File

@ -1,7 +1,7 @@
.PHONY: all build cmake clean format
BUILD_DIR := build
BUILD_TYPE ?= Debug
BUILD_TYPE ?= Release
all: build

10
build.bash Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
origin=$(pwd)
cd $origin/vn-interface
mkdir build
cd $origin/vn-interface/build
cmake .. && sudo make install
cd $origin/INS-VN-200
make
cd $origin

View File

@ -0,0 +1,66 @@
project(vn-interface)
include_directories(${CMAKE_SOURCE_DIR}/include)
set(CMAKE_TOOLCHAIN_FILE gcc-arm-none-eabi.cmake)
# include for standard directories
include(GNUInstallDirs)
# include for creating config.cmake
include(CMakePackageConfigHelpers)
set(SOURCES src/vn200.cpp)
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=hard)
add_library(${PROJECT_NAME} STATIC ${SOURCES})
target_compile_options(${PROJECT_NAME} PRIVATE
${CPU_PARAMETERS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-volatile
-Wsuggest-override
-Wno-missing-field-initializers>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0>)
# Link the desire include directories of the library - different for build and install
target_include_directories(${PROJECT_NAME}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE vn-interface::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

View File

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/vn-interfaceTargets.cmake")

View File

@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
# Some default GCC settings
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(FLAGS
"-fdata-sections -ffunction-sections \
--specs=nano.specs -Wl,--gc-sections")
set(CPP_FLAGS
"-fno-rtti -fno-exceptions \
-fno-threadsafe-statics")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${FLAGS})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${FLAGS} ${CPP_FLAGS})
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
set(CMAKE_LINK_LIBRARY_SUFFIX ".elf")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

View File

@ -0,0 +1,206 @@
#ifndef _VN200_
#define _VN200_
#include <map>
#include <stdint.h>
#include <vector>
#define VN200_SPI_READ 0x01
#define VN200_SPI_WRITE 0x02
namespace VN200 {
namespace SPI {
namespace BinaryGroups {
typedef uint8_t bit_offset_t;
namespace Group1 {
// /* The bit offset of group 1 */
// const bit_offset_t BitOffset = 0;
// /* The output fields of group 1 */
// enum OutputFields {
// TimeStartup = 0,
// TimeGps,
// TimeSyncIn,
// YawPitchRoll,
// Quaternion,
// AngularRate,
// Position,
// Velocity,
// Accel,
// Imu,
// MagPres,
// DeltaTheta,
// InsStatus,
// SyncInCnt,
// TimeGpsPps,
// EMPTY15
// };
// /* TODO */
// const uint8_t payload_sizes[16] = {8, 8, 8, 12, 16, 12, 24, 12, 12, 24, 20, 28, 2, 4, 8, 0};
} // namespace Group1
} // namespace BinaryGroups
// /* Abstract base class for all packages. */
// struct binary_package_t {
// /* TODO */
// binary_package_t(){};
// /* TODO */
// virtual uint16_t size() = 0;
// /* TODO */
// virtual uint8_t *to_array() = 0;
// std::vector<uint8_t> v;
// };
/* TODO */
union header_t {
struct request_t {
uint8_t Cmd = 0; /* Defined in VN200_SPI_READ - set in standard constructor */
uint8_t ID = 0; /* Register ID */
uint16_t Empty = 0; /* Spacer */
request_t(uint8_t ID, uint8_t Cmd) {
this->ID = ID;
this->Cmd = Cmd;
};
};
struct response_t {
uint8_t Empty1 = 0; /* Spacer */
uint8_t Cmd = 0; /* Defined in VN200_SPI_READ - set in standard constructor */
uint8_t ID = 0; /* Register ID */
uint8_t Empty2 = 0; /* Spacer */
response_t(){};
response_t(uint8_t ID, uint8_t Cmd) {
this->ID = ID;
this->Cmd = Cmd;
};
};
};
/* TODO */
// struct configuration_t : binary_package_t {
// uint16_t AsyncMode;
// uint16_t RateDivisor;
// uint16_t OutputGroup;
// uint8_t NumOutputFields;
// uint16_t *OutputFields; /* Array with unknown size. Set in constructor. */
// /* TODO */
// configuration_t(uint8_t NumOutputFields = 1 /* TODO */) {
// OutputFields = new uint16_t[NumOutputFields];
// this->NumOutputFields = NumOutputFields;
// };
// /* TODO */
// ~configuration_t() {
// delete OutputFields;
// OutputFields = nullptr;
// }
// /* TODO */
// uint16_t size() override;
// /* TODO */
// uint8_t *to_array() override;
// /* TODO */
// void setBinaryGroups(std::vector<SPI::BinaryGroups::bit_offset_t> desired_groups);
// /* TODO */
// void setOutputFields(SPI::BinaryGroups::bit_offset_t group_bit_offset, std::vector<int> desired_output_fields);
// };
/* Writes the desired payload into the specified register */
template <typename payload_t> struct pkg_request_write_t {
struct header_t::request_t header;
payload_t payload;
/* TODO */
pkg_request_write_t(uint8_t ID) : header(ID, VN200_SPI_WRITE){};
};
/* Writes the desired payload into the specified register */
struct pkg_request_read_t {
struct header_t::request_t header;
/* TODO */
pkg_request_read_t(uint8_t ID) : header(ID, VN200_SPI_READ){};
};
/* Writes the desired payload into the specified register */
template <typename payload_t> struct pkg_response_t {
struct header_t::response_t header;
payload_t payload;
/* TODO */
pkg_response_t() : header(){};
};
namespace IMU {
const uint8_t ID = 54;
struct imu_t {
float MagX = 0.0;
float MagY = 0.0;
float MagZ = 0.0;
float AccelX = 0.0;
float AccelY = 0.0;
float AccelZ = 0.0;
float GyroX = 0.0;
float GyroY = 0.0;
float GyroZ = 0.0;
float Pressure = 0.0;
};
} // namespace IMU
namespace ATT {
const uint8_t ID = 239;
struct attitude_t {
float Yaw = 0.0;
float Pitch = 0.0;
float Roll = 0.0;
float BodyAccelX = 0.0;
float BodyAccelY = 0.0;
float BodyAccelZ = 0.0;
float GyroX = 0.0;
float GyroY = 0.0;
float GyroZ = 0.0;
};
} // namespace ATT
namespace INS {
namespace LLA {
const uint8_t ID = 63;
struct lla_t {
float Yaw = 0.0;
float Pitch = 0.0;
float Roll = 0.0;
double Lattitude = 0.0;
double Longitude = 0.0;
double Altitude = 0.0;
float VelocityX = 0.0;
float VelocityY = 0.0;
float VelocityZ = 0.0;
float AccelX = 0.0;
float AccelY = 0.0;
float AccelZ = 0.0;
float AngularRateX = 0.0;
float AngularRateY = 0.0;
float AngularRateZ = 0.0;
};
} // namespace LLA
} // namespace INS
namespace GPS {
namespace LLA {
const uint8_t ID = 58;
struct lla_t {
double Time = 0.0;
uint16_t Week = 0;
uint8_t GpsFix = 0;
uint8_t NumSats = 0;
uint32_t PADDING = 0;
double Latitude = 0.0;
double Longitude = 0.0;
double Altitude = 0.0;
float NedVelX = 0.0;
float NedVelY = 0.0;
float NedVelZ = 0.0;
float NorthAcc = 0.0;
float EastAcc = 0.0;
float VertAcc = 0.0;
float SpeedAcc = 0.0;
float TimeAcc = 0.0;
};
} // namespace LLA
} // namespace GPS
} // namespace SPI
} // namespace VN200
#endif

View File

@ -0,0 +1,70 @@
#include "vn-interface/vn200.h"
namespace VN200 {
namespace SPI {
// payload_size_t::payload_size_t() {
// group1 = {{BinaryGroups::Group1::TimeStartup, 8}, {BinaryGroups::Group1::TimeGps, 8}, {BinaryGroups::Group1::TimeSyncIn, 8},
// {BinaryGroups::Group1::YawPitchRoll, 12}, {BinaryGroups::Group1::Quaternion, 16}, {BinaryGroups::Group1::AngularRate, 12},
// {BinaryGroups::Group1::Position, 24}, {BinaryGroups::Group1::Velocity, 12}, {BinaryGroups::Group1::Accel, 12},
// {BinaryGroups::Group1::Imu, 24}, {BinaryGroups::Group1::MagPres, 20}, {BinaryGroups::Group1::DeltaTheta, 28},
// {BinaryGroups::Group1::InsStatus, 2}, {BinaryGroups::Group1::SyncInCnt, 4}, {BinaryGroups::Group1::TimeGpsPps, 8},
// {BinaryGroups::Group1::EMPTY15, 0}};
// }
// uint16_t configuration_t::size() { return sizeof(AsyncMode) + sizeof(RateDivisor) + sizeof(OutputGroup) + NumOutputFields * sizeof(uint16_t); }
// uint8_t *configuration_t::to_array() {
// v.clear();
// v.push_back(AsyncMode && 0xFF);
// v.push_back(AsyncMode >> 8);
// v.push_back(RateDivisor && 0xFF);
// v.push_back(RateDivisor >> 8);
// v.push_back(OutputGroup && 0xFF);
// v.push_back(OutputGroup >> 8);
// for (uint8_t i = 0; i < NumOutputFields; i++) {
// v.push_back(OutputFields[i] && 0xFF);
// v.push_back(OutputFields[i] >> 8);
// }
// return &v[0];
// }
// void configuration_t::setBinaryGroups(std::vector<SPI::BinaryGroups::bit_offset_t> desired_groups) {
// bool hit = false;
// /* Iterate over every bit of the OutputGroup */
// for (uint8_t i = 0; i < 8; i++) {
// for (auto desired_group : desired_groups) {
// if (desired_group == i) {
// hit = true;
// break;
// }
// }
// if (hit) {
// OutputGroup++;
// hit = false;
// }
// OutputGroup = OutputGroup << 1;
// }
// }
// void configuration_t::setOutputFields(SPI::BinaryGroups::bit_offset_t group_bit_offset, std::vector<int> desired_output_fields) {
// bool hit = false;
// /* Iterate over every bit of the OutputGroup */
// for (uint8_t i = 0; i < 16; i++) {
// for (auto desired_output_field : desired_output_fields) {
// if (desired_output_field == i) {
// hit = true;
// break;
// }
// }
// if (hit) {
// OutputFields[group_bit_offset]++;
// hit = false;
// }
// OutputFields[group_bit_offset] = OutputFields[group_bit_offset] << 1;
// }
// }
} // namespace SPI
// namespace SPI
} // namespace VN200