2016-10-23 09:24 PM
Dear All,
Kindly help me to SPI receive only mode in this structure when I am using SPI1_IRQHandler, is it proper code to apply? void SPI1_IRQHandler(void) { //* SPI in Slave Receiver mode--------------------------------------- */ if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_RXNE) == SET) { /*------- Master --> Slave */ if (CmdStatus == 0x00) { CmdReceived = SPI1_RXDR8; Rx_Idx=0; Tx_Idx=0; switch(CmdReceived){ case 0x01: receiveSPI=0x01; CmdStatus = 0x01; StartSend=0x00; Cpt_Spi=0; break; case 0x81 : SendSPI=0x01; CmdStatus = 0x01; Spi_Case=0x01; if (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) != RESET)//wait for TXE = 1 SPI1_RXDR8=SPI_Tx1[Tx_Idx++]; // prepare the first byte to be send when the clock is received break; case 0x84: SendSPI=0x01; Spi_Case=0x02; CmdStatus = 0x01; if (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) != RESET) SPI1_RXDR8=SPI_Tx2[Tx_Idx++]; // // prepare the first byte to be send when the clock is received } break; default: SendSPI=0x00; Spi_Case=0x00; CmdStatus = 0x00; receiveSPI=0x00; break; }// end of switch }// end of cmdStatus =0x00 else { if(receiveSPI) // in this case the slave receives data from the master { SPI_Rx[Rx_Idx++] = SPI1_RXDR8; // the array sent by the Master in the receive mode } // end of receiveSPIBefore that I have been using following functions, 1. static void MX_DMA_Init(void)2.static void MX_SPI1_Init(void)3.void DMA_beginWrite()4.void DMA1_Stream3_IRQHandler()5. void SysTick_Handler(void)