求高手赐教
SPI_InitStructure.SPI_CRCPolynomial = 7; //CRC值计算的多项式
上述语句用寄存器版本的该怎样改呢?改成SPI1_CRCPR|=7<<0;这样好像是复位,这个7到底是什么呢?
库函数实用手册上说
SPI_CRCPolynomial 是定义了用于 CRC 值计算的多项式,我在库函数版本上查找,发现最后有
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
This parameter can be any combination of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI operating mode.
This parameter can be any combination of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be any combination of @ref SPI_data_size */
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be any combination of @ref SPI_Clock_Polarity */
uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
This parameter can be any combination of @ref SPI_Clock_Phase */
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit.
This parameter can be any combination of @ref SPI_Slave_Select_management */
uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
used to configure the transmit and receive SCK clock.
This parameter can be any combination of @ref SPI_BaudRate_Prescaler.
@note The communication clock is derived from the master
clock. The slave clock does not need to be set. */
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
This parameter can be any combination of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
最后在SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);函数中发现了
SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
这里应该就是说将
SPI_InitStructure.SPI_CRCPolynomial = 7 得到的值7给
SPIx->CRCPR ???是不是呢?
|