/** * @brief Checks whether the specified SPI flag is set or not. * @param SPIx: where x can be 1 or 2 in SPI mode or 1 in I2S mode to select * the SPI peripheral. * @param SPI_I2S_FLAG: specifies the SPI flag to check. * This parameter can be one of the following values: * @arg SPI_I2S_FLAG_TXE: Transmit buffer empty flag. * @arg SPI_I2S_FLAG_RXNE: Receive buffer not empty flag. * @arg SPI_I2S_FLAG_BSY: Busy flag. * @arg SPI_I2S_FLAG_OVR: Overrun flag. * @arg SPI_I2S_FLAG_MODF: Mode Fault flag. * @arg SPI_I2S_FLAG_CRCERR: CRC Error flag. * @arg SPI_I2S_FLAG_FRE: TI frame format error flag. * @arg I2S_FLAG_UDR: Underrun Error flag. * @arg I2S_FLAG_CHSIDE: Channel Side flag. * @retval The new state of SPI_I2S_FLAG (SET or RESET). */ FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) { FlagStatus bitstatus = RESET; /* Check the parameters */ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG)); /* Check the status of the specified SPI flag */ if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET) { /* SPI_I2S_FLAG is set */ bitstatus = SET; } else { /* SPI_I2S_FLAG is reset */ bitstatus = RESET; } /* Return the SPI_I2S_FLAG status */ return bitstatus; }
/******************************************************************************* * 函数名称: SPI_I2S_GetFlagStatus * 功能描述: 检查指定的SPI/I2S标记是否被置位. * 输入参数: (1)- SPIx: x可以是 : * - 1, 2 或 3 在 SPI 模式 * - 2 或 3 在 I2S 模式 * (2)检查指定的SPI/I2S标记是否被设置. * 这个参数可以是下面的值之一: * - SPI_I2S_FLAG_TXE: 传输缓冲为空标记. * - SPI_I2S_FLAG_RXNE: 接收缓冲不空标记. * - SPI_I2S_FLAG_BSY: 忙碌标记. * - SPI_I2S_FLAG_OVR: 溢出标记. * - SPI_FLAG_MODF: 模式错误标记. * - SPI_FLAG_CRCERR: CRC校验错误标记. * - I2S_FLAG_UDR: 空栈读出错标记. * - I2S_FLAG_CHSIDE: 通道边标志. * 输出参数: 无 * 返回参数: SPI_I2S_FLAG标记的新状态 (SET or RESET). *******************************************************************************/ FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, u16 SPI_I2S_FLAG) { FlagStatus bitstatus = RESET; /* Check the parameters [检查参数]*/ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG)); /* Check the status of the specified SPI/I2S flag [检查指定的SPI/I2S标志状态]*/ if ((SPIx->SR & SPI_I2S_FLAG) != (u16)RESET) { /* SPI_I2S_FLAG is set [置位SPI_I2S_FLAG]*/ bitstatus = SET; } else { /* SPI_I2S_FLAG is reset [复位SPI_I2S_FLAG]*/ bitstatus = RESET; } /* Return the SPI_I2S_FLAG status [返回SPI_I2S_FLAG状态]*/ return bitstatus; }