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

How mandny TWI_;NGR instances are possible

Hi,

I would like to have two different twi managers. One with TWI0 and one with TWI1. But if I try to enable them I get an error:

sdk_config.h:1810:22: error: unable to find numeric literal operator 'operator""_INSTANCE_INDEX'

Is there a reason for this?

Thanks,

C.W.

  • Post the file here. This is probably just a syntax error.

  • Okay it is inside a c++ class:

    #include <nrf_gpio.h>
    #include <nrf_drv_gpiote.h>
    #include <nrf_error.h>
    #include <nrf_delay.h>
    #include <nrf_drv_twi.h>
    #include <app_util_platform.h>
    #include <nrf_twi_mngr.h>
    #include "peripheral_pin_map.h"

    #include "PowerModule.hpp"

    #define NRF_LOG_MODULE_NAME POWERMODULE
    #include "nrf_log.h"
    NRF_LOG_MODULE_REGISTER();

    static const uint8_t MAX_PENDING_FUEL_GAUGE_TRANSACTIONS = 10;

    NRF_TWI_MNGR_DEF(m_nrf_twi_mngr_fuel, MAX_PENDING_FUEL_GAUGE_TRANSACTIONS, TWI1_INSTANCE_INDEX);

    nrf_drv_twi_config_t const twi_stc3100_config = {
       .scl                = FUEL_GAUGE_SCL,
       .sda                = FUEL_GAUGE_SDA,
       .frequency          = NRF_TWI_FREQ_400K,
       .interrupt_priority = APP_IRQ_PRIORITY_LOW,
       .clear_bus_init     = false
    };

    That is the beginning and the sdk_config.h looks like this:

    // <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
    //==========================================================
    #ifndef TWI_ENABLED
    #define TWI_ENABLED 1
    #endif
    // <o> TWI_DEFAULT_CONFIG_FREQUENCY  - Frequency
     
    // <26738688=> 100k
    // <67108864=> 250k
    // <104857600=> 400k

    #ifndef TWI_DEFAULT_CONFIG_FREQUENCY
    #define TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif

    // <q> TWI_DEFAULT_CONFIG_CLR_BUS_INIT  - Enables bus clearing procedure during init
     

    #ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT
    #define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0
    #endif

    // <q> TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT  - Enables bus holding after uninit
     

    #ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif

    // <o> TWI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     

    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest)
    // <1=> 1
    // <2=> 2
    // <3=> 3
    // <4=> 4
    // <5=> 5
    // <6=> 6
    // <7=> 7

    #ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY
    #define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 7
    #endif

    // <e> TWI0_ENABLED - Enable TWI0 instance
    //==========================================================
    #ifndef TWI0_ENABLED
    #define TWI0_ENABLED 1
    #endif
    // <q> TWI0_USE_EASY_DMA  - Use EasyDMA (if present)
     

    #ifndef TWI0_USE_EASY_DMA
    #define TWI0_USE_EASY_DMA 1
    #endif

    // </e>

    // <e> TWI1_ENABLED - Enable TWI1 instance
    //==========================================================
    #ifndef TWI1_ENABLED
    #define TWI1_ENABLED 1
    #endif
    // <q> TWI1_USE_EASY_DMA  - Use EasyDMA (if present)
     

    #ifndef TWI1_USE_EASY_DMA
    #define TWI1_USE_EASY_DMA 1
    #endif

    Since I use the TWI0 already for a different sensor bus. I would like to use TWI1 but if I use the TWI1 it gives errors.

  • Where did you define TWI1_INSTANCE_INDEX? Have you tried replacing this with 1?

  • Yes this was the issue. I guess it came from some old garbage. If I replace them with exactly 1 and 0 it is running.

Related