Hello All.
I try to build a generic function that read device reg over its I2C. I take the TWI master example of Nordic.
There is need for callback function to get in the ISR whenever there is a replay.
It build statically put the function name in nrf_twi_mngr_transaction_t type like this
static nrf_twi_mngr_transaction_t NRF_TWI_MNGR_BUFFER_LOC_IND transaction =
{
.callback = read_all_cb,
.p_user_data = NULL,
.p_transfers = transfers,
.number_of_transfers = sizeof(transfers) / sizeof(transfers[0])
};
But I want to give the function name in the function input and place it inside like this:
Serial_read_2BytesReg(uint8_t instance,uint8_t dev_add, uint16_t reg_add,void const * p_buffer,size_t size, nrf_twi_mngr_callback_t callback_fn )
.
.
.
nrf_twi_mngr_transaction_t NRF_TWI_MNGR_BUFFER_LOC_IND transaction =
{
.callback = callback_fn,
.p_user_data = NULL,
.p_transfers = transfers,
.number_of_transfers = sizeof(transfers) / sizeof(transfers[0])
};
I also place its prototype in the h file
I don't get error during build, but on run it fail. So I try to place brake point into the callback function but it tell me I can't. It is look like it don't place any code for it.
1. Can I place the callback function to the struct and don't make it const?
2. What should I I do so it recognize that function?
Thanks
Bar.