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

i2cDevlib port to nRF52 SDK15

Hi.

I'm trying to make the i2cDevlib work on an nRF52 DK board. 

There are several ports of the same to nRF51, and one to nRF25 but on the old SDK11.

I'm using SDK15 and cannot shift rest of my application to SDK11.

The closest I've gotten is this repo of an nRF52 Quadcopter but that too is using the old SDK and does not work.

I have the TWI working already, I can read bytes and write bytes. But there is a lot of peripheral and sensor support for i2cDevlib and I want to get that advantage over my own TWI abstraction layer. 

Any help in this matter would be highly appreciated. 

- Usman

Parents
  • Any help in this matter would be highly appreciated

    It's not clear how far you've got, and where you're stuck on this?

    Does the i2cDevlib site/documentation provide guidance for porting?

    Have you tried the i2cDevlib forums: http://www.i2cdevlib.com/contact

    One would hope that it would be well-structure, so the target-specific stuff should be well-isolated ... ?

    EDIT

    Step 1 under 'Implementation' seems to be the key: http://www.i2cdevlib.com/usage

  • Hi Awneil.

    I cannot use the Arduino framework, I have to stick to the baremetal C for my app. 

    The issue starts when the TWI is initialized. On the top, my old (working) code and the i2cDevlib (not working) code seem very alike. I even swapped the working initialization code with the non working one, but that doesn't work either.

    Working code:

    static const nrf_drv_twi_t twi_instance = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
    void twi_init(void)
    {
        ret_code_t err_code;
    
        const nrf_drv_twi_config_t twi_config = {
            .scl = TWI_SCL_PIN,
            .sda = TWI_SDA_PIN,
            .frequency = NRF_DRV_TWI_FREQ_400K,
            .interrupt_priority = APP_IRQ_PRIORITY_LOW,
            .clear_bus_init = false};
    
        err_code = nrf_drv_twi_init(&twi_instance, &twi_config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
        nrf_drv_twi_enable(&twi_instance);
    }

    Not working code:

    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(0);
    void i2cdev_initialize(void)
    {
        ret_code_t err_code;
    
        const nrf_drv_twi_config_t config = {
            .scl = SCL_PIN,
            .sda = SDA_PIN,
            .frequency = NRF_TWI_FREQ_400K,
            .interrupt_priority = APP_IRQ_PRIORITY_HIGH};
            
        err_code = nrf_drv_twi_init(&m_twi, &config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
    }

  • What, exactly, is "not working" ?

    Have you looked at the SDK examples?

Reply Children
No Data
Related