#ifndef _SPI_SRAM_H
#define _SPI_SRAM_H

#include "stdint.h"

#if (USE_CORE_TYPE == 1)    //使用C1F核心板

	#define SRAM_CE_H GPIOA_ResetBits(GPIO_Pin_12)   //SRAM和flash都用PA12做片选
	#define SRAM_CE_L GPIOA_SetBits(GPIO_Pin_12)
#elif (USE_CORE_TYPE == 2)   //使用C1核心板

	#define SRAM_CE_H GPIOA_SetBits(GPIO_Pin_12)
	#define SRAM_CE_L GPIOA_ResetBits(GPIO_Pin_12)
	
#endif  //USE_CORE_TYPE == CORE_TYPE_C1F


#define SRAM_CMD_Read                  	0x03
#define SRAM_CMD_Fast_Read             	0x0B
#define SRAM_CMD_Fast_Read_Quad        	0xEB
#define SRAM_CMD_Write                 	0x02
#define SRAM_CMD_Quad_Write            	0x38
#define SRAM_CMD_Enter_Quad_Mode       	0x35
#define SRAM_CMD_Exit_Quad_Mode        	0xF5
#define SRAM_CMD_Reset_Enable          	0x66
#define SRAM_CMD_Reset                 	0x99
#define SRAM_CMD_Wrap_Boundary_Toggle  	0xC0
#define SRAM_CMD_Read_ID               	0x9F

#define SRAM_ADDRESS_MAX				0x00800000

void SPI_SRAM_Init(void);
void SRAM_Write_Byte(uint8_t wdate,uint32_t add);
uint8_t SRAM_Read_Byte(uint32_t add);
void SRAM_Write_Word(uint16_t wdate,uint32_t add);
uint16_t SRAM_Read_Word(uint32_t add);
void SRAM_Write_DW(uint32_t wdate,uint32_t add);
uint32_t SRAM_Read_DW(uint32_t add);
void SRAM_Write_Buff(uint8_t* wbuff,uint16_t len,uint32_t add);
void SRAM_Read_Buff(uint8_t* rbuff,uint16_t len,uint32_t add);
void SRAM_DMA_Write_Buff(uint8_t* wbuff,uint16_t len,uint32_t add);
void SRAM_DMA_Read_Buff(uint8_t* rbuff,uint16_t len,uint32_t add);

#endif
