91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

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.
//?輸????入?:?無
//?輸????出?:?無
//?返????回?:?無
//========================================

評論

共有 條評論