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

Where is the structure definition inside the sdk for peripheral registers structure used in the two wire interface api functions?

Hi everyone,

I was just going through the library functions provided here in this link : nordic functions twi

But inside all these functions ,there is this parameter which is a pointer to a structure of this format : 

NRF_TWI_Type *  p_reg

Can anyone tell me where i can find the elements that needs to be stored inside this structure ? or give me any idea on how to declare and define this structure?

Thanks!

Rajat

Parents
  • Hi,

    NRF_TWI_Type * is a pointer to a structure with TWI registers. If you are using nRF52832 you will find the definition of the structure in a file called nrf52.h. This is what the structure looks like in SDK 15:

    /**
      * @brief I2C compatible Two-Wire Interface 0 (TWI)
      */
    
    typedef struct {                                    /*!< TWI Structure                                                         */
      __O  uint32_t  TASKS_STARTRX;                     /*!< Start TWI receive sequence                                            */
      __I  uint32_t  RESERVED0;
      __O  uint32_t  TASKS_STARTTX;                     /*!< Start TWI transmit sequence                                           */
      __I  uint32_t  RESERVED1[2];
      __O  uint32_t  TASKS_STOP;                        /*!< Stop TWI transaction                                                  */
      __I  uint32_t  RESERVED2;
      __O  uint32_t  TASKS_SUSPEND;                     /*!< Suspend TWI transaction                                               */
      __O  uint32_t  TASKS_RESUME;                      /*!< Resume TWI transaction                                                */
      __I  uint32_t  RESERVED3[56];
      __IO uint32_t  EVENTS_STOPPED;                    /*!< TWI stopped                                                           */
      __IO uint32_t  EVENTS_RXDREADY;                   /*!< TWI RXD byte received                                                 */
      __I  uint32_t  RESERVED4[4];
      __IO uint32_t  EVENTS_TXDSENT;                    /*!< TWI TXD byte sent                                                     */
      __I  uint32_t  RESERVED5;
      __IO uint32_t  EVENTS_ERROR;                      /*!< TWI error                                                             */
      __I  uint32_t  RESERVED6[4];
      __IO uint32_t  EVENTS_BB;                         /*!< TWI byte boundary, generated before each byte that is sent or
                                                             received                                                              */
      __I  uint32_t  RESERVED7[3];
      __IO uint32_t  EVENTS_SUSPENDED;                  /*!< TWI entered the suspended state                                       */
      __I  uint32_t  RESERVED8[45];
      __IO uint32_t  SHORTS;                            /*!< Shortcut register                                                     */
      __I  uint32_t  RESERVED9[64];
      __IO uint32_t  INTENSET;                          /*!< Enable interrupt                                                      */
      __IO uint32_t  INTENCLR;                          /*!< Disable interrupt                                                     */
      __I  uint32_t  RESERVED10[110];
      __IO uint32_t  ERRORSRC;                          /*!< Error source                                                          */
      __I  uint32_t  RESERVED11[14];
      __IO uint32_t  ENABLE;                            /*!< Enable TWI                                                            */
      __I  uint32_t  RESERVED12;
      __IO uint32_t  PSELSCL;                           /*!< Pin select for SCL                                                    */
      __IO uint32_t  PSELSDA;                           /*!< Pin select for SDA                                                    */
      __I  uint32_t  RESERVED13[2];
      __I  uint32_t  RXD;                               /*!< RXD register                                                          */
      __IO uint32_t  TXD;                               /*!< TXD register                                                          */
      __I  uint32_t  RESERVED14;
      __IO uint32_t  FREQUENCY;                         /*!< TWI frequency                                                         */
      __I  uint32_t  RESERVED15[24];
      __IO uint32_t  ADDRESS;                           /*!< Address used in the TWI transfer                                      */
    } NRF_TWI_Type;

    You can see how it lines up the actual TWI peripheral registers

Reply
  • Hi,

    NRF_TWI_Type * is a pointer to a structure with TWI registers. If you are using nRF52832 you will find the definition of the structure in a file called nrf52.h. This is what the structure looks like in SDK 15:

    /**
      * @brief I2C compatible Two-Wire Interface 0 (TWI)
      */
    
    typedef struct {                                    /*!< TWI Structure                                                         */
      __O  uint32_t  TASKS_STARTRX;                     /*!< Start TWI receive sequence                                            */
      __I  uint32_t  RESERVED0;
      __O  uint32_t  TASKS_STARTTX;                     /*!< Start TWI transmit sequence                                           */
      __I  uint32_t  RESERVED1[2];
      __O  uint32_t  TASKS_STOP;                        /*!< Stop TWI transaction                                                  */
      __I  uint32_t  RESERVED2;
      __O  uint32_t  TASKS_SUSPEND;                     /*!< Suspend TWI transaction                                               */
      __O  uint32_t  TASKS_RESUME;                      /*!< Resume TWI transaction                                                */
      __I  uint32_t  RESERVED3[56];
      __IO uint32_t  EVENTS_STOPPED;                    /*!< TWI stopped                                                           */
      __IO uint32_t  EVENTS_RXDREADY;                   /*!< TWI RXD byte received                                                 */
      __I  uint32_t  RESERVED4[4];
      __IO uint32_t  EVENTS_TXDSENT;                    /*!< TWI TXD byte sent                                                     */
      __I  uint32_t  RESERVED5;
      __IO uint32_t  EVENTS_ERROR;                      /*!< TWI error                                                             */
      __I  uint32_t  RESERVED6[4];
      __IO uint32_t  EVENTS_BB;                         /*!< TWI byte boundary, generated before each byte that is sent or
                                                             received                                                              */
      __I  uint32_t  RESERVED7[3];
      __IO uint32_t  EVENTS_SUSPENDED;                  /*!< TWI entered the suspended state                                       */
      __I  uint32_t  RESERVED8[45];
      __IO uint32_t  SHORTS;                            /*!< Shortcut register                                                     */
      __I  uint32_t  RESERVED9[64];
      __IO uint32_t  INTENSET;                          /*!< Enable interrupt                                                      */
      __IO uint32_t  INTENCLR;                          /*!< Disable interrupt                                                     */
      __I  uint32_t  RESERVED10[110];
      __IO uint32_t  ERRORSRC;                          /*!< Error source                                                          */
      __I  uint32_t  RESERVED11[14];
      __IO uint32_t  ENABLE;                            /*!< Enable TWI                                                            */
      __I  uint32_t  RESERVED12;
      __IO uint32_t  PSELSCL;                           /*!< Pin select for SCL                                                    */
      __IO uint32_t  PSELSDA;                           /*!< Pin select for SDA                                                    */
      __I  uint32_t  RESERVED13[2];
      __I  uint32_t  RXD;                               /*!< RXD register                                                          */
      __IO uint32_t  TXD;                               /*!< TXD register                                                          */
      __I  uint32_t  RESERVED14;
      __IO uint32_t  FREQUENCY;                         /*!< TWI frequency                                                         */
      __I  uint32_t  RESERVED15[24];
      __IO uint32_t  ADDRESS;                           /*!< Address used in the TWI transfer                                      */
    } NRF_TWI_Type;

    You can see how it lines up the actual TWI peripheral registers

Children
Related