xref: /btstack/port/renesas-tb-s1ja-cc256x/template/btstack_example/synergy/ssp/src/bsp/mcu/all/bsp_common.c (revision 3b5c872a8c45689e8cc17891f01530f5aa5e911c)
1 /***********************************************************************************************************************
2  * Copyright [2015-2017] Renesas Electronics Corporation and/or its licensors. All Rights Reserved.
3  *
4  * This file is part of Renesas SynergyTM Software Package (SSP)
5  *
6  * The contents of this file (the "contents") are proprietary and confidential to Renesas Electronics Corporation
7  * and/or its licensors ("Renesas") and subject to statutory and contractual protections.
8  *
9  * This file is subject to a Renesas SSP license agreement. Unless otherwise agreed in an SSP license agreement with
10  * Renesas: 1) you may not use, copy, modify, distribute, display, or perform the contents; 2) you may not use any name
11  * or mark of Renesas for advertising or publicity purposes or in connection with your use of the contents; 3) RENESAS
12  * MAKES NO WARRANTY OR REPRESENTATIONS ABOUT THE SUITABILITY OF THE CONTENTS FOR ANY PURPOSE; THE CONTENTS ARE PROVIDED
13  * "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14  * PARTICULAR PURPOSE, AND NON-INFRINGEMENT; AND 4) RENESAS SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, OR
15  * CONSEQUENTIAL DAMAGES, INCLUDING DAMAGES RESULTING FROM LOSS OF USE, DATA, OR PROJECTS, WHETHER IN AN ACTION OF
16  * CONTRACT OR TORT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE CONTENTS. Third-party contents
17  * included in this file may be subject to different terms.
18  **********************************************************************************************************************/
19 /***********************************************************************************************************************
20 * File Name    : bsp_common.c
21 * Description  : Implements functions common to all BSPs. Example: VersionGet() function.
22 ***********************************************************************************************************************/
23 
24 
25 /***********************************************************************************************************************
26  *
27  * Includes
28  **********************************************************************************************************************/
29 #include "bsp_api.h"
30 
31 
32 /***********************************************************************************************************************
33 Macro definitions
34 ***********************************************************************************************************************/
35 #if defined(__ICCARM__)
36 #define WEAK_ERROR_ATTRIBUTE
37 #define WEAK_INIT_ATTRIBUTE
38 #pragma weak ssp_error_log                            = ssp_error_log_internal
39 #pragma weak bsp_init                                 = bsp_init_internal
40 #elif defined(__GNUC__)
41 /*LDRA_INSPECTED 293 S */
42 #define WEAK_ERROR_ATTRIBUTE       __attribute__ ((weak, alias("ssp_error_log_internal")))
43 /*LDRA_INSPECTED 293 S */
44 #define WEAK_INIT_ATTRIBUTE        __attribute__ ((weak, alias("bsp_init_internal")))
45 #endif
46 
47 #define SSP_SECTION_VERSION ".version"
48 
49 /***********************************************************************************************************************
50 Typedef definitions
51 ***********************************************************************************************************************/
52 
53 /***********************************************************************************************************************
54 Private function prototypes
55 ***********************************************************************************************************************/
56 /** Prototype of initialization function called before main.  This prototype sets the weak association of this
57  * function to an internal example implementation. If this function is defined in the application code, the
58  * application code version is used. */
59 
60 /*LDRA_NOANALYSIS LDRA_INSPECTED below not working. */
61 /*LDRA_INSPECTED 110 D This function is weakly defined as a customer may choose to provide their own. */
62 void bsp_init(void * p_args) WEAK_INIT_ATTRIBUTE;
63 /*LDRA_ANALYSIS */
64 void bsp_init_internal(void * p_args);  /// Default initialization function
65 
66 #if ((1 == BSP_CFG_ERROR_LOG) || (1 == BSP_CFG_ASSERT))
67 /** Prototype of function called before errors are returned in SSP code if BSP_CFG_ERROR_LOG is set to 1.  This
68  * prototype sets the weak association of this function to an internal example implementation. */
69 
70 /*LDRA_NOANALYSIS LDRA_INSPECTED below not working. */
71 /*LDRA_INSPECTED 110 D This function is weakly defined as a customer may choose to provide their own. */
72 void ssp_error_log(ssp_err_t err, const char * module, int32_t line) WEAK_ERROR_ATTRIBUTE;
73 /*LDRA_ANALYSIS */
74 
75 void ssp_error_log_internal(ssp_err_t err, const char * module, int32_t line);  /// Default error logger function
76 #endif
77 
78 /***********************************************************************************************************************
79 Exported global variables (to be accessed by other files)
80 ***********************************************************************************************************************/
81 #if defined(__GNUC__)
82 /* This pragma suppresses the warnings in this structure only, and will be removed when the SSP compiler is updated to v5.3.*/
83 
84 /*LDRA_INSPECTED 69 S */
85 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
86 #endif
87 /* SSP pack version structure. */
88 static BSP_DONT_REMOVE const ssp_pack_version_t g_ssp_version BSP_PLACE_IN_SECTION_V2(SSP_SECTION_VERSION) =
89 {
90     .minor = SSP_VERSION_MINOR,
91     .major = SSP_VERSION_MAJOR,
92     .build = SSP_VERSION_BUILD,
93     .patch = SSP_VERSION_PATCH
94 };
95 #if defined(__GNUC__)
96 /* Restore warning settings for 'missing-field-initializers' to as specified on command line. */
97 /*LDRA_INSPECTED 69 S */
98 #pragma GCC diagnostic pop
99 #endif
100 
101 /* Public SSP version name. */
102 /*LDRA_INSPECTED 57 D - This global is being initialized at it's declaration below. */
103 static BSP_DONT_REMOVE const uint8_t g_ssp_version_string[] BSP_PLACE_IN_SECTION_V2(SSP_SECTION_VERSION) =
104         SSP_VERSION_STRING;
105 
106 /* Unique SSP version ID. */
107 /*LDRA_INSPECTED 57 D - This global is being initialized at it's declaration below. */
108 static BSP_DONT_REMOVE const uint8_t g_ssp_version_build_string[] BSP_PLACE_IN_SECTION_V2(SSP_SECTION_VERSION) =
109         SSP_VERSION_BUILD_STRING;
110 
111 /*******************************************************************************************************************//**
112  * @addtogroup BSP_MCU_COMMON
113  * @{
114  **********************************************************************************************************************/
115 
116 /***********************************************************************************************************************
117 Private global variables and functions
118 ***********************************************************************************************************************/
119 
120 /*******************************************************************************************************************//**
121  * @brief      Set BSP version based on compile time macros.
122  *
123  * @param[out] p_version Memory address to return version information to.
124  *
125  * @retval SSP_SUCCESS          Version information stored.
126  * @retval SSP_ERR_ASSERTION    The parameter p_version is NULL.
127  **********************************************************************************************************************/
R_BSP_VersionGet(ssp_version_t * p_version)128 ssp_err_t R_BSP_VersionGet (ssp_version_t * p_version)
129 {
130 #if BSP_CFG_PARAM_CHECKING_ENABLE
131     /** Verify parameters are valid */
132     SSP_ASSERT(NULL != p_version);
133 #endif
134 
135     p_version->api_version_major  = BSP_API_VERSION_MAJOR;
136     p_version->api_version_minor  = BSP_API_VERSION_MINOR;
137     p_version->code_version_major = BSP_CODE_VERSION_MAJOR;
138     p_version->code_version_minor = BSP_CODE_VERSION_MINOR;
139 
140     return SSP_SUCCESS;
141 }
142 
143 /*******************************************************************************************************************//**
144  * @brief      Set SSP version based on compile time macros.
145  *
146  * @param[out] p_version Memory address to return version information to.
147  *
148  * @retval SSP_SUCCESS          Version information stored.
149  * @retval SSP_ERR_ASSERTION    The parameter p_version is NULL.
150  **********************************************************************************************************************/
R_SSP_VersionGet(ssp_pack_version_t * const p_version)151 ssp_err_t R_SSP_VersionGet (ssp_pack_version_t * const p_version)
152 {
153 #if BSP_CFG_PARAM_CHECKING_ENABLE
154     /** Verify parameters are valid */
155     SSP_ASSERT(NULL != p_version);
156 #endif
157 
158     *p_version = g_ssp_version;
159 
160     return SSP_SUCCESS;
161 }
162 
163 #if ((1 == BSP_CFG_ERROR_LOG) || (1 == BSP_CFG_ASSERT))
164 /*******************************************************************************************************************//**
165  * @brief      Default error logger function, used only if ssp_error_log is not defined in the user application.
166  *
167  * @param[in]  err     The error code encountered.
168  * @param[in]  module  The module name in which the error code was encountered.
169  * @param[in]  line    The line number at which the error code was encountered.
170  **********************************************************************************************************************/
ssp_error_log_internal(ssp_err_t err,const char * module,int32_t line)171 void ssp_error_log_internal(ssp_err_t err, const char * module, int32_t line)
172 {
173     /** Do nothing. Do not generate any 'unused' warnings...*/
174     SSP_PARAMETER_NOT_USED(err);
175     SSP_PARAMETER_NOT_USED(module);
176     SSP_PARAMETER_NOT_USED(line);
177 
178 }
179 #endif
180 
181 /*******************************************************************************************************************//**
182  * @brief      Default initialization function, used only if bsp_init is not defined in the user application.
183  **********************************************************************************************************************/
bsp_init_internal(void * p_args)184 void bsp_init_internal(void * p_args)
185 {
186     /* Do nothing. */
187     SSP_PARAMETER_NOT_USED(p_args);
188 }
189 
190 /** @} (end addtogroup BSP_MCU_COMMON) */
191