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

nRF52832

static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);

Hi Everyone,

I'm new to nRF52832 programming. I want to learn more about nRF52 programs. 

I'm starts from this above line. What is the function of this line and why it's used?

And i want learn nRF52 programming what i want to do? I need some websites and Doc related to this.

I'm using Segger Embedded Studio IDE.

Thank you,

Regards,

Yuvaraj

Parents
  • The line "static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID)" creates a TWI instance (as julienh mentioned). The TWI instance is of the type nrf_drv_twi_t, which is a struct with the following fields:

    typedef struct
    {
        uint8_t inst_idx;
        union
        {
    #ifdef TWIM_PRESENT
            nrfx_twim_t twim;
    #endif
    #ifdef TWI_PRESENT
            nrfx_twi_t  twi;
    #endif
        } u;
        bool    use_easy_dma;
    } nrf_drv_twi_t

    The function NRF_DRV_TWI_INSTANCE() will create an instance of the struct above. The input can be either 0 or 1, and decides if one should use TWI instance 0 or 1 of the nRF52832 chip. If EasyDMA is enabled in the SoftDevice TWIM will be used and the field use_easy_dma will be set to true.

    If you are new to Nordic's chips, I would recommend you to take a look at the link provided by julienh, and go through the steps listed (at least the first four).

    Best regards,

    Simon

Reply
  • The line "static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID)" creates a TWI instance (as julienh mentioned). The TWI instance is of the type nrf_drv_twi_t, which is a struct with the following fields:

    typedef struct
    {
        uint8_t inst_idx;
        union
        {
    #ifdef TWIM_PRESENT
            nrfx_twim_t twim;
    #endif
    #ifdef TWI_PRESENT
            nrfx_twi_t  twi;
    #endif
        } u;
        bool    use_easy_dma;
    } nrf_drv_twi_t

    The function NRF_DRV_TWI_INSTANCE() will create an instance of the struct above. The input can be either 0 or 1, and decides if one should use TWI instance 0 or 1 of the nRF52832 chip. If EasyDMA is enabled in the SoftDevice TWIM will be used and the field use_easy_dma will be set to true.

    If you are new to Nordic's chips, I would recommend you to take a look at the link provided by julienh, and go through the steps listed (at least the first four).

    Best regards,

    Simon

Children
Related