Post Go back to editing

Simple SPI code hangs

It's the simplest test case for SPI i could come up with, and it hangs at the transceiver call.

yes, I know i'm not checking the results, but I traced through this with the debugger and all of the set-up calls succeed.

It looks like maybe it's hung trying to release a semaphore ?  Whatever is happening is something in the driver, because, as you can see, I'm not using anything else.

spitest.h is emtpy, so it can be commented out in the code.


#include <sys/platform.h>
#include <drivers/spi/adi_spi.h>
#include <stdio.h>

#include "adi_initialize.h"
#include "spitest.h"

/* SPI driver memory */
static uint8_t SPIDriverMemory[ADI_SPI_INT_MEMORY_SIZE];

/* pointer to store transceiver */

/* SPI driver handle */
static ADI_SPI_HANDLE hDevice;

* If you want to use command program arguments, then place them in the following string.
char __argv_string[] = "";

int main(int argc, char *argv[])
void *prologue = NULL;
void *rx_buffer = NULL;
uint8_t tx_buffer[3] = {0x00, 0x00, 0x00};

ADI_SPI_TRANSCEIVER transceiver = {prologue, 0, &tx_buffer[0], 3, rx_buffer, 0};

* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success


result = adi_spi_Open(1, SPIDriverMemory, (uint32_t)ADI_SPI_DMA_MEMORY_SIZE, &hDevice);

/* Begin adding your custom code here */
result = adi_spi_RegisterCallback(hDevice, NULL, NULL);

/* Disable DMA */
result = adi_spi_EnableDmaMode(hDevice, false);
result = adi_spi_SetHwSlaveSelect(hDevice, true);
result = adi_spi_SetMaster(hDevice, true);
result = adi_spi_SetWordSize(hDevice, ADI_SPI_TRANSFER_8BIT);
// divides SCLK. So now the question is how to find out what SCLK is set to.
result = adi_spi_SetClock(hDevice, 10);
result = adi_spi_SetSlaveSelect(hDevice, ADI_SPI_SSEL_ENABLE3);
result = adi_spi_ReadWrite(hDevice, &transceiver);

result = adi_spi_Close(hDevice);

return 0;