/***************************************************************************//************************* éè??SPIμ?2?êy ***********************************//***************************************************************************/
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;//????è???1¤SPI?£ê?SPI_InitStructure.SPI_Mode = SPI_Mode_Master;//?÷?ú?£ê?SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //8??SPISPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;//ê±?óDü????μ???SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;//?úμú?t??ê±?ó2é?ˉêy?YSPI_InitStructure.SPI_NSS = SPI_NSS_Soft;//Nssê1ó?èí?t????/* ????2¨ì??ê?¤·??μ?a256 */SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;//′ó×??????aê?′?ê?SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Cmd(SPI2, ENABLE);SPI_Init(SPI2, &SPI_InitStructure);}
/***************************************************************************** Function Name: SPI1_SetSpeed* Description: éè??SPI1μ?′?ê??ù?è?£* Input: ?ù?è2¨ì??ê·??μ* Output: None* Return: None****************************************************************************/
void SPI1_SetSpeed(uint8_t speed){SPI1->CR1 &= 0xFFC7;SPI1->CR1 |= speed;SPI_Cmd(SPI1, ENABLE);
}
/***************************************************************************** Function Name: SPI2_SetSpeed* Description: éè??SPI2μ?·??μêy£?ò???±?SPI2μ??ù?è.* Input: Speed£o·??μêy* Output: None* Return: None****************************************************************************/
void SPI2_SetSpeed(uint8_t Speed){
SPI2->CR1 &= 0xFFC7;SPI2->CR1 |= Speed;SPI_Cmd(SPI2,ENABLE);
}
/***************************************************************************** Function Name: SPI1_WriteReadData* Description: ê1ó?SPI1D′è?ò???×??úêy?Yí?ê±?áè?ò???×??úêy?Y?£* Input: dat£oòaD′μ?8??êy?Y* Output: None* Return: ?áè?μ?μ?8??êy?Y****************************************************************************/
uint8_t SPI1_WriteReadData(uint8_t dat){uint16_t i = 0;
/* μ±·¢?í?o3??÷?? */ while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET){i++;if(i > 10000){return 0xFF;}}
/* ·¢?íêy?Y */SPI_I2S_SendData(SPI1, dat);
/* μè′y?óê??o3??÷?a·??? */while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
/* ???áè?μ?μ?êy?μ·μ?? */ return SPI_I2S_ReceiveData(SPI1);}
/***************************************************************************** Function Name: SPI2_WriteReadData* Description: ê1ó?SPI2D′è?ò???×??úêy?Yí?ê±?áè?ò???×??úêy?Y?£* Input: dat£oD′è?μ?êy?Y* Output: None* Return: ?áè?μ?μ?êy?Y** ?áè?꧰ü·μ??0xFF****************************************************************************/
uint8_t SPI2_WriteReadData(uint8_t dat){uint16_t i = 0;
/* μ±·¢?í?o3??÷?? */ while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET){i++;if(i > 10000){return 0xFF;}}
/* ·¢?íêy?Y */SPI_I2S_SendData(SPI2, dat);
/* μè′y?óê??o3??÷?a·??? */while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
【spi通信时序图详解 spi四种工作模式时序图】 /* ???áè?μ?μ?êy?μ·μ?? */ return SPI_I2S_ReceiveData(SPI2);}
- Spirella丝普瑞是哪个国家的品牌 Spirella丝普瑞是什么国家的品牌
- 工信部通报微信等43款APP违规调用通信录、位置信息以及开屏弹窗骚扰用户等问题
- OPPO公开人体通信相关专利
- kmspico激活工具 kmspico,详细教您kmspico激活工具使用方法
- 中麦通信是哪个国家的品牌 中麦通信是什么公司
- 怎样认识交通信号灯 怎样认识交通信号灯儿歌
- 均安 最快年底可投产!顺德电子通信装备产业园一期厂房即将交付
- 2022邮政工程专业就业前景及方向 招生专业解读通信工程
- 管理计算机通信的规则称为什么优质
- pcm是什么