run auto-formatter
This commit is contained in:
parent
9b986c1400
commit
ba13f6e022
128
CMakeLists.txt
128
CMakeLists.txt
@ -1,11 +1,10 @@
|
|||||||
################################################################################
|
# ##############################################################################
|
||||||
# CMake support for the Flight Software Framework
|
# CMake support for the Flight Software Framework Author: R. Mueller
|
||||||
# Author: R. Mueller
|
# ##############################################################################
|
||||||
################################################################################
|
|
||||||
|
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
# Pre-Project preparation
|
# Pre-Project preparation
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
# set(CMAKE_VERBOSE TRUE)
|
# set(CMAKE_VERBOSE TRUE)
|
||||||
@ -15,7 +14,9 @@ set(STM32_CMAKE_PATH "${CMAKE_SCRIPT_PATH}/stm32-cmake")
|
|||||||
set(STM32_CUBE_H7_PATH STM32CubeH7)
|
set(STM32_CUBE_H7_PATH STM32CubeH7)
|
||||||
set(STM32_TOOLCHAIN_PATH $ENV{STM32_TOOLCHAIN_PATH})
|
set(STM32_TOOLCHAIN_PATH $ENV{STM32_TOOLCHAIN_PATH})
|
||||||
set(TARGET_TRIPLET "arm-none-eabi")
|
set(TARGET_TRIPLET "arm-none-eabi")
|
||||||
set(FSFW_OSAL freertos CACHE STRING "OS for the FSFW")
|
set(FSFW_OSAL
|
||||||
|
freertos
|
||||||
|
CACHE STRING "OS for the FSFW")
|
||||||
set(STM32_ADD_NETWORKING_CODE ON)
|
set(STM32_ADD_NETWORKING_CODE ON)
|
||||||
set(FSFW_HAL_ADD_STM32H7 ON)
|
set(FSFW_HAL_ADD_STM32H7 ON)
|
||||||
|
|
||||||
@ -24,15 +25,14 @@ set(CMAKE_TOOLCHAIN_FILE ${STM32_CMAKE_PATH}/cmake/stm32_gcc.cmake)
|
|||||||
# Project Name
|
# Project Name
|
||||||
project(fsfw-example-stm32h7-freertos ASM C CXX)
|
project(fsfw-example-stm32h7-freertos ASM C CXX)
|
||||||
|
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
# Pre-Sources preparation
|
# Pre-Sources preparation
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
|
|
||||||
# Specify the C++ standard
|
# Specify the C++ standard
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
|
||||||
set(FSFW_OSAL "freertos")
|
set(FSFW_OSAL "freertos")
|
||||||
set(TGT_BSP "arm/stm32h743zi-nucleo")
|
set(TGT_BSP "arm/stm32h743zi-nucleo")
|
||||||
set(FREERTOS_NAMESPACE FreeRTOS::STM32::H7::M7)
|
set(FREERTOS_NAMESPACE FreeRTOS::STM32::H7::M7)
|
||||||
@ -52,29 +52,41 @@ set(BSP_NUCLEO_PATH "${BSP_PATH}/NUCLEO-H743ZI")
|
|||||||
set(BSP_NUCLEO_INC_PATH "${BSP_NUCLEO_PATH}/Inc")
|
set(BSP_NUCLEO_INC_PATH "${BSP_NUCLEO_PATH}/Inc")
|
||||||
|
|
||||||
# See stm32-cmake documentation for more information
|
# See stm32-cmake documentation for more information
|
||||||
find_package(CMSIS COMPONENTS STM32H743ZI STM32H7_M7 RTOS REQUIRED)
|
find_package(
|
||||||
find_package(FreeRTOS COMPONENTS STM32H7 ARM_CM7 REQUIRED)
|
CMSIS
|
||||||
find_package(HAL COMPONENTS STM32H7M7 STM32H743ZI RCC GPIO UART TIM CORTEX ETH SPI DMA REQUIRED)
|
COMPONENTS STM32H743ZI STM32H7_M7 RTOS
|
||||||
|
REQUIRED)
|
||||||
|
find_package(
|
||||||
|
FreeRTOS
|
||||||
|
COMPONENTS STM32H7 ARM_CM7
|
||||||
|
REQUIRED)
|
||||||
|
find_package(
|
||||||
|
HAL
|
||||||
|
COMPONENTS STM32H7M7
|
||||||
|
STM32H743ZI
|
||||||
|
RCC
|
||||||
|
GPIO
|
||||||
|
UART
|
||||||
|
TIM
|
||||||
|
CORTEX
|
||||||
|
ETH
|
||||||
|
SPI
|
||||||
|
DMA
|
||||||
|
REQUIRED)
|
||||||
find_package(LwIP REQUIRED)
|
find_package(LwIP REQUIRED)
|
||||||
|
|
||||||
# These need to be set for the FSFW so the sources are compiled with the ABI flags
|
# These need to be set for the FSFW so the sources are compiled with the ABI
|
||||||
# and to compile FreeRTOS first
|
# flags and to compile FreeRTOS first
|
||||||
set(LIB_OS_NAME ${FREERTOS_NAMESPACE}::ARM_CM7)
|
set(LIB_OS_NAME ${FREERTOS_NAMESPACE}::ARM_CM7)
|
||||||
# This target is used because a custom linker script is used
|
# This target is used because a custom linker script is used
|
||||||
set(CMSIS_LINK_TARGET CMSIS::STM32::H743xx::M7)
|
set(CMSIS_LINK_TARGET CMSIS::STM32::H743xx::M7)
|
||||||
set(FSFW_ADDITIONAL_LINK_LIBS ${CMSIS_LINK_TARGET})
|
set(FSFW_ADDITIONAL_LINK_LIBS ${CMSIS_LINK_TARGET})
|
||||||
set(FSFW_HAL_LINK_LIBS
|
set(FSFW_HAL_LINK_LIBS HAL::STM32::H7::M7::CORTEX ${CMSIS_LINK_TARGET}
|
||||||
HAL::STM32::H7::M7::CORTEX
|
${LIB_OS_NAME})
|
||||||
${CMSIS_LINK_TARGET}
|
|
||||||
${LIB_OS_NAME}
|
|
||||||
)
|
|
||||||
set(FSFW_HAL_ADDITIONAL_INC_PATHS ${BSP_NUCLEO_INC_PATH})
|
set(FSFW_HAL_ADDITIONAL_INC_PATHS ${BSP_NUCLEO_INC_PATH})
|
||||||
set(FSFW_ADDITIONAL_INC_PATHS
|
set(FSFW_ADDITIONAL_INC_PATHS
|
||||||
"${COMMON_CONFIG_PATH}"
|
"${COMMON_CONFIG_PATH}" "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
CACHE STRING "FSFW configuration paths")
|
||||||
CACHE STRING
|
|
||||||
"FSFW configuration paths"
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
|
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
|
||||||
configure_file(${FSFW_CONFIG_PATH}/FSFWConfig.h.in FSFWConfig.h)
|
configure_file(${FSFW_CONFIG_PATH}/FSFWConfig.h.in FSFWConfig.h)
|
||||||
@ -83,13 +95,8 @@ configure_file(${BSP_NUCLEO_PATH}/Inc/FreeRTOSConfig.h.in FreeRTOSConfig.h)
|
|||||||
configure_file(${BSP_NUCLEO_PATH}/Inc/lwipopts.h.in lwipopts.h)
|
configure_file(${BSP_NUCLEO_PATH}/Inc/lwipopts.h.in lwipopts.h)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(WARNING_FLAGS
|
set(WARNING_FLAGS -Wall -Wextra -Wimplicit-fallthrough=1
|
||||||
-Wall
|
-Wno-unused-parameter -Wno-psabi)
|
||||||
-Wextra
|
|
||||||
-Wimplicit-fallthrough=1
|
|
||||||
-Wno-unused-parameter
|
|
||||||
-Wno-psabi
|
|
||||||
)
|
|
||||||
|
|
||||||
set(FSFW_WARNING_FLAGS ${WARNING_FLAGS})
|
set(FSFW_WARNING_FLAGS ${WARNING_FLAGS})
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
@ -98,9 +105,9 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|||||||
add_compile_definitions(NOMINMAX)
|
add_compile_definitions(NOMINMAX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
# Executable and Sources
|
# Executable and Sources
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
add_executable(${TARGET_NAME})
|
add_executable(${TARGET_NAME})
|
||||||
@ -111,13 +118,14 @@ add_subdirectory(${FSFW_PATH})
|
|||||||
# add_subdirectory(${LIB_FSFW_HAL_PATH})
|
# add_subdirectory(${LIB_FSFW_HAL_PATH})
|
||||||
add_subdirectory(${COMMON_PATH})
|
add_subdirectory(${COMMON_PATH})
|
||||||
|
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
# Post-Sources preparation
|
# Post-Sources preparation
|
||||||
################################################################################
|
# ##############################################################################
|
||||||
|
|
||||||
# Add libraries for all sources.
|
# Add libraries for all sources.
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE
|
target_link_libraries(
|
||||||
${LIB_FSFW_NAME}
|
${TARGET_NAME}
|
||||||
|
PRIVATE ${LIB_FSFW_NAME}
|
||||||
# ${LIB_FSFW_HAL_NAME}
|
# ${LIB_FSFW_HAL_NAME}
|
||||||
${FREERTOS_NAMESPACE}::Heap::4
|
${FREERTOS_NAMESPACE}::Heap::4
|
||||||
${FREERTOS_NAMESPACE}::ARM_CM7
|
${FREERTOS_NAMESPACE}::ARM_CM7
|
||||||
@ -139,46 +147,34 @@ target_link_libraries(${TARGET_NAME} PRIVATE
|
|||||||
STM32::Nano::FloatScan
|
STM32::Nano::FloatScan
|
||||||
LwIP
|
LwIP
|
||||||
LwIP::IPv4
|
LwIP::IPv4
|
||||||
LwIP::NETIF
|
LwIP::NETIF)
|
||||||
)
|
|
||||||
|
|
||||||
# Add include paths for all sources.
|
# Add include paths for all sources.
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE
|
target_include_directories(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR} ${FSFW_CONFIG_PATH})
|
||||||
${FSFW_CONFIG_PATH}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
target_link_options(${TARGET_NAME} PRIVATE "-Wl,-Map=${TARGET_NAME}.map")
|
||||||
"-Wl,-Map=${TARGET_NAME}.map"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Remove unused sections.
|
# Remove unused sections.
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE "-ffunction-sections"
|
||||||
"-ffunction-sections"
|
"-fdata-sections")
|
||||||
"-fdata-sections"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Removed unused sections.
|
# Removed unused sections.
|
||||||
if(NOT FSFW_OSAL MATCHES rtems)
|
if(NOT FSFW_OSAL MATCHES rtems)
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
target_link_options(${TARGET_NAME} PRIVATE "-Wl,--gc-sections")
|
||||||
"-Wl,--gc-sections"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_VERBOSE)
|
if(CMAKE_VERBOSE)
|
||||||
message(STATUS "Warning flags: ${WARNING_FLAGS}")
|
message(STATUS "Warning flags: ${WARNING_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Compile options for all sources.
|
# Compile options for all sources.
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE ${WARNING_FLAGS})
|
||||||
${WARNING_FLAGS}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(TGT_BSP)
|
if(TGT_BSP)
|
||||||
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
|
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
|
||||||
@ -186,14 +182,12 @@ else()
|
|||||||
set(TARGET_STRING "Target BSP: Hosted")
|
set(TARGET_STRING "Target BSP: Hosted")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(CONCAT POST_BUILD_COMMENT
|
string(CONCAT POST_BUILD_COMMENT "Build directory: ${CMAKE_BINARY_DIR}\n"
|
||||||
"Build directory: ${CMAKE_BINARY_DIR}\n"
|
|
||||||
"Target OSAL: ${FSFW_OSAL}\n"
|
"Target OSAL: ${FSFW_OSAL}\n"
|
||||||
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
|
"Target Build Type: ${CMAKE_BUILD_TYPE}\n" "${TARGET_STRING}")
|
||||||
"${TARGET_STRING}"
|
|
||||||
)
|
|
||||||
|
|
||||||
stm32_add_linker_script(${TARGET_NAME} "PRIVATE" "${BSP_NUCLEO_PATH}/STM32H743ZITx_FLASH.ld")
|
stm32_add_linker_script(${TARGET_NAME} "PRIVATE"
|
||||||
|
"${BSP_NUCLEO_PATH}/STM32H743ZITx_FLASH.ld")
|
||||||
|
|
||||||
include(${CMAKE_SCRIPT_PATH}/BuildType.cmake)
|
include(${CMAKE_SCRIPT_PATH}/BuildType.cmake)
|
||||||
set_build_type()
|
set_build_type()
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE main.cpp)
|
||||||
main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE)
|
||||||
)
|
|
||||||
|
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
target_link_options(${TARGET_NAME} PRIVATE)
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(${TARGET_NAME} PRIVATE
|
target_compile_definitions(${TARGET_NAME}
|
||||||
BOARD_NAME="stm32h743zi-nucleo"
|
PRIVATE BOARD_NAME="stm32h743zi-nucleo")
|
||||||
)
|
|
||||||
|
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(utility)
|
add_subdirectory(utility)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
add_subdirectory(Src)
|
add_subdirectory(Src)
|
||||||
|
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE
|
target_include_directories(${TARGET_NAME} PRIVATE Inc)
|
||||||
Inc
|
|
||||||
)
|
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void ethernet_link_status_updated(struct netif *netif);
|
void ethernet_link_status_updated(struct netif *netif);
|
||||||
@ -72,6 +71,4 @@ void set_lwip_addresses(ip_addr_t* ipaddr, ip_addr_t* netmask, ip_addr_t* gw);
|
|||||||
|
|
||||||
#endif /* __APP_ETHERNET_H */
|
#endif /* __APP_ETHERNET_H */
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|
||||||
|
@ -5,6 +5,4 @@
|
|||||||
#define DEBUG_UART_MS_TIMEOUT 10
|
#define DEBUG_UART_MS_TIMEOUT 10
|
||||||
#define DEBUG_UART_BAUDRATE 115200
|
#define DEBUG_UART_BAUDRATE 115200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_STM32_BOARDS_NUCLEO_H743ZI_INC_BOARDCONFIG_H_ */
|
#endif /* BSP_STM32_BOARDS_NUCLEO_H743ZI_INC_BOARDCONFIG_H_ */
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <stm32h7xx_hal.h>
|
#include <stm32h7xx_hal.h>
|
||||||
#include <stm32h7xx_hal_gpio.h>
|
#include <stm32h7xx_hal_gpio.h>
|
||||||
|
@ -380,8 +380,7 @@ typedef int32_t (*lan8742_ReadReg_Func) (uint32_t, uint32_t, uint32_t *);
|
|||||||
typedef int32_t (*lan8742_WriteReg_Func)(uint32_t, uint32_t, uint32_t);
|
typedef int32_t (*lan8742_WriteReg_Func)(uint32_t, uint32_t, uint32_t);
|
||||||
typedef int32_t (*lan8742_GetTick_Func)(void);
|
typedef int32_t (*lan8742_GetTick_Func)(void);
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
lan8742_Init_Func Init;
|
lan8742_Init_Func Init;
|
||||||
lan8742_DeInit_Func DeInit;
|
lan8742_DeInit_Func DeInit;
|
||||||
lan8742_WriteReg_Func WriteReg;
|
lan8742_WriteReg_Func WriteReg;
|
||||||
@ -389,9 +388,7 @@ typedef struct
|
|||||||
lan8742_GetTick_Func GetTick;
|
lan8742_GetTick_Func GetTick;
|
||||||
} lan8742_IOCtx_t;
|
} lan8742_IOCtx_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t DevAddr;
|
uint32_t DevAddr;
|
||||||
uint32_t Is_Initialized;
|
uint32_t Is_Initialized;
|
||||||
lan8742_IOCtx_t IO;
|
lan8742_IOCtx_t IO;
|
||||||
@ -429,7 +426,6 @@ int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt);
|
|||||||
#endif
|
#endif
|
||||||
#endif /* LAN8742_H */
|
#endif /* LAN8742_H */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +62,8 @@ extern "C" {
|
|||||||
/* UDP remote connection port */
|
/* UDP remote connection port */
|
||||||
#define UDP_CLIENT_PORT 2008
|
#define UDP_CLIENT_PORT 2008
|
||||||
|
|
||||||
/*Static DEST IP ADDRESS: DEST_IP_ADDR0.DEST_IP_ADDR1.DEST_IP_ADDR2.DEST_IP_ADDR3 */
|
/*Static DEST IP ADDRESS:
|
||||||
|
* DEST_IP_ADDR0.DEST_IP_ADDR1.DEST_IP_ADDR2.DEST_IP_ADDR3 */
|
||||||
#define DEST_IP_ADDR0 ((uint8_t)169U)
|
#define DEST_IP_ADDR0 ((uint8_t)169U)
|
||||||
#define DEST_IP_ADDR1 ((uint8_t)254U)
|
#define DEST_IP_ADDR1 ((uint8_t)254U)
|
||||||
#define DEST_IP_ADDR2 ((uint8_t)39U)
|
#define DEST_IP_ADDR2 ((uint8_t)39U)
|
||||||
@ -92,5 +93,4 @@ extern "C" {
|
|||||||
|
|
||||||
#endif /* __MAIN_H */
|
#endif /* __MAIN_H */
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
@ -89,18 +89,22 @@
|
|||||||
#define HAL_USART_MODULE_ENABLED
|
#define HAL_USART_MODULE_ENABLED
|
||||||
#define HAL_WWDG_MODULE_ENABLED
|
#define HAL_WWDG_MODULE_ENABLED
|
||||||
|
|
||||||
/* ########################## Oscillator Values adaptation ####################*/
|
/* ########################## Oscillator Values adaptation
|
||||||
|
* ####################*/
|
||||||
/**
|
/**
|
||||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
* @brief Adjust the value of External High Speed oscillator (HSE) used in your
|
||||||
* This value is used by the RCC HAL module to compute the system frequency
|
* application. This value is used by the RCC HAL module to compute the system
|
||||||
* (when HSE is used as system clock source, directly or through the PLL).
|
* frequency (when HSE is used as system clock source, directly or through the
|
||||||
|
* PLL).
|
||||||
*/
|
*/
|
||||||
#if !defined(HSE_VALUE)
|
#if !defined(HSE_VALUE)
|
||||||
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
|
#define HSE_VALUE \
|
||||||
|
((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
|
||||||
#endif /* HSE_VALUE */
|
#endif /* HSE_VALUE */
|
||||||
|
|
||||||
#if !defined(HSE_STARTUP_TIMEOUT)
|
#if !defined(HSE_STARTUP_TIMEOUT)
|
||||||
#define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */
|
#define HSE_STARTUP_TIMEOUT \
|
||||||
|
((uint32_t)5000) /*!< Time out for HSE start up, in ms */
|
||||||
#endif /* HSE_STARTUP_TIMEOUT */
|
#endif /* HSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,44 +112,50 @@
|
|||||||
* This value is the default CSI value after Reset.
|
* This value is the default CSI value after Reset.
|
||||||
*/
|
*/
|
||||||
#if !defined(CSI_VALUE)
|
#if !defined(CSI_VALUE)
|
||||||
#define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
|
#define CSI_VALUE \
|
||||||
|
((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
|
||||||
#endif /* CSI_VALUE */
|
#endif /* CSI_VALUE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Internal High Speed oscillator (HSI) value.
|
* @brief Internal High Speed oscillator (HSI) value.
|
||||||
* This value is used by the RCC HAL module to compute the system frequency
|
* This value is used by the RCC HAL module to compute the system
|
||||||
* (when HSI is used as system clock source, directly or through the PLL).
|
* frequency (when HSI is used as system clock source, directly or through the
|
||||||
|
* PLL).
|
||||||
*/
|
*/
|
||||||
#if !defined(HSI_VALUE)
|
#if !defined(HSI_VALUE)
|
||||||
#define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
|
#define HSI_VALUE \
|
||||||
|
((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
|
||||||
#endif /* HSI_VALUE */
|
#endif /* HSI_VALUE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief External Low Speed oscillator (LSE) value.
|
* @brief External Low Speed oscillator (LSE) value.
|
||||||
* This value is used by the UART, RTC HAL module to compute the system frequency
|
* This value is used by the UART, RTC HAL module to compute the system
|
||||||
|
* frequency
|
||||||
*/
|
*/
|
||||||
#if !defined(LSE_VALUE)
|
#if !defined(LSE_VALUE)
|
||||||
#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
|
#define LSE_VALUE \
|
||||||
|
((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
|
||||||
#endif /* LSE_VALUE */
|
#endif /* LSE_VALUE */
|
||||||
|
|
||||||
|
|
||||||
#if !defined(LSE_STARTUP_TIMEOUT)
|
#if !defined(LSE_STARTUP_TIMEOUT)
|
||||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
|
#define LSE_STARTUP_TIMEOUT \
|
||||||
|
((uint32_t)5000) /*!< Time out for LSE start up, in ms */
|
||||||
#endif /* LSE_STARTUP_TIMEOUT */
|
#endif /* LSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
#if !defined(LSI_VALUE)
|
#if !defined(LSI_VALUE)
|
||||||
#define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/
|
#define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/
|
||||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz \
|
||||||
The real value may vary depending on the variations
|
The real value may vary depending on the variations \
|
||||||
in voltage and temperature.*/
|
in voltage and temperature.*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief External clock source for I2S peripheral
|
* @brief External clock source for I2S peripheral
|
||||||
* This value is used by the I2S HAL module to compute the I2S clock source
|
* This value is used by the I2S HAL module to compute the I2S clock
|
||||||
* frequency, this source is inserted directly through I2S_CKIN pad.
|
* source frequency, this source is inserted directly through I2S_CKIN pad.
|
||||||
*/
|
*/
|
||||||
#if !defined(EXTERNAL_CLOCK_VALUE)
|
#if !defined(EXTERNAL_CLOCK_VALUE)
|
||||||
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/
|
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in \
|
||||||
|
Hz*/
|
||||||
#endif /* EXTERNAL_CLOCK_VALUE */
|
#endif /* EXTERNAL_CLOCK_VALUE */
|
||||||
|
|
||||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||||
@ -161,7 +171,8 @@
|
|||||||
/* #define USE_SD_TRANSCEIVER 1U */ /*!< use uSD Transceiver */
|
/* #define USE_SD_TRANSCEIVER 1U */ /*!< use uSD Transceiver */
|
||||||
#define USE_SPI_CRC 1U /*!< use CRC in SPI */
|
#define USE_SPI_CRC 1U /*!< use CRC in SPI */
|
||||||
|
|
||||||
/* ########################### Ethernet Configuration ######################### */
|
/* ########################### Ethernet Configuration #########################
|
||||||
|
*/
|
||||||
#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
|
#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
|
||||||
#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
|
#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
|
||||||
|
|
||||||
@ -179,7 +190,6 @@
|
|||||||
*/
|
*/
|
||||||
/* #define USE_FULL_ASSERT 1 */
|
/* #define USE_FULL_ASSERT 1 */
|
||||||
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* @brief Include module's header file
|
* @brief Include module's header file
|
||||||
@ -301,7 +311,6 @@
|
|||||||
#include "stm32h7xx_hal_mdios.h"
|
#include "stm32h7xx_hal_mdios.h"
|
||||||
#endif /* HAL_MDIOS_MODULE_ENABLED */
|
#endif /* HAL_MDIOS_MODULE_ENABLED */
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAL_MMC_MODULE_ENABLED
|
#ifdef HAL_MMC_MODULE_ENABLED
|
||||||
#include "stm32h7xx_hal_mmc.h"
|
#include "stm32h7xx_hal_mmc.h"
|
||||||
#endif /* HAL_MMC_MODULE_ENABLED */
|
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||||
@ -408,7 +417,8 @@
|
|||||||
* If expr is true, it returns no value.
|
* If expr is true, it returns no value.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
#define assert_param(expr) \
|
||||||
|
((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void assert_failed(uint8_t *file, uint32_t line);
|
void assert_failed(uint8_t *file, uint32_t line);
|
||||||
#else
|
#else
|
||||||
@ -421,5 +431,4 @@
|
|||||||
|
|
||||||
#endif /* __STM32H7xx_HAL_CONF_H */
|
#endif /* __STM32H7xx_HAL_CONF_H */
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
@ -59,21 +59,24 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(USE_NUCLEO_144)
|
#if !defined(USE_NUCLEO_144)
|
||||||
#error "Board Pin number not defined!! Add USE_NUCLEO_144 define within stm32h7xx_nucleo_conf.h file"
|
#error \
|
||||||
|
"Board Pin number not defined!! Add USE_NUCLEO_144 define within stm32h7xx_nucleo_conf.h file"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined (USE_NUCLEO_H745ZI_Q) && !defined (USE_NUCLEO_H743ZI) && !defined (USE_NUCLEO_H743ZI2) &&\
|
#if !defined(USE_NUCLEO_H745ZI_Q) && !defined(USE_NUCLEO_H743ZI) && \
|
||||||
!defined (USE_NUCLEO_H7A3ZI_Q) && !defined (USE_NUCLEO_H723ZG)
|
!defined(USE_NUCLEO_H743ZI2) && !defined(USE_NUCLEO_H7A3ZI_Q) && \
|
||||||
#error "Board Part number not defined!! Add one of the following define within stm32h7xx_nucleo_conf.h file:\
|
!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"
|
USE_NUCLEO_H745ZI_Q, USE_NUCLEO_H743ZI, USE_NUCLEO_H743ZI2, USE_NUCLEO_H7A3ZI_Q, USE_NUCLEO_H723ZG"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
/** @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)
|
#if defined(USE_NUCLEO_H745ZI_Q) || defined(USE_NUCLEO_H743ZI2) || \
|
||||||
typedef enum
|
defined(USE_NUCLEO_H7A3ZI_Q) || defined(USE_NUCLEO_H723ZG)
|
||||||
{
|
typedef enum {
|
||||||
LED1 = 0,
|
LED1 = 0,
|
||||||
LED_GREEN = LED1,
|
LED_GREEN = LED1,
|
||||||
LED2 = 1,
|
LED2 = 1,
|
||||||
@ -83,8 +86,7 @@ typedef enum
|
|||||||
LEDn
|
LEDn
|
||||||
} Led_TypeDef;
|
} Led_TypeDef;
|
||||||
#else /* USE_NUCLEO_H743ZI */
|
#else /* USE_NUCLEO_H743ZI */
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
LED1 = 0,
|
LED1 = 0,
|
||||||
LED_GREEN = LED1,
|
LED_GREEN = LED1,
|
||||||
LED2 = 1,
|
LED2 = 1,
|
||||||
@ -95,55 +97,38 @@ typedef enum
|
|||||||
} Led_TypeDef;
|
} Led_TypeDef;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum
|
typedef enum { BUTTON_USER = 0U, BUTTONn } Button_TypeDef;
|
||||||
{
|
|
||||||
BUTTON_USER = 0U,
|
|
||||||
BUTTONn
|
|
||||||
}Button_TypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum { BUTTON_MODE_GPIO = 0, BUTTON_MODE_EXTI = 1 } ButtonMode_TypeDef;
|
||||||
{
|
|
||||||
BUTTON_MODE_GPIO = 0,
|
|
||||||
BUTTON_MODE_EXTI = 1
|
|
||||||
}ButtonMode_TypeDef;
|
|
||||||
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
#if (USE_BSP_COM_FEATURE > 0)
|
||||||
typedef enum
|
typedef enum { COM1 = 0U, COMn } COM_TypeDef;
|
||||||
{
|
|
||||||
COM1 = 0U,
|
|
||||||
COMn
|
|
||||||
}COM_TypeDef;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
COM_STOPBITS_1 = UART_STOPBITS_1,
|
COM_STOPBITS_1 = UART_STOPBITS_1,
|
||||||
COM_STOPBITS_2 = UART_STOPBITS_2,
|
COM_STOPBITS_2 = UART_STOPBITS_2,
|
||||||
} COM_StopBitsTypeDef;
|
} COM_StopBitsTypeDef;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
COM_PARITY_NONE = UART_PARITY_NONE,
|
COM_PARITY_NONE = UART_PARITY_NONE,
|
||||||
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
||||||
COM_PARITY_ODD = UART_PARITY_ODD,
|
COM_PARITY_ODD = UART_PARITY_ODD,
|
||||||
} COM_ParityTypeDef;
|
} COM_ParityTypeDef;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
||||||
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
||||||
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
||||||
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_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_7B = UART_WORDLENGTH_7B,
|
||||||
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
||||||
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
||||||
} COM_WordLengthTypeDef;
|
} COM_WordLengthTypeDef;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t BaudRate;
|
uint32_t BaudRate;
|
||||||
COM_WordLengthTypeDef WordLength;
|
COM_WordLengthTypeDef WordLength;
|
||||||
COM_StopBitsTypeDef StopBits;
|
COM_StopBitsTypeDef StopBits;
|
||||||
@ -152,8 +137,7 @@ typedef struct
|
|||||||
} COM_InitTypeDef;
|
} COM_InitTypeDef;
|
||||||
|
|
||||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
void (*pMspInitCb)(UART_HandleTypeDef *);
|
void (*pMspInitCb)(UART_HandleTypeDef *);
|
||||||
void (*pMspDeInitCb)(UART_HandleTypeDef *);
|
void (*pMspDeInitCb)(UART_HandleTypeDef *);
|
||||||
} BSP_COM_Cb_t;
|
} BSP_COM_Cb_t;
|
||||||
@ -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,13 @@ typedef struct
|
|||||||
#define STM32H7XX_NUCLEO_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
#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_SUB1 (0x03U) /*!< [23:16] sub1 version */
|
||||||
#define STM32H7XX_NUCLEO_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 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_RC (0x00U) /*!< [7:0] release candidate \
|
||||||
#define STM32H7XX_NUCLEO_BSP_VERSION ((STM32H7XX_NUCLEO_BSP_VERSION_MAIN << 24)\
|
*/
|
||||||
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|
#define STM32H7XX_NUCLEO_BSP_VERSION \
|
||||||
|(STM32H7XX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|
((STM32H7XX_NUCLEO_BSP_VERSION_MAIN << 24) | \
|
||||||
|(STM32H7XX_NUCLEO_BSP_VERSION_RC))
|
(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
|
/** @defgroup STM32H7XX_NUCLEO_LOW_LEVEL_LED LOW LEVEL LED
|
||||||
* @{
|
* @{
|
||||||
@ -192,7 +179,8 @@ typedef struct
|
|||||||
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||||
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
#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_PIN GPIO_PIN_1
|
||||||
#define LED2_GPIO_PORT GPIOE
|
#define LED2_GPIO_PORT GPIOE
|
||||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||||
@ -283,7 +271,8 @@ extern USART_TypeDef* COM_USART[];
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @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);
|
int32_t BSP_GetVersion(void);
|
||||||
@ -310,7 +299,8 @@ int32_t BSP_COM_SelectLogPort (COM_TypeDef COM);
|
|||||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
|
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 */
|
#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 */
|
#endif /* USE_BSP_COM_FEATURE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32h7xx_hal.h"
|
|
||||||
#include "stm32h743xx.h"
|
#include "stm32h743xx.h"
|
||||||
|
#include "stm32h7xx_hal.h"
|
||||||
|
|
||||||
/** @addtogroup BSP
|
/** @addtogroup BSP
|
||||||
* @{
|
* @{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(
|
||||||
freertos.c
|
${TARGET_NAME}
|
||||||
|
PRIVATE freertos.c
|
||||||
hardware_init.cpp
|
hardware_init.cpp
|
||||||
stm32h7xx_hal_timebase_tim.c
|
stm32h7xx_hal_timebase_tim.c
|
||||||
stm32h7xx_nucleo.c
|
stm32h7xx_nucleo.c
|
||||||
lan8742.c
|
lan8742.c
|
||||||
stm32h7xx_it.c
|
stm32h7xx_it.c
|
||||||
syscalls.c
|
syscalls.c)
|
||||||
)
|
|
||||||
|
@ -48,13 +48,11 @@
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
|
||||||
#include "portmacro.h"
|
#include "portmacro.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
void vRequestContextSwitchFromISR() {
|
void vRequestContextSwitchFromISR() { portYIELD_FROM_ISR(pdTRUE); }
|
||||||
portYIELD_FROM_ISR(pdTRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include "stm32h7xx_nucleo.h"
|
#include "stm32h7xx_nucleo.h"
|
||||||
|
|
||||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||||
#include <app_ethernet.h>
|
|
||||||
#include "example_common/stm32h7/networking/ethernetif.h"
|
|
||||||
#include "example_common/stm32h7/networking/app_ethernet.h"
|
#include "example_common/stm32h7/networking/app_ethernet.h"
|
||||||
#include <lwip/netif.h>
|
#include "example_common/stm32h7/networking/ethernetif.h"
|
||||||
|
#include <app_ethernet.h>
|
||||||
#include <lwip/init.h>
|
#include <lwip/init.h>
|
||||||
#include <lwip/ip_addr.h>
|
#include <lwip/ip_addr.h>
|
||||||
|
#include <lwip/netif.h>
|
||||||
#include <netif/ethernet.h>
|
#include <netif/ethernet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -55,8 +55,7 @@ void performHardwareInit() {
|
|||||||
|
|
||||||
BSP_Config();
|
BSP_Config();
|
||||||
}
|
}
|
||||||
void MX_USART3_UART_Init(uint32_t baudRate)
|
void MX_USART3_UART_Init(uint32_t baudRate) {
|
||||||
{
|
|
||||||
__HAL_RCC_USART3_CONFIG(RCC_USART3CLKSOURCE_HSI);
|
__HAL_RCC_USART3_CONFIG(RCC_USART3CLKSOURCE_HSI);
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
__HAL_RCC_USART3_CLK_ENABLE();
|
__HAL_RCC_USART3_CLK_ENABLE();
|
||||||
@ -83,7 +82,8 @@ void MX_USART3_UART_Init(uint32_t baudRate)
|
|||||||
// huart3.Init.TXFIFOThreshold = UART_TXFIFO_THRESHOLD_1_8;
|
// huart3.Init.TXFIFOThreshold = UART_TXFIFO_THRESHOLD_1_8;
|
||||||
// huart3.Init.RXFIFOThreshold = UART_RXFIFO_THRESHOLD_1_8;
|
// huart3.Init.RXFIFOThreshold = UART_RXFIFO_THRESHOLD_1_8;
|
||||||
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||||
// we can't do error handling (simple print out first) here because UART3 is our print interface
|
// we can't do error handling (simple print out first) here because UART3 is
|
||||||
|
// our print interface
|
||||||
result = HAL_UART_Init(&huart3);
|
result = HAL_UART_Init(&huart3);
|
||||||
if (result == HAL_OK) {
|
if (result == HAL_OK) {
|
||||||
// print_uart3("\rUART3 configured successfully !\r\n\0");
|
// print_uart3("\rUART3 configured successfully !\r\n\0");
|
||||||
@ -91,7 +91,6 @@ void MX_USART3_UART_Init(uint32_t baudRate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief System Clock Configuration
|
* @brief System Clock Configuration
|
||||||
* The system Clock is configured as follow :
|
* The system Clock is configured as follow :
|
||||||
@ -114,21 +113,23 @@ void MX_USART3_UART_Init(uint32_t baudRate)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SystemClock_Config(void)
|
void SystemClock_Config(void) {
|
||||||
{
|
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||||
HAL_StatusTypeDef ret = HAL_OK;
|
HAL_StatusTypeDef ret = HAL_OK;
|
||||||
|
|
||||||
/*!< Supply configuration update enable */
|
/*!< Supply configuration update enable */
|
||||||
MODIFY_REG(PWR->CR3, PWR_CR3_SCUEN, 0); // @suppress("Field cannot be resolved")
|
MODIFY_REG(PWR->CR3, PWR_CR3_SCUEN,
|
||||||
|
0); // @suppress("Field cannot be resolved")
|
||||||
|
|
||||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
/* The voltage scaling allows optimizing the power consumption when the device
|
||||||
clocked below the maximum system frequency, to update the voltage scaling value
|
is clocked below the maximum system frequency, to update the voltage scaling
|
||||||
regarding system frequency refer to product datasheet. */
|
value regarding system frequency refer to product datasheet. */
|
||||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); // @suppress("Field cannot be resolved")
|
__HAL_PWR_VOLTAGESCALING_CONFIG(
|
||||||
|
PWR_REGULATOR_VOLTAGE_SCALE1); // @suppress("Field cannot be resolved")
|
||||||
|
|
||||||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} // @suppress("Field cannot be resolved")
|
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {
|
||||||
|
} // @suppress("Field cannot be resolved")
|
||||||
|
|
||||||
/* Enable D2 domain SRAM3 Clock (0x30040000 AXI)*/
|
/* Enable D2 domain SRAM3 Clock (0x30040000 AXI)*/
|
||||||
__HAL_RCC_D2SRAM3_CLK_ENABLE(); // @suppress("Field cannot be resolved")
|
__HAL_RCC_D2SRAM3_CLK_ENABLE(); // @suppress("Field cannot be resolved")
|
||||||
@ -150,15 +151,15 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
|
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
|
||||||
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
|
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
|
||||||
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||||
if(ret != HAL_OK)
|
if (ret != HAL_OK) {
|
||||||
{
|
while (1)
|
||||||
while(1);
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Select PLL as system clock source and configure bus clocks dividers */
|
/* Select PLL as system clock source and configure bus clocks dividers */
|
||||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
|
RCC_ClkInitStruct.ClockType =
|
||||||
RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
|
(RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 |
|
||||||
RCC_CLOCKTYPE_D3PCLK1);
|
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
|
||||||
|
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
@ -168,15 +169,14 @@ void SystemClock_Config(void)
|
|||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
|
||||||
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
|
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
|
||||||
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
|
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
|
||||||
if(ret != HAL_OK)
|
if (ret != HAL_OK) {
|
||||||
{
|
while (1)
|
||||||
while(1);
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Configure the MPU attributes */
|
/*Configure the MPU attributes */
|
||||||
void MPU_Config(void)
|
void MPU_Config(void) {
|
||||||
{
|
|
||||||
MPU_Region_InitTypeDef MPU_InitStruct;
|
MPU_Region_InitTypeDef MPU_InitStruct;
|
||||||
|
|
||||||
/* Disable the MPU */
|
/* Disable the MPU */
|
||||||
@ -219,8 +219,7 @@ void MPU_Config(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*CPU L1-Cache enable*/
|
/*CPU L1-Cache enable*/
|
||||||
void CPU_CACHE_Enable(void)
|
void CPU_CACHE_Enable(void) {
|
||||||
{
|
|
||||||
/* Enable I-Cache */
|
/* Enable I-Cache */
|
||||||
SCB_EnableICache();
|
SCB_EnableICache();
|
||||||
|
|
||||||
@ -228,8 +227,7 @@ void CPU_CACHE_Enable(void)
|
|||||||
SCB_EnableDCache();
|
SCB_EnableDCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSP_Config(void)
|
void BSP_Config(void) {
|
||||||
{
|
|
||||||
BSP_LED_Init(LED1);
|
BSP_LED_Init(LED1);
|
||||||
BSP_LED_Init(LED2);
|
BSP_LED_Init(LED2);
|
||||||
BSP_LED_Init(LED3);
|
BSP_LED_Init(LED3);
|
||||||
@ -237,8 +235,7 @@ void BSP_Config(void)
|
|||||||
|
|
||||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||||
|
|
||||||
void Netif_Config(void)
|
void Netif_Config(void) {
|
||||||
{
|
|
||||||
ip_addr_t ipaddr;
|
ip_addr_t ipaddr;
|
||||||
ip_addr_t netmask;
|
ip_addr_t netmask;
|
||||||
ip_addr_t gw;
|
ip_addr_t gw;
|
||||||
@ -254,9 +251,9 @@ void Netif_Config(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* add the network interface */
|
/* add the network interface */
|
||||||
struct netif* netif_valid = netif_add(&gnetif, (ip4_addr_t*)&ipaddr,
|
struct netif *netif_valid =
|
||||||
(ip4_addr_t*)&netmask, (ip4_addr_t*) &gw, NULL, ðernetif_init,
|
netif_add(&gnetif, (ip4_addr_t *)&ipaddr, (ip4_addr_t *)&netmask,
|
||||||
ðernet_input);
|
(ip4_addr_t *)&gw, NULL, ðernetif_init, ðernet_input);
|
||||||
if (netif_valid == NULL) {
|
if (netif_valid == NULL) {
|
||||||
printf("Error: netif initialization failed!\n\r");
|
printf("Error: netif initialization failed!\n\r");
|
||||||
return;
|
return;
|
||||||
@ -272,4 +269,3 @@ void Netif_Config(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
||||||
|
|
||||||
|
@ -60,10 +60,8 @@
|
|||||||
* @retval LAN8742_STATUS_OK if OK
|
* @retval LAN8742_STATUS_OK if OK
|
||||||
* LAN8742_STATUS_ERROR if missing mandatory function
|
* LAN8742_STATUS_ERROR if missing mandatory function
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
|
int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx) {
|
||||||
{
|
if (!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick) {
|
||||||
if(!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick)
|
|
||||||
{
|
|
||||||
return LAN8742_STATUS_ERROR;
|
return LAN8742_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,15 +83,12 @@ int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
|
|||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
* LAN8742_STATUS_RESET_TIMEOUT if cannot perform a software reset
|
* LAN8742_STATUS_RESET_TIMEOUT if cannot perform a software reset
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_Init(lan8742_Object_t *pObj)
|
int32_t LAN8742_Init(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t tickstart = 0, regvalue = 0, addr = 0;
|
uint32_t tickstart = 0, regvalue = 0, addr = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->Is_Initialized == 0)
|
if (pObj->Is_Initialized == 0) {
|
||||||
{
|
if (pObj->IO.Init != 0) {
|
||||||
if(pObj->IO.Init != 0)
|
|
||||||
{
|
|
||||||
/* GPIO and Clocks initialization */
|
/* GPIO and Clocks initialization */
|
||||||
pObj->IO.Init();
|
pObj->IO.Init();
|
||||||
}
|
}
|
||||||
@ -102,77 +97,60 @@ int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
|
|||||||
pObj->DevAddr = LAN8742_MAX_DEV_ADDR + 1;
|
pObj->DevAddr = LAN8742_MAX_DEV_ADDR + 1;
|
||||||
|
|
||||||
/* Get the device address from special mode register */
|
/* Get the device address from special mode register */
|
||||||
for(addr = 0; addr <= LAN8742_MAX_DEV_ADDR; addr ++)
|
for (addr = 0; addr <= LAN8742_MAX_DEV_ADDR; addr++) {
|
||||||
{
|
if (pObj->IO.ReadReg(addr, LAN8742_SMR, ®value) < 0) {
|
||||||
if(pObj->IO.ReadReg(addr, LAN8742_SMR, ®value) < 0)
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
/* Can't read from this device address
|
/* Can't read from this device address
|
||||||
continue with next address */
|
continue with next address */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((regvalue & LAN8742_SMR_PHY_ADDR) == addr)
|
if ((regvalue & LAN8742_SMR_PHY_ADDR) == addr) {
|
||||||
{
|
|
||||||
pObj->DevAddr = addr;
|
pObj->DevAddr = addr;
|
||||||
status = LAN8742_STATUS_OK;
|
status = LAN8742_STATUS_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pObj->DevAddr > LAN8742_MAX_DEV_ADDR)
|
if (pObj->DevAddr > LAN8742_MAX_DEV_ADDR) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_ADDRESS_ERROR;
|
status = LAN8742_STATUS_ADDRESS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if device address is matched */
|
/* if device address is matched */
|
||||||
if(status == LAN8742_STATUS_OK)
|
if (status == LAN8742_STATUS_OK) {
|
||||||
{
|
|
||||||
/* set a software reset */
|
/* set a software reset */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_SOFT_RESET) >= 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR,
|
||||||
{
|
LAN8742_BCR_SOFT_RESET) >= 0) {
|
||||||
/* get software reset status */
|
/* get software reset status */
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) >= 0) {
|
||||||
{
|
|
||||||
tickstart = pObj->IO.GetTick();
|
tickstart = pObj->IO.GetTick();
|
||||||
|
|
||||||
/* wait until software reset is done or timeout occured */
|
/* wait until software reset is done or timeout occured */
|
||||||
while(regvalue & LAN8742_BCR_SOFT_RESET)
|
while (regvalue & LAN8742_BCR_SOFT_RESET) {
|
||||||
{
|
if ((pObj->IO.GetTick() - tickstart) <= LAN8742_SW_RESET_TO) {
|
||||||
if((pObj->IO.GetTick() - tickstart) <= LAN8742_SW_RESET_TO)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) < 0) {
|
||||||
{
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, ®value) < 0)
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_RESET_TIMEOUT;
|
status = LAN8742_STATUS_RESET_TIMEOUT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status == LAN8742_STATUS_OK)
|
if (status == LAN8742_STATUS_OK) {
|
||||||
{
|
|
||||||
tickstart = pObj->IO.GetTick();
|
tickstart = pObj->IO.GetTick();
|
||||||
|
|
||||||
/* Wait for 2s to perform initialization */
|
/* Wait for 2s to perform initialization */
|
||||||
while((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO)
|
while ((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
pObj->Is_Initialized = 1;
|
pObj->Is_Initialized = 1;
|
||||||
}
|
}
|
||||||
@ -185,14 +163,10 @@ int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
|
|||||||
* @param pObj: device object LAN8742_Object_t.
|
* @param pObj: device object LAN8742_Object_t.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_DeInit(lan8742_Object_t *pObj)
|
int32_t LAN8742_DeInit(lan8742_Object_t *pObj) {
|
||||||
{
|
if (pObj->Is_Initialized) {
|
||||||
if(pObj->Is_Initialized)
|
if (pObj->IO.DeInit != 0) {
|
||||||
{
|
if (pObj->IO.DeInit() < 0) {
|
||||||
if(pObj->IO.DeInit != 0)
|
|
||||||
{
|
|
||||||
if(pObj->IO.DeInit() < 0)
|
|
||||||
{
|
|
||||||
return LAN8742_STATUS_ERROR;
|
return LAN8742_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,23 +184,18 @@ int32_t LAN8742_DeInit(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj)
|
int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval &= ~LAN8742_BCR_POWER_DOWN;
|
readval &= ~LAN8742_BCR_POWER_DOWN;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,23 +209,18 @@ int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj)
|
int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval |= LAN8742_BCR_POWER_DOWN;
|
readval |= LAN8742_BCR_POWER_DOWN;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,23 +234,18 @@ int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj)
|
int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval |= LAN8742_BCR_AUTONEGO_EN;
|
readval |= LAN8742_BCR_AUTONEGO_EN;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,80 +265,61 @@ int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj)
|
int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
|
|
||||||
/* Read Status register */
|
/* Read Status register */
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_READ_ERROR;
|
return LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read Status register again */
|
/* Read Status register again */
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_READ_ERROR;
|
return LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((readval & LAN8742_BSR_LINK_STATUS) == 0)
|
if ((readval & LAN8742_BSR_LINK_STATUS) == 0) {
|
||||||
{
|
|
||||||
/* Return Link Down status */
|
/* Return Link Down status */
|
||||||
return LAN8742_STATUS_LINK_DOWN;
|
return LAN8742_STATUS_LINK_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check Auto negotiaition */
|
/* Check Auto negotiaition */
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) < 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) < 0) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_READ_ERROR;
|
return LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((readval & LAN8742_BCR_AUTONEGO_EN) != LAN8742_BCR_AUTONEGO_EN)
|
if ((readval & LAN8742_BCR_AUTONEGO_EN) != LAN8742_BCR_AUTONEGO_EN) {
|
||||||
{
|
if (((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT) &&
|
||||||
if(((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT) && ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE))
|
((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE)) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
||||||
}
|
} else if ((readval & LAN8742_BCR_SPEED_SELECT) ==
|
||||||
else if ((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT)
|
LAN8742_BCR_SPEED_SELECT) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
||||||
}
|
} else if ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE) {
|
||||||
else if ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE)
|
|
||||||
{
|
|
||||||
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
||||||
}
|
}
|
||||||
}
|
} else /* Auto Nego enabled */
|
||||||
else /* Auto Nego enabled */
|
|
||||||
{
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_PHYSCSR, &readval) < 0)
|
|
||||||
{
|
{
|
||||||
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_PHYSCSR, &readval) < 0) {
|
||||||
return LAN8742_STATUS_READ_ERROR;
|
return LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if auto nego not done */
|
/* Check if auto nego not done */
|
||||||
if((readval & LAN8742_PHYSCSR_AUTONEGO_DONE) == 0)
|
if ((readval & LAN8742_PHYSCSR_AUTONEGO_DONE) == 0) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_AUTONEGO_NOTDONE;
|
return LAN8742_STATUS_AUTONEGO_NOTDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_FD)
|
if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_FD) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
return LAN8742_STATUS_100MBITS_FULLDUPLEX;
|
||||||
}
|
} else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) ==
|
||||||
else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_HD)
|
LAN8742_PHYSCSR_100BTX_HD) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
return LAN8742_STATUS_100MBITS_HALFDUPLEX;
|
||||||
}
|
} else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) ==
|
||||||
else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_10BT_FD)
|
LAN8742_PHYSCSR_10BT_FD) {
|
||||||
{
|
|
||||||
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
return LAN8742_STATUS_10MBITS_FULLDUPLEX;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
return LAN8742_STATUS_10MBITS_HALFDUPLEX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,44 +338,32 @@ int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState)
|
int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState) {
|
||||||
{
|
|
||||||
uint32_t bcrvalue = 0;
|
uint32_t bcrvalue = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &bcrvalue) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &bcrvalue) >= 0) {
|
||||||
{
|
|
||||||
/* Disable link config (Auto nego, speed and duplex) */
|
/* Disable link config (Auto nego, speed and duplex) */
|
||||||
bcrvalue &= ~(LAN8742_BCR_AUTONEGO_EN | LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
|
bcrvalue &= ~(LAN8742_BCR_AUTONEGO_EN | LAN8742_BCR_SPEED_SELECT |
|
||||||
|
LAN8742_BCR_DUPLEX_MODE);
|
||||||
|
|
||||||
if(LinkState == LAN8742_STATUS_100MBITS_FULLDUPLEX)
|
if (LinkState == LAN8742_STATUS_100MBITS_FULLDUPLEX) {
|
||||||
{
|
|
||||||
bcrvalue |= (LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
|
bcrvalue |= (LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
|
||||||
}
|
} else if (LinkState == LAN8742_STATUS_100MBITS_HALFDUPLEX) {
|
||||||
else if (LinkState == LAN8742_STATUS_100MBITS_HALFDUPLEX)
|
|
||||||
{
|
|
||||||
bcrvalue |= LAN8742_BCR_SPEED_SELECT;
|
bcrvalue |= LAN8742_BCR_SPEED_SELECT;
|
||||||
}
|
} else if (LinkState == LAN8742_STATUS_10MBITS_FULLDUPLEX) {
|
||||||
else if (LinkState == LAN8742_STATUS_10MBITS_FULLDUPLEX)
|
|
||||||
{
|
|
||||||
bcrvalue |= LAN8742_BCR_DUPLEX_MODE;
|
bcrvalue |= LAN8742_BCR_DUPLEX_MODE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Wrong link status parameter */
|
/* Wrong link status parameter */
|
||||||
status = LAN8742_STATUS_ERROR;
|
status = LAN8742_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status == LAN8742_STATUS_OK)
|
if (status == LAN8742_STATUS_OK) {
|
||||||
{
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, bcrvalue) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, bcrvalue) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,23 +378,18 @@ int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj)
|
int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval |= LAN8742_BCR_LOOPBACK;
|
readval |= LAN8742_BCR_LOOPBACK;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,23 +403,18 @@ int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj)
|
int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval &= ~LAN8742_BCR_LOOPBACK;
|
readval &= ~LAN8742_BCR_LOOPBACK;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,23 +438,18 @@ int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval |= Interrupt;
|
readval |= Interrupt;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,23 +473,18 @@ int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
|||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
* LAN8742_STATUS_WRITE_ERROR if connot write to register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0) {
|
||||||
{
|
|
||||||
readval &= ~Interrupt;
|
readval &= ~Interrupt;
|
||||||
|
|
||||||
/* Apply configuration */
|
/* Apply configuration */
|
||||||
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
|
if (pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_WRITE_ERROR;
|
status = LAN8742_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,13 +507,11 @@ int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
|||||||
* @retval LAN8742_STATUS_OK if OK
|
* @retval LAN8742_STATUS_OK if OK
|
||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = LAN8742_STATUS_OK;
|
int32_t status = LAN8742_STATUS_OK;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) < 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) < 0) {
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,17 +535,13 @@ int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt)
|
|||||||
* 0 IT flag is RESET
|
* 0 IT flag is RESET
|
||||||
* LAN8742_STATUS_READ_ERROR if connot read register
|
* LAN8742_STATUS_READ_ERROR if connot read register
|
||||||
*/
|
*/
|
||||||
int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt)
|
int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt) {
|
||||||
{
|
|
||||||
uint32_t readval = 0;
|
uint32_t readval = 0;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
|
|
||||||
if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) >= 0)
|
if (pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) >= 0) {
|
||||||
{
|
|
||||||
status = ((readval & Interrupt) == Interrupt);
|
status = ((readval & Interrupt) == Interrupt);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = LAN8742_STATUS_READ_ERROR;
|
status = LAN8742_STATUS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,37 +4,40 @@
|
|||||||
* @author MCD Application Team
|
* @author MCD Application Team
|
||||||
* @brief HAL time base based on the hardware TIM.
|
* @brief HAL time base based on the hardware TIM.
|
||||||
*
|
*
|
||||||
* This file overrides the native HAL time base functions (defined as weak)
|
* This file overrides the native HAL time base functions (defined as
|
||||||
* the TIM time base:
|
*weak) the TIM time base:
|
||||||
* + Intializes the TIM peripheral generate a Period elapsed Event each 1ms
|
* + Intializes the TIM peripheral generate a Period elapsed Event
|
||||||
* + HAL_IncTick is called inside HAL_TIM_PeriodElapsedCallback ie each 1ms
|
*each 1ms
|
||||||
|
* + HAL_IncTick is called inside HAL_TIM_PeriodElapsedCallback ie
|
||||||
|
*each 1ms
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* are permitted provided that the following conditions are met:
|
*modification, are permitted provided that the following conditions are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
*notice, this list of conditions and the following disclaimer in the
|
||||||
* and/or other materials provided with the distribution.
|
*documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
*ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
*LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
*CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
*SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
*INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
*CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
*ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
*POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -55,13 +58,13 @@ void TIM6_DAC_IRQHandler(void);
|
|||||||
* @brief This function configures the TIM6 as a time base source.
|
* @brief This function configures the TIM6 as a time base source.
|
||||||
* The time source is configured to have 1ms time base with a dedicated
|
* The time source is configured to have 1ms time base with a dedicated
|
||||||
* Tick interrupt priority.
|
* Tick interrupt priority.
|
||||||
* @note This function is called automatically at the beginning of program after
|
* @note This function is called automatically at the beginning of program
|
||||||
* reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
|
* after reset by HAL_Init() or at any time when clock is configured, by
|
||||||
|
* HAL_RCC_ClockConfig().
|
||||||
* @param TickPriority: Tick interrupt priority.
|
* @param TickPriority: Tick interrupt priority.
|
||||||
* @retval HAL status
|
* @retval HAL status
|
||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
|
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
{
|
|
||||||
RCC_ClkInitTypeDef clkconfig;
|
RCC_ClkInitTypeDef clkconfig;
|
||||||
uint32_t uwTimclock, uwAPB1Prescaler = 0U;
|
uint32_t uwTimclock, uwAPB1Prescaler = 0U;
|
||||||
uint32_t uwPrescalerValue = 0U;
|
uint32_t uwPrescalerValue = 0U;
|
||||||
@ -83,12 +86,9 @@ HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
|
|||||||
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
|
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
|
||||||
|
|
||||||
/* Compute TIM6 clock */
|
/* Compute TIM6 clock */
|
||||||
if (uwAPB1Prescaler == RCC_HCLK_DIV1)
|
if (uwAPB1Prescaler == RCC_HCLK_DIV1) {
|
||||||
{
|
|
||||||
uwTimclock = HAL_RCC_GetPCLK1Freq();
|
uwTimclock = HAL_RCC_GetPCLK1Freq();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uwTimclock = 2 * HAL_RCC_GetPCLK1Freq();
|
uwTimclock = 2 * HAL_RCC_GetPCLK1Freq();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +108,7 @@ HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
|
|||||||
TimHandle.Init.Prescaler = uwPrescalerValue;
|
TimHandle.Init.Prescaler = uwPrescalerValue;
|
||||||
TimHandle.Init.ClockDivision = 0;
|
TimHandle.Init.ClockDivision = 0;
|
||||||
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
if(HAL_TIM_Base_Init(&TimHandle) == HAL_OK)
|
if (HAL_TIM_Base_Init(&TimHandle) == HAL_OK) {
|
||||||
{
|
|
||||||
/* Start the TIM time Base generation in interrupt mode */
|
/* Start the TIM time Base generation in interrupt mode */
|
||||||
return HAL_TIM_Base_Start_IT(&TimHandle);
|
return HAL_TIM_Base_Start_IT(&TimHandle);
|
||||||
}
|
}
|
||||||
@ -124,8 +123,7 @@ HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_SuspendTick(void)
|
void HAL_SuspendTick(void) {
|
||||||
{
|
|
||||||
/* Disable TIM6 update Interrupt */
|
/* Disable TIM6 update Interrupt */
|
||||||
__HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
__HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
||||||
}
|
}
|
||||||
@ -136,8 +134,7 @@ void HAL_SuspendTick(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_ResumeTick(void)
|
void HAL_ResumeTick(void) {
|
||||||
{
|
|
||||||
/* Enable TIM6 Update interrupt */
|
/* Enable TIM6 Update interrupt */
|
||||||
__HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
__HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
||||||
}
|
}
|
||||||
@ -150,19 +147,13 @@ void HAL_ResumeTick(void)
|
|||||||
* @param htim : TIM handle
|
* @param htim : TIM handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { HAL_IncTick(); }
|
||||||
{
|
|
||||||
HAL_IncTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM interrupt request.
|
* @brief This function handles TIM interrupt request.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void TIM6_DAC_IRQHandler(void)
|
void TIM6_DAC_IRQHandler(void) { HAL_TIM_IRQHandler(&TimHandle); }
|
||||||
{
|
|
||||||
HAL_TIM_IRQHandler(&TimHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
@ -8,34 +8,35 @@
|
|||||||
*
|
*
|
||||||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* are permitted provided that the following conditions are met:
|
*modification, are permitted provided that the following conditions are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
*notice, this list of conditions and the following disclaimer in the
|
||||||
* and/or other materials provided with the distribution.
|
*documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
*ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
*LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
*CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
*SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
*INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
*CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
*ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
*POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "OBSWConfig.h"
|
|
||||||
#include "stm32h7xx_it.h"
|
#include "stm32h7xx_it.h"
|
||||||
|
#include "OBSWConfig.h"
|
||||||
|
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -61,20 +62,16 @@ void ETH_IRQHandler(void);
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void NMI_Handler(void)
|
void NMI_Handler(void) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Hard Fault exception.
|
* @brief This function handles Hard Fault exception.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void) {
|
||||||
{
|
|
||||||
/* Go to infinite loop when Hard Fault exception occurs */
|
/* Go to infinite loop when Hard Fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,11 +80,9 @@ void HardFault_Handler(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void MemManage_Handler(void)
|
void MemManage_Handler(void) {
|
||||||
{
|
|
||||||
/* Go to infinite loop when Memory Manage exception occurs */
|
/* Go to infinite loop when Memory Manage exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,11 +91,9 @@ void MemManage_Handler(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void BusFault_Handler(void)
|
void BusFault_Handler(void) {
|
||||||
{
|
|
||||||
/* Go to infinite loop when Bus Fault exception occurs */
|
/* Go to infinite loop when Bus Fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,34 +102,25 @@ void BusFault_Handler(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void UsageFault_Handler(void)
|
void UsageFault_Handler(void) {
|
||||||
{
|
|
||||||
/* Go to infinite loop when Usage Fault exception occurs */
|
/* Go to infinite loop when Usage Fault exception occurs */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Debug Monitor exception.
|
* @brief This function handles Debug Monitor exception.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void DebugMon_Handler(void)
|
void DebugMon_Handler(void) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles SysTick Handler.
|
* @brief This function handles SysTick Handler.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SysTick_Handler(void)
|
void SysTick_Handler(void) { osSystickHandler(); }
|
||||||
{
|
|
||||||
osSystickHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* STM32H7xx Peripherals Interrupt Handlers */
|
/* STM32H7xx Peripherals Interrupt Handlers */
|
||||||
@ -149,14 +133,12 @@ void SysTick_Handler(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void ETH_IRQHandler(void)
|
void ETH_IRQHandler(void) {
|
||||||
{
|
|
||||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||||
HAL_ETH_IRQHandler(&EthHandle);
|
HAL_ETH_IRQHandler(&EthHandle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
@ -31,12 +31,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** @addtogroup STM32H7XX_NUCLEO_LOW_LEVEL
|
/** @addtogroup STM32H7XX_NUCLEO_LOW_LEVEL
|
||||||
* @brief This file provides set of firmware functions to manage Leds and push-button
|
* @brief This file provides set of firmware functions to manage Leds and
|
||||||
* available on STM32H7xx-Nucleo Kit from STMicroelectronics.
|
* 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,7 +45,8 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @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);
|
||||||
@ -52,7 +54,8 @@ 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];
|
EXTI_HandleTypeDef hpb_exti[BUTTONn];
|
||||||
@ -63,23 +66,19 @@ USART_TypeDef* COM_USART[COMn] = {COM1_UART};
|
|||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
/** @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,
|
static GPIO_TypeDef *LED_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT,
|
||||||
LED2_GPIO_PORT,
|
|
||||||
LED3_GPIO_PORT};
|
LED3_GPIO_PORT};
|
||||||
|
|
||||||
static const uint16_t LED_PIN[LEDn] = {LED1_PIN,
|
static const uint16_t LED_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_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 uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_USER_PIN};
|
||||||
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
|
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
#if (USE_BSP_COM_FEATURE > 0)
|
||||||
#if (USE_COM_LOG > 0)
|
#if (USE_COM_LOG > 0)
|
||||||
static COM_TypeDef COM_ActiveLogPort = COM1;
|
static COM_TypeDef COM_ActiveLogPort = COM1;
|
||||||
@ -93,7 +92,8 @@ static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @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);
|
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
|
* @brief This method returns the STM32H7XX NUCLEO BSP Driver revision
|
||||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
||||||
*/
|
*/
|
||||||
int32_t BSP_GetVersion(void)
|
int32_t BSP_GetVersion(void) { return (int32_t)STM32H7XX_NUCLEO_BSP_VERSION; }
|
||||||
{
|
|
||||||
return (int32_t)STM32H7XX_NUCLEO_BSP_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configures LED GPIO.
|
* @brief Configures LED GPIO.
|
||||||
@ -127,28 +125,19 @@ int32_t BSP_GetVersion(void)
|
|||||||
* @arg LED3
|
* @arg LED3
|
||||||
* @retval BSP status
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
GPIO_InitTypeDef gpio_init_structure;
|
GPIO_InitTypeDef gpio_init_structure;
|
||||||
|
|
||||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Enable the GPIO LED Clock */
|
/* Enable the GPIO LED Clock */
|
||||||
if(Led == LED1)
|
if (Led == LED1) {
|
||||||
{
|
|
||||||
LED1_GPIO_CLK_ENABLE();
|
LED1_GPIO_CLK_ENABLE();
|
||||||
}
|
} else if (Led == LED2) {
|
||||||
else if(Led == LED2)
|
|
||||||
{
|
|
||||||
LED2_GPIO_CLK_ENABLE();
|
LED2_GPIO_CLK_ENABLE();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
LED3_GPIO_CLK_ENABLE();
|
LED3_GPIO_CLK_ENABLE();
|
||||||
}
|
}
|
||||||
/* Configure the GPIO_LED pin */
|
/* 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
|
* @note Led DeInit does not disable the GPIO clock nor disable the Mfx
|
||||||
* @retval BSP status
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
GPIO_InitTypeDef gpio_init_structure;
|
GPIO_InitTypeDef gpio_init_structure;
|
||||||
|
|
||||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Turn off LED */
|
/* Turn off LED */
|
||||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
||||||
/* DeInit the GPIO_LED pin */
|
/* DeInit the GPIO_LED pin */
|
||||||
@ -204,16 +189,12 @@ int32_t BSP_LED_DeInit(Led_TypeDef Led)
|
|||||||
* @arg LED3
|
* @arg LED3
|
||||||
* @retval BSP status
|
* @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;
|
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;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
|
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
|
* @arg LED3
|
||||||
* @retval BSP status
|
* @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;
|
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;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
|
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
|
* @arg LED3
|
||||||
* @retval BSP status
|
* @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;
|
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;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
|
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,16 +252,12 @@ int32_t BSP_LED_Toggle(Led_TypeDef Led)
|
|||||||
* @arg LED3
|
* @arg LED3
|
||||||
* @retval LED status
|
* @retval LED status
|
||||||
*/
|
*/
|
||||||
int32_t BSP_LED_GetState (Led_TypeDef Led)
|
int32_t BSP_LED_GetState(Led_TypeDef Led) {
|
||||||
{
|
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
if((Led != LED1) && (Led != LED2) && (Led != LED3))
|
if ((Led != LED1) && (Led != LED2) && (Led != LED3)) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = (int32_t)HAL_GPIO_ReadPin(LED_PORT[Led], LED_PIN[Led]);
|
ret = (int32_t)HAL_GPIO_ReadPin(LED_PORT[Led], LED_PIN[Led]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,10 +275,10 @@ int32_t BSP_LED_GetState (Led_TypeDef Led)
|
|||||||
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
|
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
|
||||||
* with interrupt generation capability
|
* 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;
|
GPIO_InitTypeDef gpio_init_structure;
|
||||||
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {BUTTON_USER_EXTI_Callback};
|
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {
|
||||||
|
BUTTON_USER_EXTI_Callback};
|
||||||
static uint32_t BSP_BUTTON_PRIO[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
|
static uint32_t BSP_BUTTON_PRIO[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
|
||||||
static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE};
|
static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE};
|
||||||
|
|
||||||
@ -320,13 +289,11 @@ int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
|||||||
gpio_init_structure.Pull = GPIO_PULLDOWN;
|
gpio_init_structure.Pull = GPIO_PULLDOWN;
|
||||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
|
||||||
if(ButtonMode == BUTTON_MODE_GPIO)
|
if (ButtonMode == BUTTON_MODE_GPIO) {
|
||||||
{
|
|
||||||
/* Configure Button pin as input */
|
/* Configure Button pin as input */
|
||||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||||
}
|
} else /* (ButtonMode == BUTTON_MODE_EXTI) */
|
||||||
else /* (ButtonMode == BUTTON_MODE_EXTI) */
|
|
||||||
{
|
{
|
||||||
/* Configure Button pin as input with External interrupt */
|
/* Configure Button pin as input with External interrupt */
|
||||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
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);
|
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||||
|
|
||||||
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);
|
(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 */
|
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||||
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), BSP_BUTTON_PRIO[Button], 0x00);
|
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
|
* @arg BUTTON_USER: Wakeup Push Button
|
||||||
* @note PB DeInit does not disable the GPIO clock
|
* @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_InitTypeDef gpio_init_structure;
|
||||||
|
|
||||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
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
|
* @arg BUTTON_USER: Wakeup Push Button
|
||||||
* @retval The Button GPIO pin value (GPIO_PIN_RESET = button pressed)
|
* @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]);
|
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
|
* @param Button Can only be BUTTON_USER
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void BSP_PB_IRQHandler(Button_TypeDef Button)
|
void BSP_PB_IRQHandler(Button_TypeDef Button) {
|
||||||
{
|
|
||||||
HAL_EXTI_IRQHandler(&hpb_exti[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
|
* @param Button Specifies the pin connected EXTI line
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
__weak void BSP_PB_Callback(Button_TypeDef Button)
|
__weak void BSP_PB_Callback(Button_TypeDef Button) {
|
||||||
{
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
/* Prevent unused argument(s) compilation warning */
|
||||||
UNUSED(Button);
|
UNUSED(Button);
|
||||||
|
|
||||||
@ -404,34 +368,28 @@ __weak void BSP_PB_Callback(Button_TypeDef Button)
|
|||||||
* @param COM COM port to be configured.
|
* @param COM COM port to be configured.
|
||||||
* This parameter can be COM1
|
* This parameter can be COM1
|
||||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
* @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
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
|
|
||||||
if(COM >= COMn)
|
if (COM >= COMn) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||||
/* Init the UART Msp */
|
/* Init the UART Msp */
|
||||||
COM1_MspInit(&hcom_uart[COM]);
|
COM1_MspInit(&hcom_uart[COM]);
|
||||||
#else
|
#else
|
||||||
if(IsComMspCbValid[COM] == 0U)
|
if (IsComMspCbValid[COM] == 0U) {
|
||||||
{
|
if (BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE) {
|
||||||
if(BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
|
|
||||||
{
|
|
||||||
return BSP_ERROR_MSP_FAILURE;
|
return BSP_ERROR_MSP_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
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
|
* This parameter can be COM1
|
||||||
* @retval BSP status
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
|
|
||||||
if(COM >= COMn)
|
if (COM >= COMn) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* USART configuration */
|
/* USART configuration */
|
||||||
hcom_uart[COM].Instance = COM_USART[COM];
|
hcom_uart[COM].Instance = COM_USART[COM];
|
||||||
|
|
||||||
@ -462,8 +416,7 @@ int32_t BSP_COM_DeInit(COM_TypeDef COM)
|
|||||||
COM1_MspDeInit(&hcom_uart[COM]);
|
COM1_MspDeInit(&hcom_uart[COM]);
|
||||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
|
#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;
|
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,11 +428,12 @@ int32_t BSP_COM_DeInit(COM_TypeDef COM)
|
|||||||
* @brief Configures COM port.
|
* @brief Configures COM port.
|
||||||
* @param huart USART handle
|
* @param huart USART handle
|
||||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
* @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
|
* @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 */
|
/* USART configuration */
|
||||||
huart->Instance = COM_USART[COM1];
|
huart->Instance = COM_USART[COM1];
|
||||||
huart->Init.BaudRate = COM_Init->BaudRate;
|
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
|
* This parameter can be COM1
|
||||||
* @retval BSP status
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
|
|
||||||
if(COM >= COMn)
|
if (COM >= COMn) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||||
|
|
||||||
/* Register default MspInit/MspDeInit Callback */
|
/* 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;
|
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||||
}
|
} else if (HAL_UART_RegisterCallback(&hcom_uart[COM],
|
||||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, COM1_MspDeInit) != HAL_OK)
|
HAL_UART_MSPDEINIT_CB_ID,
|
||||||
{
|
COM1_MspDeInit) != HAL_OK) {
|
||||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IsComMspCbValid[COM] = 1U;
|
IsComMspCbValid[COM] = 1U;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -538,29 +486,23 @@ int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
|
|||||||
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
|
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
|
||||||
* @retval BSP status
|
* @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;
|
int32_t ret = BSP_ERROR_NONE;
|
||||||
|
|
||||||
if(COM >= COMn)
|
if (COM >= COMn) {
|
||||||
{
|
|
||||||
ret = BSP_ERROR_WRONG_PARAM;
|
ret = BSP_ERROR_WRONG_PARAM;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||||
|
|
||||||
/* Register MspInit/MspDeInit Callbacks */
|
/* 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;
|
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||||
}
|
} else if (HAL_UART_RegisterCallback(&hcom_uart[COM],
|
||||||
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
|
HAL_UART_MSPDEINIT_CB_ID,
|
||||||
{
|
Callback->pMspDeInitCb) != HAL_OK) {
|
||||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IsComMspCbValid[COM] = 1U;
|
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
|
* This parameter can be COM1
|
||||||
* @retval BSP status
|
* @retval BSP status
|
||||||
*/
|
*/
|
||||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
|
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM) {
|
||||||
{
|
if (COM_ActiveLogPort != COM) {
|
||||||
if(COM_ActiveLogPort != COM)
|
|
||||||
{
|
|
||||||
COM_ActiveLogPort = COM;
|
COM_ActiveLogPort = COM;
|
||||||
}
|
}
|
||||||
return BSP_ERROR_NONE;
|
return BSP_ERROR_NONE;
|
||||||
@ -594,7 +534,8 @@ int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
|
|||||||
int fputc(int ch, FILE *f)
|
int fputc(int ch, FILE *f)
|
||||||
#endif /* __GNUC__ */
|
#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;
|
return ch;
|
||||||
}
|
}
|
||||||
#endif /* USE_COM_LOG */
|
#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.
|
* @brief Key EXTI line detection callbacks.
|
||||||
* @retval BSP status
|
* @retval BSP status
|
||||||
*/
|
*/
|
||||||
static void BUTTON_USER_EXTI_Callback(void)
|
static void BUTTON_USER_EXTI_Callback(void) { BSP_PB_Callback(BUTTON_USER); }
|
||||||
{
|
|
||||||
BSP_PB_Callback(BUTTON_USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (USE_BSP_COM_FEATURE > 0)
|
#if (USE_BSP_COM_FEATURE > 0)
|
||||||
/**
|
/**
|
||||||
@ -622,8 +561,7 @@ static void BUTTON_USER_EXTI_Callback(void)
|
|||||||
* @param huart UART handle
|
* @param huart UART handle
|
||||||
* @retval BSP status
|
* @retval BSP status
|
||||||
*/
|
*/
|
||||||
static void COM1_MspInit(UART_HandleTypeDef *huart)
|
static void COM1_MspInit(UART_HandleTypeDef *huart) {
|
||||||
{
|
|
||||||
GPIO_InitTypeDef gpio_init_structure;
|
GPIO_InitTypeDef gpio_init_structure;
|
||||||
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
/* Prevent unused argument(s) compilation warning */
|
||||||
@ -656,8 +594,7 @@ static void COM1_MspInit(UART_HandleTypeDef *huart)
|
|||||||
* @param huart UART handle
|
* @param huart UART handle
|
||||||
* @retval BSP status
|
* @retval BSP status
|
||||||
*/
|
*/
|
||||||
static void COM1_MspDeInit(UART_HandleTypeDef *huart)
|
static void COM1_MspDeInit(UART_HandleTypeDef *huart) {
|
||||||
{
|
|
||||||
GPIO_InitTypeDef gpio_init_structure;
|
GPIO_InitTypeDef gpio_init_structure;
|
||||||
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
/* Prevent unused argument(s) compilation warning */
|
||||||
|
@ -4,19 +4,18 @@
|
|||||||
* the debug port.
|
* the debug port.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdio.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <hardware_init.h>
|
|
||||||
#include <boardconfig.h>
|
#include <boardconfig.h>
|
||||||
|
#include <hardware_init.h>
|
||||||
|
|
||||||
#define AUTO_RETURN_AFTER_NEWLINE 1
|
#define AUTO_RETURN_AFTER_NEWLINE 1
|
||||||
|
|
||||||
@ -53,19 +52,17 @@ int _write(int file, const void *ptr, size_t len) {
|
|||||||
#if AUTO_RETURN_AFTER_NEWLINE
|
#if AUTO_RETURN_AFTER_NEWLINE
|
||||||
if (((const char *)ptr)[i] == '\n' &&
|
if (((const char *)ptr)[i] == '\n' &&
|
||||||
((const char *)ptr)[i + 1] != '\r') {
|
((const char *)ptr)[i + 1] != '\r') {
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t*)"\r", 1 ,
|
HAL_UART_Transmit(&huart3, (uint8_t *)"\r", 1, DEBUG_UART_MS_TIMEOUT);
|
||||||
DEBUG_UART_MS_TIMEOUT);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
uint8_t *character = (uint8_t *)ptr;
|
uint8_t *character = (uint8_t *)ptr;
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t*) (character + i),
|
HAL_UART_Transmit(&huart3, (uint8_t *)(character + i), 1,
|
||||||
1 , DEBUG_UART_MS_TIMEOUT);
|
DEBUG_UART_MS_TIMEOUT);
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _lseek(int file, int ptr, int dir) {
|
int _lseek(int file, int ptr, int dir) {
|
||||||
@ -123,8 +120,7 @@ int _stat(const char *path, struct stat *st) {
|
|||||||
int _isatty(int fd) {
|
int _isatty(int fd) {
|
||||||
if (fd <= STDERR_FILENO) {
|
if (fd <= STDERR_FILENO) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,23 +128,19 @@ int _isatty(int fd) {
|
|||||||
void exit(int n) {
|
void exit(int n) {
|
||||||
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
||||||
// restart();
|
// restart();
|
||||||
while(1);
|
while (1)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _exit(int n) {
|
void _exit(int n) {
|
||||||
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
||||||
// restart();
|
// restart();
|
||||||
while(1);
|
while (1)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _kill() {
|
int _kill() { return -1; }
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _getpid() {
|
int _getpid() { return 1; }
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _gettimeofday() {
|
int _gettimeofday() { return -1; }
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE SpiTest.cpp)
|
||||||
SpiTest.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
#include "SpiTest.h"
|
#include "SpiTest.h"
|
||||||
#include "fsfw_hal/stm32h7/spi/stm32h743zi.h"
|
#include "fsfw_hal/stm32h7/spi/stm32h743zi.h"
|
||||||
|
|
||||||
SpiTest::SpiTest(SpiComIF &spiComIF):
|
SpiTest::SpiTest(SpiComIF &spiComIF)
|
||||||
spiComIF(spiComIF), spiCookie(TEST_ADDRESS, spi::SpiBus::SPI_1,
|
: spiComIF(spiComIF),
|
||||||
spi::TransferModes::POLLING, &mspCfg, 1000000, spi::SpiModes::MODE_0, 32) {
|
spiCookie(TEST_ADDRESS, spi::SpiBus::SPI_1, spi::TransferModes::POLLING,
|
||||||
|
&mspCfg, 1000000, spi::SpiModes::MODE_0, 32) {
|
||||||
stm32h7::h743zi::standardPollingCfg(mspCfg);
|
stm32h7::h743zi::standardPollingCfg(mspCfg);
|
||||||
spiComIF.initializeInterface(&spiCookie);
|
spiComIF.initializeInterface(&spiCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SpiTest::performOperation(uint8_t opCode) {
|
ReturnValue_t SpiTest::performOperation(uint8_t opCode) {
|
||||||
std::array<uint8_t, 3> dummyData = {0x01, 0x02, 0x03};
|
std::array<uint8_t, 3> dummyData = {0x01, 0x02, 0x03};
|
||||||
ReturnValue_t result = spiComIF.sendMessage(&spiCookie, dummyData.data(), dummyData.size());
|
ReturnValue_t result =
|
||||||
|
spiComIF.sendMessage(&spiCookie, dummyData.data(), dummyData.size());
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ public:
|
|||||||
SpiTest(SpiComIF &spiComIF);
|
SpiTest(SpiComIF &spiComIF);
|
||||||
|
|
||||||
ReturnValue_t performOperation(uint8_t opCode = 0);
|
ReturnValue_t performOperation(uint8_t opCode = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr address_t TEST_ADDRESS = 0x00;
|
static constexpr address_t TEST_ADDRESS = 0x00;
|
||||||
spi::MspPollingConfigStruct mspCfg;
|
spi::MspPollingConfigStruct mspCfg;
|
||||||
|
@ -1,5 +1 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE InitMission.cpp ObjectFactory.cpp)
|
||||||
InitMission.cpp
|
|
||||||
ObjectFactory.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
#include "example/utility/TaskCreation.h"
|
#include "example/utility/TaskCreation.h"
|
||||||
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
|
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
|
||||||
|
|
||||||
|
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
||||||
|
#include "fsfw/modes/HasModesIF.h"
|
||||||
|
#include "fsfw/modes/ModeMessage.h"
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
||||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||||
#include "fsfw/tasks/TaskFactory.h"
|
#include "fsfw/tasks/TaskFactory.h"
|
||||||
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
|
||||||
#include "fsfw/modes/HasModesIF.h"
|
|
||||||
#include "fsfw/modes/ModeMessage.h"
|
|
||||||
|
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
@ -22,9 +22,10 @@ void InitMission::createTasks() {
|
|||||||
|
|
||||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||||
/* TMTC Distribution */
|
/* TMTC Distribution */
|
||||||
PeriodicTaskIF* distributerTask = taskFactory->createPeriodicTask(
|
PeriodicTaskIF *distributerTask =
|
||||||
"DIST", 5, 1024 * 2, 0.2, nullptr);
|
taskFactory->createPeriodicTask("DIST", 5, 1024 * 2, 0.2, nullptr);
|
||||||
ReturnValue_t result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
|
ReturnValue_t result =
|
||||||
|
distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR);
|
task::printInitError("CCSDS distributor", objects::CCSDS_DISTRIBUTOR);
|
||||||
}
|
}
|
||||||
@ -44,15 +45,16 @@ void InitMission::createTasks() {
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
task::printInitError("UDP bridge", objects::UDP_BRIDGE);
|
task::printInitError("UDP bridge", objects::UDP_BRIDGE);
|
||||||
}
|
}
|
||||||
PeriodicTaskIF* udpPollingTask = TaskFactory::instance()->
|
PeriodicTaskIF *udpPollingTask = TaskFactory::instance()->createPeriodicTask(
|
||||||
createPeriodicTask("UDP_POLLING", 8, 1024, 0.1, nullptr);
|
"UDP_POLLING", 8, 1024, 0.1, nullptr);
|
||||||
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
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);
|
task::printInitError("UDP polling task", objects::UDP_POLLING_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeriodicTaskIF* eventManagerTask = TaskFactory::instance()->createPeriodicTask(
|
PeriodicTaskIF *eventManagerTask =
|
||||||
"EVENT_MGMT", 4, 1024 * 2, 0.1, nullptr);
|
TaskFactory::instance()->createPeriodicTask("EVENT_MGMT", 4, 1024 * 2,
|
||||||
|
0.1, nullptr);
|
||||||
result = eventManagerTask->addComponent(objects::EVENT_MANAGER);
|
result = eventManagerTask->addComponent(objects::EVENT_MANAGER);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
task::printInitError("Event Manager", objects::EVENT_MANAGER);
|
task::printInitError("Event Manager", objects::EVENT_MANAGER);
|
||||||
@ -103,12 +105,14 @@ void InitMission::createTasks() {
|
|||||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||||
|
|
||||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||||
FixedTimeslotTaskIF* timeslotDemoTask = TaskFactory::instance()->createFixedTimeslotTask(
|
FixedTimeslotTaskIF *timeslotDemoTask =
|
||||||
"PST_TASK", 6, 1024 * 2, 0.5, nullptr);
|
TaskFactory::instance()->createFixedTimeslotTask("PST_TASK", 6, 1024 * 2,
|
||||||
|
0.5, nullptr);
|
||||||
result = pst::pollingSequenceExamples(timeslotDemoTask);
|
result = pst::pollingSequenceExamples(timeslotDemoTask);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "InitMission::createTasks: PST initialization failed!" << std::endl;
|
sif::error << "InitMission::createTasks: PST initialization failed!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("InitMission::createTasks: PST initialization failed!\n");
|
sif::printError("InitMission::createTasks: PST initialization failed!\n");
|
||||||
#endif
|
#endif
|
||||||
@ -123,18 +127,21 @@ void InitMission::createTasks() {
|
|||||||
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
|
||||||
|
|
||||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||||
FixedTimeslotTaskIF* testDevicesTask = TaskFactory::instance()->createFixedTimeslotTask(
|
FixedTimeslotTaskIF *testDevicesTask =
|
||||||
"PST_TEST_TASK", 7, 1024 * 2, 1.0, nullptr);
|
TaskFactory::instance()->createFixedTimeslotTask("PST_TEST_TASK", 7,
|
||||||
|
1024 * 2, 1.0, nullptr);
|
||||||
result = pst::pollingSequenceDevices(testDevicesTask);
|
result = pst::pollingSequenceDevices(testDevicesTask);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "InitMission::createTasks: Test PST initialization failed!" << std::endl;
|
sif::error << "InitMission::createTasks: Test PST initialization failed!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("InitMission::createTasks: Test PST initialization faiedl!\n");
|
sif::printError(
|
||||||
|
"InitMission::createTasks: Test PST initialization faiedl!\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
PeriodicTaskIF* assemblyTask = taskFactory->createPeriodicTask("ASS_TASK", 3,
|
PeriodicTaskIF *assemblyTask =
|
||||||
1024, 2.0, nullptr);
|
taskFactory->createPeriodicTask("ASS_TASK", 3, 1024, 2.0, nullptr);
|
||||||
if (assemblyTask == nullptr) {
|
if (assemblyTask == nullptr) {
|
||||||
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
||||||
}
|
}
|
||||||
@ -152,14 +159,17 @@ void InitMission::createTasks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if OBSW_PERIPHERAL_PST == 1
|
#if OBSW_PERIPHERAL_PST == 1
|
||||||
FixedTimeslotTaskIF* peripheralPst = TaskFactory::instance()->createFixedTimeslotTask(
|
FixedTimeslotTaskIF *peripheralPst =
|
||||||
"PST_PERIPHERAL_TASK", 9, 1024 * 2, 2.0, nullptr);
|
TaskFactory::instance()->createFixedTimeslotTask("PST_PERIPHERAL_TASK", 9,
|
||||||
|
1024 * 2, 2.0, nullptr);
|
||||||
result = pst::pstPeripheralsTest(peripheralPst);
|
result = pst::pstPeripheralsTest(peripheralPst);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "InitMission::createTasks: Test PST initialization failed!" << std::endl;
|
sif::error << "InitMission::createTasks: Test PST initialization failed!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("InitMission::createTasks: Test PST initialization faiedl!\n");
|
sif::printError(
|
||||||
|
"InitMission::createTasks: Test PST initialization faiedl!\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -201,8 +211,8 @@ void InitMission::createTasks() {
|
|||||||
testTask->startTask();
|
testTask->startTask();
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Remaining FreeRTOS heap size: " << std::dec << xPortGetFreeHeapSize() <<
|
sif::info << "Remaining FreeRTOS heap size: " << std::dec
|
||||||
" bytes." << std::endl;
|
<< xPortGetFreeHeapSize() << " bytes." << std::endl;
|
||||||
sif::info << "Tasks started.." << std::endl;
|
sif::info << "Tasks started.." << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("Remaining FreeRTOS heap size: %lu\n",
|
sif::printInfo("Remaining FreeRTOS heap size: %lu\n",
|
||||||
@ -211,20 +221,25 @@ void InitMission::createTasks() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO
|
#if OBSW_ADD_DEVICE_HANDLER_DEMO
|
||||||
HasModesIF* assembly = ObjectManager::instance()->get<HasModesIF>(objects::TEST_ASSEMBLY);
|
HasModesIF *assembly =
|
||||||
|
ObjectManager::instance()->get<HasModesIF>(objects::TEST_ASSEMBLY);
|
||||||
if (assembly == nullptr) {
|
if (assembly == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Waiting 5 Seconds and then command Test Assembly to Normal, Dual" << std::endl;
|
sif::info
|
||||||
|
<< "Waiting 5 Seconds and then command Test Assembly to Normal, Dual"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("Waiting 5 Seconds and then command Test Assembly to Normal, Dual \n");
|
sif::printInfo(
|
||||||
|
"Waiting 5 Seconds and then command Test Assembly to Normal, Dual \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TaskFactory::delayTask(5000);
|
TaskFactory::delayTask(5000);
|
||||||
CommandMessage modeMessage;
|
CommandMessage modeMessage;
|
||||||
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
||||||
DeviceHandlerIF::MODE_NORMAL, TestAssembly::submodes::DUAL);
|
DeviceHandlerIF::MODE_NORMAL,
|
||||||
|
TestAssembly::submodes::DUAL);
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl;
|
sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl;
|
||||||
#else
|
#else
|
||||||
@ -234,4 +249,3 @@ void InitMission::createTasks() {
|
|||||||
MessageQueueIF::NO_QUEUE);
|
MessageQueueIF::NO_QUEUE);
|
||||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO */
|
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#include "ObjectFactory.h"
|
#include "ObjectFactory.h"
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "devices/devAddresses.h"
|
#include "devices/devAddresses.h"
|
||||||
#include "objects/systemObjectList.h"
|
|
||||||
#include "hardware_init.h"
|
#include "hardware_init.h"
|
||||||
|
#include "objects/systemObjectList.h"
|
||||||
|
|
||||||
#include "example/utility/TmFunnel.h"
|
|
||||||
#include "example/core/GenericFactory.h"
|
#include "example/core/GenericFactory.h"
|
||||||
|
#include "example/utility/TmFunnel.h"
|
||||||
|
|
||||||
#include "example_common/stm32h7/networking/UdpTcLwIpPollingTask.h"
|
|
||||||
#include "example_common/stm32h7/networking/TmTcLwIpUdpBridge.h"
|
|
||||||
#include "example_common/stm32h7/STM32TestTask.h"
|
#include "example_common/stm32h7/STM32TestTask.h"
|
||||||
|
#include "example_common/stm32h7/networking/TmTcLwIpUdpBridge.h"
|
||||||
|
#include "example_common/stm32h7/networking/UdpTcLwIpPollingTask.h"
|
||||||
|
|
||||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||||
#include "fsfw/monitoring/MonitoringMessageContent.h"
|
#include "fsfw/monitoring/MonitoringMessageContent.h"
|
||||||
@ -18,13 +18,12 @@
|
|||||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||||
|
|
||||||
|
|
||||||
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
||||||
#include "fsfw/hal/stm32h7/spi/SpiCookie.h"
|
|
||||||
#include "fsfw/hal/stm32h7/spi/SpiComIF.h"
|
|
||||||
#include "fsfw/hal/devicehandlers/GyroL3GD20Handler.h"
|
#include "fsfw/hal/devicehandlers/GyroL3GD20Handler.h"
|
||||||
#include "fsfw/hal/stm32h7/spi/stm32h743ziSpi.h"
|
#include "fsfw/hal/stm32h7/spi/SpiComIF.h"
|
||||||
|
#include "fsfw/hal/stm32h7/spi/SpiCookie.h"
|
||||||
#include "fsfw/hal/stm32h7/spi/spiCore.h"
|
#include "fsfw/hal/stm32h7/spi/spiCore.h"
|
||||||
|
#include "fsfw/hal/stm32h7/spi/stm32h743ziSpi.h"
|
||||||
DMA_HandleTypeDef *txHandle = nullptr;
|
DMA_HandleTypeDef *txHandle = nullptr;
|
||||||
DMA_HandleTypeDef *rxHandle = nullptr;
|
DMA_HandleTypeDef *rxHandle = nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -36,29 +35,27 @@ void ObjectFactory::produce(void* args) {
|
|||||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||||
{
|
{
|
||||||
LocalPool::LocalPoolConfig poolCfg = {
|
LocalPool::LocalPoolConfig poolCfg = {
|
||||||
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
|
{100, 32}, {30, 64}, {10, 128}, {2, 1024}};
|
||||||
};
|
|
||||||
new PoolManager(objects::TC_STORE, poolCfg);
|
new PoolManager(objects::TC_STORE, poolCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
LocalPool::LocalPoolConfig poolCfg = {
|
LocalPool::LocalPoolConfig poolCfg = {
|
||||||
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
|
{100, 32}, {30, 64}, {10, 128}, {2, 1024}};
|
||||||
};
|
|
||||||
new PoolManager(objects::TM_STORE, poolCfg);
|
new PoolManager(objects::TM_STORE, poolCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
LocalPool::LocalPoolConfig poolCfg = {
|
LocalPool::LocalPoolConfig poolCfg = {
|
||||||
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
|
{100, 32}, {30, 64}, {10, 128}, {2, 1024}};
|
||||||
};
|
|
||||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* UDP Server */
|
/* UDP Server */
|
||||||
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE,
|
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE, objects::CCSDS_DISTRIBUTOR,
|
||||||
objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE);
|
objects::TM_STORE, objects::TC_STORE);
|
||||||
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE, &gnetif);
|
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE,
|
||||||
|
&gnetif);
|
||||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||||
|
|
||||||
ObjectFactory::produceGenericObjects();
|
ObjectFactory::produceGenericObjects();
|
||||||
@ -74,27 +71,28 @@ void ObjectFactory::produce(void* args) {
|
|||||||
auto typedCfg = new spi::MspPollingConfigStruct();
|
auto typedCfg = new spi::MspPollingConfigStruct();
|
||||||
spi::h743zi::standardPollingCfg(*typedCfg);
|
spi::h743zi::standardPollingCfg(*typedCfg);
|
||||||
mspCfg = typedCfg;
|
mspCfg = typedCfg;
|
||||||
}
|
} else if (transferMode == spi::TransferModes::INTERRUPT) {
|
||||||
else if(transferMode == spi::TransferModes::INTERRUPT) {
|
|
||||||
auto typedCfg = new spi::MspIrqConfigStruct();
|
auto typedCfg = new spi::MspIrqConfigStruct();
|
||||||
spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS);
|
spi::h743zi::standardInterruptCfg(*typedCfg,
|
||||||
|
IrqPriorities::HIGHEST_FREERTOS);
|
||||||
mspCfg = typedCfg;
|
mspCfg = typedCfg;
|
||||||
}
|
} else if (transferMode == spi::TransferModes::DMA) {
|
||||||
else if(transferMode == spi::TransferModes::DMA) {
|
|
||||||
auto typedCfg = new spi::MspDmaConfigStruct();
|
auto typedCfg = new spi::MspDmaConfigStruct();
|
||||||
txHandle = new DMA_HandleTypeDef();
|
txHandle = new DMA_HandleTypeDef();
|
||||||
rxHandle = new DMA_HandleTypeDef();
|
rxHandle = new DMA_HandleTypeDef();
|
||||||
spi::setDmaHandles(txHandle, rxHandle);
|
spi::setDmaHandles(txHandle, rxHandle);
|
||||||
spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
|
spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
|
||||||
IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS);
|
IrqPriorities::HIGHEST_FREERTOS,
|
||||||
|
IrqPriorities::HIGHEST_FREERTOS);
|
||||||
mspCfg = typedCfg;
|
mspCfg = typedCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
new SpiComIF(objects::SPI_COM_IF);
|
new SpiComIF(objects::SPI_COM_IF);
|
||||||
auto spiCookie = new SpiCookie(devaddress::L3GD20H, spi::SpiBus::SPI_1, transferMode, mspCfg,
|
auto spiCookie = new SpiCookie(devaddress::L3GD20H, spi::SpiBus::SPI_1,
|
||||||
3900000, spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32);
|
transferMode, mspCfg, 3900000,
|
||||||
auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF,
|
spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32);
|
||||||
spiCookie);
|
auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST,
|
||||||
|
objects::SPI_COM_IF, spiCookie);
|
||||||
gyroDevice->setStartUpImmediately();
|
gyroDevice->setStartUpImmediately();
|
||||||
gyroDevice->setGoNormalModeAtStartup();
|
gyroDevice->setGoNormalModeAtStartup();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#ifndef MISSION_CORE_OBJECTFACTORY_H_
|
#ifndef MISSION_CORE_OBJECTFACTORY_H_
|
||||||
#define MISSION_CORE_OBJECTFACTORY_H_
|
#define MISSION_CORE_OBJECTFACTORY_H_
|
||||||
|
|
||||||
|
|
||||||
namespace ObjectFactory {
|
namespace ObjectFactory {
|
||||||
void setStatics();
|
void setStatics();
|
||||||
void produce(void *args);
|
void produce(void *args);
|
||||||
};
|
}; // namespace ObjectFactory
|
||||||
|
|
||||||
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */
|
#endif /* MISSION_CORE_OBJECTFACTORY_H_ */
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
target_sources(${TARGET_NAME}
|
target_sources(
|
||||||
PRIVATE
|
${TARGET_NAME} PRIVATE ipc/missionMessageTypes.cpp
|
||||||
ipc/missionMessageTypes.cpp
|
pollingsequence/pollingSequenceFactory.cpp)
|
||||||
pollingsequence/pollingSequenceFactory.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add include paths for the executable
|
# Add include paths for the executable
|
||||||
target_include_directories(${TARGET_NAME}
|
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
PUBLIC
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
|
@ -4,11 +4,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace devaddress {
|
namespace devaddress {
|
||||||
enum devaddress: uint32_t {
|
enum devaddress : uint32_t { L3GD20H = 1 };
|
||||||
L3GD20H = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_ */
|
#endif /* BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_ */
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include "commonSubsystemIds.h"
|
#include "commonSubsystemIds.h"
|
||||||
|
|
||||||
namespace SUBSYSTEM_ID {
|
namespace SUBSYSTEM_ID {
|
||||||
enum subsystemId: uint8_t {
|
enum subsystemId : uint8_t {};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_ */
|
#endif /* FSFWCONFIG_TMTC_SUBSYSTEMIDRANGES_H_ */
|
||||||
|
@ -7,13 +7,14 @@ class CommandMessage;
|
|||||||
|
|
||||||
namespace messagetypes {
|
namespace messagetypes {
|
||||||
/* First type must have number MESSAGE_TYPE::FW_MESSAGES_COUNT! */
|
/* 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 {
|
enum MISSION_MESSAGE_TYPE {
|
||||||
COSTUM_MESSAGE = FW_MESSAGES_COUNT,
|
COSTUM_MESSAGE = FW_MESSAGES_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
void clearMissionMessage(CommandMessage *message);
|
void clearMissionMessage(CommandMessage *message);
|
||||||
|
|
||||||
}
|
} // namespace messagetypes
|
||||||
|
|
||||||
#endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */
|
#endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */
|
||||||
|
@ -12,22 +12,26 @@ ReturnValue_t pst::pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence) {
|
|||||||
static_cast<void>(length);
|
static_cast<void>(length);
|
||||||
|
|
||||||
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
||||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0, DeviceHandlerIF::PERFORM_OPERATION);
|
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0,
|
||||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3, DeviceHandlerIF::SEND_WRITE);
|
DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3,
|
||||||
|
DeviceHandlerIF::SEND_WRITE);
|
||||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length,
|
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length,
|
||||||
DeviceHandlerIF::GET_WRITE);
|
DeviceHandlerIF::GET_WRITE);
|
||||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length,
|
||||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length, DeviceHandlerIF::GET_READ);
|
DeviceHandlerIF::SEND_READ);
|
||||||
|
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length,
|
||||||
|
DeviceHandlerIF::GET_READ);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
|
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
|
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@ namespace pst {
|
|||||||
ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence);
|
ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence);
|
||||||
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
|
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
|
||||||
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence);
|
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence);
|
||||||
}
|
} // namespace pst
|
||||||
|
|
||||||
#endif /* POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_ */
|
#endif /* POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_ */
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
#include <commonConfig.h>
|
#include <commonConfig.h>
|
||||||
|
|
||||||
namespace CLASS_ID {
|
namespace CLASS_ID {
|
||||||
enum classIds: uint8_t {
|
enum classIds : uint8_t {};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */
|
#endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef FSFWCONFIG_TMTC_APID_H_
|
#ifndef FSFWCONFIG_TMTC_APID_H_
|
||||||
#define FSFWCONFIG_TMTC_APID_H_
|
#define FSFWCONFIG_TMTC_APID_H_
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <commonConfig.h>
|
#include <commonConfig.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace apid {
|
namespace apid {
|
||||||
static const uint16_t APID = COMMON_APID;
|
static const uint16_t APID = COMMON_APID;
|
||||||
|
@ -3,5 +3,4 @@
|
|||||||
|
|
||||||
#include <commonConfig.h>
|
#include <commonConfig.h>
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFWCONFIG_TMTC_PUSIDS_H_ */
|
#endif /* FSFWCONFIG_TMTC_PUSIDS_H_ */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "hardware_init.h"
|
|
||||||
#include "boardconfig.h"
|
|
||||||
#include "OBSWVersion.h"
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
|
#include "OBSWVersion.h"
|
||||||
|
#include "boardconfig.h"
|
||||||
|
#include "hardware_init.h"
|
||||||
|
|
||||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||||
#include <lwip/init.h>
|
#include <lwip/init.h>
|
||||||
@ -17,15 +17,14 @@
|
|||||||
#include <fsfw/tasks/TaskFactory.h>
|
#include <fsfw/tasks/TaskFactory.h>
|
||||||
|
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(BOARD_NAME)
|
#if !defined(BOARD_NAME)
|
||||||
#define BOARD_NAME "unknown board"
|
#define BOARD_NAME "unknown board"
|
||||||
#endif
|
#endif
|
||||||
@ -53,7 +52,8 @@ int main() {
|
|||||||
osKernelStart();
|
osKernelStart();
|
||||||
|
|
||||||
/* Should not be reached, scheduler should now be running. */
|
/* Should not be reached, scheduler should now be running. */
|
||||||
for(;;) {}
|
for (;;) {
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +85,4 @@ void initTask(void *parameters) {
|
|||||||
#endif
|
#endif
|
||||||
InitMission::createTasks();
|
InitMission::createTasks();
|
||||||
TaskFactory::instance()->deleteTask(nullptr);
|
TaskFactory::instance()->deleteTask(nullptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE print.c)
|
||||||
print.c
|
|
||||||
)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <hardware_init.h>
|
|
||||||
#include <boardconfig.h>
|
#include <boardconfig.h>
|
||||||
|
#include <hardware_init.h>
|
||||||
|
|
||||||
void printChar(const char *character) {
|
void printChar(const char *character) {
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)character, 1, DEBUG_UART_MS_TIMEOUT);
|
HAL_UART_Transmit(&huart3, (uint8_t *)character, 1, DEBUG_UART_MS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8203995deb087c0a51ce7ec7fdc0f0f4f21d06ce
|
Subproject commit d34effb278c645fb6532db56521dd4d08eb0f4a6
|
32
scripts/auto-formatter.sh
Executable file
32
scripts/auto-formatter.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [[ ! -f README.md ]]; then
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
folder_list=(
|
||||||
|
"./bsp_stm32h7_freertos"
|
||||||
|
"./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
|
Loading…
x
Reference in New Issue
Block a user