/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** * File Name : fsmc_sram.c * Author : MCD Application Team * Version : V2.0.1 * Date : 06/13/2008 * Description : This file provides a set of functions needed to drive the * IS61WV51216BLL SRAM memory mounted on STM3210E-EVAL board. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/
/* Includes ------------------------------------------------------------------*/ #include "fsmc_sram.h"
/******************************************************************************* * Function Name : FSMC_SRAM_Init * Description : Configures the FSMC and GPIOs to interface with the SRAM memory. * This function must be called before any write/read operation * on the SRAM. * Input : None * Output : None * Return : None *******************************************************************************/ void FSMC_SRAM_Init(void) { FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p;
/* Enable FSMC Bank1_SRAM Bank */ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); }
/******************************************************************************* * Function Name : FSMC_SRAM_WriteBuffer * Description : Writes a Half-word buffer to the FSMC SRAM memory. * Input : - pBuffer : pointer to buffer. * - WriteAddr : SRAM memory internal address from which the data * will be written. * - NumHalfwordToWrite : number of half-words to write. * * Output : None * Return : None *******************************************************************************/ void FSMC_SRAM_WriteBuffer(u8* pBuffer, u32 WriteAddr, u8 NumHalfwordToWrite) {
for(; NumHalfwordToWrite != 0; NumHalfwordToWrite--) /* while there is data to write */ { /* Transfer data to the memory */ // *(u8 *) (Bank1_SRAM3_ADDR + WriteAddr) = *pBuffer++; //液晶屏只使用地址线A0,不需要地址向上偏移操作 *(u8 *) (Bank1_SRAM3_ADDR + WriteAddr) = *pBuffer++;
/* Increment the address*/ // WriteAddr += 1; } }
/******************************************************************************* * Function Name : FSMC_SRAM_ReadBuffer * Description : Reads a block of data from the FSMC SRAM memory. * Input : - pBuffer : pointer to the buffer that receives the data read * from the SRAM memory. * - ReadAddr : SRAM memory internal address to read from. * - NumHalfwordToRead : number of half-words to read. * Output : None * Return : None *******************************************************************************/ void FSMC_SRAM_ReadBuffer(u8* pBuffer, u32 ReadAddr, u8 NumHalfwordToRead) { for(; NumHalfwordToRead != 0; NumHalfwordToRead--) /* while there is data to read */ { /* Read a half-word from the memory */ *pBuffer++ = *(vu8*) (Bank1_SRAM3_ADDR + ReadAddr);
/* Increment the address*/ ReadAddr += 1; } }
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/