学前班
最后登录1970-1-1
在线时间 小时
注册时间2018-11-23
|
麻烦大家帮忙看看哪里出问题了啊?
int main(void)
{
gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
/*Set clock source for LPSPI*/
CLOCK_SetMux(kCLOCK_LpspiMux, EXAMPLE_LPSPI_CLOCK_SOURCE_SELECT);
CLOCK_SetDiv(kCLOCK_LpspiDiv, EXAMPLE_LPSPI_CLOCK_SOURCE_DIVIDER);
PRINTF("lpspi_functional_interrupt_board_2_board_master start.\r\n");
PRINTF("This example use one board as master and another as slave.\r\n");
PRINTF("Master and slave uses interrupt way. Slave should start first. \r\n");
PRINTF("Please make sure you make the correct line connection. Basically, the connection is: \r\n");
PRINTF("LPSPI_master -- LPSPI_slave \r\n");
PRINTF(" CLK -- CLK \r\n");
PRINTF(" PCS -- PCS \r\n");
PRINTF(" SOUT -- SIN \r\n");
PRINTF(" SIN -- SOUT \r\n");
PRINTF(" GND -- GND \r\n");
GPIO_PinInit(GPIO1, 2U, &gpio_config);
GPIO_PinWrite(GPIO1, 2U, 1U);
uint32_t srcClock_Hz;
uint32_t errorCount;
uint32_t i;
uint32_t whichPcs;
uint8_t txWatermark;
lpspi_master_config_t masterConfig;
/*Master config*/
masterConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.bitsPerFrame = 8;
masterConfig.cpol = kLPSPI_ClockPolarityActiveHigh;
masterConfig.cpha = kLPSPI_ClockPhaseFirstEdge;
masterConfig.direction = kLPSPI_MsbFirst;
masterConfig.pcsToSckDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.lastSckToPcsDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.betweenTransferDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.whichPcs = EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT;
masterConfig.pcsActiveHighOrLow = kLPSPI_PcsActiveLow;
masterConfig.pinCfg = kLPSPI_SdiInSdoOut;
masterConfig.dataOutConfig = kLpspiDataOutRetained;
srcClock_Hz = LPSPI_MASTER_CLK_FREQ;
LPSPI_MasterInit(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterConfig, srcClock_Hz);
unsigned char wData = 0;
uint32_t byte = 0;
unsigned char c = 0;
// c =((0x26 << 1) & ~(0x80));
c = (0x03 << 1) & 0x7E;
wData = (((0x03 << 1) & 0x7E ) | 0x80);
// wData = ((0x26 << 1) | 0x80);
while (1)
{
#if 1
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, c);
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, 0xFE);
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, wData);
byte = LPSPI_ReadData(EXAMPLE_LPSPI_MASTER_BASEADDR);
// debug_printf("addr is 0x%x, spi data is 0x%x, return byte is 0x%x", addr, wData, byte);
PRINTF("byte = %d \r\n",byte);
#endif
}
}
|
|