Cheers, again!
Our project uses an array of different modules, many of which will need to make use of the TWI manager.
I've been able to create the manager successfully using
NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID); void twi_init (void){ uint32_t err_code; ret_code_t ret; const nrf_drv_twi_config_t config = { .scl = TWI_SCL, .sda = TWI_SDA, .frequency = NRF_TWI_FREQ_100K, .interrupt_priority = APP_IRQ_PRIORITY_HIGH, .clear_bus_init = false }; ret = nrf_twi_mngr_init(&m_nrf_twi_mngr, &config); printf("twi_config nrf_twi_mngr_init %d \n", ret); }
If the manager is defined in the same function I call
APP_ERROR_CHECK(nrf_twi_mngr_schedule(&m_nrf_twi_mngr, &accel_modeset_transaction));
It queues up fine.
However, I'm trying to extract the TWI management into its own module (with its own .c and .h) that other modules wishing to use it can call in (such as my accelerator, my temp sensor, and other sensors). Queueing into the manager schedule within each of these require a pointer to m_nrf_twi_mngr, however when generated with the NRF_TWI_MNGR_DEF macro, &m_nrf_twi_mngr only accessible within the c file I declare it.
I've yet to figure out how to expose this to other modules who want to use it.
Defining "nrf_twi_mngr_t m_nrf_twi_mngr" in the h gives me compile errors over either conflicting qualifiers, or multiple definitions.
I've tried moving the macro into the twi.h, but I get a flood of linker errors such as:
TWI/twi.h:19: multiple definition of `m_nrf_twi_mngr_queue' twi.h:19: first defined here TWI/twi.h:19: multiple definition of `m_nrf_log_queue_m_nrf_twi_mngr_queue_logs_data_dynamic' twi.h:19: first defined here TWI/twi.h:19: multiple definition of `m_nrf_log_queue_m_nrf_twi_mngr_queue_logs_data_const' twi.h:19: first defined here
Those 3 get repeated 9 times.
Is there a known way to instantiate the m_nrf_twi_mngr in a way that would let me expose it in other module's C files, where I can define transactions and such like so
void accel_init_cb(ret_code_t result, void * p_user_data){ printf("accel_init_cb: %ld \n",result); } static nrf_twi_mngr_transfer_t const transfers_accel_init[] ={ NRF_TWI_MNGR_WRITE(ACCEL_ADDRESS, accel_init_regdata, sizeof(accel_init_regdata), 0) }; nrf_twi_mngr_transaction_t NRF_TWI_MNGR_BUFFER_LOC_IND accel_init_transaction ={ .callback = accel_init_cb, .p_user_data = NULL, .p_transfers = transfers_accel_init, .number_of_transfers = sizeof(transfers_accel_init) / sizeof(transfers_accel_init[0]) }; void start_accel(){ // <--- This would be the function called in an overarching HAL.c APP_ERROR_CHECK(nrf_twi_mngr_schedule(&m_nrf_twi_mngr, &accel_init_transaction)); }
I can't seem to find any examples that instantiate the manager in a way that let's it be referenced from an included source; any help would be exceptionally appreciated!
Oh, and we're using SDK 15.0, SoftDevice 6.0, and the NRF5832 on a custom board, compiled with GCC
Thanks!