Hello i am using the mimxRT685 evk and use spi function to communicate with max7219 and lora lr1110
and i search for the example on sdk spi_polling_b2b_transfer_master
and modify the tx buffer to command the max7219 and lora module, but seems that its not working
below is my code:
i use SPI_MasterTransferBlocking function and the transfer is success, but its just not working
and for lr1110, the rx data buffer are all 0, do not have the response data.
thanks.
#include "fsl_spi.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "pin_mux.h"
#include "clock_config.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define EXAMPLE_SPI_MASTER SPI5
#define EXAMPLE_SPI_MASTER_IRQ FLEXCOMM5_IRQn
#define EXAMPLE_SPI_MASTER_CLK_SRC kCLOCK_Flexcomm5
#define EXAMPLE_SPI_MASTER_CLK_FREQ CLOCK_GetFlexCommClkFreq(5U)
#define EXAMPLE_SPI_SSEL 0
#define EXAMPLE_SPI_SPOL kSPI_SpolActiveAllLow
/*******************************************************************************
* Prototypes
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/
#define BUFFER_SIZE (64)
static uint8_t srcBuff[8];
static uint8_t destBuff[8];
/*******************************************************************************
* Code
******************************************************************************/
int main(void)
{
spi_master_config_t userConfig = {0};
uint32_t srcFreq = 0;
uint32_t i = 0;
uint32_t err = 0;
spi_transfer_t xfer = {0};
CLOCK_AttachClk(kSFRO_to_FLEXCOMM5);
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
PRINTF("\n\rMaster Start...\n\r");
/*
userConfig.enableLoopback = false;
userConfig.enableMaster = true;
userConfig.polarity = kSPI_ClockPolarityActiveHigh;
userConfig.phase = kSPI_ClockPhaseFirstEdge;
userConfig.direction = kSPI_MsbFirst;
userConfig.baudRate_Bps = 500000U;
*/
SPI_MasterGetDefaultConfig(&userConfig);
srcFreq = EXAMPLE_SPI_MASTER_CLK_FREQ;
userConfig.sselNum = (spi_ssel_t)EXAMPLE_SPI_SSEL;
userConfig.sselPol = (spi_spol_t)EXAMPLE_SPI_SPOL;
SPI_MasterInit(EXAMPLE_SPI_MASTER, &userConfig, srcFreq);
srcBuff[0] = 0x11;
srcBuff[1] = 0x10;
srcBuff[2] = 0x10;
srcBuff[3] = 0x11;
srcBuff[4] = 0x11;
srcBuff[5] = 0x11;
srcBuff[6] = 0x11;
srcBuff[7] = 0x11;
/*Start Transfer*/
xfer.txData = srcBuff;
xfer.rxData = destBuff;
xfer.dataSize = 8;
xfer.configFlags = kSPI_FrameDelay;
if(SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &xfer) == kStatus_Success){
PRINTF("Transfer success!\n");
}
else{
PRINTF("Transfer failed QQ~\n");
}
PRINTF("%x %x\n\r", srcBuff[0], srcBuff[1]);
PRINTF("%x %x\n\r", destBuff[0], destBuff[1]);
while (1)
{
}
}