Index: Common.h =================================================================== diff -u -rf4ee38d0f7a18e47e6e4980360a7eac9220d244a -rdbc7d6c6b4f59a74282875928cf9ee087f42344d --- Common.h (.../Common.h) (revision f4ee38d0f7a18e47e6e4980360a7eac9220d244a) +++ Common.h (.../Common.h) (revision dbc7d6c6b4f59a74282875928cf9ee087f42344d) @@ -19,24 +19,6 @@ #include "hal_stdtypes.h" -// ********** build switches ********** - -#ifndef _VECTORCAST_ -// #define RM46_EVAL_BOARD_TARGET 1 -// #define SIMULATE_UI 1 - #define DEBUG_ENABLED 1 -// #define ACK_NOT_IMPLEMENTED 1 - #define UF_TEST_ENABLED 1 - #define DISABLE_CRC_ERROR 1 - #define DISABLE_MOTOR_CURRENT_ERRORS 1 - #define SHOW_RAW_FLOW_VALUES 1 - - #ifdef DEBUG_ENABLED - #include - #include - #endif -#endif - /** * @defgroup CommonHeader CommonHeader * @brief Provides commonly used definitions and macros. @@ -123,6 +105,8 @@ // **** Common Macros **** +#define ABS(v) ((v) < 0 ? (v) * -1 : (v)) +#define FABS(v) ((v) < 0.0 ? (v) * -1.0 : (v)) #define FLOAT_TO_INT_WITH_ROUND(f) ((f) < 0.0 ? (S32)((f) - FLOAT_TO_INT_ROUNDUP_OFFSET) : (S32)((f) + FLOAT_TO_INT_ROUNDUP_OFFSET)) ///< Macro converts a floating point value to an integer. #define CAP(v, u) ((v) > (u) ? (u) : (v)) ///< Macro caps a value to a maximum. #define RANGE(v, l, u) ((v) > (u) ? (u) : ((v) < (l) ? (l) : (v))) ///< Macro enforces a range on a value. @@ -150,7 +134,8 @@ activateAlarm1Data( a, dat1 ); \ } -/// Macro to set a specific alarm with 1 piece of unsigned floating point alarm data. +/// Macro to set a specific alarm with 1 piece of floating point alarm data. + #define SET_ALARM_WITH_1_F32_DATA(a,d1) { \ ALARM_DATA_T dat1; \ dat1.dataType = ALARM_DATA_TYPE_F32; \ @@ -169,26 +154,36 @@ activateAlarm2Data( a, dat1, dat2 ); \ } +/// Macro to set a specific alarm with 2 pieces of floating point alarm data. +#define SET_ALARM_WITH_2_F32_DATA(a,d1,d2) { \ + ALARM_DATA_T dat1; \ + ALARM_DATA_T dat2; \ + dat1.dataType = ALARM_DATA_TYPE_F32; \ + dat1.data.flt.data = (F32)(d1); \ + dat2.dataType = ALARM_DATA_TYPE_F32; \ + dat2.data.flt.data = (F32)(d2); \ + activateAlarm2Data( a, dat1, dat2 ); \ +} + // **** VectorCAST Definitions **** #ifdef _VECTORCAST_ #define _enable_IRQ() #define _disable_IRQ() #define _enable_FIQ() - #ifndef _MINGW_ - #pragma WEAK(can1LowLevelInterrupt) - void can1LowLevelInterrupt(void) {} - #pragma WEAK(can1HighLevelInterrupt) - void can1HighLevelInterrupt(void) {} - #endif + #define _disable_FIQ() + #define fabs(v) ((v) < 0.0 ? ((v) * -1.0) : (v)) #endif -// include alarm mgmt header +// include alarm mgmt header so any module can trigger an alarm #include "AlarmMgmt.h" +// include Message definitions header for access to system message IDs +#include "MsgDefs.h" + // include test support definitions and macros #include "TestSupport.h"