/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: SST25VF_Driver.h
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: SST25VF Drivers lib
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: SST25VF Drivers lib
|
**
|
***************************************************************************/
|
//
|
|
#ifndef SST25VF_Driver_H
|
#define SST25VF_Driver_H
|
|
//--------------------------------------------------------------------------------------------------
|
//--------------------- IOPORT -----------------------------------------------------
|
#define SST25VF_CS_DDR DDRG
|
#define SST25VF_CS_PORT PORTG
|
#define SST25VF_CS_PIN PG2
|
#define SST25VF_SPI_OFF SST25VF_CS_PORT |= (1<<SST25VF_CS_PIN) //PING2
|
#define SST25VF_SPI_ON SST25VF_CS_PORT &= ~(1<<SST25VF_CS_PIN)
|
//----------------------------------------------------------------------------------
|
#define SST25VF_MOSI_DDR DDRB
|
#define SST25VF_MOSI_PORT PORTB
|
#define SST25VF_MOSI_PIN PB2
|
#define SST25VF_MOSI_1 SST25VF_MOSI_PORT |= (1<<SST25VF_MOSI_PIN) //PINB2
|
#define SST25VF_MOSI_0 SST25VF_MOSI_PORT &= ~(1<<SST25VF_MOSI_PIN)
|
//----------------------------------------------------------------------------------
|
#define SST25VF_MISO_DDR DDRB
|
#define SST25VF_MISO_PORT PORTB
|
#define SST25VF_MISO_PIN PB3
|
#define SST25VF_MISO_PNAME PINB
|
#define SST25VF_MISO_1 (SST25VF_MISO_PNAME & (1<<SST25VF_MISO_PIN)) //PINB3
|
//----------------------------------------------------------------------------------
|
#define SST25VF_SCK_DDR DDRB
|
#define SST25VF_SCK_PORT PORTB
|
#define SST25VF_SCK_PIN PB1
|
#define SST25VF_SCK_1 SST25VF_SCK_PORT |= (1<<SST25VF_SCK_PIN) //PINB1
|
#define SST25VF_SCK_0 SST25VF_SCK_PORT &= ~(1<<SST25VF_SCK_PIN)
|
//----------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
/*
|
//--------------------- IOPORT --------------------------------
|
#define SST25VF_SPI_OFF PORTG |= 1<<PG2 //PING2
|
#define SST25VF_SPI_ON PORTG &= ~(1<<PG2)
|
|
#define SST25VF_MOSI_1 PORTB |= 0x04 //PINB2
|
#define SST25VF_MOSI_0 PORTB &= (~0x04)
|
#define SST25VF_MISO_1 PINB & 0x08 //PINB3
|
|
#define SST25VF_SCK_1 PORTB |= 0x02 //PINB1
|
#define SST25VF_SCK_0 PORTB &= (~0x02)
|
*/
|
//--------------------- CMD -----------------------------------
|
#define SSTMemorySize 0x100000UL
|
#define SSTBlockSize 32768UL
|
#define SSTBlockSum 32
|
|
#define SST25VF_WriteEN 0x06
|
#define SST25VF_FlashProtectNone 0x00
|
#define SST25VF_WriteAAI_EN 0x40
|
//--------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
|
#include<avr/io.h>
|
#include <util/delay.h>
|
#include "Define.h"
|
#include "FileManage.h"
|
|
void InitIO_SST25VF(void);
|
void Config_SST25VF(void);
|
void ReadID_SST25VF(unsigned char *id);
|
unsigned char ReadSR_SST25VF(void);
|
void WriteSR_SST25VF(const unsigned char data);
|
void EraseChip_SST25VF(void);
|
void Erase32K_SST25VF(const unsigned long addr);
|
void Erase4K_SST25VF(const unsigned long addr);
|
unsigned char SpiRead_SST25VF(void);
|
void WriteCMD_SST25VF(const unsigned char cmd);
|
unsigned char ReadBlock_SST25VF(const unsigned char tag,
|
const unsigned char BlockSum,
|
const unsigned char device);
|
void ReadFileInf(const unsigned long addr, File_Inf *fileinf);
|
unsigned char ReadByte_SST25VF(const unsigned long addr);
|
void WriteByte_SST25VF(const unsigned long addr, const unsigned char data);
|
void WriteBlock_SST25VF(const unsigned long addr, volatile const void *data,
|
const unsigned int count);
|
|
#endif
|
//
|