Compare commits
15 Commits
mueller/fs
...
mueller/cl
Author | SHA1 | Date | |
---|---|---|---|
a7eb165f34 | |||
dd1e26e719 | |||
a2c024b24c | |||
e90960a7b6 | |||
e2b3cdd6c4 | |||
1e7a39a8e1 | |||
28380deab0 | |||
c361751751 | |||
17a153485d | |||
fffe1f812f | |||
2a9300e947 | |||
13f3a312be | |||
9705bf5d40 | |||
5425360876 | |||
b904d33cfe |
7
.run/fsfw-tests_coverage.run.xml
Normal file
7
.run/fsfw-tests_coverage.run.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="fsfw-tests_coverage" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-example-hosted" TARGET_NAME="fsfw-tests_coverage" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-example-hosted" RUN_TARGET_NAME="fsfw-tests">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
7
.run/fsfw.run.xml
Normal file
7
.run/fsfw.run.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="fsfw" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
27
CHANGELOG.md
27
CHANGELOG.md
@ -8,18 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [unreleased]
|
||||
|
||||
## Changes
|
||||
|
||||
- Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED`
|
||||
constants.
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659
|
||||
|
||||
## Added
|
||||
|
||||
- Add new `UnsignedByteField` class
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660
|
||||
|
||||
# [v5.0.0] 25.07.2022
|
||||
# [v5.0.0]
|
||||
|
||||
## Changes
|
||||
|
||||
@ -30,13 +19,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern
|
||||
compiler supports it
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622
|
||||
- HAL Linux SPI: Set the Clock Default State when setting new SPI speed
|
||||
and mode
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573
|
||||
- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents
|
||||
name clashes with Windows defines.
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
|
||||
- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code.
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
|
||||
- HAL Devicehandlers: Periodic printout is run-time configurable now
|
||||
- `oneShotAction` flag in the `TestTask` class is not static anymore
|
||||
- `SimpleRingBuffer::writeData` now checks if the amount is larger than the total size of the
|
||||
Buffer and rejects such writeData calls with `returnvalue::FAILED`
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/586
|
||||
- Major update for version handling, using `git describe` to fetch version information with git.
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/601
|
||||
- Add helper functions provided by [`cmake-modules`](https://github.com/bilke/cmake-modules)
|
||||
@ -54,9 +46,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
creation call. It allows passing context information and an arbitrary user argument into
|
||||
the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583
|
||||
- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal
|
||||
tests part of `fsfw_tests` to `src`. Unittests are now in a dedicated folder called `unittests`
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653
|
||||
|
||||
### Task Module Refactoring
|
||||
|
||||
@ -131,8 +120,6 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
|
||||
|
||||
## Additions
|
||||
|
||||
- New constructor for PoolEntry which allows to simply specify the length of the pool entry.
|
||||
This is also the new default constructor for scalar value with 0 as an initial value
|
||||
- Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know
|
||||
whether it is running in CI/CD
|
||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623
|
||||
|
@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
|
||||
# Version file handling #
|
||||
# ##############################################################################
|
||||
|
||||
set(FSFW_VERSION_IF_GIT_FAILS 5)
|
||||
set(FSFW_VERSION_IF_GIT_FAILS 4)
|
||||
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
|
||||
set(FSFW_REVISION_IF_GIT_FAILS 0)
|
||||
|
||||
@ -67,7 +67,6 @@ endif()
|
||||
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
|
||||
|
||||
set(FSFW_ETL_LIB_NAME etl)
|
||||
set(FSFW_ETL_LINK_TARGET etl::etl)
|
||||
set(FSFW_ETL_LIB_MAJOR_VERSION
|
||||
20
|
||||
CACHE STRING "ETL library major version requirement")
|
||||
@ -104,11 +103,11 @@ if(FSFW_GENERATE_SECTIONS)
|
||||
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
|
||||
endif()
|
||||
|
||||
option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library"
|
||||
OFF)
|
||||
option(FSFW_BUILD_UNITTESTS
|
||||
"Build unittest binary in addition to static library" OFF)
|
||||
option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF)
|
||||
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
|
||||
if(FSFW_BUILD_TESTS)
|
||||
if(FSFW_BUILD_UNITTESTS)
|
||||
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
|
||||
endif()
|
||||
|
||||
@ -118,12 +117,6 @@ option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
|
||||
option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF)
|
||||
option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON)
|
||||
|
||||
if(UNIX)
|
||||
option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers"
|
||||
OFF)
|
||||
option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF)
|
||||
endif()
|
||||
|
||||
# Optional sources
|
||||
option(FSFW_ADD_PUS "Compile with PUS sources" ON)
|
||||
option(FSFW_ADD_MONITORING "Compile with monitoring components" ON)
|
||||
@ -146,7 +139,7 @@ if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
||||
TRUE)
|
||||
endif()
|
||||
|
||||
if(FSFW_BUILD_TESTS)
|
||||
if(FSFW_BUILD_UNITTESTS)
|
||||
message(
|
||||
STATUS
|
||||
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
|
||||
@ -169,9 +162,10 @@ if(FSFW_BUILD_TESTS)
|
||||
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
|
||||
endif()
|
||||
|
||||
set(FSFW_CONFIG_PATH unittests/testcfg)
|
||||
configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
||||
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
|
||||
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
|
||||
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
||||
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in
|
||||
tests/TestsConfig.h)
|
||||
|
||||
project(${FSFW_TEST_TGT} CXX C)
|
||||
add_executable(${FSFW_TEST_TGT})
|
||||
@ -189,10 +183,7 @@ if(FSFW_BUILD_TESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(
|
||||
STATUS
|
||||
"${MSG_PREFIX} Finding and/or providing etl library with version ${FSFW_ETL_LIB_MAJOR_VERSION}"
|
||||
)
|
||||
message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
|
||||
|
||||
# Check whether the user has already installed ETL first
|
||||
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
|
||||
@ -200,7 +191,7 @@ find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
|
||||
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
|
||||
message(
|
||||
STATUS
|
||||
"${MSG_PREFIX} No ETL installation was found with find_package. Installing and providing "
|
||||
"No ETL installation was found with find_package. Installing and providing "
|
||||
"etl with FindPackage")
|
||||
include(FetchContent)
|
||||
|
||||
@ -290,15 +281,16 @@ message(
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(contrib)
|
||||
if(FSFW_BUILD_TESTS)
|
||||
add_subdirectory(unittests)
|
||||
add_subdirectory(tests)
|
||||
if(FSFW_ADD_HAL)
|
||||
add_subdirectory(hal)
|
||||
endif()
|
||||
add_subdirectory(contrib)
|
||||
if(FSFW_BUILD_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif()
|
||||
|
||||
if(FSFW_BUILD_TESTS)
|
||||
if(FSFW_BUILD_UNITTESTS)
|
||||
if(FSFW_TESTS_GEN_COV)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
include(CodeCoverage)
|
||||
@ -360,7 +352,7 @@ if(NOT FSFW_CONFIG_PATH)
|
||||
if(NOT FSFW_BUILD_DOCS)
|
||||
message(
|
||||
WARNING
|
||||
"${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set")
|
||||
"${MSG_PREFIX} Flight Software Framework configuration path not set")
|
||||
message(
|
||||
WARNING
|
||||
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
|
||||
@ -455,8 +447,8 @@ target_include_directories(
|
||||
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
|
||||
${COMPILER_FLAGS})
|
||||
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS})
|
||||
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET})
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET}
|
||||
${FSFW_ADDITIONAL_LINK_LIBS})
|
||||
|
||||
string(
|
||||
CONCAT
|
||||
|
@ -132,14 +132,14 @@ You can use the following commands inside the `fsfw` folder to set up the build
|
||||
|
||||
```sh
|
||||
mkdir build-tests && cd build-tests
|
||||
cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
|
||||
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug ..
|
||||
```
|
||||
|
||||
You can also use `-DFSFW_OSAL=linux` on Linux systems.
|
||||
|
||||
Coverage data in HTML format can be generated using the `CodeCoverage`
|
||||
[CMake module](https://github.com/bilke/cmake-modules/tree/master).
|
||||
To build the unittests, run them and then generate the coverage data in this format,
|
||||
To build the unittests, run them and then generare the coverage data in this format,
|
||||
the following command can be used inside the build directory after the build system was set up
|
||||
|
||||
```sh
|
||||
@ -188,10 +188,7 @@ and open the documentation conveniently. Try `helper.py -h for more information.
|
||||
|
||||
The formatting is done by the `clang-format` tool. The configuration is contained within the
|
||||
`.clang-format` file in the repository root. As long as `clang-format` is installed, you
|
||||
can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with:
|
||||
````sh
|
||||
sudo pip install cmakelang
|
||||
````
|
||||
can run the `apply-clang-format.sh` helper script to format all source files consistently.
|
||||
|
||||
## Index
|
||||
|
||||
|
@ -12,9 +12,3 @@ RUN git clone https://github.com/catchorg/Catch2.git && \
|
||||
git checkout v3.0.0-preview5 && \
|
||||
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
|
||||
cmake --build build/ --target install
|
||||
|
||||
RUN git clone https://github.com/ETLCPP/etl.git && \
|
||||
cd etl && \
|
||||
git checkout 20.28.0 && \
|
||||
cmake -B build . && \
|
||||
cmake --install build/
|
||||
|
4
automation/Jenkinsfile
vendored
4
automation/Jenkinsfile
vendored
@ -3,7 +3,7 @@ pipeline {
|
||||
BUILDDIR = 'build-tests'
|
||||
}
|
||||
agent {
|
||||
docker { image 'fsfw-ci:d3'}
|
||||
docker { image 'fsfw-ci:d2'}
|
||||
}
|
||||
stages {
|
||||
stage('Clean') {
|
||||
@ -14,7 +14,7 @@ pipeline {
|
||||
stage('Configure') {
|
||||
steps {
|
||||
dir(BUILDDIR) {
|
||||
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..'
|
||||
sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON -DFSFW_CICD_BUILD=ON ..'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ FSFW to achieve that. The fsfw uses run-time type information but exceptions are
|
||||
# Failure Handling
|
||||
|
||||
Functions should return a defined `ReturnValue_t` to signal to the caller that something has
|
||||
gone wrong. Returnvalues must be unique. For this the function `returnvalue::makeCode`
|
||||
gone wrong. Returnvalues must be unique. For this the function `HasReturnvaluesIF::makeReturnCode`
|
||||
or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object.
|
||||
See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the
|
||||
`fsfwconfig` folder.
|
||||
|
@ -144,7 +144,7 @@ ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDat
|
||||
new PoolEntry<uint8_t>({0}));
|
||||
|
||||
poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
```
|
||||
|
||||
@ -154,7 +154,7 @@ in any case:
|
||||
|
||||
```cpp
|
||||
PoolReadGuard readHelper(&gyroData);
|
||||
if(readHelper.getReadResult() == returnvalue::OK) {
|
||||
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
if(not gyroData.isValid()) {
|
||||
gyroData.setValidity(true, true);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
Returnvalue API
|
||||
==================
|
||||
|
||||
.. doxygenfile:: returnvalue.h
|
||||
.. doxygenfile:: HasReturnvaluesIF.h
|
||||
|
||||
.. _fwclassids:
|
||||
|
||||
|
@ -75,11 +75,11 @@ and the respective source file with sensible default return values:
|
||||
void TestDeviceHandler::doShutDown() {}
|
||||
|
||||
ReturnValue_t TestDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TestDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void TestDeviceHandler::fillCommandAndReplyMap() {}
|
||||
@ -87,17 +87,17 @@ and the respective source file with sensible default return values:
|
||||
ReturnValue_t TestDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TestDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TestDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t* packet) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t TestDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
||||
@ -106,5 +106,5 @@ and the respective source file with sensible default return values:
|
||||
|
||||
ReturnValue_t TestDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ You can use the following commands inside the ``fsfw`` folder to set up the buil
|
||||
.. code-block:: console
|
||||
|
||||
mkdir build-tests && cd build-tests
|
||||
cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host ..
|
||||
cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host ..
|
||||
|
||||
|
||||
You can also use ``-DFSFW_OSAL=linux`` on Linux systems.
|
||||
|
@ -18,7 +18,7 @@ Failure Handling
|
||||
-----------------
|
||||
|
||||
Functions should return a defined :cpp:type:`ReturnValue_t` to signal to the caller that something has
|
||||
gone wrong. Returnvalues must be unique. For this the function :cpp:func:`returnvalue::makeCode`
|
||||
gone wrong. Returnvalues must be unique. For this the function :cpp:func:`HasReturnvaluesIF::makeReturnCode`
|
||||
or the :ref:`macro MAKE_RETURN_CODE <retvalapi>` can be used. The ``CLASS_ID`` is a unique ID for that type of object.
|
||||
See the :ref:`FSFW Class IDs file <fwclassids>`. The user can add custom ``CLASS_ID``\s via the
|
||||
``fsfwconfig`` folder.
|
||||
|
@ -150,7 +150,7 @@ with a housekeeping service command.
|
||||
new PoolEntry<uint8_t>({0}));
|
||||
|
||||
poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false);
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
Now, if we receive some sensor data and converted them into the right format,
|
||||
@ -160,7 +160,7 @@ in any case:
|
||||
.. code-block:: cpp
|
||||
|
||||
PoolReadGuard readHelper(&gyroData);
|
||||
if(readHelper.getReadResult() == returnvalue::OK) {
|
||||
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
if(not gyroData.isValid()) {
|
||||
gyroData.setValidity(true, true);
|
||||
}
|
||||
|
48
hal/CMakeLists.txt
Normal file
48
hal/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# Can also be changed by upper CMakeLists.txt file
|
||||
find_library(LIB_FSFW_NAME fsfw REQUIRED)
|
||||
|
||||
option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod library" OFF)
|
||||
# On by default for now because I did not have an issue including and compiling those files
|
||||
# and libraries on a Desktop Linux system and the primary target of the FSFW is still embedded
|
||||
# Linux. The only exception from this is the gpiod library which requires a dedicated installation,
|
||||
# but CMake is able to determine whether this library is installed with find_library.
|
||||
option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON)
|
||||
option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Target implements libgpiod" ON)
|
||||
|
||||
option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF)
|
||||
option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF)
|
||||
option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
||||
|
||||
set(LINUX_HAL_PATH_NAME linux)
|
||||
set(STM32H7_PATH_NAME stm32h7)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
foreach(INCLUDE_PATH ${FSFW_HAL_ADDITIONAL_INC_PATHS})
|
||||
if(IS_ABSOLUTE ${INCLUDE_PATH})
|
||||
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
|
||||
else()
|
||||
get_filename_component(CURR_ABS_INC_PATH
|
||||
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERBOSE)
|
||||
message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
|
||||
endif()
|
||||
|
||||
list(APPEND FSFW_HAL_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
|
||||
endforeach()
|
||||
|
||||
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_HAL_ADD_INC_PATHS_ABS}
|
||||
)
|
||||
|
||||
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_HAL_DEFINES}
|
||||
)
|
||||
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||
${FSFW_HAL_LINK_LIBS}
|
||||
)
|
9
hal/src/CMakeLists.txt
Normal file
9
hal/src/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
target_include_directories(${LIB_FSFW_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_FSFW_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_subdirectory(fsfw_hal)
|
@ -2,9 +2,9 @@ add_subdirectory(devicehandlers)
|
||||
add_subdirectory(common)
|
||||
|
||||
if(UNIX)
|
||||
add_subdirectory(linux)
|
||||
add_subdirectory(linux)
|
||||
endif()
|
||||
|
||||
if(FSFW_HAL_ADD_STM32H7)
|
||||
add_subdirectory(stm32h7)
|
||||
add_subdirectory(stm32h7)
|
||||
endif()
|
1
hal/src/fsfw_hal/common/CMakeLists.txt
Normal file
1
hal/src/fsfw_hal/common/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(gpio)
|
3
hal/src/fsfw_hal/common/gpio/CMakeLists.txt
Normal file
3
hal/src/fsfw_hal/common/gpio/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
GpioCookie.cpp
|
||||
)
|
@ -11,7 +11,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||
#else
|
||||
sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n");
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
auto gpioMapIter = gpioMap.find(gpioId);
|
||||
if (gpioMapIter == gpioMap.end()) {
|
||||
@ -25,9 +25,9 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||
sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId);
|
||||
#endif
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -36,7 +36,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||
sif::printWarning("GpioCookie::addGpio: GPIO already exists in GPIO map\n");
|
||||
#endif
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
GpioMap GpioCookie::getGpioMap() const { return gpioMap; }
|
@ -2,7 +2,7 @@
|
||||
#define COMMON_GPIO_GPIOCOOKIE_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include "GpioIF.h"
|
||||
#include "gpioDefinitions.h"
|
@ -2,7 +2,7 @@
|
||||
#define COMMON_GPIO_GPIOIF_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include "gpioDefinitions.h"
|
||||
|
||||
@ -13,7 +13,7 @@ class GpioCookie;
|
||||
* over GPIOs.
|
||||
* @author J. Meier
|
||||
*/
|
||||
class GpioIF {
|
||||
class GpioIF : public HasReturnvaluesIF {
|
||||
public:
|
||||
virtual ~GpioIF(){};
|
||||
|
||||
@ -29,7 +29,7 @@ class GpioIF {
|
||||
* functionality to pull a certain GPIO to high logic level.
|
||||
*
|
||||
* @param gpioId A unique number which specifies the GPIO to drive.
|
||||
* @return Returns returnvalue::OK for success. This should never return returnvalue::FAILED.
|
||||
* @return Returns RETURN_OK for success. This should never return RETURN_FAILED.
|
||||
*/
|
||||
virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0;
|
||||
|
5
hal/src/fsfw_hal/devicehandlers/CMakeLists.txt
Normal file
5
hal/src/fsfw_hal/devicehandlers/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
GyroL3GD20Handler.cpp
|
||||
MgmRM3100Handler.cpp
|
||||
MgmLIS3MDLHandler.cpp
|
||||
)
|
@ -70,9 +70,9 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
"GyroL3GD20Handler::buildTransitionDeviceCommand: "
|
||||
"Unknown internal state!\n");
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroHandlerL3GD20H::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
@ -135,7 +135,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildCommandFromCommand(DeviceCommandId_t devi
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len,
|
||||
@ -144,12 +144,12 @@ ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len,
|
||||
*foundId = this->getPendingCommand();
|
||||
*foundLen = this->rawPacketLen;
|
||||
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch (id) {
|
||||
case (L3GD20H::CONFIGURE_CTRL_REGS): {
|
||||
commandExecuted = true;
|
||||
@ -207,7 +207,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
|
||||
}
|
||||
|
||||
PoolReadGuard readSet(&dataset);
|
||||
if (readSet.getReadResult() == returnvalue::OK) {
|
||||
if (readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
if (std::abs(angVelocX) < this->absLimitX) {
|
||||
dataset.angVelocX = angVelocX;
|
||||
dataset.angVelocX.setValid(true);
|
||||
@ -252,7 +252,7 @@ ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &l
|
||||
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry<float>({0.0}));
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GyroHandlerL3GD20H::fillCommandAndReplyMap() {
|
@ -17,8 +17,6 @@ MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCom
|
||||
registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT;
|
||||
}
|
||||
|
||||
MgmLIS3MDLHandler::~MgmLIS3MDLHandler() {}
|
||||
|
||||
void MgmLIS3MDLHandler::doStartUp() {
|
||||
switch (internalState) {
|
||||
case (InternalState::STATE_NONE): {
|
||||
@ -82,7 +80,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
#else
|
||||
sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
return buildCommandFromCommand(*id, NULL, 0);
|
||||
@ -90,7 +88,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
|
||||
uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::RW_BIT);
|
||||
if (continuousCom == true) {
|
||||
if (continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::MS_BIT);
|
||||
}
|
||||
return command;
|
||||
@ -98,7 +96,7 @@ uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
||||
|
||||
uint8_t MgmLIS3MDLHandler::writeCommand(uint8_t command, bool continuousCom) {
|
||||
command &= ~(1 << MGMLIS3MDL::RW_BIT);
|
||||
if (continuousCom == true) {
|
||||
if (continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::MS_BIT);
|
||||
}
|
||||
return command;
|
||||
@ -137,7 +135,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
||||
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1;
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (MGMLIS3MDL::READ_TEMPERATURE): {
|
||||
std::memset(commandBuffer, 0, 3);
|
||||
@ -145,7 +143,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
||||
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = 3;
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (MGMLIS3MDL::IDENTIFY_DEVICE): {
|
||||
return identifyDevice();
|
||||
@ -155,7 +153,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
||||
}
|
||||
case (MGMLIS3MDL::SETUP_MGM): {
|
||||
setupMgm();
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case (MGMLIS3MDL::ACCURACY_OP_MODE_SET): {
|
||||
return setOperatingMode(commandData, commandDataLen);
|
||||
@ -163,7 +161,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmLIS3MDLHandler::identifyDevice() {
|
||||
@ -174,7 +172,7 @@ ReturnValue_t MgmLIS3MDLHandler::identifyDevice() {
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = size;
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
@ -234,7 +232,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
|
||||
/* Data with SPI Interface always has this answer */
|
||||
if (start[0] == 0b11111111) {
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return DeviceHandlerIF::INVALID_DATA;
|
||||
}
|
||||
@ -285,23 +283,27 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
}
|
||||
|
||||
PoolReadGuard readHelper(&dataset);
|
||||
if (readHelper.getReadResult() == returnvalue::OK) {
|
||||
if (std::abs(mgmX) > absLimitX or std::abs(mgmY) > absLimitY or
|
||||
std::abs(mgmZ) > absLimitZ) {
|
||||
dataset.fieldStrengths.setValid(false);
|
||||
}
|
||||
if (readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
if (std::abs(mgmX) < absLimitX) {
|
||||
dataset.fieldStrengths[0] = mgmX;
|
||||
dataset.fieldStrengthX = mgmX;
|
||||
dataset.fieldStrengthX.setValid(true);
|
||||
} else {
|
||||
dataset.fieldStrengthX.setValid(false);
|
||||
}
|
||||
|
||||
if (std::abs(mgmY) < absLimitY) {
|
||||
dataset.fieldStrengths[1] = mgmY;
|
||||
dataset.fieldStrengthY = mgmY;
|
||||
dataset.fieldStrengthY.setValid(true);
|
||||
} else {
|
||||
dataset.fieldStrengthY.setValid(false);
|
||||
}
|
||||
|
||||
if (std::abs(mgmZ) < absLimitZ) {
|
||||
dataset.fieldStrengths[2] = mgmZ;
|
||||
dataset.fieldStrengthZ = mgmZ;
|
||||
dataset.fieldStrengthZ.setValid(true);
|
||||
} else {
|
||||
dataset.fieldStrengthZ.setValid(false);
|
||||
}
|
||||
dataset.fieldStrengths.setValid(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -320,7 +322,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
}
|
||||
|
||||
ReturnValue_t result = dataset.read();
|
||||
if (result == returnvalue::OK) {
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
dataset.temperature = tempValue;
|
||||
dataset.commit();
|
||||
}
|
||||
@ -331,7 +333,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
MGMLIS3MDL::Sensitivies MgmLIS3MDLHandler::getSensitivity(uint8_t ctrlRegister2) {
|
||||
@ -394,7 +396,7 @@ ReturnValue_t MgmLIS3MDLHandler::enableTemperatureSensor(const uint8_t *commandD
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = size;
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmLIS3MDLHandler::setOperatingMode(const uint8_t *commandData,
|
||||
@ -451,7 +453,7 @@ ReturnValue_t MgmLIS3MDLHandler::prepareCtrlRegisterWrite() {
|
||||
rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1;
|
||||
|
||||
// We dont have to check if this is working because we just did i
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void MgmLIS3MDLHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
@ -464,10 +466,11 @@ void MgmLIS3MDLHandler::modeChanged(void) { internalState = InternalState::STATE
|
||||
|
||||
ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ);
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature);
|
||||
poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false);
|
||||
return returnvalue::OK;
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_X, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, new PoolEntry<float>({0.0}));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLimit) {
|
@ -2,6 +2,7 @@
|
||||
#define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_
|
||||
|
||||
#include "devicedefinitions/MgmLIS3HandlerDefs.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
||||
|
||||
@ -27,7 +28,7 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
|
||||
MgmLIS3MDLHandler(uint32_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
||||
uint32_t transitionDelay);
|
||||
virtual ~MgmLIS3MDLHandler();
|
||||
~MgmLIS3MDLHandler() override = default;
|
||||
|
||||
void enablePeriodicPrintouts(bool enable, uint8_t divider);
|
||||
/**
|
||||
@ -45,7 +46,7 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
void doShutDown() override;
|
||||
void doStartUp() override;
|
||||
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
||||
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
|
||||
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
||||
@ -59,9 +60,9 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
void modeChanged(void) override;
|
||||
void modeChanged() override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) override;
|
||||
|
||||
@ -71,8 +72,6 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
|
||||
|
||||
uint32_t transitionDelay;
|
||||
// Single SPI command has 2 bytes, first for adress, second for content
|
||||
size_t singleComandSize = 2;
|
||||
// Has the size for all adresses of the lis3mdl + the continous write bit
|
||||
uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1];
|
||||
|
||||
@ -87,7 +86,6 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
*/
|
||||
uint8_t registers[MGMLIS3MDL::NR_OF_CTRL_REGISTERS];
|
||||
|
||||
uint8_t statusRegister = 0;
|
||||
bool goToNormalMode = false;
|
||||
|
||||
enum class InternalState {
|
||||
@ -102,8 +100,6 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
CommunicationStep communicationStep = CommunicationStep::DATA;
|
||||
bool commandExecuted = false;
|
||||
|
||||
PoolEntry<float> mgmXYZ = PoolEntry<float>(3);
|
||||
PoolEntry<float> temperature = PoolEntry<float>();
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Device specific commands and variables */
|
||||
/*------------------------------------------------------------------------*/
|
||||
@ -112,14 +108,14 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase {
|
||||
* @param single command to set the read-bit at
|
||||
* @param boolean to select a continuous read bit, default = false
|
||||
*/
|
||||
uint8_t readCommand(uint8_t command, bool continuousCom = false);
|
||||
static uint8_t readCommand(uint8_t command, bool continuousCom = false);
|
||||
|
||||
/**
|
||||
* Sets the write bit for the command
|
||||
* @param single command to set the write-bit at
|
||||
* @param boolean to select a continuous write bit, default = false
|
||||
*/
|
||||
uint8_t writeCommand(uint8_t command, bool continuousCom = false);
|
||||
static uint8_t writeCommand(uint8_t command, bool continuousCom = false);
|
||||
|
||||
/**
|
||||
* This Method gets the full scale for the measurement range
|
@ -4,7 +4,7 @@
|
||||
#include "fsfw/devicehandlers/DeviceHandlerMessage.h"
|
||||
#include "fsfw/globalfunctions/bitutility.h"
|
||||
#include "fsfw/objectmanager/SystemObjectIF.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication,
|
||||
CookieIF *comCookie, uint32_t transitionDelay)
|
||||
@ -93,7 +93,7 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t *
|
||||
"Unknown internal state\n");
|
||||
#endif
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
return buildCommandFromCommand(*id, commandBuffer, commandLen);
|
||||
@ -146,7 +146,7 @@ ReturnValue_t MgmRM3100Handler::buildCommandFromCommand(DeviceCommandId_t device
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmRM3100Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
@ -159,11 +159,11 @@ ReturnValue_t MgmRM3100Handler::scanForReply(const uint8_t *start, size_t len,
|
||||
// For SPI, ID will always be the one of the last sent command
|
||||
*foundId = this->getPendingCommand();
|
||||
*foundLen = len;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch (id) {
|
||||
case (RM3100::CONFIGURE_CMM):
|
||||
case (RM3100::CONFIGURE_CYCLE_COUNT):
|
||||
@ -250,7 +250,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCountConfigCommand(DeviceCommandId_t
|
||||
std::memcpy(commandBuffer + 5, &cycleCountRegValueZ, 2);
|
||||
rawPacketLen = 7;
|
||||
rawPacket = commandBuffer;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uint8_t *commandData,
|
||||
@ -258,7 +258,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin
|
||||
RM3100::CycleCountCommand command(oneCycleValue);
|
||||
ReturnValue_t result =
|
||||
command.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin
|
||||
cycleCountRegValueX = command.cycleCountX;
|
||||
cycleCountRegValueY = command.cycleCountY;
|
||||
cycleCountRegValueZ = command.cycleCountZ;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t deviceCommand,
|
||||
@ -289,7 +289,7 @@ ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t device
|
||||
tmrcRegValue = commandData[0];
|
||||
rawPacketLen = 2;
|
||||
rawPacket = commandBuffer;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void MgmRM3100Handler::fillCommandAndReplyMap() {
|
||||
@ -309,9 +309,10 @@ void MgmRM3100Handler::modeChanged(void) { internalState = InternalState::NONE;
|
||||
|
||||
ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ);
|
||||
poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false);
|
||||
return returnvalue::OK;
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0}));
|
||||
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0}));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) {
|
||||
@ -328,9 +329,9 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
|
||||
int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8;
|
||||
|
||||
// Now scale to physical value in microtesla
|
||||
float fieldStrengthX = fieldStrengthRawX * scaleFactorX;
|
||||
float fieldStrengthY = fieldStrengthRawY * scaleFactorX;
|
||||
float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX;
|
||||
float fieldStrengthX = static_cast<float>(fieldStrengthRawX) * scaleFactorX;
|
||||
float fieldStrengthY = static_cast<float>(fieldStrengthRawY) * scaleFactorY;
|
||||
float fieldStrengthZ = static_cast<float>(fieldStrengthRawZ) * scaleFactorZ;
|
||||
|
||||
if (periodicPrintout) {
|
||||
if (debugDivider.checkAndIncrement()) {
|
||||
@ -352,13 +353,13 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
|
||||
|
||||
// TODO: Sanity check on values?
|
||||
PoolReadGuard readGuard(&primaryDataset);
|
||||
if (readGuard.getReadResult() == returnvalue::OK) {
|
||||
primaryDataset.fieldStrengths[0] = fieldStrengthX;
|
||||
primaryDataset.fieldStrengths[1] = fieldStrengthY;
|
||||
primaryDataset.fieldStrengths[2] = fieldStrengthZ;
|
||||
if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
|
||||
primaryDataset.fieldStrengthX = fieldStrengthX;
|
||||
primaryDataset.fieldStrengthY = fieldStrengthY;
|
||||
primaryDataset.fieldStrengthZ = fieldStrengthZ;
|
||||
primaryDataset.setValidity(true, true);
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void MgmRM3100Handler::enablePeriodicPrintouts(bool enable, uint8_t divider) {
|
@ -72,7 +72,6 @@ class MgmRM3100Handler : public DeviceHandlerBase {
|
||||
RM3100::Rm3100PrimaryDataset primaryDataset;
|
||||
|
||||
uint8_t commandBuffer[10];
|
||||
uint8_t commandBufferLen = 0;
|
||||
|
||||
uint8_t cmmRegValue = RM3100::CMM_VALUE;
|
||||
uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE;
|
||||
@ -85,7 +84,6 @@ class MgmRM3100Handler : public DeviceHandlerBase {
|
||||
|
||||
bool goToNormalModeAtStartup = false;
|
||||
uint32_t transitionDelay;
|
||||
PoolEntry<float> mgmXYZ = PoolEntry<float>(3);
|
||||
|
||||
ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t *commandData, size_t commandDataLen);
|
||||
@ -101,4 +99,4 @@ class MgmRM3100Handler : public DeviceHandlerBase {
|
||||
PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */
|
||||
#endif /* MISSION_DEVICES_MGMRM3100HANDLER_H_ */
|
@ -139,7 +139,12 @@ static const uint8_t CTRL_REG5_DEFAULT = 0;
|
||||
|
||||
static const uint32_t MGM_DATA_SET_ID = READ_CONFIG_AND_DATA;
|
||||
|
||||
enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS, TEMPERATURE_CELCIUS };
|
||||
enum MgmPoolIds : lp_id_t {
|
||||
FIELD_STRENGTH_X,
|
||||
FIELD_STRENGTH_Y,
|
||||
FIELD_STRENGTH_Z,
|
||||
TEMPERATURE_CELCIUS
|
||||
};
|
||||
|
||||
class MgmPrimaryDataset : public StaticLocalDataSet<4> {
|
||||
public:
|
||||
@ -147,10 +152,9 @@ class MgmPrimaryDataset : public StaticLocalDataSet<4> {
|
||||
|
||||
MgmPrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATA_SET_ID)) {}
|
||||
|
||||
/**
|
||||
* Field strenghts in uT
|
||||
*/
|
||||
lp_vec_t<float, 3> fieldStrengths = lp_vec_t<float, 3>(sid.objectId, FIELD_STRENGTHS, this);
|
||||
lp_var_t<float> fieldStrengthX = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_X, this);
|
||||
lp_var_t<float> fieldStrengthY = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_Y, this);
|
||||
lp_var_t<float> fieldStrengthZ = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_Z, this);
|
||||
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId, TEMPERATURE_CELCIUS, this);
|
||||
};
|
||||
|
@ -101,7 +101,11 @@ class CycleCountCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
|
||||
static constexpr uint32_t MGM_DATASET_ID = READ_DATA;
|
||||
|
||||
enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS };
|
||||
enum MgmPoolIds : lp_id_t {
|
||||
FIELD_STRENGTH_X,
|
||||
FIELD_STRENGTH_Y,
|
||||
FIELD_STRENGTH_Z,
|
||||
};
|
||||
|
||||
class Rm3100PrimaryDataset : public StaticLocalDataSet<3> {
|
||||
public:
|
||||
@ -109,10 +113,10 @@ class Rm3100PrimaryDataset : public StaticLocalDataSet<3> {
|
||||
|
||||
Rm3100PrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {}
|
||||
|
||||
/**
|
||||
* Field strenghts in uT
|
||||
*/
|
||||
lp_vec_t<float, 3> fieldStrengths = lp_vec_t<float, 3>(sid.objectId, FIELD_STRENGTHS, this);
|
||||
// Field strengths in micro Tesla.
|
||||
lp_var_t<float> fieldStrengthX = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_X, this);
|
||||
lp_var_t<float> fieldStrengthY = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_Y, this);
|
||||
lp_var_t<float> fieldStrengthZ = lp_var_t<float>(sid.objectId, FIELD_STRENGTH_Z, this);
|
||||
};
|
||||
|
||||
} // namespace RM3100
|
25
hal/src/fsfw_hal/linux/CMakeLists.txt
Normal file
25
hal/src/fsfw_hal/linux/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
if(FSFW_HAL_ADD_RASPBERRY_PI)
|
||||
add_subdirectory(rpi)
|
||||
endif()
|
||||
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
UnixFileGuard.cpp
|
||||
CommandExecutor.cpp
|
||||
utility.cpp
|
||||
)
|
||||
|
||||
if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS)
|
||||
if(FSFW_HAL_LINUX_ADD_LIBGPIOD)
|
||||
add_subdirectory(gpio)
|
||||
endif()
|
||||
add_subdirectory(uart)
|
||||
# Adding those does not really make sense on Apple systems which
|
||||
# are generally host systems. It won't even compile as the headers
|
||||
# are missing
|
||||
if(NOT APPLE)
|
||||
add_subdirectory(i2c)
|
||||
add_subdirectory(spi)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(uio)
|
@ -23,7 +23,7 @@ ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool pri
|
||||
if (state == States::IDLE) {
|
||||
state = States::COMMAND_LOADED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::execute() {
|
||||
@ -35,7 +35,7 @@ ReturnValue_t CommandExecutor::execute() {
|
||||
currentCmdFile = popen(currentCmd.c_str(), "r");
|
||||
if (currentCmdFile == nullptr) {
|
||||
lastError = errno;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (blocking) {
|
||||
ReturnValue_t result = executeBlocking();
|
||||
@ -46,7 +46,7 @@ ReturnValue_t CommandExecutor::execute() {
|
||||
waiter.fd = currentFd;
|
||||
}
|
||||
state = States::PENDING;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::close() {
|
||||
@ -56,7 +56,7 @@ ReturnValue_t CommandExecutor::close() {
|
||||
pclose(currentCmdFile);
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void CommandExecutor::printLastError(std::string funcName) const {
|
||||
@ -79,7 +79,7 @@ void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer,
|
||||
|
||||
ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
if (blocking) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
switch (state) {
|
||||
case (States::IDLE):
|
||||
@ -94,7 +94,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
int result = poll(&waiter, 1, 0);
|
||||
switch (result) {
|
||||
case (0): {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case (1): {
|
||||
@ -151,7 +151,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
ReturnValue_t retval = EXECUTION_FINISHED;
|
||||
if (result != 0) {
|
||||
lastError = result;
|
||||
retval = returnvalue::FAILED;
|
||||
retval = HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
state = States::IDLE;
|
||||
currentCmdFile = nullptr;
|
||||
@ -161,7 +161,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void CommandExecutor::reset() {
|
||||
@ -201,7 +201,7 @@ ReturnValue_t CommandExecutor::executeBlocking() {
|
||||
int result = pclose(currentCmdFile);
|
||||
if (result != 0) {
|
||||
lastError = result;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "fsfw/returnvalues/FwClassIds.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class SimpleRingBuffer;
|
||||
template <typename T>
|
||||
@ -31,18 +31,20 @@ class CommandExecutor {
|
||||
static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Execution of the current command has finished
|
||||
static constexpr ReturnValue_t EXECUTION_FINISHED = returnvalue::makeCode(CLASS_ID, 0);
|
||||
static constexpr ReturnValue_t EXECUTION_FINISHED =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
|
||||
|
||||
//! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries
|
||||
//! to load another command but a command is still pending
|
||||
static constexpr ReturnValue_t COMMAND_PENDING = returnvalue::makeCode(CLASS_ID, 1);
|
||||
static constexpr ReturnValue_t COMMAND_PENDING = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
||||
//! [EXPORT] : [COMMENT] Some bytes have been read from the executing process
|
||||
static constexpr ReturnValue_t BYTES_READ = returnvalue::makeCode(CLASS_ID, 2);
|
||||
static constexpr ReturnValue_t BYTES_READ = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
||||
//! [EXPORT] : [COMMENT] Command execution failed
|
||||
static constexpr ReturnValue_t COMMAND_ERROR = returnvalue::makeCode(CLASS_ID, 3);
|
||||
static constexpr ReturnValue_t COMMAND_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
|
||||
//! [EXPORT] : [COMMENT]
|
||||
static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = returnvalue::makeCode(CLASS_ID, 4);
|
||||
static constexpr ReturnValue_t PCLOSE_CALL_ERROR = returnvalue::makeCode(CLASS_ID, 6);
|
||||
static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
|
||||
static constexpr ReturnValue_t PCLOSE_CALL_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6);
|
||||
|
||||
/**
|
||||
* Constructor. Is initialized with maximum size of internal buffer to read data from the
|
||||
@ -62,11 +64,11 @@ class CommandExecutor {
|
||||
/**
|
||||
* Execute the loaded command.
|
||||
* @return
|
||||
* - In blocking mode, it will return returnvalue::FAILED if
|
||||
* - In blocking mode, it will return RETURN_FAILED if
|
||||
* the result of the system call was not 0. The error value can be accessed using
|
||||
* getLastError
|
||||
* - In non-blocking mode, this call will start
|
||||
* the execution and then return returnvalue::OK
|
||||
* the execution and then return RETURN_OK
|
||||
*/
|
||||
ReturnValue_t execute();
|
||||
/**
|
||||
@ -75,8 +77,8 @@ class CommandExecutor {
|
||||
* @return
|
||||
* - BYTES_READ if bytes have been read from the executing process. It is recommended to call
|
||||
* check again after this
|
||||
* - returnvalue::OK execution is pending, but no bytes have been read from the executing process
|
||||
* - returnvalue::FAILED if execution has failed, error value can be accessed using getLastError
|
||||
* - RETURN_OK execution is pending, but no bytes have been read from the executing process
|
||||
* - RETURN_FAILED if execution has failed, error value can be accessed using getLastError
|
||||
* - EXECUTION_FINISHED if the process was executed successfully
|
||||
* - NO_COMMAND_LOADED_OR_PENDING self-explanatory
|
||||
* - COMMAND_ERROR internal poll error
|
||||
@ -85,7 +87,7 @@ class CommandExecutor {
|
||||
/**
|
||||
* Abort the current command. Should normally not be necessary, check can be used to find
|
||||
* out whether command execution was successful
|
||||
* @return returnvalue::OK
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
ReturnValue_t close();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define LINUX_UTILITY_UNIXFILEGUARD_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
@ -24,7 +24,7 @@ class UnixFileGuard {
|
||||
|
||||
private:
|
||||
int* fileDescriptor = nullptr;
|
||||
ReturnValue_t openStatus = returnvalue::OK;
|
||||
ReturnValue_t openStatus = HasReturnvaluesIF::RETURN_OK;
|
||||
};
|
||||
|
||||
#endif /* LINUX_UTILITY_UNIXFILEGUARD_H_ */
|
16
hal/src/fsfw_hal/linux/gpio/CMakeLists.txt
Normal file
16
hal/src/fsfw_hal/linux/gpio/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# This abstraction layer requires the gpiod library. You can install this library
|
||||
# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need
|
||||
# to install the package before syncing the sysroot to your host computer.
|
||||
find_library(LIB_GPIO gpiod)
|
||||
|
||||
if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND)
|
||||
message(STATUS "gpiod library not found, not linking against it")
|
||||
else()
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
LinuxLibgpioIF.cpp
|
||||
)
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
|
||||
${LIB_GPIO}
|
||||
)
|
||||
endif()
|
||||
|
@ -23,30 +23,30 @@ ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LinuxLibgpioIF::addGpios: Invalid cookie" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
GpioMap mapToAdd = gpioCookie->getGpioMap();
|
||||
|
||||
/* Check whether this ID already exists in the map and remove duplicates */
|
||||
result = checkForConflicts(mapToAdd);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = configureGpios(mapToAdd);
|
||||
if (result != returnvalue::OK) {
|
||||
return returnvalue::FAILED;
|
||||
if (result != RETURN_OK) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
/* Register new GPIOs in gpioMap */
|
||||
gpioMap.insert(mapToAdd.begin(), mapToAdd.end());
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
for (auto& gpioConfig : mapToAdd) {
|
||||
auto& gpioType = gpioConfig.second->gpioType;
|
||||
switch (gpioType) {
|
||||
@ -86,7 +86,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
|
||||
gpioCallback->initValue, gpioCallback->callbackArgs);
|
||||
}
|
||||
}
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
return GPIO_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLabel(gpioId_t gpioId,
|
||||
sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio "
|
||||
<< "group with label " << label << ". Gpio ID: " << gpioId << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
std::string failOutput = "label: " + label;
|
||||
return configureRegularGpio(gpioId, chip, gpioByLabel, failOutput);
|
||||
@ -116,7 +116,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByChip(gpioId_t gpioId, GpiodRegularB
|
||||
sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip " << chipname
|
||||
<< ". Gpio ID: " << gpioId << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
std::string failOutput = "chipname: " + chipname;
|
||||
return configureRegularGpio(gpioId, chip, gpioByChip, failOutput);
|
||||
@ -132,7 +132,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId,
|
||||
gpiod_ctxless_find_line(lineName.c_str(), chipname, MAX_CHIPNAME_LENGTH, &lineOffset);
|
||||
if (result != LINE_FOUND) {
|
||||
parseFindeLineResult(result, lineName);
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
gpioByLineName.lineNum = static_cast<int>(lineOffset);
|
||||
@ -143,7 +143,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId,
|
||||
sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip " << chipname
|
||||
<< ". <Gpio ID: " << gpioId << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
std::string failOutput = "line name: " + lineName;
|
||||
return configureRegularGpio(gpioId, chip, gpioByLineName, failOutput);
|
||||
@ -168,7 +168,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
||||
sif::warning << "Check if Linux GPIO configuration has changed. " << std::endl;
|
||||
#endif
|
||||
gpiod_chip_close(chip);
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
direction = regularGpio.direction;
|
||||
@ -202,7 +202,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
||||
lineNum, gpioId);
|
||||
#endif
|
||||
gpiod_line_release(lineHandle);
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -210,7 +210,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
||||
* read states of GPIOs.
|
||||
*/
|
||||
regularGpio.lineHandle = lineHandle;
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
|
||||
@ -238,7 +238,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
|
||||
}
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::HIGH,
|
||||
gpioCallback->callbackArgs);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
@ -270,7 +270,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
|
||||
}
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::LOW,
|
||||
gpioCallback->callbackArgs);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
@ -291,7 +291,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regul
|
||||
return DRIVE_GPIO_FAILURE;
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
|
||||
@ -321,14 +321,14 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
|
||||
}
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::READ, gpio::Levels::NONE,
|
||||
gpioCallback->callbackArgs);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) {
|
||||
ReturnValue_t status = returnvalue::OK;
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
for (auto& gpioConfig : mapToAdd) {
|
||||
switch (gpioConfig.second->gpioType) {
|
||||
case (gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
||||
@ -340,7 +340,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) {
|
||||
}
|
||||
// Check for conflicts and remove duplicates if necessary
|
||||
result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
break;
|
||||
@ -352,7 +352,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) {
|
||||
}
|
||||
// Check for conflicts and remove duplicates if necessary
|
||||
result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
break;
|
||||
@ -426,7 +426,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
|
||||
mapToAdd.erase(gpioIdToCheck);
|
||||
return GPIO_DUPLICATE_DETECTED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) {
|
@ -19,12 +19,18 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
||||
public:
|
||||
static const uint8_t gpioRetvalId = CLASS_ID::HAL_GPIO;
|
||||
|
||||
static constexpr ReturnValue_t UNKNOWN_GPIO_ID = returnvalue::makeCode(gpioRetvalId, 1);
|
||||
static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = returnvalue::makeCode(gpioRetvalId, 2);
|
||||
static constexpr ReturnValue_t GPIO_TYPE_FAILURE = returnvalue::makeCode(gpioRetvalId, 3);
|
||||
static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = returnvalue::makeCode(gpioRetvalId, 4);
|
||||
static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED = returnvalue::makeCode(gpioRetvalId, 5);
|
||||
static constexpr ReturnValue_t GPIO_INIT_FAILED = returnvalue::makeCode(gpioRetvalId, 6);
|
||||
static constexpr ReturnValue_t UNKNOWN_GPIO_ID =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1);
|
||||
static constexpr ReturnValue_t DRIVE_GPIO_FAILURE =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2);
|
||||
static constexpr ReturnValue_t GPIO_TYPE_FAILURE =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3);
|
||||
static constexpr ReturnValue_t GPIO_INVALID_INSTANCE =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4);
|
||||
static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 5);
|
||||
static constexpr ReturnValue_t GPIO_INIT_FAILED =
|
||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 6);
|
||||
|
||||
LinuxLibgpioIF(object_id_t objectId);
|
||||
virtual ~LinuxLibgpioIF();
|
||||
@ -65,7 +71,7 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
||||
*
|
||||
* @param mapToAdd The GPIOs which shall be added to the gpioMap.
|
||||
*
|
||||
* @return returnvalue::OK if successful, otherwise returnvalue::FAILED
|
||||
* @return RETURN_OK if successful, otherwise RETURN_FAILED
|
||||
*/
|
||||
ReturnValue_t checkForConflicts(GpioMap& mapToAdd);
|
||||
|
8
hal/src/fsfw_hal/linux/i2c/CMakeLists.txt
Normal file
8
hal/src/fsfw_hal/linux/i2c/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
target_sources(${LIB_FSFW_NAME} PUBLIC
|
||||
I2cComIF.cpp
|
||||
I2cCookie.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -52,16 +52,16 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
||||
<< i2cAddress << "to I2C device "
|
||||
<< "map" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress
|
||||
<< "already in use" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||
@ -73,11 +73,11 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
if (sendLen == 0) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
@ -95,16 +95,16 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
|
||||
<< "registered in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
deviceFile = i2cCookie->getDeviceFile();
|
||||
UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::sendMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
}
|
||||
result = openDevice(deviceFile, i2cAddress, &fd);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -114,17 +114,17 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
"device with error code "
|
||||
<< errno << ". Error description: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
#if FSFW_HAL_I2C_WIRETAPPING == 1
|
||||
sif::info << "Sent I2C data to bus " << deviceFile << ":" << std::endl;
|
||||
arrayprinter::print(sendData, sendLen);
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; }
|
||||
ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
ReturnValue_t result;
|
||||
@ -132,7 +132,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
std::string deviceFile;
|
||||
|
||||
if (requestLen == 0) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
@ -152,16 +152,16 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
<< "registered in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
deviceFile = i2cCookie->getDeviceFile();
|
||||
UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
}
|
||||
result = openDevice(deviceFile, i2cAddress, &fd);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
return result;
|
||||
}
|
||||
@ -182,7 +182,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen
|
||||
<< " bytes" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
#if FSFW_HAL_I2C_WIRETAPPING == 1
|
||||
@ -191,7 +191,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
#endif
|
||||
|
||||
i2cDeviceMapIter->second.replyLen = requestLen;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
@ -210,12 +210,12 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "
|
||||
<< "found in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*buffer = i2cDeviceMapIter->second.replyBuffer.data();
|
||||
*size = i2cDeviceMapIter->second.replyLen;
|
||||
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress,
|
||||
@ -231,7 +231,7 @@ ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress,
|
||||
sif::printWarning("Error description: %s\n", strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
@ -49,7 +49,7 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
* @param deviceFile The name of the device file. E.g. i2c-0
|
||||
* @param i2cAddress The address of the i2c slave device.
|
||||
* @param fileDescriptor Pointer to device descriptor.
|
||||
* @return returnvalue::OK if successful, otherwise returnvalue::FAILED.
|
||||
* @return RETURN_OK if successful, otherwise RETURN_FAILED.
|
||||
*/
|
||||
ReturnValue_t openDevice(std::string deviceFile, address_t i2cAddress, int *fileDescriptor);
|
||||
};
|
3
hal/src/fsfw_hal/linux/rpi/CMakeLists.txt
Normal file
3
hal/src/fsfw_hal/linux/rpi/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
GpioRPi.cpp
|
||||
)
|
@ -9,7 +9,7 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int
|
||||
std::string consumer, gpio::Direction direction,
|
||||
gpio::Levels initValue) {
|
||||
if (cookie == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
auto config = new GpiodRegularByChip();
|
||||
@ -30,9 +30,9 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int
|
||||
sif::printError("createRpiGpioConfig: BCM pin %d invalid!\n", bcmPin);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
config->lineNum = bcmPin;
|
||||
cookie->addGpio(gpioId, config);
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#ifndef BSP_RPI_GPIO_GPIORPI_H_
|
||||
#define BSP_RPI_GPIO_GPIORPI_H_
|
||||
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include "../../common/gpio/gpioDefinitions.h"
|
||||
|
8
hal/src/fsfw_hal/linux/spi/CMakeLists.txt
Normal file
8
hal/src/fsfw_hal/linux/spi/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
target_sources(${LIB_FSFW_NAME} PUBLIC
|
||||
SpiComIF.cpp
|
||||
SpiCookie.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
static_cast<unsigned long>(spiAddress));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
/* Now we emplaced the read buffer in the map, we still need to assign that location
|
||||
to the SPI driver transfer struct */
|
||||
@ -69,7 +69,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
/* Pull CS high in any case to be sure that device is inactive */
|
||||
@ -87,7 +87,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
int fileDescriptor = 0;
|
||||
UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::initializeInterface");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
}
|
||||
|
||||
@ -129,12 +129,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
"Could not write bits per word!");
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
if (spiCookie == nullptr) {
|
||||
return NULLPOINTER;
|
||||
@ -178,13 +178,13 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
spiCookie->assignReadBuffer(iter->second.replyBuffer.data());
|
||||
}
|
||||
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
int retval = 0;
|
||||
/* Prepare transfer */
|
||||
int fileDescriptor = 0;
|
||||
std::string device = spiCookie->getSpiDevice();
|
||||
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return OPENING_FILE_FAILED;
|
||||
}
|
||||
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
|
||||
@ -200,7 +200,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
/* Pull SPI CS low. For now, no support for active high given */
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
|
||||
@ -211,7 +211,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
return result;
|
||||
}
|
||||
result = gpioComIF->pullLow(gpioId);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl;
|
||||
@ -251,7 +251,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
gpioComIF->pullHigh(gpioId);
|
||||
result = spiMutex->unlockMutex();
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl;
|
||||
#endif
|
||||
@ -261,7 +261,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; }
|
||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
@ -270,32 +270,32 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
}
|
||||
|
||||
if (spiCookie->isFullDuplex()) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
return performHalfDuplexReception(spiCookie);
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
std::string device = spiCookie->getSpiDevice();
|
||||
int fileDescriptor = 0;
|
||||
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::requestReceiveMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return OPENING_FILE_FAILED;
|
||||
}
|
||||
|
||||
uint8_t* rxBuf = nullptr;
|
||||
size_t readSize = spiCookie->getCurrentTransferSize();
|
||||
result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl;
|
||||
#endif
|
||||
@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
gpioComIF->pullHigh(gpioId);
|
||||
result = spiMutex->unlockMutex();
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl;
|
||||
#endif
|
||||
@ -332,18 +332,18 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
if (spiCookie == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
uint8_t* rxBuf = nullptr;
|
||||
ReturnValue_t result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
*buffer = rxBuf;
|
||||
*size = spiCookie->getCurrentTransferSize();
|
||||
spiCookie->setTransferSize(0);
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
MutexIF* SpiComIF::getMutex(MutexIF::TimeoutType* timeoutType, uint32_t* timeoutMs) {
|
||||
@ -377,16 +377,16 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) {
|
||||
|
||||
ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) {
|
||||
if (buffer == nullptr) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
auto iter = spiDeviceMap.find(spiAddress);
|
||||
if (iter == spiDeviceMap.end()) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
*buffer = iter->second.replyBuffer.data();
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
GpioIF* SpiComIF::getGpioInterface() { return gpioComIF; }
|
@ -23,13 +23,14 @@ class SpiCookie;
|
||||
class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
public:
|
||||
static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI;
|
||||
static constexpr ReturnValue_t OPENING_FILE_FAILED = returnvalue::makeCode(spiRetvalId, 0);
|
||||
static constexpr ReturnValue_t OPENING_FILE_FAILED =
|
||||
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 0);
|
||||
/* Full duplex (ioctl) transfer failure */
|
||||
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED =
|
||||
returnvalue::makeCode(spiRetvalId, 1);
|
||||
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 1);
|
||||
/* Half duplex (read/write) transfer failure */
|
||||
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
|
||||
returnvalue::makeCode(spiRetvalId, 2);
|
||||
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 2);
|
||||
|
||||
SpiComIF(object_id_t objectId, GpioIF* gpioComIF);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "../../common/gpio/gpioDefinitions.h"
|
||||
#include "../../common/spi/spiCommon.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class SpiCookie;
|
||||
class SpiComIF;
|
4
hal/src/fsfw_hal/linux/uart/CMakeLists.txt
Normal file
4
hal/src/fsfw_hal/linux/uart/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
target_sources(${LIB_FSFW_NAME} PUBLIC
|
||||
UartComIF.cpp
|
||||
UartCookie.cpp
|
||||
)
|
@ -37,7 +37,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
int fileDescriptor = configureUartPort(uartCookie);
|
||||
if (fileDescriptor < 0) {
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
size_t maxReplyLen = uartCookie->getMaxReplyLen();
|
||||
UartElements uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
|
||||
@ -47,17 +47,17 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile
|
||||
<< "to UART device map" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile
|
||||
<< " already in use" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
@ -329,14 +329,14 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
|
||||
if (sendLen == 0) {
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
if (sendData == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
@ -354,7 +354,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||
sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
fd = uartDeviceMapIter->second.fileDescriptor;
|
||||
@ -364,13 +364,13 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||
sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno
|
||||
<< ": Error description: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; }
|
||||
ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return RETURN_OK; }
|
||||
|
||||
ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
std::string deviceFile;
|
||||
@ -389,7 +389,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||
|
||||
if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) {
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
@ -397,7 +397,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile
|
||||
<< " not in uart map" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
if (uartMode == UartModes::CANONICAL) {
|
||||
@ -405,13 +405,13 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
} else if (uartMode == UartModes::NON_CANONICAL) {
|
||||
return handleNoncanonicalRead(*uartCookie, uartDeviceMapIter, requestLen);
|
||||
} else {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter,
|
||||
size_t requestLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
uint8_t maxReadCycles = uartCookie.getReadCycles();
|
||||
uint8_t currentReadCycles = 0;
|
||||
int bytesRead = 0;
|
||||
@ -454,7 +454,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
strerror(errno));
|
||||
#endif
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
} else if (bytesRead > 0) {
|
||||
@ -487,18 +487,18 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
|
||||
}
|
||||
int bytesRead = read(fd, bufferPtr, requestLen);
|
||||
if (bytesRead < 0) {
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
} else if (bytesRead != static_cast<int>(requestLen)) {
|
||||
if (uartCookie.isReplySizeFixed()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of "
|
||||
<< requestLen << " bytes" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
iter->second.replyLen = bytesRead;
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
@ -520,7 +520,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
*buffer = uartDeviceMapIter->second.replyBuffer.data();
|
||||
@ -529,7 +529,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
/* Length is reset to 0 to prevent reading the same data twice */
|
||||
uartDeviceMapIter->second.replyLen = 0;
|
||||
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
@ -547,9 +547,9 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
if (uartDeviceMapIter != uartDeviceMap.end()) {
|
||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||
tcflush(fd, TCIFLUSH);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
@ -567,9 +567,9 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
if (uartDeviceMapIter != uartDeviceMap.end()) {
|
||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||
tcflush(fd, TCOFLUSH);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||
@ -587,9 +587,9 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||
if (uartDeviceMapIter != uartDeviceMap.end()) {
|
||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
return returnvalue::OK;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
void UartComIF::setUartMode(struct termios* options, UartCookie& uartCookie) {
|
@ -22,9 +22,12 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
public:
|
||||
static constexpr uint8_t uartRetvalId = CLASS_ID::HAL_UART;
|
||||
|
||||
static constexpr ReturnValue_t UART_READ_FAILURE = returnvalue::makeCode(uartRetvalId, 1);
|
||||
static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = returnvalue::makeCode(uartRetvalId, 2);
|
||||
static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = returnvalue::makeCode(uartRetvalId, 3);
|
||||
static constexpr ReturnValue_t UART_READ_FAILURE =
|
||||
HasReturnvaluesIF::makeReturnCode(uartRetvalId, 1);
|
||||
static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH =
|
||||
HasReturnvaluesIF::makeReturnCode(uartRetvalId, 2);
|
||||
static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL =
|
||||
HasReturnvaluesIF::makeReturnCode(uartRetvalId, 3);
|
||||
|
||||
UartComIF(object_id_t objectId);
|
||||
|
3
hal/src/fsfw_hal/linux/uio/CMakeLists.txt
Normal file
3
hal/src/fsfw_hal/linux/uio/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${LIB_FSFW_NAME} PUBLIC
|
||||
UioMapper.cpp
|
||||
)
|
@ -18,17 +18,17 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum
|
||||
UioMapper::~UioMapper() {}
|
||||
|
||||
ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permissions) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
int fd = open(uioFile.c_str(), O_RDWR);
|
||||
if (fd < 1) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
size_t size = 0;
|
||||
result = getMapSize(&size);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
*address = static_cast<uint32_t*>(
|
||||
@ -39,9 +39,9 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss
|
||||
sif::error << "UioMapper::getMappedAdress: Failed to map physical address of uio device "
|
||||
<< uioFile.c_str() << " and map" << static_cast<int>(mapNum) << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t UioMapper::getMapSize(size_t* size) {
|
||||
@ -54,7 +54,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
char hexstring[SIZE_HEX_STRING] = "";
|
||||
int items = fscanf(fp, "%s", hexstring);
|
||||
@ -66,7 +66,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) {
|
||||
<< namestream.str() << std::endl;
|
||||
#endif
|
||||
fclose(fp);
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
uint32_t sizeTmp = 0;
|
||||
items = sscanf(hexstring, "%x", &sizeTmp);
|
||||
@ -79,8 +79,8 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) {
|
||||
<< "size of map" << mapNum << " to integer" << std::endl;
|
||||
#endif
|
||||
fclose(fp);
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
fclose(fp);
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
* @brief Class to help opening uio device files and mapping the physical addresses into the user
|
@ -2,4 +2,6 @@ add_subdirectory(spi)
|
||||
add_subdirectory(gpio)
|
||||
add_subdirectory(devicetest)
|
||||
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE dma.cpp)
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
dma.cpp
|
||||
)
|
3
hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt
Normal file
3
hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
GyroL3GD20H.cpp
|
||||
)
|
@ -84,7 +84,7 @@ ReturnValue_t GyroL3GD20H::initialize() {
|
||||
spiHandle->Init.Mode = SPI_MODE_MASTER;
|
||||
if (HAL_SPI_Init(spiHandle) != HAL_OK) {
|
||||
sif::printWarning("Error initializing SPI\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
delete mspCfg;
|
||||
@ -106,11 +106,11 @@ ReturnValue_t GyroL3GD20H::initialize() {
|
||||
return handlePollingTransferInit();
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::performOperation() {
|
||||
@ -125,10 +125,10 @@ ReturnValue_t GyroL3GD20H::performOperation() {
|
||||
return handleInterruptSensorRead();
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::handleDmaTransferInit() {
|
||||
@ -162,10 +162,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() {
|
||||
case (TransferStates::FAILURE): {
|
||||
sif::printWarning("Transfer failure\n");
|
||||
transferState = TransferStates::FAILURE;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,10 +194,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() {
|
||||
case (TransferStates::FAILURE): {
|
||||
sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n");
|
||||
transferState = TransferStates::FAILURE;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,13 +228,13 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() {
|
||||
case (TransferStates::FAILURE): {
|
||||
sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n");
|
||||
transferState = TransferStates::FAILURE;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::handleDmaSensorRead() {
|
||||
@ -259,13 +259,13 @@ ReturnValue_t GyroL3GD20H::handleDmaSensorRead() {
|
||||
case (TransferStates::FAILURE): {
|
||||
sif::printWarning("GyroL3GD20H::handleDmaSensorRead: Sensor read failure\n");
|
||||
transferState = TransferStates::FAILURE;
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef GyroL3GD20H::performDmaTransfer(size_t sendSize) {
|
||||
@ -298,14 +298,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() {
|
||||
}
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case (HAL_ERROR): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,14 +323,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() {
|
||||
}
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case (HAL_ERROR): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,17 +353,17 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() {
|
||||
}
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case (HAL_ERROR): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::handlePollingSensorRead() {
|
||||
@ -380,17 +380,17 @@ ReturnValue_t GyroL3GD20H::handlePollingSensorRead() {
|
||||
}
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case (HAL_ERROR): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() {
|
||||
@ -416,7 +416,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() {
|
||||
case (HAL_ERROR):
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() {
|
||||
case (HAL_ERROR):
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,10 +465,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() {
|
||||
case (HAL_ERROR):
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() {
|
||||
@ -489,10 +489,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() {
|
||||
case (HAL_ERROR):
|
||||
case (HAL_TIMEOUT): {
|
||||
sif::printDebug("GyroL3GD20H::initialize: Sensor read failure using interrupts\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GyroL3GD20H::prepareConfigRegs(uint8_t *configRegs) {
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "../spi/mspInit.h"
|
||||
#include "../spi/spiDefinitions.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "stm32h7xx_hal.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
|
3
hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt
Normal file
3
hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
gpio.cpp
|
||||
)
|
2
hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt
Normal file
2
hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
)
|
9
hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt
Normal file
9
hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
spiCore.cpp
|
||||
spiDefinitions.cpp
|
||||
spiInterrupts.cpp
|
||||
mspInit.cpp
|
||||
SpiCookie.cpp
|
||||
SpiComIF.cpp
|
||||
stm32h743zi.cpp
|
||||
)
|
@ -35,7 +35,7 @@ void SpiComIF::addDmaHandles(DMA_HandleTypeDef *txHandle, DMA_HandleTypeDef *rxH
|
||||
spi::setDmaHandles(txHandle, rxHandle);
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::initialize() { return returnvalue::OK; }
|
||||
ReturnValue_t SpiComIF::initialize() { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
SpiCookie *spiCookie = dynamic_cast<SpiCookie *>(cookie);
|
||||
@ -55,7 +55,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
spi::getDmaHandles(&txHandle, &rxHandle);
|
||||
if (txHandle == nullptr or rxHandle == nullptr) {
|
||||
sif::printError("SpiComIF::initialize: DMA handles not set!\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
// This semaphore ensures thread-safety for a given bus
|
||||
@ -79,7 +79,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
static_cast<unsigned long>(spiAddress));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
auto gpioPin = spiCookie->getChipSelectGpioPin();
|
||||
@ -98,7 +98,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
#endif
|
||||
} else {
|
||||
printCfgError("SPI Bus Index");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
auto mspCfg = spiCookie->getMspCfg();
|
||||
@ -107,21 +107,21 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
auto typedCfg = dynamic_cast<spi::MspPollingConfigStruct *>(mspCfg);
|
||||
if (typedCfg == nullptr) {
|
||||
printCfgError("Polling MSP");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
spi::setSpiPollingMspFunctions(typedCfg);
|
||||
} else if (transferMode == spi::TransferModes::INTERRUPT) {
|
||||
auto typedCfg = dynamic_cast<spi::MspIrqConfigStruct *>(mspCfg);
|
||||
if (typedCfg == nullptr) {
|
||||
printCfgError("IRQ MSP");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
spi::setSpiIrqMspFunctions(typedCfg);
|
||||
} else if (transferMode == spi::TransferModes::DMA) {
|
||||
auto typedCfg = dynamic_cast<spi::MspDmaConfigStruct *>(mspCfg);
|
||||
if (typedCfg == nullptr) {
|
||||
printCfgError("DMA MSP");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
// Check DMA handles
|
||||
DMA_HandleTypeDef *txHandle = nullptr;
|
||||
@ -129,7 +129,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
spi::getDmaHandles(&txHandle, &rxHandle);
|
||||
if (txHandle == nullptr or rxHandle == nullptr) {
|
||||
printCfgError("DMA Handle");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
spi::setSpiDmaMspFunctions(typedCfg);
|
||||
}
|
||||
@ -145,12 +145,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
|
||||
if (HAL_SPI_Init(&spiHandle) != HAL_OK) {
|
||||
sif::printWarning("SpiComIF::initialize: Error initializing SPI\n");
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
// The MSP configuration struct is not required anymore
|
||||
spiCookie->deleteMspCfg();
|
||||
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) {
|
||||
@ -163,7 +163,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
||||
|
||||
auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress());
|
||||
if (iter == spiDeviceMap.end()) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
iter->second.currentTransferLen = sendLen;
|
||||
|
||||
@ -176,7 +176,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
||||
case (spi::TransferStates::FAILURE):
|
||||
case (spi::TransferStates::SUCCESS):
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,13 +194,13 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
||||
sendData, sendLen);
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; }
|
||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) {
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) {
|
||||
@ -212,7 +212,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
case (spi::TransferStates::SUCCESS): {
|
||||
auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress());
|
||||
if (iter == spiDeviceMap.end()) {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*buffer = iter->second.replyBuffer.data();
|
||||
*size = iter->second.currentTransferLen;
|
||||
@ -228,18 +228,18 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
#endif
|
||||
#endif
|
||||
spiCookie->setTransferState(spi::TransferStates::IDLE);
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case (spi::TransferStates::WAIT):
|
||||
case (spi::TransferStates::IDLE): {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void SpiComIF::setDefaultPollingTimeout(dur_millis_t timeout) {
|
||||
@ -252,7 +252,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT
|
||||
auto gpioPort = spiCookie.getChipSelectGpioPort();
|
||||
auto gpioPin = spiCookie.getChipSelectGpioPin();
|
||||
auto returnval = spiSemaphore->acquire(timeoutType, timeoutMs);
|
||||
if (returnval != returnvalue::OK) {
|
||||
if (returnval != HasReturnvaluesIF::RETURN_OK) {
|
||||
return returnval;
|
||||
}
|
||||
spiCookie.setTransferState(spi::TransferStates::WAIT);
|
||||
@ -299,7 +299,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT
|
||||
return spi::HAL_ERROR_RETVAL;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::handleInterruptSendOperation(uint8_t *recvPtr, SPI_HandleTypeDef &spiHandle,
|
||||
@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::handleIrqSendOperation(uint8_t *recvPtr, SPI_HandleTypeD
|
||||
SpiCookie &spiCookie, const uint8_t *sendData,
|
||||
size_t sendLen) {
|
||||
ReturnValue_t result = genericIrqSendSetup(recvPtr, spiHandle, spiCookie, sendData, sendLen);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
// yet another HAL driver which is not const-correct..
|
||||
@ -366,7 +366,7 @@ ReturnValue_t SpiComIF::halErrorHandler(HAL_StatusTypeDef status, spi::TransferM
|
||||
return spi::HAL_TIMEOUT_RETVAL;
|
||||
}
|
||||
default: {
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -379,7 +379,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef
|
||||
|
||||
// Take the semaphore which will be released by a callback when the transfer is complete
|
||||
ReturnValue_t result = spiSemaphore->acquire(SemaphoreIF::TimeoutType::WAITING, timeoutMs);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// Configuration error
|
||||
sif::printWarning(
|
||||
"SpiComIF::handleInterruptSendOperation: Semaphore "
|
||||
@ -399,7 +399,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef
|
||||
HAL_GPIO_WritePin(spiCookie.getChipSelectGpioPort(), spiCookie.getChipSelectGpioPin(),
|
||||
GPIO_PIN_RESET);
|
||||
}
|
||||
return returnvalue::OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void SpiComIF::spiTransferTxCompleteCallback(SPI_HandleTypeDef *hspi, void *args) {
|
||||
@ -445,7 +445,7 @@ void SpiComIF::genericIrqHandler(void *irqArgsVoid, spi::TransferStates targetSt
|
||||
#elif defined FSFW_OSAL_RTEMS
|
||||
ReturnValue_t result = comIF->spiSemaphore->release();
|
||||
#endif
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// Configuration error
|
||||
printf("SpiComIF::genericIrqHandler: Failure releasing Semaphore!\n");
|
||||
}
|
@ -3,16 +3,17 @@
|
||||
|
||||
#include "../../common/spi/spiCommon.h"
|
||||
#include "fsfw/returnvalues/FwClassIds.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "stm32h7xx_hal.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
|
||||
namespace spi {
|
||||
|
||||
static constexpr uint8_t HAL_SPI_ID = CLASS_ID::HAL_SPI;
|
||||
static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 0);
|
||||
static constexpr ReturnValue_t HAL_BUSY_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 1);
|
||||
static constexpr ReturnValue_t HAL_ERROR_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 2);
|
||||
static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL =
|
||||
HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 0);
|
||||
static constexpr ReturnValue_t HAL_BUSY_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 1);
|
||||
static constexpr ReturnValue_t HAL_ERROR_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 2);
|
||||
|
||||
enum class TransferStates { IDLE, WAIT, SUCCESS, FAILURE };
|
||||
|
2
hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt
Normal file
2
hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
)
|
@ -11,15 +11,15 @@ ReturnValue_t pst::pollingSequenceInitDefault(
|
||||
|
||||
/* Add polling sequence table here */
|
||||
|
||||
if (thisSequence->checkSequence() == returnvalue::OK) {
|
||||
return returnvalue::OK;
|
||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return returnvalue::FAILED;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef POLLINGSEQUENCEFACTORY_H_
|
||||
#define POLLINGSEQUENCEFACTORY_H_
|
||||
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
class FixedTimeslotTaskIF;
|
||||
|
||||
|
@ -3,11 +3,6 @@ if [[ ! -f README.md ]]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
folder_list=(
|
||||
"./src"
|
||||
"./unittests"
|
||||
)
|
||||
|
||||
cmake_fmt="cmake-format"
|
||||
file_selectors="-iname CMakeLists.txt"
|
||||
if command -v ${cmake_fmt} &> /dev/null; then
|
||||
@ -20,10 +15,9 @@ fi
|
||||
cpp_format="clang-format"
|
||||
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
|
||||
if command -v ${cpp_format} &> /dev/null; then
|
||||
for dir in ${folder_list[@]}; do
|
||||
echo "Auto-formatting ${dir} recursively"
|
||||
find ${dir} ${file_selectors} | xargs clang-format --style=file -i
|
||||
done
|
||||
find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
|
||||
find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i
|
||||
find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i
|
||||
else
|
||||
echo "No ${cpp_format} tool found, not formatting C++/C files"
|
||||
fi
|
||||
|
@ -48,20 +48,6 @@ def main():
|
||||
action="store_true",
|
||||
help="Run valgrind on generated test binary",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-g",
|
||||
"--generators",
|
||||
default = "Ninja",
|
||||
action="store",
|
||||
help="CMake generators",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-w",
|
||||
"--windows",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Run on windows",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.all:
|
||||
@ -129,14 +115,14 @@ def handle_tests_type(args, build_dir_list: list):
|
||||
if args.create:
|
||||
if os.path.exists(UNITTEST_FOLDER_NAME):
|
||||
shutil.rmtree(UNITTEST_FOLDER_NAME)
|
||||
create_tests_build_cfg(args)
|
||||
create_tests_build_cfg()
|
||||
build_directory = UNITTEST_FOLDER_NAME
|
||||
elif len(build_dir_list) == 0:
|
||||
print(
|
||||
"No valid CMake tests build directory found. "
|
||||
"Trying to set up test build system"
|
||||
)
|
||||
create_tests_build_cfg(args)
|
||||
create_tests_build_cfg()
|
||||
build_directory = UNITTEST_FOLDER_NAME
|
||||
elif len(build_dir_list) == 1:
|
||||
build_directory = build_dir_list[0]
|
||||
@ -161,15 +147,10 @@ def handle_tests_type(args, build_dir_list: list):
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
def create_tests_build_cfg(args):
|
||||
def create_tests_build_cfg():
|
||||
os.mkdir(UNITTEST_FOLDER_NAME)
|
||||
os.chdir(UNITTEST_FOLDER_NAME)
|
||||
if args.windows:
|
||||
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \
|
||||
-DGCOVR_PATH="py -m gcovr" ..'
|
||||
else:
|
||||
cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..'
|
||||
cmd_runner(cmake_cmd)
|
||||
cmd_runner("cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..")
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
|
@ -4,8 +4,3 @@ target_include_directories(${LIB_FSFW_NAME}
|
||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(fsfw)
|
||||
if(FSFW_ADD_HAL)
|
||||
add_subdirectory(fsfw_hal)
|
||||
endif()
|
||||
|
||||
add_subdirectory(fsfw_tests)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user