/** **************************************************************************************** * * @file ble_arch.h * * @brief This file contains the definitions of the macros and functions that are * architecture dependent. The implementation of those is implemented in the * appropriate architecture directory. * * Copyright (C) RivieraWaves 2009-2015 * * **************************************************************************************** */ #ifndef _BLE_ARCH_H_ #define _BLE_ARCH_H_ /** **************************************************************************************** * @defgroup REFIP * @brief Reference IP Platform * * This module contains reference platform components - REFIP. * * * @{ **************************************************************************************** */ /** **************************************************************************************** * @defgroup DRIVERS * @ingroup REFIP * @brief Reference IP Platform Drivers * * This module contains the necessary drivers to run the platform with the * RW BT SW protocol stack. * * This has the declaration of the platform architecture API. * * * @{ **************************************************************************************** */ /* * INCLUDE FILES **************************************************************************************** */ #include // standard integer definition #include #include #include "rwip_config.h" #define GLOBAL_INT_DISABLE() \ do{\ __disable_irq();\ //__set_PRIMASK(1);\ }while (0);\ #define GLOBAL_INT_RESTORE() \ do{\ __enable_irq();\ // __set_PRIMASK(0);\ }while (0);\ //#include "compiler.h" // inline functions #define __INLINE inline #ifndef NULL #define NULL 0 #endif /// define the IRQ handler attribute for this compiler #define __IRQ __attribute__ ((interrupt)) /// define the BLE IRQ handler attribute for this compiler #define __BTIRQ /// define the BLE IRQ handler attribute for this compiler #define __BLEIRQ /// define the FIQ handler attribute for this compiler #define __FIQ __attribute__ ((interrupt)) /// define size of an empty array (used to declare structure with an array size not defined) #define __ARRAY_EMPTY /// Put a variable in a memory maintained during deep sleep #define __LOWPOWER_SAVED /* * CPU WORD SIZE **************************************************************************************** */ /// ARM is a 32-bit CPU #define CPU_WORD_SIZE 4 /* * CPU Endianness **************************************************************************************** */ /// ARM is little endian #define CPU_LE 1 /* * NVDS **************************************************************************************** */ /// NVDS #ifdef CFG_NVDS #define PLF_NVDS 1 #else // CFG_NVDS #define PLF_NVDS 0 #endif // CFG_NVDS /* * UART **************************************************************************************** */ /// UART #define PLF_UART 1 /* * DEFINES **************************************************************************************** */ /// Possible errors detected by FW #define RESET_NO_ERROR 0x00000000 #define RESET_MEM_ALLOC_FAIL 0xF2F2F2F2 /// Reset platform and stay in ROM #define RESET_TO_ROM 0xA5A5A5A5 /// Reset platform and reload FW #define RESET_AND_LOAD_FW 0xC3C3C3C3 /// Exchange memory size limit #define EM_SIZE_LIMIT 0x8000 /* * EXPORTED FUNCTION DECLARATION **************************************************************************************** */ /** **************************************************************************************** * @brief Compute size of SW stack used. * * This function is compute the maximum size stack used by SW. * * @return Size of stack used (in bytes) **************************************************************************************** */ uint16_t get_stack_usage(void); /** **************************************************************************************** * @brief Re-boot FW. * * This function is used to re-boot the FW when error has been detected, it is the end of * the current FW execution. * After waiting transfers on UART to be finished, and storing the information that * FW has re-booted by itself in a non-loaded area, the FW restart by branching at FW * entry point. * * Note: when calling this function, the code after it will not be executed. * * @param[in] error Error detected by FW **************************************************************************************** */ void platform_reset(uint32_t error); #if PLF_DEBUG /** **************************************************************************************** * @brief Print the assertion error reason and loop forever. * * @param condition C string containing the condition. * @param file C string containing file where the assertion is located. * @param line Line number in the file where the assertion is located. **************************************************************************************** */ void eif_assert_err(const char *condition, const char * file, int line); /** **************************************************************************************** * @brief Print the assertion error reason and loop forever. * The parameter value that is causing the assertion will also be disclosed. * * @param param0 parameter value 0. * @param param1 parameter value 1. * @param file C string containing file where the assertion is located. * @param line Line number in the file where the assertion is located. **************************************************************************************** */ void eif_assert_param(int param0, int param1, const char * file, int line); /** **************************************************************************************** * @brief Print the assertion warning reason. * * @param param0 parameter value 0. * @param param1 parameter value 1. * @param file C string containing file where the assertion is located. * @param line Line number in the file where the assertion is located. **************************************************************************************** */ void eif_assert_warn(int param0, int param1, const char * file, int line); /** **************************************************************************************** * @brief Dump data value into FW. * * @param data start pointer of the data. * @param length data size to dump **************************************************************************************** */ void dump_data(uint8_t* data, uint16_t length); #endif //PLF_DEBUG /* * ASSERTION CHECK **************************************************************************************** */ #if PLF_DEBUG /// Assertions showing a critical error that could require a full system reset #define ASSERT_ERR(cond) \ do { \ if (!(cond)) { \ eif_assert_err(#cond, __MODULE__, __LINE__); \ } \ } while (0) /// Assertions showing a critical error that could require a full system reset #define ASSERT_INFO(cond, param0, param1) \ do { \ if (!(cond)) { \ eif_assert_param((int)param0, (int)param1, __MODULE__, __LINE__); \ } \ } while (0) /// Assertions showing a non-critical problem that has to be fixed by the SW #define ASSERT_WARN(cond, param0, param1) \ do { \ if (!(cond)) { \ eif_assert_warn((int)param0, (int)param1, __MODULE__, __LINE__); \ } \ } while (0) #define DUMP_DATA(data, length) \ dump_data((uint8_t*)data, length) #else /// Assertions showing a critical error that could require a full system reset #define ASSERT_ERR(cond) /// Assertions showing a critical error that could require a full system reset #define ASSERT_INFO(cond, param0, param1) /// Assertions showing a non-critical problem that has to be fixed by the SW #define ASSERT_WARN(cond, param0, param1) /// DUMP data array present in the SW. #define DUMP_DATA(data, length) #endif //PLF_DEBUG /// Object allocated in shared memory - check linker script #define __SHARED __attribute__ ((section("shram"))) // required to define GLOBAL_INT_** macros as inline assembly. This file is included after // definition of ASSERT macros as they are used inside ll.h //#include "ll.h" // ll definitions /// @} DRIVERS #endif // _BLE_ARCH_H_