OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4661|回复: 1

SPI的内容

[复制链接]

13

主题

32

帖子

0

精华

初级会员

Rank: 2

积分
106
金钱
106
注册时间
2012-4-14
在线时间
0 小时
发表于 2013-5-5 13:51:26 | 显示全部楼层 |阅读模式
求高手赐教


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 ???是不是呢?






正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2013-5-5 15:27:59 | 显示全部楼层
这个功能没用到过,看看<stm32参考手册>对这个寄存器的描述吧.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-20 14:06

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表