STM32 SPI总线
来源:互联网 发布:软件安全检测 编辑:程序博客网 时间:2024/05/29 18:56
数据手册关于SPI的介绍
2.3.18 Serial peripheral interface (SPI)
Up to two SPIs are able to communicate up to 18 Mbits/s in slave and master modes in fullduplexand simplex communication modes. The 3-bit prescaler gives 8 master modefrequencies and the frame is configurable to 8 bits or 16 bits. The hardware CRCgeneration/verification supports basic SD Card/MMC modes.
Both SPIs can be served by the DMA controller
=======================================================
关于SPI配置的简单例子
/* SPI1 configuration ------------------------------------------------------*/
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
/* Enable SPI1 CRC calculation */
SPI_CalculateCRC(SPI1, ENABLE);
/* Enable SPI1 */
SPI_Cmd(SPI1, ENABLE);
发送函数
/* Wait for SPI1 Tx buffer empty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
/* Send SPI1 data */
SPI_I2S_SendData(SPI1, SPI1_Buffer_Tx[TxIdx++]);
接收函数
/* Wait for SPI1 data reception */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
/* Read SPI1 received data */
SPI1_Buffer_Rx[RxIdx++] = SPI_I2S_ReceiveData(SPI1);
- STM32 SPI总线
- STM32 的SPI总线配置
- stm32 华邦W25X32芯片spi总线配置
- 踏踏实实搞清 stm32 SPI总线 基础和编程
- STM32 SPI总线移植fatfs产生硬件异常问题
- SPI总线
- SPI总线
- SPI总线
- spi总线
- SPI总线
- SPI总线
- SPI总线
- SPI总线
- SPI总线
- SPI总线
- spi总线
- SPI总线
- SPI总线
- 归并排序
- #pragma once VS #ifndef的方式
- C-MINUS扫描程序 DFA图
- java面试题经典20例【第三季_常瑞鹏】
- 安卓JNI
- STM32 SPI总线
- 关于24点游戏的编程思路与基本算法
- Codeforces 69D. Dot 博弈 dp
- jqGrid 实现这种select - 同一列的不同行的select 的option 不同
- 快速排序
- enum和struct何union
- Android 4.0.3 源码结构分析
- source insight 3.5 遇到的奇怪问题(部分解决)
- 51单片机程序存储器扩展