Adding SPI to a project

I am running VSCode with the latest nRF extension. I am on v2.9.1 of the SDK

I created a new app and copied the bluetooth_st_ble_sensor sample project.

I would like to add SPI to this project.

I don't know how.

I tried using KConfig GUI, but it doesn't come up. I have another ticket here for that one.

Parents
  • I created this application using the "copy a sample" option in VSCode. It doesn't have a sysbuild.conf or sysbuild folder. The sample I copied was the Bluetooth Peripheral sample.

    Is that an issue?

    Can I add a custom driver to an application copied from that sample. If so, what are the details of doing that?

    I will do that tutorial on sysbuild as an additional thing so I understand sysbuild better as well.

  • On a related note I have some things building now and ran into an error that may or may not be related to the folder structure or how the project is set up.

    I am getting errors that it can't find my node that I defined in my overlay:

    That image also shows the spi config with the node.

    Here is my ti,cc1101.yaml file:

    # Copyright (c) 2018, Linaro Limited
    # SPDX-License-Identifier: Apache-2.0

    description: Texas Instruments CC1101 wireless transceiver

    compatible: "ti,cc1101"

    include: spi-device.yaml

    properties:
    int_gpios:
    type: phandle-array
    required: true
    description: |
    GPIOs connected to the GDO0 and GDO2 pins of the transceiver.
    cs-gpios:
    type: phandle-array
    description: |
    GPIO connected nCS
    frequency:
    type: int
    description: |
    The carrier frequency, in kHz.
    bitrate:
    type: int
    description: |
    The bitrate in bit per second.
    How do I fix this issue?
  • Tony said:

    I created this application using the "copy a sample" option in VSCode. It doesn't have a sysbuild.conf or sysbuild folder. The sample I copied was the Bluetooth Peripheral sample.

    Is that an issue?

    No, that is not an issue and is the approach we recommend when starting from a sample.

    Most samples does not have a sysbuild folder, since they don't use any companion components. As an example, an exception is the multicore SoCs such as the nRF5340 In those cases the build system detects that if it is an nRF5340 and that it uses BLE, it should automatically add the HCI_IPC companion component so that it has BLE. If you were to make a BLE application for the nRF5340, you would have to do this manually by yourself, i.e add a sysbuild.conf and a sysbuild folder where you add any configurations specific for the hci_ipc image that will run on the netcore.

    But that is just a digression. For your case with the nRF54L15 this will not be relevant for the BLE image since it does not have a network core such as the nRF5340 has. It will however be relevant if you intend to add DFU and MCUboot support. In that case you will have to create a sysbuild.conf and sysbuild folder for the relevant configurations.

    Here's another example of a project that works in sysbuild without any sysbuild related configurations and a custom device binding: https://github.com/NordicDeveloperAcademy/ncs-inter/tree/main/v2.9.0-v2.7.0/l4/l4_e2_sol. It is from lesson 4 in the intermediate course. 

    Tony said:
    I am getting errors that it can't find my node that I defined in my overlay:

    Does this device exist in the device bindings? It has to either be placed within the project as illustrated in the L4E2 solution git link or the device has to be placed in a folder that your project knows about

    Kind regards,
    Andreas

  • I do have the bindings file in a dts/bindings folder called ti,cc1101.yaml. Here are the contents:

    ```
    # Copyright (c) 2018, Linaro Limited
    # SPDX-License-Identifier: Apache-2.0

    description: Texas Instruments CC1101 wireless transceiver

    compatible: "ti-cc1101"

    include: spi-device.yaml

    properties:
    int_gpios:
    type: phandle-array
    required: true
    description: |
    GPIOs connected to the GDO0 and GDO2 pins of the transceiver.
    cs-gpios:
    type: phandle-array
    description: |
    GPIO connected nCS
    frequency:
    type: int
    description: |
    The carrier frequency, in kHz.
    bitrate:
    type: int
    description: |
    The bitrate in bit per second.
    ```
    I tried the compatible line with ti,cc1101 and that didn't change anything. I made it a dash (-) because that is how it is in L4E2.
    Here is the relevant section in the overlay file:
    ```
    &spi21 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    pinctrl-0 = <&spi21_default>;
    pinctrl-1 = <&spi21_sleep>;
    pinctrl-names = "default", "sleep";
    cs-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
    cc1101: cc1101@0 {
    reg = <0>;
    compatible = "ti,cc1101";
    spi-max-frequency = <2500000>;
    int_gpios = <&gpio1 7 (GPIO_ACTIVE_LOW)>, <&gpio0 34 (GPIO_ACTIVE_LOW)>;
    frequency = <868300>;
    bitrate = <38368>;
    status = "okay";
    };
    };
    ```
    Here is the error I am getting:
    ```
    .../build/BLETPMSBridge/zephyr/include/generated/zephyr/devicetree_generated.h:14776:31: error: 'DT_N_S_soc_S_peripheral_50000000_S_spi_c7000_S_cc1101_0_P_bitrate' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_spi_c7000_S_cc1101_0_P_status'?
    14776 | #define DT_N_INST_0_ti_cc1101 DT_N_S_soc_S_peripheral_50000000_S_spi_c7000_S_cc1101_0
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ```
  • This is the line I am getting the error on:

    #define SPIOP SPI_WORD_SET(8) | SPI_TRANSFER_MSB
    struct spi_dt_spec spispec = SPI_DT_SPEC_GET(DT_NODELABEL(cc1101), SPIOP, 0);

Reply Children
No Data
Related