The SPI Hal Library changes

Source: Internet
Author: User

{
while ((Hspi->txxfercount > 0) | | (Hspi->rxxfercount > 0))
{
/* Check TXE flag */
if ((Hspi->txxfercount > 0) && ((HSPI->INSTANCE->SR & spi_flag_txe) = = Spi_flag_txe))
{
if (Hspi->txxfercount > 1)
{
HSPI->INSTANCE->DR = * ((uint16_t*) hspi->ptxbuffptr);
Hspi->ptxbuffptr + = sizeof (uint16_t);
Hspi->txxfercount-= 2;
}
Else
{
* (__io uint8_t *) &hspi->instance->dr = (*hspi->ptxbuffptr++);
hspi->txxfercount--;
}

/* Enable CRC Transmission */
if ((Hspi->txxfercount = = 0) && (hspi->init.crccalculation = = spi_crccalculation_enable))
{
HSPI->INSTANCE->CR1 |= Spi_cr1_crcnext;
}
}

/* Wait until RXNE flag is reset */
if ((Hspi->rxxfercount > 0)/*&& ((HSPI->INSTANCE->SR & spi_flag_rxne) = = spi_flag_rxne) */)
{
while (((HSPI->INSTANCE->SR & spi_flag_rxne)! = Spi_flag_rxne));
if (Hspi->rxxfercount > 1)
{
* ((uint16_t*) hspi->prxbuffptr) = hspi->instance->dr;
Hspi->prxbuffptr + = sizeof (uint16_t);
Hspi->rxxfercount-= 2;
if (Hspi->rxxfercount <= 1)
{
/* Set fiforxthresold before to switch on 8 bit data size */
Set_bit (HSPI-&GT;INSTANCE-&GT;CR2, spi_rxfifo_threshold);
}
}
Else
{
(*hspi->prxbuffptr++) = * (__io uint8_t *) &hspi->Instance->DR;
hspi->rxxfercount--;
}
}
if (timeout! = Hal_max_delay) && ((Hal_gettick ()-tickstart) >= Timeout))
{
ErrorCode = Hal_timeout;
Goto error;
}
}
The purpose of the red font change is to interrupt the interrupt without waiting for the packet to be dropped. If the wait will start from the wait.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.