河北水利局项目
This commit is contained in:
75
shuangjia/FRAM.h
Normal file
75
shuangjia/FRAM.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef _FRAM_H_
|
||||
#define _FRAM_H_
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "stm32f10x_gpio.h"
|
||||
|
||||
//#define FRAM_SPI SPI3
|
||||
//#define FRAM_SPI_CLK RCC_APB2Periph_SPI1
|
||||
|
||||
|
||||
|
||||
#define FRAM_SPI_SCK_PIN GPIO_Pin_3
|
||||
#define FRAM_SPI_SCK_GPIO_PORT GPIOB
|
||||
#define FRAM_SPI_SCK_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
|
||||
#define FRAM_SPI_MISO_PIN GPIO_Pin_4
|
||||
#define FRAM_SPI_MISO_GPIO_PORT GPIOB
|
||||
#define FRAM_SPI_MISO_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
|
||||
#define FRAM_SPI_MOSI_PIN GPIO_Pin_5
|
||||
#define FRAM_SPI_MOSI_GPIO_PORT GPIOA
|
||||
#define FRAM_SPI_MOSI_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
|
||||
#define SPI_FLASH_CS_PIN GPIO_Pin_15
|
||||
#define SPI_FLASH_GPIO_PORT GPIOA
|
||||
#define SPI_FLASH_GPIO_CLK RCC_APB2Periph_GPIOA
|
||||
|
||||
|
||||
/*
|
||||
#define FRAM_CS_PIN GPIO_Pin_0
|
||||
#define FRAM_CS_GPIO_PORT GPIOB
|
||||
#define FRAM_CS_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#define FRAM_CS_PIN GPIO_Pin_4
|
||||
#define FRAM_CS_GPIO_PORT GPIOA
|
||||
#define FRAM_CS_GPIO_CLK RCC_APB2Periph_GPIOA
|
||||
|
||||
#define SPI_FLASH_CS_PIN GPIO_Pin_0
|
||||
#define SPI_FLASH_GPIO_PORT GPIOB
|
||||
#define SPI_FLASH_GPIO_CLK RCC_APB2Periph_GPIOB
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define DGFLASH_CS_LOW() GPIO_ResetBits(SPI_FLASH_GPIO_PORT, GPIO_Pin_15)
|
||||
#define DGFLASH_CS_HIGH() GPIO_SetBits(SPI_FLASH_GPIO_PORT, GPIO_Pin_15)
|
||||
|
||||
|
||||
|
||||
#define FRAM_CS_LOW() GPIO_ResetBits(SPI_FLASH_GPIO_PORT, GPIO_Pin_15)
|
||||
|
||||
#define FRAM_CS_HIGH() GPIO_SetBits(SPI_FLASH_GPIO_PORT, GPIO_Pin_15)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void FRAM_init(void);
|
||||
void set_write_enable_latch(void);
|
||||
void reset_write_enable_latch(void);
|
||||
u8 read_status_reg(void);
|
||||
void write_status_reg(u8 val);
|
||||
void read_memory_code(u16 addr, u8 *buf, u16 length);
|
||||
void write_memory_code(u16 addr, u8 *buf, u16 length);
|
||||
void read_device_ID(u8 *buf);
|
||||
void fast_read_memory_code(u16 addr, u8 *buf, u16 length);
|
||||
uint8_t sFLASH_SendByte(uint8_t byte);
|
||||
u8 FRAMReadWriteByte(u8 data);
|
||||
void spiFlash_FRAMFlash_init(void);
|
||||
void fill_FRAM_area(u16 start, u8 value, u16 length);
|
||||
#endif
|
||||
Reference in New Issue
Block a user