Enable SPIM0 and TWIM1 Drivers in KConfig NCS

Hello,

I am trying to enable the SPIM0 and TWIM1 drivers for my current project. Under the VS Code GUI for KConfig, I see the options, but they are grayed out and cannot be selected. Can someone guide me as to how to enable them? Maybe I have something enabled/disabled that is causing this. Manually adding them in the KConfig only produces compile errors. I am using nRF Connect SDK v2.1.2 and have the nRF52 DK (nRF52832) board for eval purposes.

Thanks,

Adnan

Parents Reply Children
  • Hello Siguard,

    So in the echo_bot example I commented out the CONFIG_NRFX_SPIM0 and CONFIG_NRFX_TWIM1 configs in the prj.conf file and the overlay file already had the spi0 and i2c1 enabled as follows:

    &spi0 {
        status = "okay";
    };

    &spi1 {
        status = "disabled";
    };

    &i2c1 {
        status = "okay";
    };

    &i2c0 {
        status = "disabled";
    };
    I built and flashed the sample to the board but again I do not get anything on the RTT.
    Please advise.
     
    Adnan

     

  • Hello,

    So I added the following to the overlay file:

    &spi0 {

        compatible = "nordic,nrf-spim";
        status = "okay";
        sck-pin = <23>;
        mosi-pin = <25>;
        miso-pin = <24>;
        cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    };
    &spi1 {
        status = "disabled";
    };

    &i2c0 {
        status = "disabled";
    };

    &i2c1 {
        compatible = "nordic,nrf-twim";
        status = "okay";
    };
    I added the following to the prj.conf:
    #Enable SPI and I2C
    CONFIG_SPI=y
    CONFIG_I2C=y
    CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58=y
    The following to the KCONFIG:
    config CONFIG_SPI_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_SPI

    config CONFIG_I2C_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_I2C
    Now I seem to have access to the SPIM and TWIM drivers!
    Please advise if this is the right approach?
    Now I am trying to find the equivalent in NCS for the following:
    Get image data over the SPI/TWI and send it over BLE to device
    Any help/sample code to get this done would be most helpful.
    Thanks!
  • Hi,

    It looks like it should work.
    The following part seems redundant, since you already set CONFIG_SPI and CONFIG_I2C in prj.conf:

    adnankhalid said:
    The following to the KCONFIG:
    config CONFIG_SPI_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_SPI

    config CONFIG_I2C_NRFX
        bool "Enable SPI NRFX"
        default y
        select CONFIG_I2C

    To get started with SPI and I2C, see the following:

    Zephyr drivers for SPI and I2C.

    For C code, have a look at this spi test.

    For an I2C example, I always liked https://github.com/crfosse/ncs_projects/tree/main/peripheral_zephyr/i2c.

    For how to send serial data over Bluetooth Low Energy, the Peripheral UART sample  should be relevant.

    Regards,
    Sigurd Hellesvik

Related