1 #ifndef _ARCH_H_ 2 #define _ARCH_H_ 3 4 /** 5 **************************************************************************************** 6 * @defgroup REFIP 7 * @brief Reference IP Platform 8 * 9 * This module contains reference platform components - REFIP. 10 * 11 * 12 * @{ 13 **************************************************************************************** 14 */ 15 16 /** 17 **************************************************************************************** 18 * @defgroup DRIVERS 19 * @ingroup REFIP 20 * @brief Reference IP Platform Drivers 21 * 22 * This module contains the necessary drivers to run the platform with the 23 * RW BT SW protocol stack. 24 * 25 * This has the declaration of the platform architecture API. 26 * 27 * 28 * @{ 29 **************************************************************************************** 30 */ 31 32 /* 33 * INCLUDE FILES 34 **************************************************************************************** 35 */ 36 #include <stdint.h> // standard integer definition 37 //#include "compiler.h" // inline functions 38 #include "hal_trace.h" 39 40 /* 41 * CPU WORD SIZE 42 **************************************************************************************** 43 */ 44 /// ARM is a 32-bit CPU 45 #define CPU_WORD_SIZE 4 46 47 /* 48 * CPU Endianness 49 **************************************************************************************** 50 */ 51 /// ARM is little endian 52 #define CPU_LE 1 53 54 /* 55 * DEBUG configuration 56 **************************************************************************************** 57 */ 58 #if defined(CFG_DBG) 59 #define PLF_DEBUG 1 60 #else //CFG_DBG 61 #define PLF_DEBUG 0 62 #endif //CFG_DBG 63 64 65 /* 66 * NVDS 67 **************************************************************************************** 68 */ 69 70 /// NVDS 71 #ifdef CFG_NVDS 72 #define PLF_NVDS 1 73 #else // CFG_NVDS 74 #define PLF_NVDS 0 75 #endif // CFG_NVDS 76 77 78 /* 79 * UART 80 **************************************************************************************** 81 */ 82 83 /// UART 84 #define PLF_UART 1 85 86 /* 87 * DEFINES 88 **************************************************************************************** 89 */ 90 91 /// Possible errors detected by FW 92 #define RESET_NO_ERROR 0x00000000 93 #define RESET_MEM_ALLOC_FAIL 0xF2F2F2F2 94 95 /// Reset platform and stay in ROM 96 #define RESET_TO_ROM 0xA5A5A5A5 97 /// Reset platform and reload FW 98 #define RESET_AND_LOAD_FW 0xC3C3C3C3 99 100 /// Exchange memory size limit 101 #define EM_SIZE_LIMIT 0x8000 102 /* 103 * EXPORTED FUNCTION DECLARATION 104 **************************************************************************************** 105 */ 106 107 /** 108 **************************************************************************************** 109 * @brief Compute size of SW stack used. 110 * 111 * This function is compute the maximum size stack used by SW. 112 * 113 * @return Size of stack used (in bytes) 114 **************************************************************************************** 115 */ 116 uint16_t get_stack_usage(void); 117 118 /** 119 **************************************************************************************** 120 * @brief Re-boot FW. 121 * 122 * This function is used to re-boot the FW when error has been detected, it is the end of 123 * the current FW execution. 124 * After waiting transfers on UART to be finished, and storing the information that 125 * FW has re-booted by itself in a non-loaded area, the FW restart by branching at FW 126 * entry point. 127 * 128 * Note: when calling this function, the code after it will not be executed. 129 * 130 * @param[in] error Error detected by FW 131 **************************************************************************************** 132 */ 133 void platform_reset(uint32_t error); 134 135 #if PLF_DEBUG 136 /** 137 **************************************************************************************** 138 * @brief Print the assertion error reason and loop forever. 139 * 140 * @param condition C string containing the condition. 141 * @param file C string containing file where the assertion is located. 142 * @param line Line number in the file where the assertion is located. 143 **************************************************************************************** 144 */ 145 void assert_err(const char *condition, const char * file, int line); 146 147 /** 148 **************************************************************************************** 149 * @brief Print the assertion error reason and loop forever. 150 * The parameter value that is causing the assertion will also be disclosed. 151 * 152 * @param param0 parameter value 0. 153 * @param param1 parameter value 1. 154 * @param file C string containing file where the assertion is located. 155 * @param line Line number in the file where the assertion is located. 156 **************************************************************************************** 157 */ 158 void assert_param(int param0, int param1, const char * file, int line); 159 160 /** 161 **************************************************************************************** 162 * @brief Print the assertion warning reason. 163 * 164 * @param param0 parameter value 0. 165 * @param param1 parameter value 1. 166 * @param file C string containing file where the assertion is located. 167 * @param line Line number in the file where the assertion is located. 168 **************************************************************************************** 169 */ 170 void assert_warn(int param0, int param1, const char * file, int line); 171 172 173 /** 174 **************************************************************************************** 175 * @brief Dump data value into FW. 176 * 177 * @param data start pointer of the data. 178 * @param length data size to dump 179 **************************************************************************************** 180 */ 181 void dump_data(uint8_t* data, uint16_t length); 182 #endif //PLF_DEBUG 183 184 185 /* 186 * ASSERTION CHECK 187 **************************************************************************************** 188 */ 189 #if 1 190 /// Assertions showing a critical error that could require a full system reset 191 #define ASSERT_ERR(cond) { if (!(cond)) { TRACE("line is %d file is %s", __LINE__, __FILE__); } } 192 193 /// Assertions showing a critical error that could require a full system reset 194 #define ASSERT_INFO(cond, param0, param1) { if (!(cond)) { TRACE("line is %d file is %s", __LINE__, __FILE__); } } 195 196 /// Assertions showing a non-critical problem that has to be fixed by the SW 197 #define ASSERT_WARN(cond, param0, param1) { if (!(cond)) { TRACE("line is %d file is %s", __LINE__, __FILE__); } } 198 199 #define DUMP_DATA(data, length) \ 200 // dump_data((uint8_t*)data, length) 201 202 #else 203 /// Assertions showing a critical error that could require a full system reset 204 #define ASSERT_ERR(cond) 205 206 /// Assertions showing a critical error that could require a full system reset 207 #define ASSERT_INFO(cond, param0, param1) 208 209 /// Assertions showing a non-critical problem that has to be fixed by the SW 210 #define ASSERT_WARN(cond, param0, param1) 211 212 /// DUMP data array present in the SW. 213 #define DUMP_DATA(data, length) 214 #endif //PLF_DEBUG 215 216 /// @} DRIVERS 217 #endif // _ARCH_H_ 218