资源简介
stm32 spi方式读写EEPROM,有c源码。完成对at25128芯片的基本配置,实现对at25128的单字节的读和写以及多字节的读写。
代码片段和文件信息
/***************************************** (C) COPYRIGHT 2014 Lianfly ************************************************
* FileName : EEPROM.c
* Author : G.
* Version : V1.01
* Date : 2015/10/11
* Description : 永久保存数据
**********************************************************************************************************************/
#include “includes.h“
//=====================================================================================================================
// 函数名称 : SPI_FLASH_SendByte()
// 函数功能 : Sends a byte through the SPI interface and return the byte
// 输 入 : 无
// 输 出 : 无
// 返 回 : 无
//=====================================================================================================================
u8 SPI2_FLASH_SendByte(u8 byte)
{
while(SPI_I2S_GetFlagStatus(SPI2 SPI_I2S_FLAG_TXE) == RESET); // Loop while DR register in not emplty
SPI_I2S_SendData(SPI2 byte); // Send byte through the SPI1 peripheral
while(SPI_I2S_GetFlagStatus(SPI2 SPI_I2S_FLAG_RXNE) == RESET); // Wait to receive a byte
return SPI_I2S_ReceiveData(SPI2); // Return the byte read from the SPI bus
}
//=====================================================================================================================
// 函数名称 : SPI_FLASH_WaitForWriteEnd()
// 函数功能 :
// 输 入 : 无
// 输 出 : 无
// 返 回 : 无
//=====================================================================================================================
void SPI_FLASH_WaitForWriteEnd(void)
{
u8 FLASH_Status = 0;
SPI_FLASH_CS_LOW(); // Select the FLASH: Chip Select low
SPI2_FLASH_SendByte(RDSR); // Send “Read Status Register“ instruction
do
{
FLASH_Status = SPI2_FLASH_SendByte(Dummy_Byte);
} while((FLASH_Status & WIP_Flag) == SET); // Write in progress
SPI_FLASH_CS_HIGH(); // Deselect the FLASH: Chip Select high
}
//=====================================================================================================================
// 函数名称 : SPI_FLASH_WriteEnable()
// 函数功能 : Enables the write access to the FLASH.
// 输 入 : 无
// 输 出 : 无
// 返 回 : 无
//=====================================================================================================================
void SPI_FLASH_WriteEnable(void)
{
SPI_FLASH_CS_LOW(); // Select the FLASH: Chip Select low
SPI2_FLASH_SendByte(0x06); // Send “Write Enable“ instruction
SPI_FLASH_CS_HIGH(); // Deselect the FLASH: Chip Select high
}
//=====================================================================================================================
// 函数名称 : SPI2_FLASH_ReadByte()
// 函数功能 : Reads a byte from the SPI Flash.
// 输 入 : 无
// 输 出 : 无
// 返 回 : 无
//========================================
- 上一篇:sockets5 代理服务器教程
- 下一篇:BQ76940.rar
相关资源
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- Spire API文档
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- The direction of synaptic plasticity mediated
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- stm32f030 IAP Demo(原创)
- 飞思卡尔单片机MC9S12XS12G128驱动(硬件
- STM32基于rt_thread操作系统的SDHC卡文件
- 51模拟SPI读写SD卡(包括Fat和Fat32文件
- NRF24L01实现51与STM32双向通讯
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- proteus_24C08—有注释(proteus里面使用的
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
- 28335写的用spi读取传感器数据并用CA
- STM32F103 CC2500完整驱动(模拟SPI)
- AD7606采集程序
- 课程设计蔬菜大棚自动控制系统,包
- 手机短信api接口(源代码)
评论
共有 条评论