This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI master and slave on the same port

Hi

I am using the nRF52840 with an external sensor which I need to config (nRF is the master). after this, nRF is acting like a I2C slave (twis) and i like to trigger an interrupt as soon as the sensor is sending some data (sensor = master, nRF = slave) To read out values from the sensor, nRF will change to master, sensor to slave.

nRF is always the master or the slave, not both at the same time of course.

Master communication is running, but as soon as I enabled the twis in the SDK config, I got the Error of an already defined IRQ:

multiple definition of `SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler;

what I found in the DevZone is that nRF is using the same IDs and it would be possible to solve this with the function

nrfx_err_t nrfx_prs_acquire(void       const * p_base_addr,
                            nrfx_irq_handler_t irq_handler);

Is tis correct? How do I have to implement this function to solve the Error?

Do you have an example which shows how should this be implemented?

Thanks a lot

Parents Reply Children
  • Like I saw in this code, I have to handle manually, or is there aother example you know?

    /* Force resource release. This is necessary because mbed drivers don't
             * deinitialize on object destruction.
             */
            NRFX_IRQ_DISABLE((nrfx_get_irq_number((void const *)nordic_nrf5_twi_register[instance])));
            /* Release and re-initialize the irq handlers.
             * observation: based on call flow, this is called only during i2c_reset and i2c_byte_write
             * The nrfx_prs_acquire is normally called in nrfx_twi_init which is part of the i2c_configure_driver_instance,
             * not i2c_configure_twi_intance. Hence I think the release and acquire is not doing any useful work here.
             * Keeping for reference and should clean up after testing if found not useful.
            */
    
            nrfx_prs_release(nordic_nrf5_twi_register[instance]);
            if (nrfx_prs_acquire(nordic_nrf5_twi_register[instance],
                                 irq_handlers[instance]) != NRFX_SUCCESS) {
                DEBUG_PRINTF("Function: %s, nrfx_prs_acquire error code: %s.",
                             __func__,
                             err_code);
            }
    

  • I see. I haven't used mbed, I don't know why they require this to be handled manually.

    For regular nRF5 SDK projects it should be sufficient to add nrfx_prs to the project and add those two defines in sdk_config.

Related