OpenCores
URL https://opencores.org/ocsvn/gecko3/gecko3/trunk

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-fw/] [firmware/] [include/] [spi_flash.h] - Diff between revs 13 and 32

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 13 Rev 32
Line 50... Line 50...
 *
 *
 *   \date 17.09.2007 first version
 *   \date 17.09.2007 first version
 *
 *
 */
 */
 
 
#ifndef SPI_FLASH /* prevent circular inclusions */
#ifndef _SPI_FLASH_H_ /* prevent circular inclusions */
#define SPI_FLASH /* by using protection macros */
#define _SPI_FLASH_H_
 
 
#include <stdint.h>
#include <stdint.h>
//#include "spi.h"
//#include "spi.h"
 
 
/**************************** Type Definitions *******************************/
/**************************** Type Definitions *******************************/
Line 89... Line 89...
#define MEMCAPACITY_8MBIT_SPA 0x13      /**< 8 MBit memory capacity */
#define MEMCAPACITY_8MBIT_SPA 0x13      /**< 8 MBit memory capacity */
#define MEMCAPACITY_16MBIT_SPA 0x14     /**< 16 MBit memory capacity */
#define MEMCAPACITY_16MBIT_SPA 0x14     /**< 16 MBit memory capacity */
#define MEMCAPACITY_32MBIT_SPA 0x15     /**< 32 MBit memory capacity */
#define MEMCAPACITY_32MBIT_SPA 0x15     /**< 32 MBit memory capacity */
 
 
 
 
#define MAXADRESS_8MBIT 0x0FFFFF
#define MAXADRESS_8MBIT 0x0FFFFF             /**< 8 Mbit device highest usable Adress */
#define FLASH_SIZE_8MBIT (0x0100000)         /**< Total 8 Mbit device size in Bytes */
#define FLASH_SIZE_8MBIT (0x0100000)         /**< Total 8 Mbit device size in Bytes */
#define FLASH_PAGE_COUNT_8MBIT (0x01000)     /**< Total 8 Mbit device size in Pages */
#define FLASH_PAGE_COUNT_8MBIT (0x01000)     /**< Total 8 Mbit device size in Pages */
#define FLASH_SECTOR_COUNT_8MBIT (0x10)      /**< Total 8 Mbit device size in Sectors */
#define FLASH_SECTOR_COUNT_8MBIT (0x10)      /**< Total 8 Mbit device size in Sectors */
 
 
#define MAXADRESS_16MBIT 0x1FFFFF
#define MAXADRESS_16MBIT 0x1FFFFF            /**< 16 Mbit device highest usable Adress */
#define FLASH_SIZE_16MBIT (0x0200000)        /**< Total 16 Mbit device size in Bytes */
#define FLASH_SIZE_16MBIT (0x0200000)        /**< Total 16 Mbit device size in Bytes */
#define FLASH_PAGE_COUNT_16MBIT (0x02000)    /**< Total 16 Mbit device size in Pages */
#define FLASH_PAGE_COUNT_16MBIT (0x02000)    /**< Total 16 Mbit device size in Pages */
#define FLASH_SECTOR_COUNT_16MBIT (0x20)     /**< Total 16 Mbit device size in Sectors */
#define FLASH_SECTOR_COUNT_16MBIT (0x20)     /**< Total 16 Mbit device size in Sectors */
 
 
#define MAXADRESS_32MBIT 0x3FFFFF
#define MAXADRESS_32MBIT 0x3FFFFF               /**< 32 Mbit device highest usable Adress */
#define FLASH_SIZE_32MBIT (0x0400000)           /**< Total 32 Mbit device size in Bytes */
#define FLASH_SIZE_32MBIT (0x0400000)           /**< Total 32 Mbit device size in Bytes */
#define FLASH_PAGE_COUNT_32MBIT (0x04000)       /**< Total 32 Mbit device size in Pages */
#define FLASH_PAGE_COUNT_32MBIT (0x04000)       /**< Total 32 Mbit device size in Pages */
#define FLASH_SECTOR_COUNT_32MBIT (0x40)        /**< Total 32 Mbit device size in Sectors */
#define FLASH_SECTOR_COUNT_32MBIT (0x40)        /**< Total 32 Mbit device size in Sectors */
 
 
  /* Return Codes */
  /* Return Codes */
Line 181... Line 181...
/** returns the end adress of the page that belongs to this adress
/** returns the end adress of the page that belongs to this adress
 * \param[in] adr adress somewhere in the flash
 * \param[in] adr adress somewhere in the flash
 */
 */
#define pageEnd(adr) ((adr) | 0x000000FF)        
#define pageEnd(adr) ((adr) | 0x000000FF)        
 
 
 
/** This struct contains all the needed information about the detected flash
 
 *  chip (limits, memory structure,...) to work with it.
 
 *  Is filled during init */
extern SPI_flash xdata flash_dr;
extern SPI_flash xdata flash_dr;
 
 
/************************** Function Prototypes ******************************/
/************************** Function Prototypes ******************************/
 
 
/** \brief Checks if the SPI flash is busy
/** \brief Checks if the SPI flash is busy
Line 205... Line 207...
int8_t init_spiflash(xdata SPI_flash *flashPtr);
int8_t init_spiflash(xdata SPI_flash *flashPtr);
 
 
 
 
/** \brief Reads data from the SPI flash
/** \brief Reads data from the SPI flash
 *
 *
 * \param[in] xdata SPI_flash flashPtr pointer to an SPI_flash struct
 * \param[in]  flashPtr pointer to an SPI_flash struct
 * \param[in] xdata uint32_t *adress pointer to the flash start adress to read
 * \param[in]  *adress pointer to the flash start adress to read from
 *            from
 * \param[out] *buffer pointer to a buffer to write the data into
 * \param[out] xdata uint8_t *buffer, pointer to a buffer to write the data into
 * \param[in]  length length of the data to read
 * \param[in] length of the data to read
 
 * \return    returns non-zero if successful, else 0
 * \return    returns non-zero if successful, else 0
 */
 */
int8_t spiflash_read(xdata SPI_flash *flashPtr, xdata uint32_t *adress, xdata uint8_t *buffer, const idata uint16_t length);
int8_t spiflash_read(xdata SPI_flash *flashPtr, xdata uint32_t *adress, \
 
                     xdata uint8_t *buffer, const idata uint16_t length);
 
 
 
 
/** \brief deletes the whole SPI flash
/** \brief deletes the whole SPI flash
 *
 *
 * \param[in] *flashPtr pointer to an SPI_flash struct
 * \param[in] *flashPtr pointer to an SPI_flash struct
Line 247... Line 249...
 * \param[in] length of the data to read
 * \param[in] length of the data to read
 * \return    returns non-zero if successful, else 0
 * \return    returns non-zero if successful, else 0
 */
 */
int8_t spiflash_write(xdata SPI_flash *flashPtr, xdata uint32_t *adress, xdata uint8_t *buffer, uint16_t length);
int8_t spiflash_write(xdata SPI_flash *flashPtr, xdata uint32_t *adress, xdata uint8_t *buffer, uint16_t length);
 
 
#ifdef __cplusplus
 
}
 
#endif
 
 
 
#endif
#endif /* _SPI_FLASH_H_ */
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.