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

How to disable/uninitialize SPI on nRF9160DK used for interfacing SD card?

Hello,

I interfaced nRF9160 and SD card using SPI. I started with this sample: ncs/zephyr/samples/subsys/fs/fat_fs.

Now once the files from SD card are read, I want to uninitialize this SPI, so it can be used by other peripheral. So how can I disable or uninitialize this SPI?

I found that by using "sdhc_spi_set_cs(data, 1)" function, I can deassert chip select pin. But using this function in main program gives the error. I included the header files, still it shows error.

Code:

	while (1) {

              if(sdcard)
              {
                  sd_card();
                  file_open();
                  sdhc_spi_set_cs(data, 1);     //Error
                  sdcard = 0;
              }
		k_sleep(1000);
	}

Parents Reply
  • Hi again,

    I tried to implement DEVICE_POWER_MANAGEMENT.

    But by just adding CONFIG_DEVICE_POWER_MANAGEMENT=y in prj.conf file gives error.

    The error is:

    Building ‘zephyr/libzephyr.a’ from solution ‘build’ in configuration ‘Common’
      Compiling ‘device.c’
        #error "Add SoC's core devices list for PM"
        'MAX_PM_DEVICES' undeclared here (not in a function)
        'NUM_CORE_DEVICES' undeclared (first use in this function); did you mean 'MAX_PM_DEVICES'?
        each undeclared identifier is reported only once for each function it appears in
        'core_devices' undeclared (first use in this function); did you mean 'device'?
        
        'device_retval' defined but not used [-Wunused-variable]
        'device_ordered_list' defined but not used [-Wunused-variable]
      Compiling ‘nrf_power_clock.c’
      Compiling ‘sys_clock_init.c’
      Compiling ‘nrf_rtc_timer.c’
      Compiling ‘secure_services_ns.c’
    Build failed

    I tried to compile this example also: https://github.com/nrfconnect/sdk-zephyr/tree/master/samples/subsys/power/device_pm/src, but it gives the same error.

    How to remove this error? Do I need to add anything else in prj.conf file?

Children
No Data
Related