⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nf_file.c

📁 通过车载终端采集GPS数据
💻 C
字号:
/******************************************************************************/
/*Usage:按照定义好的文件格式,读取flash上的内容
        :填写好相应的变量
/******************************************************************************/
#include "global.h"
#include "nf_file.h"
#include "nf_drv.h"
#include "string.h"
#include "msm9841.h"
#include "playsound.h"
#include "position.h"
#include "display.h"
#include <string.h>
#include <stdio.h>
#include "commoninterface.h"
#include "common_function.h"
#define STARTADDR_BACKWARD 102 //报站位置数据中下行数据的起始位置
/*************全局变量*******************************/
xdata Uint8 xAddrBackward;//报站位置数据中下行数据在stationData中的起始位置
xdata Uint32 xFileAddress;//该线路语音文件在flash中存储的起始地址
xdata BUS_INFO busInfo;//线路当前信息
xdata STATION_TONE stationTone[128];//上下行车站数据
xdata Byte fixedTone[MAX_CUR_FIXNUM];//固定服务短语
xdata Uint32 tonePointer[MAX_TONEPOINTER_NUMBER];//语音指针
xdata Uint16 toneArrayPointer[MAX_TONEARRAY_SIZE];//语音串的存放空间
xdata Uint16 toneArrayAddr[MAX_TONEARRAY_NUMBER];//所有语音串的起始序号(在toneArrayPointer中的位置)
xdata TERM_PARA termPara;//线路参数

extern char positionMode[128];
extern POSITIONINFO positionInfo[204];

extern Uint8 voiceSynMethod;
extern Uint8 samplingFreq;

PROGRAM_BUFPOINT gProgramBuf;



/**********判断数据是否有效**********************/
/*return value: OK:数据有效
/*              KO:数据无效(pBuf中的数据为全0)
/************************************************/
Byte CheckDataValid(Byte *pBuf, Uint8 nLen)
{
    Uint8 i;
    for (i=0; i<nLen; i++)
    {
        if (0 != pBuf[i])
            return OK;
    }
    return KO;
}
/*******************write file********************/
//xdata Byte writeBuf[512];
xdata Byte writeBuf1[128] _at_ 0x1000;
xdata Byte writeBuf2[128] _at_ 0x1100;
xdata Byte writeBuf3[128] _at_ 0x1200;
xdata Byte writeBuf4[128] _at_ 0x1300;
xdata Byte* bufPoint[4] = {writeBuf1, writeBuf2, writeBuf3, writeBuf4};
xdata Uint32 basePage;//写flash时起始的页地址

/*****************以下是更新程序的代码************
*pBuf:数据内容
*nLen:pBuf的长度
*nOffset:该块程序的偏移地址
*返回值:OK,可以返回应答;KO
*************************************************/
/*通过串口更新程序时使用*/
void init_serialupdateprogram(Byte status)
{
    if (status == SERIAL_FIRSTUPDATE)
    {
        gProgramBuf.curBlock = ZONE_PROGRAM_BASEADDR;
    }
    gProgramBuf.bufvalid = 0;
}

Uint32 gnRemoteUpAddr;
Byte write_programtoFlash(Byte* pBuf, Uint16 nLen, Uint32 nOffset)
{
//    Uint8 i;

	//当前无语音播放
	Uint32 nTmp32;
	nf_wp_off();
/*	for (i=0; i<gProgramBuf.bufvalid; i++)
	{
	    if (gProgramBuf.offset[i] >= gProgramBuf.curBlock)
	    {                
	        nf_block_erase(gProgramBuf.curBlock>>1);
	        gProgramBuf.curBlock += 32*512;
	    }
	    else if (gProgramBuf.offset[i] == ZONE_PROGRAM_BASEADDR)
	    {
	        gProgramBuf.curBlock = ZONE_PROGRAM_BASEADDR;
	        nf_block_erase(gProgramBuf.curBlock>>1);
	        gProgramBuf.curBlock += 32*512;                
	    }
	    
	    nf_write_onebuf_withouterase(gProgramBuf.offset[i], bufPoint[i], gProgramBuf.bufLen);
	}
*/	
	if ((nOffset+ZONE_PROGRAM_BASEADDR) >= gProgramBuf.curBlock)
	{
	    nf_block_erase(gProgramBuf.curBlock>>1);
	    gProgramBuf.curBlock += 32*512;
	}
	else if (nOffset == 0)
	{
	    gProgramBuf.curBlock = ZONE_PROGRAM_BASEADDR;
	    nf_block_erase(gProgramBuf.curBlock>>1);
	    gProgramBuf.curBlock += 32*512;                
	}
	
	nTmp32 = nOffset+ZONE_PROGRAM_BASEADDR;
	nf_write_onebuf_withouterase(nTmp32, pBuf, nLen);
	gProgramBuf.bufvalid = 0;
	nf_wp_on();
	return OK;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -