📄 get_data.c
字号:
/****************************************************************************/
/* */
/* Copyright (C) 2006 Oki Electric Industry Co., LTD. */
/* */
/* System Name : ML675050 */
/* Module Name : Flash Memory Write Utility flash module */
/* File Name : get_data.c */
/* Revision : 01.00 */
/* Date : 2006/03/20 */
/* */
/****************************************************************************/
#include "fmwu_common.h"
#include "get_data.h"
typedef int FileHandle;
typedef struct file_p{
const char *file_name;
unsigned long mode;
unsigned long len;
} FILE_POINT;
typedef struct filer_p{
unsigned long fp;
const unsigned char *read_buff;
unsigned long cnt;
unsigned long mode;
} FILE_READ_POINT;
static FileHandle Sys_Open(const char *filename, int mode);
static UWORD Sys_Read(FileHandle handle, unsigned char *buff, UWORD size, int mode);
/* We use the following Debug Monitor SWIs in this example */
#ifndef SemiSWI
#ifdef __thumb
/* Define Angel Semihosting SWI to be Thumb one */
#define SemiSWI 0xAB
#else
/* Define Angel Semihosting SWI to be ARM one */
#define SemiSWI 0x123456
#endif
#endif
/* open */
__swi(SemiSWI) FileHandle _sys_open(unsigned long op, FILE_POINT *pointer);
/* close */
__swi(SemiSWI) long _sys_close(unsigned long op, FileHandle *phandle);
#define Sys_Close(handle) _sys_close(0x2,&(handle))
/* read */
__swi(SemiSWI) unsigned long _sys_read(unsigned long op, FILE_READ_POINT *pointer);
/* len */
__swi(SemiSWI) unsigned long _sys_flen(unsigned long op, FileHandle *phandle);
#define Sys_Flen(handle) _sys_flen(0xc,&(handle))
#define MODE_rb 1
/***** Work Area Definition *****/
static FileHandle handle;
/********************************************************************/
/* File Open Proc */
/********************************************************************/
int gdFileOpen(char *filename)
{
handle = Sys_Open(filename, MODE_rb);
if(handle == -1){
return ERROR;
}
return OK;
}
/********************************************************************/
/* File Open Proc */
/********************************************************************/
int gdFileClose(void)
{
if(Sys_Close(handle) == -1){
return ERROR;
}
return OK;
}
/********************************************************************/
/* Data Read Proc */
/********************************************************************/
UWORD gdDataRead(unsigned char *dst_addr, UWORD read_size)
{
UWORD size;
size = Sys_Read(handle, dst_addr, read_size, MODE_rb);
return read_size - size;
}
/********************************************************************/
/* Get Data Size Proc */
/********************************************************************/
int gdGetDataSize(void)
{
return (int)Sys_Flen(handle);
}
/********************************************************************/
/* File Open Proc */
/********************************************************************/
static FileHandle Sys_Open(const char *filename, int mode)
{
FILE_POINT pointer;
UWORD len;
len = (UWORD)strlen(filename);
pointer.file_name = filename;
pointer.mode = (UWORD)mode;
pointer.len = len;
return _sys_open(0x1,&pointer);
}
/********************************************************************/
/* File Read Proc */
/********************************************************************/
static UWORD Sys_Read(FileHandle handle, unsigned char *buff, UWORD size, int mode)
{
FILE_READ_POINT rpointer;
rpointer.fp = (UWORD)handle;
rpointer.read_buff = buff;
rpointer.cnt = size;
rpointer.mode = (UWORD)mode;
return _sys_read (0x6,&rpointer);
}
/********************************************************************/
/* File Read Proc */
/********************************************************************/
UBYTE get_char(void)
{
return (UBYTE)ReadC();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -