How to use MCUXpresso SDK API (SDSPI)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use MCUXpresso SDK API (SDSPI)

971 Views
stephenfzhou
Contributor I

Hi All,

I'm a new user of NXP's MCU.  I want to use the SDSPI in MCUXpresso SDK API, but I don't know how to do the initial. The typical use case is written as below:

/* SPI_Init(). */
/* Register the SDSPI driver callback. */
/* Initializes card. */
if (kStatus_Success != SDSPI_Init(card))
and I also check the definition of struct "sdspi_host_t" and "sdspi_card_t".
But I'm confused about how to initialize them, how to use the SPI1 port to use the API.  
ps: I'm using FRDM-KL46Z and Xpresso IDE + SDK 2.4.1.
Thank you for your kindly reply!
0 Kudos
4 Replies

833 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Fei,

Please read the following documents in order to implement FatFs using SPI.

Porting FatFs file system to KL26 SPI SD card code 

https://www.nxp.com/docs/en/application-note/AN10406.pdf 

Regards,

Jing

0 Kudos

833 Views
stephenfzhou
Contributor I

Hi Jing, 

Thank you for your kindly reply!

The tutorial you gave is really useful to implement FatFs using SPI. But my project developed on SDK 2.4.1, actually I don't need FatFs.

And the problem I met is when I used the SDSPI, I found in the function SDSPI_Init(card), the structure "card" is defined by struct "sdspi_host_t" and "sdspi_card_t".  And I don't know how to connect to the SPI port: SPI1. I didn't find any information about it in Reference Manual

I'm a new developer, appreciate any specific tips! 

Thank you!

Best,

Fei

0 Kudos

833 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

You should initialize sdspi_card_t base on your card. The  "sdspi_host_t" is initialize in fsl_sdspi_disk.c.

BOARD_SDSPI_SPI_BASE should point to the SPI peripheral you used. Define BOARD_SDSPI_SPI_BASE in board.h.

Regards,

Jing

0 Kudos

833 Views
stephenfzhou
Contributor I

Hi Jing,

Thanks! I'll have a try.

Best,

Fei

0 Kudos