Community
cancel
Showing results for 
Search instead for 
Did you mean: 
RTsou
Beginner
1,292 Views

A problem : using SPI_1 interface in Zephyr

Hi :

I'm try the SPI interface with Quark C1000 CRB and used Zephyr 1.7.0.

I had reference LSM9DS0 SPI sample code to modify a testing code.

The test code use SPI_0 to read/write register of a LoRa chip is workable.

But when I change the interface to SPI_1, it can't read/write via SPI_1.

Does any special setting need to do when use SPI_1 interface in Zephyr?

my code :

void main(void)

{

struct spi_config config = { 0 };

//struct device *spi_mst_1 = device_get_binding("SPI_0"); // workable, can read REG from SPI_0

struct device *spi_mst_1 = device_get_binding("SPI_1"); // can't work, the result always 0x00 from SPI_1

uint8_t id;

int err;

printk("SPI Example application\n");

if (!spi_mst_1)

return;

config.config = SPI_MODE_CPOL | SPI_MODE_CPHA | SPI_WORD(16);

config.max_sys_freq = 256;

err = spi_configure(spi_mst_1, &config);

if (err) {

printk("Could not configure SPI device\n");

return;

}

err = spi_slave_select(spi_mst_1, 1);

if (err) {

printk("Could not select SPI slave\n");

return;

}

id = sx1276_read_version(spi_mst_1,SX1276_RegVersion);

printk("SX1276 REG Version: 0x%x\n", id);

}

0 Kudos
2 Replies
Michelle_C_Intel
Employee
247 Views

Hi ,

Your code looks ok - can you just confirm your pin connection

Quark SE Devboard LSM9DS0 pin SPI 0 SPI 1 VIN VDD_HDR_3P3 VDD_HDR_3P3 CS_G AP_GPIO24_SPI0_M_CS0_N AP_GPIO11_SPI1_M_CS0_N CS_XM VDD_HDR_3P3 VDD_HDR_3P3 SCL AP_GPIO21_SPI0_M_SCK AP_GPIO8_SPI1_M_SCK SDO_G AP_GPIO22_SPI0_M_MISOAP_GPIO9_SPI1_M_MISO SDO_XM Ground Ground SDA AP_GPIO23_SPI0_M_MOSI AP_GPIO10_SPI1_M_MOSI GND Ground Ground

If you look at the C1000 Platform User Guide you will see that some of the SPI1 signals are reserved on the CRB (for the 802.15.4 Radio Module) so you will need to consult the platform schematic if you need to use these signals.

http://www.intel.com/content/dam/www/public/us/en/documents/guides/quark-c1000-development-platform-... http://www.intel.com/content/dam/www/public/us/en/documents/guides/quark-c1000-development-platform-...

http://www.intel.com/content/dam/www/public/us/en/documents/schematic/quark-c1000-development-platfo... http://www.intel.com/content/dam/www/public/us/en/documents/schematic/quark-c1000-development-platfo...

-- Michelle.

RTsou
Beginner
247 Views

Hi Michelle :

After reference your answer, I check the Kconfig.defconfig( Quark C1000 CRB). (/zephyr/board/x86/quark_se_c1000_devboard/Kconfig.defconfig)

This file set the SPI_1 parameters.

In my prj.conf, I didn't use IEEE802154_CC2520. So, I modify the Kconfig.defconfig

and mark two line : 49 and 88.

Kconfig.defconfig :

line 49 --> # if IEEE802154_CC2520_LEGACY || IEEE802154_CC2520 || IEEE802154_CC2520_RAW

line 88 --> # endif # IEEE802154_CC2520_LEGACY || IEEE802154_CC2520 || IEEE802154_CC2520_RAW

After modfiy the file, I rebuild project, then the SPI_1 interface could workable.

Thanks~~

Reply