2015-12-21 10:16 PM
Hal spi wait ?
2015-12-22 12:18 AM
Hi h.rick,
Could you please provide more explanation on your case, so that it will be easier to understand the issue and may bring you some help?-Syrine-2015-12-22 06:19 AM
I want to migrate this function to HAL_SPI...
How can I make SPIwait on HAL_SPI ? ThanksMp3SelectData();
00180 SPIPutCharWithoutWaiting(0);
00181 for (temp.i=0; temp.i<1048; temp.i++){ /* TESTING 1048 TESTING */
00182 while (!MP3_DREQ)
00183 ;
00184 SPIPutChar(0);
00185 }
00186 SPIWait();
00187 Mp3DeselectData();
00188 }
2015-12-22 06:30 AM
On STM32F107...this register :
23.5.3 SPI status register (SPI_SR), page 617 reference manual.... bit 0 and bit 1, how can I check it ? Bit 1 TXE: Transmit buffer empty 0: Tx buffer not empty 1: Tx buffer empty Bit 0 RXNE: Receive buffer not empty 0: Rx buffer empty 1: Rx buffer not empty How can I check SPI status on HAL_SPI stm32cubeMX ? Similar like this one from AT89C51#define SPIWait(){while(!(SPSTA & 0x80));;}
2015-12-22 06:57 AM
How can I make this on HAL_SPI ?
while (!(SPI->SR & SPI_SR_TXE)); // Wait while receive buffer is not empty
SPI->DR = data; // Send byte to SPI
while (!(SPI->SR & SPI_SR_RXNE)); // Wait while receive buffer is empty
2015-12-22 07:57 AM
Wouldn't the register level access remain pretty much identical?
2015-12-22 01:51 PM
How can I acces register SPI_SR and bit
SPI_SR_TXE
on STMCubeMx...
Thanks
2015-12-22 02:02 PM
is it this one ? I've found it at stm32fxx_hal_spi.c
How can I use it ?? /** * @brief This function handles SPI Communication Timeout. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param Flag: SPI flag to check * @param Status: Flag status to check: RESET or set * @param Timeout: Timeout duration * @retval HAL status */ static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, FlagStatus Status, uint32_t Timeout) Probably SPI_WaitOnFlagUntilTimeout(&hspi1, SPI_SR, RESET, 1000); ??? I got : error: #20: identifier ''SPI_SR'' is undefined How can I define SPI_SR on STM32CubeMx ? Thanks2015-12-22 09:09 PM
Please correct me if I'm wrong....
#define SPI_Transmit_Wait() {while (__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_TXE) = RESET); } //while TX not empty
#define SPI_Receive_Wait() {while (__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_RXNE) = RESET); } //while RX not empty
Thanks
2015-12-22 09:39 PM
Regardless of using HAL or SPL, you can use your previous approach. Registers are same.
Maybe only definition of TXE bit (SPI_SR_TXE) and RXNE bit are not exactly the same, but I am almost sure they are.while (!(SPI->SR & SPI_SR_TXE)); // Wait while receive buffer is not empty
SPI->DR = data; // Send byte to SPI
while (!(SPI->SR & SPI_SR_RXNE)); // Wait while receive buffer is empty