资源简介
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
相关资源
- 关于FM93C56的SPI例程
- STM32F10x 系列ORCAD 原理图库
- STM32F103+模拟I2C实现
- STM32F4 硬件I2C 使用DMA
- stm32f103zet6开发板LCD显示屏源码
- STM32直流电机控制程序
- STM32彩屏显示AD采集数据并通过RS485接
- 基于STM32F407的幅频特性和相频特性测
- STM32F103VCT6+W5500 TCP 服务端通信成功开
- 基于STM32F103的W5500 TCP Client测试程序
- 基于STM32的MP4播放器带gps定位,界面显
- STM32 MPU6050-DMP-欧拉角串口输出 滤波
- STM32的FSMC驱动ILI9341屏幕
- STM32系列flash
- Ti的DAC8552、DAC8554驱动程序
- AD5761R驱动程序,支持STM32
- stm32串行驱动12864字符,图片
- STM32 定时器捕获PWM波 以及占空比
- STM32学习笔记STM32学习笔记
- STM32 USART1 USART2 UASRT3 UART4 UART5串口通信
- STM32F103产生正弦波DEMO
- STM32 MCP2515 CAN 通信收发程序,调试通
- stm32f103rc_hcsr04.rar
- STM32F103 WS2812真彩LED灯驱动例程
- stm32PWM呼吸灯
- STM32-DS18B20程序
- 基于STM32的寝室指纹门锁设计
- stm32f1对MLX90614ESF读取数据
- STM32F407ZGT6用TB6600驱动器驱动4257步进电
- STM32f103vET6 最小系统原理图
评论
共有 条评论