/** * @brief Returns the transmit or the receive CRC register value for the specified SPI. * @param SPIx: where x can be 1 or 2 to select the SPI peripheral. * @param SPI_CRC: specifies the CRC register to be read. * This parameter can be one of the following values: * @arg SPI_CRC_Tx: Selects Tx CRC register * @arg SPI_CRC_Rx: Selects Rx CRC register * @retval The selected CRC register value.. */ uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC) { uint16_t crcreg = 0; /* Check the parameters */ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_CRC(SPI_CRC)); if (SPI_CRC != SPI_CRC_Rx) { /* Get the Tx CRC register */ crcreg = SPIx->TXCRCR; } else { /* Get the Rx CRC register */ crcreg = SPIx->RXCRCR; } /* Return the selected CRC register */ return crcreg; }
/******************************************************************************* * Function Name : SPI_GetCRC * Description : Returns the transmit or the receive CRC register value for * the specified SPI. * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral. * - SPI_CRC: specifies the CRC register to be read. * This parameter can be one of the following values: * - SPI_CRC_Tx: Selects Tx CRC register * - SPI_CRC_Rx: Selects Rx CRC register * Output : None * Return : The selected CRC register value.. *******************************************************************************/ u16 SPI_GetCRC(SPI_TypeDef* SPIx, u8 SPI_CRC) { u16 crcreg = 0; /* Check the parameters */ assert(IS_SPI_CRC(SPI_CRC)); if (SPI_CRC != SPI_CRC_Rx) { /* Get the Tx CRC register */ crcreg = SPIx->TXCRCR; } else { /* Get the Rx CRC register */ crcreg = SPIx->RXCRCR; } /* Return the selected CRC register */ return crcreg; }
/******************************************************************************* * 函数名称: SPI_GetCRC * 功能描述: 返回特定SPI外设传送或接收的CRC寄存器的值. * 输入参数: (1)SPIx :x为1,2或3用于选定SPI外设。 * (2)SPI_CRC:将被读取的CRC寄存器。 * 这个参数可以是下面的值之一: * - SPI_CRC_Tx: 选择Tx CRC寄存器 * - SPI_CRC_Rx: 选择Rx CRC寄存器 * 输出参数: 无 * 返回参数: 所选择的CRC寄存器的值。 *******************************************************************************/ u16 SPI_GetCRC(SPI_TypeDef* SPIx, u8 SPI_CRC) { u16 crcreg = 0; /* Check the parameters [检查参数]*/ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_CRC(SPI_CRC)); if (SPI_CRC != SPI_CRC_Rx) { /* Get the Tx CRC register [取得Tx CRC寄存器]*/ crcreg = SPIx->TXCRCR; } else { /* Get the Rx CRC register [取得Rx CRC寄存器]*/ crcreg = SPIx->RXCRCR; } /* Return the selected CRC register [返回选择的CRC寄存器]*/ return crcreg; }