Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ option(ENABLE_FORMAT_CHECKS "Run format checks during configuration stage and ge
option(SKIP_FORMAT_REPORTS "Skip generation of format XML reports in build directory" ON)
option(ENABLE_STATIC_CHECKS "Configure a build tree for static code analysis" OFF)
option(ENABLE_COVERAGE "Build unit tests with coverage information to use with GCOV and LCOV" ON)
option(ENABLE_INTEGRATION_TESTING "Build for integration tests application" OFF)
option(INTEGRATION_TEST_ENTRY_PATH "Specify which integratin test entry to build default essentials" core/essentials)

## Include config file if it exists
include(kiso_defaults.cmake OPTIONAL)
Expand All @@ -17,14 +19,16 @@ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT ${ENABLE_TESTING})
include(cmake/ArmToolchain.cmake)
endif()

message("------------- KISO CONFIG -------------")
message("Building Kiso tests: ${ENABLE_TESTING}")
message(" ... with coverage: ${ENABLE_COVERAGE}")
message("Kiso Board Path: ${KISO_BOARD_PATH}")
message("Kiso OS: ${KISO_OS_LIB}")
message("Kiso Application Path: ${KISO_APPLICATION_PATH}")
message("Project Config Path: ${PROJECT_CONFIG_PATH}")
message("------------- KISO CONFIG -------------")
message("------------- KISO CONFIG --------------------------------")
message("Building Kiso tests: ${ENABLE_TESTING}")
message(" ... with coverage: ${ENABLE_COVERAGE}")
message("Building Kiso integration tests: ${ENABLE_INTEGRATION_TESTING}")
message(" with entry in: ${INTEGRATION_TEST_ENTRY_PATH}")
message("Kiso Board Path: ${KISO_BOARD_PATH}")
message("Kiso OS: ${KISO_OS_LIB}")
message("Kiso Application Path: ${KISO_APPLICATION_PATH}")
message("Project Config Path: ${PROJECT_CONFIG_PATH}")
message("------------- KISO CONFIG --------------------------------")

project (Kiso C)

Expand Down Expand Up @@ -89,7 +93,12 @@ if(${ENABLE_STATIC_CHECKS})
endif()

## Add application code
add_subdirectory(${KISO_APPLICATION_PATH} ${CMAKE_CURRENT_BINARY_DIR}/applications/${KISO_APPLICATION_NAME})
if(${ENABLE_INTEGRATION_TESTING})
add_subdirectory(testing/integration/test-executor)
add_subdirectory(${INTEGRATION_TEST_ENTRY_PATH})
else()
add_subdirectory(${KISO_APPLICATION_PATH} ${CMAKE_CURRENT_BINARY_DIR}/applications/${KISO_APPLICATION_NAME})
endif()

include(KisoLibsConfig)

Expand All @@ -98,6 +107,9 @@ include(KisoLibsConfig)
add_subdirectory(core/essentials)
add_subdirectory(core/utils)
add_subdirectory(core/connectivity/cellular)
if(${ENABLE_INTEGRATION_TESTING})
add_subdirectory(core/testing)
endif()

## Add thirdparty libs
add_subdirectory(thirdparty)
Expand Down
228 changes: 228 additions & 0 deletions boards/NucleoF767/bsp/source/bsp_api_GenericUart.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/********************************************************************************
* Copyright (c) 2010-2019 Robert Bosch GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial contribution
*
********************************************************************************/

#include "Kiso_BSP_GenericUart.h"

#if KISO_FEATURE_BSP_GENERIC_UART

#include "stm32/stm32f7/Kiso_MCU_STM32F7_UART_Handle.h"
#include "Kiso_HAL_Delay.h"
#include "BSP_NucleoF767.h"
#include "protected/gpio.h"

/*---------------------- MACROS DEFINITION --------------------------------------------------------------------------*/

#undef KISO_MODULE_ID
#define KISO_MODULE_ID MODULE_BSP_API_GENERICUART

#define UART_INT_PRIORITY UINT32_C(10)
#define UART_SUBPRIORITY UINT32_C(1)

/*---------------------- LOCAL FUNCTIONS DECLARATION ----------------------------------------------------------------*/

void USART2_IRQHandler(void);

/*---------------------- VARIABLES DECLARATION ----------------------------------------------------------------------*/

static uint8_t bspState = (uint8_t)BSP_STATE_INIT; /**< BSP State of the cellular module */

/**
* Static structure storing the UART handle for Test Interface
*/
static struct MCU_UART_S uartCtrlStruct =
{
.TxMode = KISO_HAL_TRANSFER_MODE_INTERRUPT,
.RxMode = KISO_HAL_TRANSFER_MODE_INTERRUPT,
.Datarate = 115200U,
.huart.Instance = USART2,
.huart.Init.BaudRate = 115200U,
.huart.Init.WordLength = UART_WORDLENGTH_8B,
.huart.Init.StopBits = UART_STOPBITS_1,
.huart.Init.Parity = UART_PARITY_NONE,
.huart.Init.Mode = UART_MODE_TX_RX,
.huart.Init.HwFlowCtl = UART_HWCONTROL_NONE,
.huart.Init.OverSampling = UART_OVERSAMPLING_16,
.huart.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE,
.huart.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT,
};
/*---------------------- EXPOSED FUNCTIONS IMPLEMENTATION -----------------------------------------------------------*/

/**
* See API interface for function documentation
* @retval RETCODE_OK in case of success.
* @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow connecting.
*/
Retcode_T BSP_GenericUart_Connect(uint32_t id)
{
KISO_UNUSED(id);
Retcode_T retcode = RETCODE_OK;

if (!(bspState & (uint8_t)BSP_STATE_TO_CONNECTED))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE);
}
if (RETCODE_OK == retcode)
{
/* IOSV bit MUST be set to access GPIO port G[2:15] */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_RCC_LPTIM1_CLK_ENABLE();

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* UART RX/TX GPIO pin configuration */
GPIO_OpenClockGate(GPIO_PORT_D, PIND_USART2_TX | PIND_USART2_RX);

GPIO_InitStruct.Pin = PIND_USART2_TX | PIND_USART2_RX;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;

HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

bspState = (uint8_t)BSP_STATE_CONNECTED;
}
return retcode;
}

/**
* See API interface for function documentation
* @retval RETCODE_OK in case of success.
* @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow enabling.
*/
Retcode_T BSP_GenericUart_Enable(uint32_t id)
{
KISO_UNUSED(id);
Retcode_T retcode = RETCODE_OK;

if (!(bspState & (uint8_t)BSP_STATE_TO_ENABLED))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE);
}
if (RETCODE_OK == retcode)
{
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_USART2_FORCE_RESET();
__HAL_RCC_USART2_RELEASE_RESET();
__GPIOD_CLK_ENABLE();
/* Configure the UART resource */
if (HAL_OK != HAL_UART_Init(&uartCtrlStruct.huart))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_INIT_FAILED);
}
}
if (RETCODE_OK == retcode)
{
NVIC_ClearPendingIRQ(USART2_IRQn);
HAL_NVIC_SetPriority(USART2_IRQn, UART_INT_PRIORITY, UART_SUBPRIORITY);
HAL_NVIC_EnableIRQ(USART2_IRQn);

bspState = (uint8_t)BSP_STATE_ENABLED;
}
return retcode;
}

/**
* See API interface for function documentation
* @retval RETCODE_OK in case of success.
* @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow disabling.
*/
Retcode_T BSP_GenericUart_Disable(uint32_t id)
{
KISO_UNUSED(id);
Retcode_T retcode = RETCODE_OK;

if (!(bspState & (uint8_t)BSP_STATE_TO_DISABLED))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE);
}
if (RETCODE_OK == retcode)
{
/* Disable interrupts and deactivate UART peripheral */
HAL_NVIC_DisableIRQ(USART2_IRQn);
/* Clear the pending interrupt */
HAL_NVIC_ClearPendingIRQ(USART2_IRQn);

if (HAL_OK != HAL_UART_DeInit(&uartCtrlStruct.huart))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_DEINIT_FAILED);
}
}
if (RETCODE_OK == retcode)
{
__USART2_CLK_DISABLE();
bspState = (uint8_t)BSP_STATE_DISABLED;
}
return retcode;
}

/**
* See API interface for function documentation
* @retval RETCODE_OK in case of success.
* @retval RETCODE_INCONSISTENT_STATE in case the module is not in a state to allow disconnecting.
*/
Retcode_T BSP_GenericUart_Disconnect(uint32_t id)
{
KISO_UNUSED(id);
Retcode_T retcode = RETCODE_OK;
if (!(bspState & (uint8_t)BSP_STATE_TO_DISCONNECTED))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_INCONSISTENT_STATE);
}
if (RETCODE_OK == retcode)
{
HAL_GPIO_DeInit(GPIOD, PIND_USART2_TX | PIND_USART2_RX);
GPIO_CloseClockGate(GPIO_PORT_D, PIND_USART2_TX | PIND_USART2_RX);
}
if (RETCODE_OK == retcode)
{
bspState = (uint8_t)BSP_STATE_DISCONNECTED;
}
return retcode;
}

/**
* See API interface for function documentation
* @return A pointer to the UART control structure
*/
HWHandle_T BSP_GenericUart_GetHandle(uint32_t id)
{
KISO_UNUSED(id);
return (HWHandle_T)&uartCtrlStruct;
}

/**
* This function is not in use.
*/
Retcode_T BSP_GenericUart_UserControl(uint32_t control, void *param)
{
KISO_UNUSED(control);
KISO_UNUSED(param);

return RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NOT_SUPPORTED);
}

/*---------------------- LOCAL FUNCTIONS IMPLEMENTATION -------------------------------------------------------------*/

/**
* Interrupt Service Routine handling USART2 IRQ. Forwards call to MCU Layer for handling.
*/
void USART2_IRQHandler(void)
{
if (uartCtrlStruct.IrqCallback)
{
uartCtrlStruct.IrqCallback((UART_T)&uartCtrlStruct);
}
}
#endif /* KISO_FEATURE_BSP_TEST_INTERFACE */
18 changes: 13 additions & 5 deletions boards/NucleoF767/bsp/source/bsp_api_testif.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ Retcode_T BSP_TestInterface_Connect(void)
}
if (RETCODE_OK == retcode)
{
GPIO_InitTypeDef BSP_GPIOInitStruct = {0};
/* IOSV bit MUST be set to access GPIO port G[2:15] */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_RCC_LPTIM1_CLK_ENABLE();

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* UART RX/TX GPIO pin configuration */
GPIO_OpenClockGate(GPIO_PORT_D, PIND_USART3_TX | PIND_USART3_RX);

GPIO_OpenClockGate(GPIO_PORT_D, PINB_DBG_TX | PINB_DBG_RX);
/* Configure RX TX as alternate function push pull */
Expand Down Expand Up @@ -146,7 +153,8 @@ Retcode_T BSP_TestInterface_Disable(void)
{
/* Disable interrupts and deactivate UART peripheral */
HAL_NVIC_DisableIRQ(USART3_IRQn);
if (HAL_OK != HAL_UART_DeInit(&testIf_UARTStruct.huart))

if (HAL_OK != HAL_UART_DeInit(&testIf_UARTStruct.huart))
{
retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_BSP_UART_DEINIT_FAILED);
}
Expand All @@ -173,8 +181,8 @@ Retcode_T BSP_TestInterface_Disconnect(void)
}
if (RETCODE_OK == retcode)
{
HAL_GPIO_DeInit(GPIOD, PINB_DBG_TX | PINB_DBG_RX);
GPIO_CloseClockGate(GPIO_PORT_D, PINB_DBG_TX | PINB_DBG_RX);
HAL_GPIO_DeInit(GPIOD, PIND_USART3_TX | PIND_USART3_RX);
GPIO_CloseClockGate(GPIO_PORT_D, PIND_USART3_TX | PIND_USART3_RX);
}
if (RETCODE_OK == retcode)
{
Expand Down Expand Up @@ -206,7 +214,7 @@ Retcode_T BSP_TestInterface_Control(uint32_t command, void *arg)
/*---------------------- LOCAL FUNCTIONS IMPLEMENTATION -------------------------------------------------------------*/

/**
* Interrupt Service Routine handling USART1 IRQ. Forwards call to MCU Layer for handling.
* Interrupt Service Routine handling USART3 IRQ. Forwards call to MCU Layer for handling.
*/
void USART3_IRQHandler(void)
{
Expand Down
5 changes: 2 additions & 3 deletions cmake/KisoLibsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ if(NOT KISO_STATIC_CONFIG)
configure_file(${ABS_BOARD_CONFIG_PATH}/${HEADER} ${DEST} COPYONLY)
endforeach(HEADER ${BOARD_CONF_FILES})

# Copy app-specific config files in intermediary directory
# APP_CONFIG_PATH is not required - only act if present
if(NOT APP_CONFIG_PATH)
message(STATUS "APP_CONFIG_PATH not set to a valid path. Not using application-specific configuration.")
Expand All @@ -99,7 +98,7 @@ if(NOT KISO_STATIC_CONFIG)
configure_file(${ABS_APP_CONFIG_PATH}/${HEADER} ${DEST} COPYONLY)
endforeach(HEADER ${USER_CONF_FILES})
endif(NOT EXISTS ${ABS_APP_CONFIG_PATH})
endif(NOT APP_CONFIG_PATH)
endif(NOT APP_CONFIG _PATH)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
endif(NOT APP_CONFIG _PATH)
endif(NOT APP_CONFIG_PATH)

typo, ...not dramatic, as the contents of endif(...) are ignored anyway :)

endif(NOT KISO_STATIC_CONFIG)

message(STATUS "Configuration headers merged in ${KISO_CONFIG_PATH}.")
message(STATUS "Configuration headers merged in ${KISO_CONFIG_PATH}.")
30 changes: 30 additions & 0 deletions core/essentials/test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.6)

project ("Essentials integration test entry" C ASM)

# the checks will be executed as it would be on the desired compile step
if(${ENABLE_STATIC_CHECKS})
set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY} --extra-arg=--target=arm-none-eabi --extra-arg=-mthumb --extra-arg=--sysroot=${CMAKE_SYSROOT} -checks=-*,readability-*,clang-analyzer-*,-clang-analyzer-cplusplus*)
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY} --extra-arg=--target=arm-none-eabi --extra-arg=--sysroot=${CMAKE_SYSROOT} -checks=-*,readability-*,clang-analyzer-*,-clang-analyzer-cplusplus*)
endif()

## Only compilable for a target
if(${CMAKE_CROSSCOMPILING})
file(GLOB TEST_ENTRY_SOURCES
source/*.c
)
add_library(testentry STATIC ${TEST_ENTRY_SOURCES})

target_include_directories(testentry
PRIVATE
source
)
# List of additional libs from board_config.cmake
target_link_libraries(testentry testing essentials ${KISO_BOARD_LIBS})
endif(${CMAKE_CROSSCOMPILING})

# Include the tests for this module
if(${CMAKE_TESTING_ENABLED})
#add_subdirectory(testentry/test)
endif()

7 changes: 7 additions & 0 deletions core/essentials/test/integration/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Integration Test Framework

It is composed by the following packages:
* Test-scheduler: Called in the continious integration. Define where the tests should be run.
* Test-coordinator: Coordiante the build and execution of the tests.
* Test-auxiliaries: List of elements that supports more complex tests (example: communication tests between a cloud service and a device)
* Test-executor: Software that will be flashed on the device under test.
Loading