apply afmt

This commit is contained in:
Robin Müller 2022-05-27 02:17:19 +02:00
parent ec6a398631
commit 603b23714a
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
34 changed files with 952 additions and 1013 deletions

View File

@ -1,11 +1,10 @@
################################################################################
# CMake support for the Flight Software Framework
# Author: R. Mueller
################################################################################
# ##############################################################################
# CMake support for the Flight Software Framework Author: R. Mueller
# ##############################################################################
################################################################################
# ##############################################################################
# Pre-Project preparation
################################################################################
# ##############################################################################
cmake_minimum_required(VERSION 3.13)
# set(CMAKE_VERBOSE TRUE)
@ -13,8 +12,10 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(RTEMS_CMAKE_PATH "${CMAKE_SCRIPT_PATH}/rtems-cmake")
set(FSFW_OSAL rtems CACHE STRING "OS for the FSFW")
SET(STM32_ADD_NETWORKING_CODE ON)
set(FSFW_OSAL
rtems
CACHE STRING "OS for the FSFW")
set(STM32_ADD_NETWORKING_CODE ON)
set(OBSW_MAX_SCHEDULED_TCS 200)
set(FSFW_HAL_ADD_STM32H7 ON)
@ -28,9 +29,9 @@ include("${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake")
# Project Name
project(fsfw-example-stm32h7-rtems ASM C CXX)
################################################################################
# ##############################################################################
# Pre-Sources preparation
################################################################################
# ##############################################################################
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
@ -52,11 +53,8 @@ set(BSP_NUCLEO_PATH "${BSP_PATH}/boarconfig/NUCLEO-H743ZI")
set(BSP_NUCLEO_PATH_INC "${BSP_PATH}/boardconfig/NUCLEO-H743ZI/Inc")
set(FSFW_ADDITIONAL_INC_PATHS
"${COMMON_CONFIG_PATH}"
"${CMAKE_CURRENT_BINARY_DIR}"
CACHE STRING
"FSFW configuration paths"
)
"${COMMON_CONFIG_PATH}" "${CMAKE_CURRENT_BINARY_DIR}"
CACHE STRING "FSFW configuration paths")
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
configure_file(${FSFW_CONFIG_PATH}/FSFWConfig.h.in FSFWConfig.h)
@ -65,13 +63,8 @@ configure_file(${BSP_NUCLEO_PATH_INC}/lwipopts.h.in lwipopts.h)
configure_file(${BSP_PATH}/RTEMSConfig.h.in RTEMSConfig.h)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(WARNING_FLAGS
-Wall
-Wextra
-Wimplicit-fallthrough=1
-Wno-unused-parameter
-Wno-psabi
)
set(WARNING_FLAGS -Wall -Wextra -Wimplicit-fallthrough=1
-Wno-unused-parameter -Wno-psabi)
set(FSFW_WARNING_FLAGS ${WARNING_FLAGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
@ -80,9 +73,9 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_definitions(NOMINMAX)
endif()
################################################################################
# ##############################################################################
# Executable and Sources
################################################################################
# ##############################################################################
# Add executable
add_executable(${TARGET_NAME})
@ -92,76 +85,83 @@ add_subdirectory(${BSP_PATH})
add_subdirectory(${FSFW_PATH})
add_subdirectory(${COMMON_PATH})
################################################################################
# ##############################################################################
# Post-Sources preparation
################################################################################
# ##############################################################################
# Check whether the user has already installed ETL first find_package(etl
# ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) Not installed, so use FetchContent
# to download and provide etl if(NOT etl_FOUND) There are issues using
# find_package. For now, always use FetchContent See this github issue:
# https://github.com/ETLCPP/etl/issues/548
message(
STATUS
"No ETL installation was found with find_package. Installing and providing "
"etl with FindPackage")
include(FetchContent)
FetchContent_Declare(
etl
GIT_REPOSITORY https://github.com/ETLCPP/etl
GIT_TAG ${FSFW_ETL_LIB_VERSION})
list(APPEND FSFW_FETCH_CONTENT_TARGETS etl)
# endif()
# The documentation for FetchContent recommends declaring all the dependencies
# before making them available. We make all declared dependency available here
# after their declaration
if(FSFW_FETCH_CONTENT_TARGETS)
FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS})
endif()
# Add libraries for all sources.
target_link_libraries(${TARGET_NAME} PRIVATE
${LIB_FSFW_NAME}
target_link_libraries(
${TARGET_NAME}
PRIVATE ${LIB_FSFW_NAME} etl
# Link against lwip which is part of the RTEMS BSP
${LIB_LWIP_NAME}
)
${LIB_LWIP_NAME})
# Add include paths for all sources.
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${FSFW_CONFIG_PATH}
)
target_include_directories(
${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR} ${FSFW_CONFIG_PATH})
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(${TARGET_NAME} PRIVATE
"-Wl,-Map=${TARGET_NAME}.map"
)
target_link_options(${TARGET_NAME} PRIVATE "-Wl,-Map=${TARGET_NAME}.map")
# Remove unused sections.
target_compile_options(${TARGET_NAME} PRIVATE
"-ffunction-sections"
"-fdata-sections"
)
target_compile_options(${TARGET_NAME} PRIVATE "-ffunction-sections"
"-fdata-sections")
# Removed unused sections.
if(NOT FSFW_OSAL MATCHES rtems)
target_link_options(${TARGET_NAME} PRIVATE
"-Wl,--gc-sections"
)
target_link_options(${TARGET_NAME} PRIVATE "-Wl,--gc-sections")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif()
if(CMAKE_VERBOSE)
message(STATUS "Warning flags: ${WARNING_FLAGS}")
endif()
# Compile options for all sources.
target_compile_options(${TARGET_NAME} PRIVATE
${WARNING_FLAGS}
)
target_compile_options(${TARGET_NAME} PRIVATE ${WARNING_FLAGS})
string(CONCAT POST_BUILD_COMMENT
"Build directory: ${CMAKE_BINARY_DIR}\n"
"Target OSAL: ${FSFW_OSAL}\n"
"Target RTEMS BSP: ${RTEMS_BSP}\n"
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
"${TARGET_STRING}"
)
string(CONCAT POST_BUILD_COMMENT "Build directory: ${CMAKE_BINARY_DIR}\n"
"Target OSAL: ${FSFW_OSAL}\n" "Target RTEMS BSP: ${RTEMS_BSP}\n"
"Target Build Type: ${CMAKE_BUILD_TYPE}\n" "${TARGET_STRING}")
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE} ${TARGET_NAME}
COMMENT ${POST_BUILD_COMMENT}
)
COMMENT ${POST_BUILD_COMMENT})
include("${RTEMS_CONFIG_DIR}/BuildType.cmake")
set_build_type()
################################################################################
# ##############################################################################
# Load RTEMS post-project configuration and checks
################################################################################
# ##############################################################################
include("${RTEMS_CONFIG_DIR}/RTEMSPostProjectConfig.cmake")
rtems_post_project_config(${TARGET_NAME})

View File

@ -1,7 +1,4 @@
target_sources(${TARGET_NAME} PRIVATE
init.c
main.cpp
)
target_sources(${TARGET_NAME} PRIVATE init.c main.cpp)
add_subdirectory(boardconfig)
add_subdirectory(fsfwconfig)

View File

@ -1,4 +1,3 @@
target_sources(${TARGET_NAME} PRIVATE
)
target_sources(${TARGET_NAME} PRIVATE)
add_subdirectory(NUCLEO-H743ZI)

View File

@ -1,5 +1,4 @@
add_subdirectory(Src)
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Inc
)
target_include_directories(${TARGET_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Inc)

View File

@ -1,7 +1,6 @@
#ifndef BSP_STM32H7_RTEMS_NUCLEO_H743ZI_INC_HARDWARE_INIT_H_
#define BSP_STM32H7_RTEMS_NUCLEO_H743ZI_INC_HARDWARE_INIT_H_
#include <stdint.h>
#ifdef __cplusplus

View File

@ -24,7 +24,7 @@
#define STM32H7XX_NUCLEO_H
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
@ -32,11 +32,11 @@
#include "stm32h7xx_nucleo_errno.h"
#if (USE_BSP_COM_FEATURE > 0)
#if (USE_COM_LOG > 0)
#ifndef __GNUC__
#include <stdio.h>
#endif
#endif
#if (USE_COM_LOG > 0)
#ifndef __GNUC__
#include <stdio.h>
#endif
#endif
#endif
/** @addtogroup BSP
@ -54,26 +54,29 @@
/**
* @brief Define for STM32H7XX_NUCLEO board
*/
#if !defined (USE_STM32H7XX_NUCLEO)
#define USE_STM32H7XX_NUCLEO
#if !defined(USE_STM32H7XX_NUCLEO)
#define USE_STM32H7XX_NUCLEO
#endif
#if !defined (USE_NUCLEO_144)
#error "Board Pin number not defined!! Add USE_NUCLEO_144 define within stm32h7xx_nucleo_conf.h file"
#if !defined(USE_NUCLEO_144)
#error \
"Board Pin number not defined!! Add USE_NUCLEO_144 define within stm32h7xx_nucleo_conf.h file"
#endif
#if !defined (USE_NUCLEO_H745ZI_Q) && !defined (USE_NUCLEO_H743ZI) && !defined (USE_NUCLEO_H743ZI2) &&\
!defined (USE_NUCLEO_H7A3ZI_Q) && !defined (USE_NUCLEO_H723ZG)
#error "Board Part number not defined!! Add one of the following define within stm32h7xx_nucleo_conf.h file:\
#if !defined(USE_NUCLEO_H745ZI_Q) && !defined(USE_NUCLEO_H743ZI) && \
!defined(USE_NUCLEO_H743ZI2) && !defined(USE_NUCLEO_H7A3ZI_Q) && \
!defined(USE_NUCLEO_H723ZG)
#error \
"Board Part number not defined!! Add one of the following define within stm32h7xx_nucleo_conf.h file:\
USE_NUCLEO_H745ZI_Q, USE_NUCLEO_H743ZI, USE_NUCLEO_H743ZI2, USE_NUCLEO_H7A3ZI_Q, USE_NUCLEO_H723ZG"
#endif
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
* @{
*/
#if defined (USE_NUCLEO_H745ZI_Q) || defined (USE_NUCLEO_H743ZI2) || defined (USE_NUCLEO_H7A3ZI_Q) || defined (USE_NUCLEO_H723ZG)
typedef enum
{
#if defined(USE_NUCLEO_H745ZI_Q) || defined(USE_NUCLEO_H743ZI2) || \
defined(USE_NUCLEO_H7A3ZI_Q) || defined(USE_NUCLEO_H723ZG)
typedef enum {
LED1 = 0,
LED_GREEN = LED1,
LED2 = 1,
@ -81,10 +84,9 @@ typedef enum
LED3 = 2,
LED_RED = LED3,
LEDn
}Led_TypeDef;
} Led_TypeDef;
#else /* USE_NUCLEO_H743ZI */
typedef enum
{
typedef enum {
LED1 = 0,
LED_GREEN = LED1,
LED2 = 1,
@ -92,71 +94,53 @@ typedef enum
LED3 = 2,
LED_RED = LED3,
LEDn
}Led_TypeDef;
} Led_TypeDef;
#endif
typedef enum
{
BUTTON_USER = 0U,
BUTTONn
}Button_TypeDef;
typedef enum { BUTTON_USER = 0U, BUTTONn } Button_TypeDef;
typedef enum
{
BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1
}ButtonMode_TypeDef;
typedef enum { BUTTON_MODE_GPIO = 0, BUTTON_MODE_EXTI = 1 } ButtonMode_TypeDef;
#if (USE_BSP_COM_FEATURE > 0)
typedef enum
{
COM1 = 0U,
COMn
}COM_TypeDef;
typedef enum { COM1 = 0U, COMn } COM_TypeDef;
typedef enum
{
typedef enum {
COM_STOPBITS_1 = UART_STOPBITS_1,
COM_STOPBITS_2 = UART_STOPBITS_2,
}COM_StopBitsTypeDef;
} COM_StopBitsTypeDef;
typedef enum
{
typedef enum {
COM_PARITY_NONE = UART_PARITY_NONE,
COM_PARITY_EVEN = UART_PARITY_EVEN,
COM_PARITY_ODD = UART_PARITY_ODD,
}COM_ParityTypeDef;
} COM_ParityTypeDef;
typedef enum
{
typedef enum {
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
}COM_HwFlowCtlTypeDef;
} COM_HwFlowCtlTypeDef;
typedef enum
{
typedef enum {
COM_WORDLENGTH_7B = UART_WORDLENGTH_7B,
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
}COM_WordLengthTypeDef;
} COM_WordLengthTypeDef;
typedef struct
{
typedef struct {
uint32_t BaudRate;
COM_WordLengthTypeDef WordLength;
COM_StopBitsTypeDef StopBits;
COM_ParityTypeDef Parity;
COM_HwFlowCtlTypeDef HwFlowCtl;
}COM_InitTypeDef;
} COM_InitTypeDef;
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
typedef struct
{
void (* pMspInitCb)(UART_HandleTypeDef *);
void (* pMspDeInitCb)(UART_HandleTypeDef *);
}BSP_COM_Cb_t;
typedef struct {
void (*pMspInitCb)(UART_HandleTypeDef *);
void (*pMspDeInitCb)(UART_HandleTypeDef *);
} BSP_COM_Cb_t;
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1) */
#define MX_UART_InitTypeDef COM_InitTypeDef
@ -166,7 +150,8 @@ typedef struct
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported
* Constants
* @{
*/
@ -176,11 +161,14 @@ typedef struct
#define STM32H7XX_NUCLEO_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
#define STM32H7XX_NUCLEO_BSP_VERSION_SUB1 (0x03U) /*!< [23:16] sub1 version */
#define STM32H7XX_NUCLEO_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
#define STM32H7XX_NUCLEO_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
#define STM32H7XX_NUCLEO_BSP_VERSION ((STM32H7XX_NUCLEO_BSP_VERSION_MAIN << 24)\
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|(STM32H7XX_NUCLEO_BSP_VERSION_RC))
#define STM32H7XX_NUCLEO_BSP_VERSION_RC \
(0x00U) /*!< [7:0] release candidate \
*/
#define STM32H7XX_NUCLEO_BSP_VERSION \
((STM32H7XX_NUCLEO_BSP_VERSION_MAIN << 24) | \
(STM32H7XX_NUCLEO_BSP_VERSION_SUB1 << 16) | \
(STM32H7XX_NUCLEO_BSP_VERSION_SUB2 << 8) | \
(STM32H7XX_NUCLEO_BSP_VERSION_RC))
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_LED LOW LEVEL LED
* @{
@ -192,7 +180,8 @@ typedef struct
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#if defined (USE_NUCLEO_H745ZI_Q) || defined (USE_NUCLEO_H743ZI2) || defined (USE_NUCLEO_H7A3ZI_Q) || defined (USE_NUCLEO_H723ZG)
#if defined(USE_NUCLEO_H745ZI_Q) || defined(USE_NUCLEO_H743ZI2) || \
defined(USE_NUCLEO_H7A3ZI_Q) || defined(USE_NUCLEO_H723ZG)
#define LED2_PIN GPIO_PIN_1
#define LED2_GPIO_PORT GPIOE
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
@ -276,14 +265,15 @@ typedef struct
extern EXTI_HandleTypeDef hpb_exti[];
#if (USE_BSP_COM_FEATURE > 0)
extern UART_HandleTypeDef hcom_uart[];
extern USART_TypeDef* COM_USART[];
extern USART_TypeDef *COM_USART[];
#endif
/**
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_FunctionsPrototypes LOW LEVEL Exported Functions Prototypes
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_FunctionsPrototypes LOW LEVEL
* Exported Functions Prototypes
* @{
*/
int32_t BSP_GetVersion(void);
@ -292,7 +282,7 @@ int32_t BSP_LED_DeInit(Led_TypeDef Led);
int32_t BSP_LED_On(Led_TypeDef Led);
int32_t BSP_LED_Off(Led_TypeDef Led);
int32_t BSP_LED_Toggle(Led_TypeDef Led);
int32_t BSP_LED_GetState (Led_TypeDef Led);
int32_t BSP_LED_GetState(Led_TypeDef Led);
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
int32_t BSP_PB_DeInit(Button_TypeDef Button);
int32_t BSP_PB_GetState(Button_TypeDef Button);
@ -303,14 +293,15 @@ void BSP_PB_Callback(Button_TypeDef Button);
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init);
int32_t BSP_COM_DeInit(COM_TypeDef COM);
#if (USE_COM_LOG > 0)
int32_t BSP_COM_SelectLogPort (COM_TypeDef COM);
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM);
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback);
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM, BSP_COM_Cb_t *Callback);
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init);
HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart,
MX_UART_InitTypeDef *COM_Init);
#endif /* USE_BSP_COM_FEATURE */
/**

View File

@ -22,12 +22,12 @@
#define STM32H7XX_NUCLEO_CONF_H
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"
#include "stm32h743xx.h"
#include "stm32h7xx_hal.h"
/** @addtogroup BSP
* @{

View File

@ -22,7 +22,7 @@
#define STM32H7XX_NUCLEO_ERRNO_H
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
/* Common Error codes */

View File

@ -1,4 +1 @@
target_sources(${TARGET_NAME} PRIVATE
hardware_init.cpp
stm32h7xx_nucleo.c
)
target_sources(${TARGET_NAME} PRIVATE hardware_init.cpp stm32h7xx_nucleo.c)

View File

@ -1,11 +1,9 @@
#include "hardware_init.h"
#include "fsfw/tasks/PeriodicTaskIF.h"
#include <rtems_lwip/rtems_lwip.h>
#include <rtems_lwip/ethernetif.h>
#include <rtems_lwip/app_ethernet.h>
#include <rtems_lwip/app_dhcp.h>
#include <rtems_lwip/app_ethernet.h>
#include <rtems_lwip/ethernetif.h>
#include <rtems_lwip/rtems_lwip.h>
void hardware_init() {
rtems_lwip_init(NULL, &ethernet_link_status_updated);
}
void hardware_init() { rtems_lwip_init(NULL, &ethernet_link_status_updated); }

View File

@ -31,12 +31,13 @@
*/
/** @addtogroup STM32H7XX_NUCLEO_LOW_LEVEL
* @brief This file provides set of firmware functions to manage Leds and push-button
* available on STM32H7xx-Nucleo Kit from STMicroelectronics.
* @brief This file provides set of firmware functions to manage Leds and
* push-button available on STM32H7xx-Nucleo Kit from STMicroelectronics.
* @{
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Defines LOW LEVEL Private Defines
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Defines LOW LEVEL Private
* Defines
* @{
*/
@ -44,56 +45,55 @@
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions LOW LEVEL Private Typedef
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions LOW LEVEL
* Private Typedef
* @{
*/
typedef void (* BSP_EXTI_LineCallback) (void);
typedef void (*BSP_EXTI_LineCallback)(void);
/**
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported Variables
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported
* Variables
* @{
*/
EXTI_HandleTypeDef hpb_exti[BUTTONn];
#if (USE_BSP_COM_FEATURE > 0)
UART_HandleTypeDef hcom_uart[COMn];
USART_TypeDef* COM_USART[COMn] = {COM1_UART};
USART_TypeDef *COM_USART[COMn] = {COM1_UART};
#endif
/**
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Variables LOW LEVEL Private Variables
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Variables LOW LEVEL Private
* Variables
* @{
*/
static GPIO_TypeDef* LED_PORT[LEDn] = {LED1_GPIO_PORT,
LED2_GPIO_PORT,
static GPIO_TypeDef *LED_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT,
LED3_GPIO_PORT};
static const uint16_t LED_PIN[LEDn] = {LED1_PIN,
LED2_PIN,
LED3_PIN};
static const uint16_t LED_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN};
static GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {BUTTON_USER_GPIO_PORT};
static GPIO_TypeDef *BUTTON_PORT[BUTTONn] = {BUTTON_USER_GPIO_PORT};
static const uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_USER_PIN};
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
#if (USE_BSP_COM_FEATURE > 0)
#if (USE_COM_LOG > 0)
static COM_TypeDef COM_ActiveLogPort = COM1;
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
static uint32_t IsComMspCbValid[COMn] = {0};
#endif
#if (USE_COM_LOG > 0)
static COM_TypeDef COM_ActiveLogPort = COM1;
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
static uint32_t IsComMspCbValid[COMn] = {0};
#endif
#endif
/**
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_FunctionPrototypes LOW LEVEL Private functions Prototypes
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_FunctionPrototypes LOW LEVEL
* Private functions Prototypes
* @{
*/
static void BUTTON_USER_EXTI_Callback(void);
@ -105,7 +105,8 @@ static void COM1_MspDeInit(UART_HandleTypeDef *huart);
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Functions LOW LEVEL Exported
* Functions
* @{
*/
@ -113,10 +114,7 @@ static void COM1_MspDeInit(UART_HandleTypeDef *huart);
* @brief This method returns the STM32H7XX NUCLEO BSP Driver revision
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
*/
int32_t BSP_GetVersion(void)
{
return (int32_t)STM32H7XX_NUCLEO_BSP_VERSION;
}
int32_t BSP_GetVersion(void) { return (int32_t)STM32H7XX_NUCLEO_BSP_VERSION; }
/**
* @brief Configures LED GPIO.
@ -127,28 +125,19 @@ int32_t BSP_GetVersion(void)
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Init(Led_TypeDef Led)
{
int32_t BSP_LED_Init(Led_TypeDef Led) {
int32_t ret = BSP_ERROR_NONE;
GPIO_InitTypeDef gpio_init_structure;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
/* Enable the GPIO LED Clock */
if(Led == LED1)
{
if (Led == LED1) {
LED1_GPIO_CLK_ENABLE();
}
else if(Led == LED2)
{
} else if (Led == LED2) {
LED2_GPIO_CLK_ENABLE();
}
else
{
} else {
LED3_GPIO_CLK_ENABLE();
}
/* Configure the GPIO_LED pin */
@ -174,17 +163,13 @@ int32_t BSP_LED_Init(Led_TypeDef Led)
* @note Led DeInit does not disable the GPIO clock nor disable the Mfx
* @retval BSP status
*/
int32_t BSP_LED_DeInit(Led_TypeDef Led)
{
int32_t BSP_LED_DeInit(Led_TypeDef Led) {
int32_t ret = BSP_ERROR_NONE;
GPIO_InitTypeDef gpio_init_structure;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
/* Turn off LED */
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
/* DeInit the GPIO_LED pin */
@ -204,16 +189,12 @@ int32_t BSP_LED_DeInit(Led_TypeDef Led)
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_On(Led_TypeDef Led)
{
int32_t BSP_LED_On(Led_TypeDef Led) {
int32_t ret = BSP_ERROR_NONE;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
}
@ -229,16 +210,12 @@ int32_t BSP_LED_On(Led_TypeDef Led)
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Off(Led_TypeDef Led)
{
int32_t BSP_LED_Off(Led_TypeDef Led) {
int32_t ret = BSP_ERROR_NONE;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
}
@ -254,16 +231,12 @@ int32_t BSP_LED_Off(Led_TypeDef Led)
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Toggle(Led_TypeDef Led)
{
int32_t BSP_LED_Toggle(Led_TypeDef Led) {
int32_t ret = BSP_ERROR_NONE;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
}
@ -279,17 +252,13 @@ int32_t BSP_LED_Toggle(Led_TypeDef Led)
* @arg LED3
* @retval LED status
*/
int32_t BSP_LED_GetState (Led_TypeDef Led)
{
int32_t BSP_LED_GetState(Led_TypeDef Led) {
int32_t ret;
if((Led != LED1) && (Led != LED2) && (Led != LED3))
{
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
ret = (int32_t)HAL_GPIO_ReadPin (LED_PORT [Led], LED_PIN [Led]);
} else {
ret = (int32_t)HAL_GPIO_ReadPin(LED_PORT[Led], LED_PIN[Led]);
}
return ret;
@ -306,27 +275,25 @@ int32_t BSP_LED_GetState (Led_TypeDef Led)
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
* with interrupt generation capability
*/
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode) {
GPIO_InitTypeDef gpio_init_structure;
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {BUTTON_USER_EXTI_Callback};
static uint32_t BSP_BUTTON_PRIO [BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {
BUTTON_USER_EXTI_Callback};
static uint32_t BSP_BUTTON_PRIO[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE};
/* Enable the BUTTON clock */
BUTTON_USER_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = BUTTON_PIN [Button];
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Pull = GPIO_PULLDOWN;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
if(ButtonMode == BUTTON_MODE_GPIO)
{
if (ButtonMode == BUTTON_MODE_GPIO) {
/* Configure Button pin as input */
gpio_init_structure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(BUTTON_PORT [Button], &gpio_init_structure);
}
else /* (ButtonMode == BUTTON_MODE_EXTI) */
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
} else /* (ButtonMode == BUTTON_MODE_EXTI) */
{
/* Configure Button pin as input with External interrupt */
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
@ -334,7 +301,8 @@ int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, ButtonCallback[Button]);
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID,
ButtonCallback[Button]);
/* Enable and set Button EXTI Interrupt to the lowest priority */
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), BSP_BUTTON_PRIO[Button], 0x00);
@ -351,8 +319,7 @@ int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
* @arg BUTTON_USER: Wakeup Push Button
* @note PB DeInit does not disable the GPIO clock
*/
int32_t BSP_PB_DeInit(Button_TypeDef Button)
{
int32_t BSP_PB_DeInit(Button_TypeDef Button) {
GPIO_InitTypeDef gpio_init_structure;
gpio_init_structure.Pin = BUTTON_PIN[Button];
@ -369,8 +336,7 @@ int32_t BSP_PB_DeInit(Button_TypeDef Button)
* @arg BUTTON_USER: Wakeup Push Button
* @retval The Button GPIO pin value (GPIO_PIN_RESET = button pressed)
*/
int32_t BSP_PB_GetState(Button_TypeDef Button)
{
int32_t BSP_PB_GetState(Button_TypeDef Button) {
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
}
@ -379,8 +345,7 @@ int32_t BSP_PB_GetState(Button_TypeDef Button)
* @param Button Can only be BUTTON_USER
* @retval None
*/
void BSP_PB_IRQHandler(Button_TypeDef Button)
{
void BSP_PB_IRQHandler(Button_TypeDef Button) {
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
}
@ -389,8 +354,7 @@ void BSP_PB_IRQHandler(Button_TypeDef Button)
* @param Button Specifies the pin connected EXTI line
* @retval None
*/
__weak void BSP_PB_Callback(Button_TypeDef Button)
{
__weak void BSP_PB_Callback(Button_TypeDef Button) {
/* Prevent unused argument(s) compilation warning */
UNUSED(Button);
@ -404,34 +368,28 @@ __weak void BSP_PB_Callback(Button_TypeDef Button)
* @param COM COM port to be configured.
* This parameter can be COM1
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
* configuration information for the specified USART
* peripheral.
* @retval BSP error code
*/
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
{
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init) {
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
if (COM >= COMn) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
/* Init the UART Msp */
COM1_MspInit(&hcom_uart[COM]);
#else
if(IsComMspCbValid[COM] == 0U)
{
if(BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
{
if (IsComMspCbValid[COM] == 0U) {
if (BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE) {
return BSP_ERROR_MSP_FAILURE;
}
}
#endif
if(MX_USART3_Init(&hcom_uart[COM], COM_Init) != HAL_OK)
{
if (MX_USART3_Init(&hcom_uart[COM], COM_Init) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
@ -445,16 +403,12 @@ int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_DeInit(COM_TypeDef COM)
{
int32_t BSP_COM_DeInit(COM_TypeDef COM) {
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
if (COM >= COMn) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
/* USART configuration */
hcom_uart[COM].Instance = COM_USART[COM];
@ -462,8 +416,7 @@ int32_t BSP_COM_DeInit(COM_TypeDef COM)
COM1_MspDeInit(&hcom_uart[COM]);
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
if(HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK)
{
if (HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
@ -475,11 +428,12 @@ int32_t BSP_COM_DeInit(COM_TypeDef COM)
* @brief Configures COM port.
* @param huart USART handle
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
* configuration information for the specified USART
* peripheral.
* @retval HAL error code
*/
__weak HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init)
{
__weak HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart,
MX_UART_InitTypeDef *COM_Init) {
/* USART configuration */
huart->Instance = COM_USART[COM1];
huart->Init.BaudRate = COM_Init->BaudRate;
@ -500,29 +454,23 @@ __weak HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitT
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
{
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM) {
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
if (COM >= COMn) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
/* Register default MspInit/MspDeInit Callback */
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, COM1_MspInit) != HAL_OK)
{
if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID,
COM1_MspInit) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, COM1_MspDeInit) != HAL_OK)
{
} else if (HAL_UART_RegisterCallback(&hcom_uart[COM],
HAL_UART_MSPDEINIT_CB_ID,
COM1_MspDeInit) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
} else {
IsComMspCbValid[COM] = 1U;
}
}
@ -538,29 +486,23 @@ int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
* @retval BSP status
*/
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback)
{
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM, BSP_COM_Cb_t *Callback) {
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
if (COM >= COMn) {
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
} else {
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
/* Register MspInit/MspDeInit Callbacks */
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, Callback->pMspInitCb) != HAL_OK)
{
if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID,
Callback->pMspInitCb) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
{
} else if (HAL_UART_RegisterCallback(&hcom_uart[COM],
HAL_UART_MSPDEINIT_CB_ID,
Callback->pMspDeInitCb) != HAL_OK) {
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
} else {
IsComMspCbValid[COM] = 1U;
}
}
@ -576,10 +518,8 @@ int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback)
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
{
if(COM_ActiveLogPort != COM)
{
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM) {
if (COM_ActiveLogPort != COM) {
COM_ActiveLogPort = COM;
}
return BSP_ERROR_NONE;
@ -588,13 +528,14 @@ int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
/**
* @brief Redirect console output to COM
*/
#ifdef __GNUC__
int __io_putchar (int ch)
#else
int fputc (int ch, FILE *f)
#endif /* __GNUC__ */
#ifdef __GNUC__
int __io_putchar(int ch)
#else
int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
{
HAL_UART_Transmit (&hcom_uart [COM_ActiveLogPort], (uint8_t *) &ch, 1, COM_POLL_TIMEOUT);
HAL_UART_Transmit(&hcom_uart[COM_ActiveLogPort], (uint8_t *)&ch, 1,
COM_POLL_TIMEOUT);
return ch;
}
#endif /* USE_COM_LOG */
@ -604,17 +545,15 @@ int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
* @}
*/
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Functions LOW LEVEL Private functions
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Private_Functions LOW LEVEL Private
* functions
* @{
*/
/**
* @brief Key EXTI line detection callbacks.
* @retval BSP status
*/
static void BUTTON_USER_EXTI_Callback(void)
{
BSP_PB_Callback(BUTTON_USER);
}
static void BUTTON_USER_EXTI_Callback(void) { BSP_PB_Callback(BUTTON_USER); }
#if (USE_BSP_COM_FEATURE > 0)
/**
@ -622,8 +561,7 @@ static void BUTTON_USER_EXTI_Callback(void)
* @param huart UART handle
* @retval BSP status
*/
static void COM1_MspInit(UART_HandleTypeDef *huart)
{
static void COM1_MspInit(UART_HandleTypeDef *huart) {
GPIO_InitTypeDef gpio_init_structure;
/* Prevent unused argument(s) compilation warning */
@ -656,8 +594,7 @@ static void COM1_MspInit(UART_HandleTypeDef *huart)
* @param huart UART handle
* @retval BSP status
*/
static void COM1_MspDeInit(UART_HandleTypeDef *huart)
{
static void COM1_MspDeInit(UART_HandleTypeDef *huart) {
GPIO_InitTypeDef gpio_init_structure;
/* Prevent unused argument(s) compilation warning */

View File

@ -1,2 +1 @@
target_sources(${TARGET_NAME} PRIVATE
)
target_sources(${TARGET_NAME} PRIVATE)

View File

@ -1,6 +1,2 @@
target_sources(${TARGET_NAME} PRIVATE
InitMission.cpp
ObjectFactory.cpp
printChar.c
)
target_sources(${TARGET_NAME} PRIVATE InitMission.cpp ObjectFactory.cpp
printChar.c)

View File

@ -1,58 +1,58 @@
#include "InitMission.h"
#include "example/utility/TaskCreation.h"
#include <OBSWConfig.h>
#include <mission/utility/TaskCreation.h>
#include <objects/systemObjectList.h>
#include <pollingsequence/pollingSequenceFactory.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
#include <fsfw/tasks/PeriodicTaskIF.h>
#include <fsfw/tasks/TaskFactory.h>
#include <objects/systemObjectList.h>
#include <pollingsequence/pollingSequenceFactory.h>
#include <rtems/rtems/support.h>
#include <rtems/score/heapinfo.h>
void InitMission::createTasks() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
#if OBSW_ADD_CORE_COMPONENTS == 1
/* TMTC Distribution */
PeriodicTaskIF* distributerTask = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *distributerTask = TaskFactory::instance()->createPeriodicTask(
"DIST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR);
}
result = distributerTask->addComponent(objects::PUS_DISTRIBUTOR);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS distributor", objects::CCSDS_DISTRIBUTOR);
}
result = distributerTask->addComponent(objects::TM_FUNNEL);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("TM funnel", objects::TM_FUNNEL);
}
PeriodicTaskIF* eventManagerTask = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *eventManagerTask =
TaskFactory::instance()->createPeriodicTask(
"EVENT_MGMT", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.1, nullptr);
result = eventManagerTask->addComponent(objects::EVENT_MANAGER);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("TM funnel", objects::TM_FUNNEL);
}
#if OBSW_ADD_LWIP_COMPONENTS == 1
/* UDP bridge */
PeriodicTaskIF* udpBridgeTask = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *udpBridgeTask = TaskFactory::instance()->createPeriodicTask(
"UDP_UNIX_BRIDGE", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
result = udpBridgeTask->addComponent(objects::UDP_BRIDGE);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("UDP bridge", objects::UDP_BRIDGE);
}
PeriodicTaskIF* udpPollingTask = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *udpPollingTask = TaskFactory::instance()->createPeriodicTask(
"UDP_POLLING", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.1, nullptr);
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("UDP polling task", objects::UDP_POLLING_TASK);
}
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
@ -60,84 +60,92 @@ void InitMission::createTasks() {
#if OBSW_ADD_PUS_STACK == 1
/* PUS Services */
PeriodicTaskIF* pusVerification = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *pusVerification = TaskFactory::instance()->createPeriodicTask(
"PUS_VERIF_1", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
if(result != HasReturnvaluesIF::RETURN_OK){
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 1", objects::PUS_SERVICE_1_VERIFICATION);
}
PeriodicTaskIF* pusHighPrio = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *pusHighPrio = TaskFactory::instance()->createPeriodicTask(
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, nullptr);
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
}
result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
if(result != HasReturnvaluesIF::RETURN_OK){
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 5", objects::PUS_SERVICE_5_EVENT_REPORTING);
}
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 9", objects::PUS_SERVICE_9_TIME_MGMT);
}
PeriodicTaskIF* pusMedPrio = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *pusMedPrio = TaskFactory::instance()->createPeriodicTask(
"PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, nullptr);
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 200", objects::PUS_SERVICE_200_MODE_MGMT);
}
PeriodicTaskIF* pusLowPrio = TaskFactory::instance()->createPeriodicTask(
PeriodicTaskIF *pusLowPrio = TaskFactory::instance()->createPeriodicTask(
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, nullptr);
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
if(result != HasReturnvaluesIF::RETURN_OK){
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("PUS 17", objects::PUS_SERVICE_17_TEST);
}
#endif /* OBSW_ADD_PUS_STACK == 1 */
#if OBSW_ADD_TASK_EXAMPLE == 1
FixedTimeslotTaskIF* timeslotDemoTask = TaskFactory::instance()->createFixedTimeslotTask(
FixedTimeslotTaskIF *timeslotDemoTask =
TaskFactory::instance()->createFixedTimeslotTask(
"PST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, nullptr);
result = pst::pollingSequenceExamples(timeslotDemoTask);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission::createTasks: Examples PST initialization failed!" << std::endl;
sif::error
<< "InitMission::createTasks: Examples PST initialization failed!"
<< std::endl;
#else
sif::printError("InitMission::createTasks: Examples PST initialization failed!\n");
sif::printError(
"InitMission::createTasks: Examples PST initialization failed!\n");
#endif
}
PeriodicTaskIF* readerTask = TaskFactory::instance()->
createPeriodicTask("READER_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
PeriodicTaskIF *readerTask = TaskFactory::instance()->createPeriodicTask(
"READER_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = readerTask->addComponent(objects::TEST_DUMMY_4);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("Demo Reader Task", objects::TEST_DUMMY_4);
}
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
FixedTimeslotTaskIF* testTimeslotTask = TaskFactory::instance()->createFixedTimeslotTask(
"PST_TEST_TASK", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
FixedTimeslotTaskIF *testTimeslotTask =
TaskFactory::instance()->createFixedTimeslotTask(
"PST_TEST_TASK", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0,
nullptr);
result = pst::pollingSequenceDevices(testTimeslotTask);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission::createTasks: Devices PST initialization failed!" << std::endl;
sif::error << "InitMission::createTasks: Devices PST initialization failed!"
<< std::endl;
#else
sif::printError("InitMission::createTasks: Devices PST initialization failed!\n");
sif::printError(
"InitMission::createTasks: Devices PST initialization failed!\n");
#endif
}
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
PeriodicTaskIF* testTask = TaskFactory::instance()->
createPeriodicTask("TEST", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
PeriodicTaskIF *testTask = TaskFactory::instance()->createPeriodicTask(
"TEST", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
result = testTask->addComponent(objects::TEST_TASK);
if(result != HasReturnvaluesIF::RETURN_OK) {
if (result != HasReturnvaluesIF::RETURN_OK) {
task::printInitError("Test Task", objects::TEST_TASK);
}
@ -180,17 +188,17 @@ void InitMission::createTasks() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tasks started.." << std::endl;
sif::info << "Remaining RTEMS heap: " << block.Stats.free_size << " bytes" << std::endl;
sif::info << "Remaining RTEMS heap: " << block.Stats.free_size << " bytes"
<< std::endl;
#else
sif::printInfo("Tasks started..\n");
sif::printInfo("Allocated RTEMS heap: %lu bytes\n", static_cast<unsigned long>(
block.Stats.size));
sif::printInfo("Remaining RTEMS heap: %lu bytes\n", static_cast<unsigned long>(
block.Stats.free_size));
if(failedAllocs > 0) {
sif::printWarning("%d allocations from RTEMS workspace failed!\n", failedAllocs);
sif::printInfo("Allocated RTEMS heap: %lu bytes\n",
static_cast<unsigned long>(block.Stats.size));
sif::printInfo("Remaining RTEMS heap: %lu bytes\n",
static_cast<unsigned long>(block.Stats.free_size));
if (failedAllocs > 0) {
sif::printWarning("%d allocations from RTEMS workspace failed!\n",
failedAllocs);
}
#endif
}

View File

@ -2,12 +2,12 @@
#include <OBSWConfig.h>
#include <objects/systemObjectList.h>
#include "example_common/stm32h7/networking/UdpTcLwIpPollingTask.h"
#include "example_common/stm32h7/networking/TmTcLwIpUdpBridge.h"
#include "example/core/GenericFactory.h"
#include "example/test/FsfwTestTask.h"
#include "example/utility/TmFunnel.h"
#include "example_common/stm32h7/STM32TestTask.h"
#include <test/TestTask.h>
#include <mission/utility/TmFunnel.h>
#include <mission/core/GenericFactory.h>
#include "example_common/stm32h7/networking/TmTcLwIpUdpBridge.h"
#include "example_common/stm32h7/networking/UdpTcLwIpPollingTask.h"
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/monitoring/MonitoringMessageContent.h>
@ -18,36 +18,33 @@
#include <rtems_lwip/rtems_lwip.h>
void ObjectFactory::produce(void* args) {
void ObjectFactory::produce(void *args) {
/* Located inside GenericFactory source file */
Factory::setStaticFrameworkObjectIds();
#if OBSW_ADD_CORE_COMPONENTS == 1
{
LocalPool::LocalPoolConfig poolCfg = {
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
};
{15, 32}, {10, 64}, {5, 128}, {1, 1024}};
new PoolManager(objects::TC_STORE, poolCfg);
}
{
LocalPool::LocalPoolConfig poolCfg = {
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
};
{15, 32}, {10, 64}, {5, 128}, {1, 1024}};
new PoolManager(objects::TM_STORE, poolCfg);
}
{
LocalPool::LocalPoolConfig poolCfg = {
{15, 32}, {10, 64}, {5, 128}, {1, 1024}
};
{15, 32}, {10, 64}, {5, 128}, {1, 1024}};
new PoolManager(objects::IPC_STORE, poolCfg);
}
#if OBSW_ADD_LWIP_COMPONENTS == 1
/* UDP Server */
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE,
objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE);
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE, objects::CCSDS_DISTRIBUTOR,
objects::TM_STORE, objects::TC_STORE);
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE,
rtems_lwip_get_netif(0));
#endif /* OBSW_ADD_LWIP_NETWORKING == 1 */

View File

@ -1,9 +1,8 @@
#ifndef MISSION_CORE_OBJECTFACTORY_H_
#define MISSION_CORE_OBJECTFACTORY_H_
namespace ObjectFactory {
void produce(void* args);
void produce(void *args);
};
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */

View File

@ -1,16 +1,14 @@
#include <OBSWConfig.h>
#include <stdbool.h>
#include <stdio.h>
#include <OBSWConfig.h>
#include <stm32h7xx_hal_uart.h>
#include <hal.h>
void printChar(const char* character, bool errStream) {
HAL_UART_Transmit(&stm32h7_usart3_instance.uart, (uint8_t*) character, 1,
void printChar(const char *character, bool errStream) {
HAL_UART_Transmit(&stm32h7_usart3_instance.uart, (uint8_t *)character, 1,
DEBUG_UART_MS_TIMEOUT);
/* Does not work for some reason */
//stm32h7_uart_polled_write(&stm32h7_usart3_instance.device, (int) character);
// stm32h7_uart_polled_write(&stm32h7_usart3_instance.device, (int)
// character);
}

View File

@ -1,11 +1,6 @@
target_sources(${TARGET_NAME}
PRIVATE
ipc/missionMessageTypes.cpp
pollingsequence/pollingSequenceFactory.cpp
)
target_sources(
${TARGET_NAME} PRIVATE ipc/missionMessageTypes.cpp
pollingsequence/pollingSequenceFactory.cpp)
# Add include paths for the executable
target_include_directories(${TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -4,11 +4,8 @@
#include <cstdint>
namespace devaddress {
enum devaddress: uint32_t {
L3GD20H = 1
};
enum devaddress : uint32_t { L3GD20H = 1 };
}
#endif /* BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_ */

View File

@ -4,8 +4,7 @@
#include "commonSubsystemIds.h"
namespace SUBSYSTEM_ID {
enum subsystemId: uint8_t {
};
enum subsystemId : uint8_t {};
}
#endif /* FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_ */

View File

@ -2,8 +2,8 @@
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/ipc/CommandMessageCleaner.h>
void messagetypes::clearMissionMessage(CommandMessage* message) {
switch((message->getMessageType())) {
void messagetypes::clearMissionMessage(CommandMessage *message) {
switch ((message->getMessageType())) {
default:
message->setCommand(CommandMessage::CMD_NONE);
break;

View File

@ -7,13 +7,14 @@ class CommandMessage;
namespace messagetypes {
/* First type must have number MESSAGE_TYPE::FW_MESSAGES_COUNT! */
/* Remember to add new message types to the clearMissionMessage function below! */
/* Remember to add new message types to the clearMissionMessage function below!
*/
enum MISSION_MESSAGE_TYPE {
COSTUM_MESSAGE = FW_MESSAGES_COUNT,
};
void clearMissionMessage(CommandMessage* message);
void clearMissionMessage(CommandMessage *message);
}
} // namespace messagetypes
#endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */

View File

@ -1,7 +1,7 @@
#ifndef FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#define FSFWCONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#include <commonSystemObjects.h>
#include "commonObjects.h"
namespace objects {
enum mission_objects {

View File

@ -12,22 +12,26 @@ ReturnValue_t pst::pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence) {
static_cast<void>(length);
#if OBSW_PERFORM_L3GD20H_TEST == 1
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length,
DeviceHandlerIF::GET_READ);
#endif
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!"
<< std::endl;
#else
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -9,7 +9,7 @@ class FixedTimeslotTaskIF;
namespace pst {
ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence);
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF* thisSequence);
}
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence);
} // namespace pst
#endif /* POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_ */

View File

@ -4,9 +4,7 @@
#include <commonConfig.h>
namespace CLASS_ID {
enum classIds: uint8_t {
};
enum classIds : uint8_t {};
}
#endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */

View File

@ -1,8 +1,8 @@
#ifndef FSFWCONFIG_TMTC_APID_H_
#define FSFWCONFIG_TMTC_APID_H_
#include <cstdint>
#include <commonConfig.h>
#include <cstdint>
namespace apid {
static const uint16_t APID = COMMON_APID;

View File

@ -3,5 +3,4 @@
#include <commonConfig.h>
#endif /* FSFWCONFIG_TMTC_PUSIDS_H_ */

View File

@ -3,12 +3,12 @@
extern int main();
/**
* Entry point for the RTEMS BSP after low level and RTEMS executive initialization.
* Entry point for the RTEMS BSP after low level and RTEMS executive
* initialization.
* @param argument
* @return
*/
rtems_task Init(rtems_task_argument argument) {
main();
return (void) rtems_task_delete( RTEMS_SELF );
return (void)rtems_task_delete(RTEMS_SELF);
}

View File

@ -1,9 +1,9 @@
#include "core/ObjectFactory.h"
#include "core/InitMission.h"
#include "stm32h7xx_nucleo.h"
#include "core/ObjectFactory.h"
#include "hardware_init.h"
#include "stm32h7xx_nucleo.h"
#include "example_common/mission/utility/compile_time.h"
#include "example/utility/compile_time.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
@ -34,19 +34,19 @@ int main() {
printf("\n\r%s-- FSFW Example (RTEMS) --\n", sif::ANSI_COLOR_RESET);
printf("-- Compiled for %s --\n", BOARD_NAME);
printf("-- Compiled on %s %s --\n\r",__DATE__, __TIME__);
printf("-- Compiled on %s %s --\n\r", __DATE__, __TIME__);
timeval timeToSet;
timeval timeToSet{};
timeToSet.tv_sec = UNIX_TIMESTAMP;
timeToSet.tv_usec = 0;
ReturnValue_t clockStatus = Clock::setClock(&timeToSet);
if(clockStatus != HasReturnvaluesIF::RETURN_OK) {
if (clockStatus != HasReturnvaluesIF::RETURN_OK) {
sif::printError("Clock configuration failed!\n");
}
else {
} else {
sif::printInfo("Clock configured successfully.\n");
}
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce,
nullptr);
ObjectManager::instance()->initialize();
InitMission::createTasks();

@ -1 +1 @@
Subproject commit 365c84c4f2be44cb14cb990c9d04769b1e69fbc2
Subproject commit 65b89ccd888df8f873b6dafb344efbc6692c0d45

@ -1 +1 @@
Subproject commit d34effb278c645fb6532db56521dd4d08eb0f4a6
Subproject commit ebb6a6d6a15d5b3a9bb3178b7fb02b70378ebfb1

2
fsfw

@ -1 +1 @@
Subproject commit c7cf8e710db2fbf99b37f263f064aabdddf379b5
Subproject commit 828ede80964f04ab94eda199415f16d0161fdb0e

32
scripts/auto-formatter.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
if [[ ! -f README.md ]]; then
cd ..
fi
folder_list=(
"./bsp_stm32h7_rtems"
"./example_common"
)
cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then
echo "Auto-formatting all CMakeLists.txt files"
${cmake_fmt} -i CMakeLists.txt
for dir in ${folder_list[@]}; do
find ${dir} ${file_selectors} | xargs ${cmake_fmt} -i
done
else
echo "No ${cmake_fmt} tool found, not formatting CMake files"
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 C/C++ files in ${dir} recursively"
find ${dir} ${file_selectors} | xargs ${cpp_format} --style=file -i
done
else
echo "No ${cpp_format} tool found, not formatting C++/C files"
fi