[ATSAMD51J18A-AU] SERCOM - SPI Communication

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

In my project we have to develop SPI communication between jethro processor (ARM based) and ATSAMD51J18A controller (SAM controller) .

In data sheet it is mentioned that SERCOM SPI interface is used in SAMD51.

We referred the ASF4 API reference manual to find APIs for SERCOM SPI interface.

_http://ww1.microchip.com/downloa...

 

Found some predefined API's for SPI driver. We have created new project by adding controller(SAMD51) and SPI_0 software component using Atmel Start configuration and generated the solution. In the SPI module preview code (in atmel start) found the same APIs ,which we referred from the API reference manual.

we tried some basic code to implement simple communication between master and slave (asynchronous spi slave driver has chosen) using the APIs mentioned in the API reference manual and preview code in atmel start.

Example code flow:

---------------

struct io_descriptor *io;

/*To get io_descriptor structure details for SPI module */

spi_s_async_get_io_descriptor(&SPI_0, &io);

/* To register the call back functions for TX and RX

spi_s_async_register_callback(&SPI_0, SPI_S_CB_TX, (FUNC_PTR)complete_cb_tx_SPI_0);

spi_s_async_register_callback(&SPI_0, SPI_S_CB_RX, (FUNC_PTR)complete_cb_rx_SPI_0);

/* Enabling SPI module */

spi_s_async_enable(&SPI_0);

/* Read the received data from master */

io_read(io, &ReadData,1);

if(ReadData == 0xAA) /*0xAA data received from Host*/

{

/* Send the data to master */

io_write(io, &ReturnValue,1);

}

spi_s_async_disable(&SPI_0);

Will it work or any other APIs are there for SERCOM SPI interface in SAMD51 ?

Jana8153