Hello,
Could you help me to unpack this MACRO? It's hard to understand how it works, and it is impossible to debug!
here they are: SH_SENS_CHANNEL_CONFIG_DEF(...); SH_SENS_PROFILE_CONFIG_DEF(...); SH_SENS_CHANNEL_CONFIG(...); SH_SENS_PROFILE_CONFIG(...);
#define HRM_SENS_CHANNEL_CONFIG_DEF(NAME, \
CHANNEL_NUMBER, \
TRANSMISSION_TYPE, \
DEVICE_NUMBER, \
NETWORK_NUMBER) \
static const ant_channel_config_t CONCAT_2(NAME,_channel_hrm_sens_config)={ \
.channel_number = (CHANNEL_NUMBER), \
.channel_type = HRM_SENS_CHANNEL_TYPE, \
.ext_assign = HRM_EXT_ASSIGN, \
.rf_freq = HRM_ANTPLUS_RF_FREQ, \
.transmission_type = (TRANSMISSION_TYPE), \
.device_type = HRM_DEVICE_TYPE, \
.device_number = (DEVICE_NUMBER), \
.channel_period = HRM_MSG_PERIOD_4Hz, \
.network_number = (NETWORK_NUMBER), \
}
#define HRM_SENS_PROFILE_CONFIG_DEF(NAME, \
PAGE_1_PRESENT, \
MAIN_PAGE_NUMBER, \
EVT_HANDLER) \
static ant_hrm_sens_cb_t CONCAT_2(NAME,_hrm_sens_cb); \
static const ant_hrm_sens_config_t CONCAT_2(NAME,_profile_hrm_sens_config) ={ \
.page_1_present = (PAGE_1_PRESENT), \
.main_page_number = (MAIN_PAGE_NUMBER), \
.p_cb = &CONCAT_2(NAME,_hrm_sens_cb), \
.evt_handler = (EVT_HANDLER), \
}
#define HRM_SENS_CHANNEL_CONFIG(NAME) &CONCAT_2(NAME,_channel_hrm_sens_config)
#define HRM_SENS_PROFILE_CONFIG(NAME) &CONCAT_2(NAME,_profile_hrm_sens_config)
static ant_hrm_profile_t m_ant_hrm;
static void ant_hrm_evt_handler( ant_hrm_profile_t *p_profile, ant_hrm_evt_t event ); // forward declaration
HRM_SENS_CHANNEL_CONFIG_DEF( m_ant_hrm, HRM_CHANNEL_NUM, CHAN_ID_TRANS_TYPE, CHAN_ID_DEV_NUM, ANTPLUS_NETWORK_NUM );
HRM_SENS_PROFILE_CONFIG_DEF( m_ant_hrm, true, ANT_HRM_PAGE_0, ant_hrm_evt_handler );
void foo( void ) {
ret_code_t err_code;
err_code = ant_hrm_sens_init( &m_ant_hrm,
HRM_SENS_CHANNEL_CONFIG( m_ant_hrm ),
HRM_SENS_PROFILE_CONFIG( m_ant_hrm ) );
APP_ERROR_CHECK( err_code );
return;
Thanks!