2 posts / 0 new
Last post
awesley
Offline
Last seen:2 years 10 months ago
Joined:2015-07-07 12:08
#define DBG_SWDIAG(bank , field , value)

大家好,有个问题想请教下:
/// Macro used to set a SW diag to specific value
#define DBG_SWDIAG(bank , field , value)

上面定义的宏什么意思,不是很明白。
DBG_SWDIAG(SLEEP, ALGO, 0);
DBG_SWDIAG(SLEEP, ALGO, 1);
DBG_SWDIAG(SLEEP, ALGO, 2);
DBG_SWDIAG(SLEEP, ALGO, 3);
DBG_SWDIAG(SLEEP, ALGO, 4);
DBG_SWDIAG(SLEEP, ALGO, 5);
DBG_SWDIAG(SLEEP, ALGO, 6);

Keywords:
Device:
snowdream1
Offline
Last seen:4 months 1 week ago
Staff
Joined:2014-08-17 14:25
看一下宏的定义:

看一下宏的定义:
#define DBG_SWDIAG(bank , field , value) \
如果(sw_to_hw [DBG_SWDIAG_ # #银行]! = DBG_SWDIAG_UNDEFINED) \
{ \
SW_DIAG_SET( ((SW_DIAG_GET()) & (~(DBG_SWDIAG_##bank##_##field##_MASK << (8 * sw_to_hw[DBG_SWDIAG_##bank])))) | ((((value << DBG_SWDIAG_##bank##_##field##_OFFSET) & DBG_SWDIAG_##bank##_##field##_MASK) << (8*sw_to_hw[DBG_SWDIAG_##bank]))) ); \
}

现在分配了24个bank,见Dbg_swdiag.h。用来记录软件运行的自定义调试信息。最后调用下面的函数写到相应的寄存器里面。也可以调用读操作,读取运行最后的状态

__INLINE void ble_swprofiling_set(uint32_t value)
{
REG_BLE_WR(BLE_SWPROFILING_ADDR, value);
}