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

Strange definition of NRF_DRV_TWIS_DEFAULT_CONFIG

In the API file nrf_drv_twis.h for the nRF SDK, the definition of NRF_DRV_TWIS_DEFAULT_CONFIG looks interesting. The definitions for SCL and SDA pins are both set to the same value (31).

/**
 * @brief Generate default configuration for TWIS driver instance
 */
#define NRF_DRV_TWIS_DEFAULT_CONFIG \
{ \
    .addr               = { TWIS_DEFAULT_CONFIG_ADDR0, TWIS_DEFAULT_CONFIG_ADDR1 }, \
    .scl                = 31, \
    .scl_pull           = (nrf_gpio_pin_pull_t)TWIS_DEFAULT_CONFIG_SCL_PULL, \
    .sda                = 31, \
    .sda_pull           = (nrf_gpio_pin_pull_t)TWIS_DEFAULT_CONFIG_SDA_PULL, \
    .interrupt_priority = TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
}

It looks the same in both SDK 12 and SDK 13.

Parents
  • Hi Ulf, I guess purpose of these xxx_DEFAULT_CONFIG constants is to set all parameters which are board independent (= typically everything except PIN numbers) but to force you to overload it with board specific values (like PIN numbers;). I do agree that it would be good to use some generic defines in this constant (e.g. TWIS_SDA etc.) which could be set in board defines, however it is kind of chicken and egg problem: how to set them in SDK before your custom HW defines are known and how to overload that generic define later... (probably solvable but it will require some attention form developer which is probably equal to remembering "after using xxx_DEFAULT_CONFIG I need to set board specific parts manually")

Reply
  • Hi Ulf, I guess purpose of these xxx_DEFAULT_CONFIG constants is to set all parameters which are board independent (= typically everything except PIN numbers) but to force you to overload it with board specific values (like PIN numbers;). I do agree that it would be good to use some generic defines in this constant (e.g. TWIS_SDA etc.) which could be set in board defines, however it is kind of chicken and egg problem: how to set them in SDK before your custom HW defines are known and how to overload that generic define later... (probably solvable but it will require some attention form developer which is probably equal to remembering "after using xxx_DEFAULT_CONFIG I need to set board specific parts manually")

Children
No Data
Related