天天热资讯!stm32驱动SST25VF程序怎么下载安装?


(资料图片)

在生活中,很多人都不知道stm32驱动SST25VF程序是什么意思,其实他的意思是非常简单的,下面就是小编搜索到的stm32驱动SST25VF程序相关的一些知识,我们一起来学习下吧!

SST25VF.h:#include "stm32f10x_lib.h"#ifndef __SST25V_H#define __SST25V_H#define BufferSize (countof(Tx_Buffer)-1)#define countof(a) (sizeof(a) / sizeof(*(a)))#define SST25V_PageSize 256#define Dummy_Byte 0xA5#define SST25V_CS_LOW() GPIO_ResetBits(GPIOA, GPIO_Pin_4)#define SST25V_CS_HIGH() GPIO_SetBits(GPIOA, GPIO_Pin_4)#define SST25V_WP_LOW() GPIO_ResetBits(GPIOC, GPIO_Pin_0)#define SST25V_WP_HIGH() GPIO_SetBits(GPIOC, GPIO_Pin_0)#define SST25V_HOLD_LOW() GPIO_ResetBits(GPIOC, GPIO_Pin_1)#define SST25V_HOLD_HIGH() GPIO_SetBits(GPIOC, GPIO_Pin_1)#define Read_Data 0x03 //读取存储器数据#define HighSpeedReadData 0x0B //快速读取存储器数据#define SectorErace_4KB 0x20 //扇区擦除#define BlockErace_32KB 0x52 //32KB块擦除#define BlockErace_64KB 0xD8 //64KB块擦除#define ChipErace 0xC7 //片擦除#define Byte_Program 0x02 //页面编程--写数据#define AAI_WordProgram 0xAD#define ReadStatusRegister 0x05 //读状态寄存器#define EnableWriteStatusRegister 0x50#define WriteStatusRegister 0x01 //写状态寄存器#define WriteEnable 0x06 //写使能,设置状态寄存器#define WriteDisable 0x04 //写禁止#define ReadDeviceID 0xAB //获取设备ID信息#define ReadJedec_ID 0x9F //JEDEC的ID信息#define EBSY 0X70 //允许AAI模式期间,SO脚输出忙状态命令#define DBSY 0X80 //禁止AAI模式期间,SO脚输出忙状态命令void SST25V_Init(void); //Flash芯片初始化u8 SST25V_ByteRead(u32 ReadAddr); //从ReadAddr地址读取一个字节数据void SST25V_BufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead); //从ReadAddr地址开始读取NumByteToRead个字节数据u8 SST25V_HighSpeedByteRead(u32 ReadAddr); //从ReadAddr高速读取一个字节数据void SST25V_HighSpeedBufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead);//从ReadAddr开始高速读取NumByteToRead个字节数据,并存储于pBuffer中u8 SPI_Flash_SendByte(u8 byte); //SPI发送数据u8 SPI_Flash_ReceiveByte(void); //SPI接收数据void SST25V_ByteWrite(u8 Byte, u32 WriteAddr); //写入一个数据字节void SST25V_BufferWrite(u8 *pBuffer,u32 Addr,u16 BufferLength);//将pBuffer中的BufferLength个字节数据写入到以Addr为起始地址的区域void SST25V_WriteBytes(u8 Byte, u32 WriteAddr,u32 ByteLength); //以WriteAddr为起始地址,写入ByteLength个数据Byte(写入的是同一个数据Byte)void SST25V_AAI_WriteBytes(u8 Byte, u32 Addr,u32 ByteLength); //以Addr为起始地址,用AAI模式,写入ByteLength个数据Byte(写入的是同一个数据Byte)ByteLength必须为偶数void SST25V_AAI_BufferProgram(u8 *pBuffer,u32 Addr,u16 BufferLength); //用AAI模式将pBuffer中的BufferLength个字节数据写入到以Addr为起始地址的区域,ByteLength必须为偶数void SST25V_AAI_WordProgram(u8 Byte1, u8 Byte2, u32 Addr); //在AAI模式下,以Addr为起始地址,分别写入Byte1和Byte2,必须和SST25V_AAI_WordsProgram()函数配套使用void SST25V_AAI_WordsProgram(u8 state,u8 Byte1, u8 Byte2); //在AAI模式下,继续写入Byte1和Byte2,必须和SST25V_AAI_WordProgram()函数配套使用,state==1退出AAI模式void SST25V_SectorErase_4KByte(u32 Addr); //擦除4KB数据空间,Addr是擦除起始地址void SST25V_BlockErase_32KByte(u32 Addr); //擦除32KB数据空间,Addr是擦除起始地址void SST25V_BlockErase_64KByte(u32 Addr); //擦除64KB数据空间,Addr是擦除起始地址void SST25V_ChipErase(void); //擦除整个芯片数据空间u8 SST25V_ReadStatusRegister(void); //读取状态寄存器void SST25V_WriteEnable(void); //允许对芯片写入操作void SST25V_WriteDisable(void); //禁止对芯片写入操作void SST25V_EnableWriteStatusRegister(void); //允许改写状态寄存器void SST25V_WriteStatusRegister(u8 Byte); //改写状态寄存器,向状态寄存器写入数据Bytevoid SST25V_WaitForWriteEnd(void); //等待写入操作完成u32 SST25V_ReadJedecID(void); //读取JEDEC IDu16 SST25V_ReadManuID_DeviceID(u32 ReadManu_DeviceID_Addr); //读取ManufacturerID和DeviceID,ReadManu_DeviceID_Addr的状态决定第一个字节是DeviceID还是ManufacturerIDvoid SST25V_EBSY(); //允许AAI模式期间,SO脚输出忙状态void SST25V_DBSY(); //禁止AAI模式期间,SO脚输出忙状态#endifhw_conf.c:#include"stm32f10x_lib.h"#include "hw_conf.h"ErrorStatus HSEStartUpStatus;void RCC_Configuration(void){RCC_DeInit();RCC_HSEConfig(RCC_HSE_ON);HSEStartUpStatus = RCC_WaitForHSEStartUp();if(HSEStartUpStatus == SUCCESS){FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);FLASH_SetLatency(FLASH_Latency_2);RCC_HCLKConfig(RCC_SYSCLK_Div1);RCC_PCLK2Config(RCC_HCLK_Div1);RCC_PCLK1Config(RCC_HCLK_Div2);RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);RCC_PLLCmd(ENABLE);while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);while(RCC_GetSYSCLKSource() != 0x08){}}RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);}void GPIO_Configuration(void){//PC4567分别接LED4,3,2,1,以便调试观察GPIO_InitTypeDef GPIO_InitStructure;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5 |GPIO_Pin_6 | GPIO_Pin_7;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;GPIO_Init(GPIOC, &GPIO_InitStructure);//PA5--SPI1_SCK PA6--SPI1--MISO PA7--SPI1--MOSIGPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; //Configure SPI1 pins: NSS, SCK, MISO and MOSIGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_Init(GPIOA, &GPIO_InitStructure);//PA4--SPI1_NSSGPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //Configure PA.4 as Output push-pull, used as Flash Chip selectGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;GPIO_Init(GPIOA, &GPIO_InitStructure);}void SPI_configuration() //SPI1 configuration{SPI_InitTypeDef SPI_InitStructure;SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //SPI设置为双线双向全双工SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //设置为主 SPI SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //SPI发送接收 8 位帧结构SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; //时钟悬空高SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; //数据捕获于第二个时钟沿SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //内部 NSS 信号有 SSI位控制SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; //波特率预分频值为 4SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //数据传输从 MSB 位开始SPI_InitStructure.SPI_CRCPolynomial = 7; //定义了用于 CRC值计算的多项式 7SPI_Init(SPI1, &SPI_InitStructure);SPI_Cmd(SPI1, ENABLE); //Enable SPI1}void NVIC_Configuration(void){#ifdef VECT_TAB_RAM NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);#elseNVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif}void Setup_System(void){RCC_Configuration();GPIO_Configuration();SPI_configuration();NVIC_Configuration();}hw_conf.h:#ifndef _hw_conf_H_#define _hw_conf_H_extern void Setup_System(void);#endif
关键词: stm32SST25V