/* * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates * * SPDX-License-Identifier: BSD-3-Clause */ /*********************************************************************************************************************** * * Includes **********************************************************************************************************************/ #include "bsp_api.h" /*********************************************************************************************************************** * Macro definitions **********************************************************************************************************************/ #if defined(__ICCARM__) #define WEAK_ERROR_ATTRIBUTE #define WEAK_INIT_ATTRIBUTE #pragma weak fsp_error_log = fsp_error_log_internal #pragma weak bsp_init = bsp_init_internal #elif defined(__GNUC__) #define WEAK_ERROR_ATTRIBUTE __attribute__((weak, alias("fsp_error_log_internal"))) #define WEAK_INIT_ATTRIBUTE __attribute__((weak, alias("bsp_init_internal"))) #endif #define FSP_SECTION_VERSION ".version" /*********************************************************************************************************************** * Typedef definitions **********************************************************************************************************************/ /*********************************************************************************************************************** * Private function prototypes **********************************************************************************************************************/ /** Prototype of initialization function called before main. This prototype sets the weak association of this * function to an internal example implementation. If this function is defined in the application code, the * application code version is used. */ void bsp_init(void * p_args) WEAK_INIT_ATTRIBUTE; void bsp_init_internal(void * p_args); /// Default initialization function #if ((1 == BSP_CFG_ERROR_LOG) || (1 == BSP_CFG_ASSERT)) /** Prototype of function called before errors are returned in FSP code if BSP_CFG_ERROR_LOG is set to 1. This * prototype sets the weak association of this function to an internal example implementation. */ void fsp_error_log(fsp_err_t err, const char * file, int32_t line) WEAK_ERROR_ATTRIBUTE; void fsp_error_log_internal(fsp_err_t err, const char * file, int32_t line); /// Default error logger function #endif /*********************************************************************************************************************** * Exported global variables (to be accessed by other files) **********************************************************************************************************************/ /* BSP version structure. */ const fsp_version_t g_bsp_version = { .api_version_minor = BSP_API_VERSION_MINOR, .api_version_major = BSP_API_VERSION_MAJOR, .code_version_major = BSP_CODE_VERSION_MAJOR, .code_version_minor = BSP_CODE_VERSION_MINOR }; /* FSP pack version structure. */ static BSP_DONT_REMOVE const fsp_pack_version_t g_fsp_version BSP_PLACE_IN_SECTION (FSP_SECTION_VERSION) = { .minor = FSP_VERSION_MINOR, .major = FSP_VERSION_MAJOR, .build = FSP_VERSION_BUILD, .patch = FSP_VERSION_PATCH }; /* Public FSP version name. */ static BSP_DONT_REMOVE const uint8_t g_fsp_version_string[] BSP_PLACE_IN_SECTION(FSP_SECTION_VERSION) = FSP_VERSION_STRING; /* Unique FSP version ID. */ static BSP_DONT_REMOVE const uint8_t g_fsp_version_build_string[] BSP_PLACE_IN_SECTION(FSP_SECTION_VERSION) = FSP_VERSION_BUILD_STRING; /*******************************************************************************************************************//** * @addtogroup BSP_MCU * @{ **********************************************************************************************************************/ /*********************************************************************************************************************** * Private global variables and functions **********************************************************************************************************************/ /*******************************************************************************************************************//** * Get the BSP version based on compile time macros. * * @param[out] p_version Memory address to return version information to. * * @retval FSP_SUCCESS Version information stored. * @retval FSP_ERR_ASSERTION The parameter p_version is NULL. **********************************************************************************************************************/ fsp_err_t R_BSP_VersionGet (fsp_version_t * p_version) { #if BSP_CFG_PARAM_CHECKING_ENABLE /** Verify parameters are valid */ FSP_ASSERT(NULL != p_version); #endif p_version->api_version_major = BSP_API_VERSION_MAJOR; p_version->api_version_minor = BSP_API_VERSION_MINOR; p_version->code_version_major = BSP_CODE_VERSION_MAJOR; p_version->code_version_minor = BSP_CODE_VERSION_MINOR; return FSP_SUCCESS; } /*******************************************************************************************************************//** * Get the FSP version based on compile time macros. * * @param[out] p_version Memory address to return version information to. * * @retval FSP_SUCCESS Version information stored. * @retval FSP_ERR_ASSERTION The parameter p_version is NULL. **********************************************************************************************************************/ fsp_err_t R_FSP_VersionGet (fsp_pack_version_t * const p_version) { #if BSP_CFG_PARAM_CHECKING_ENABLE /** Verify parameters are valid */ FSP_ASSERT(NULL != p_version); #endif *p_version = g_fsp_version; return FSP_SUCCESS; } #if ((1 == BSP_CFG_ERROR_LOG) || (1 == BSP_CFG_ASSERT)) /*******************************************************************************************************************//** * Default error logger function, used only if fsp_error_log is not defined in the user application. * * @param[in] err The error code encountered. * @param[in] file The file name in which the error code was encountered. * @param[in] line The line number at which the error code was encountered. **********************************************************************************************************************/ void fsp_error_log_internal (fsp_err_t err, const char * file, int32_t line) { /** Do nothing. Do not generate any 'unused' warnings. */ FSP_PARAMETER_NOT_USED(err); FSP_PARAMETER_NOT_USED(file); FSP_PARAMETER_NOT_USED(line); } #endif /** @} (end addtogroup BSP_MCU) */ /*******************************************************************************************************************//** * Default initialization function, used only if bsp_init is not defined in the user application. **********************************************************************************************************************/ void bsp_init_internal (void * p_args) { /* Do nothing. */ FSP_PARAMETER_NOT_USED(p_args); } #if defined(__ARMCC_VERSION) /*******************************************************************************************************************//** * Default implementation of assert for AC6. **********************************************************************************************************************/ __attribute__((weak, noreturn)) void __aeabi_assert (const char * expr, const char * file, int line) { FSP_PARAMETER_NOT_USED(expr); FSP_PARAMETER_NOT_USED(file); FSP_PARAMETER_NOT_USED(line); __BKPT(0); while (1) { /* Do nothing. */ } } #endif