FatFsR0.14:移植简介

背景说明

移植到日本某操作系统。

本文只简单介绍一下移植FatFs的要点。

移植流程

FatFs的源码并不多,需要实现的接口也不多,相对来说还是很好移植的。

系统相关的接口

1、变量类型的定义ff.h
      开源代码一般都有这些定义需要实现:
            8位有符号,例如char;
            8位无符号,例如unsigned char;
            16位有符号,例如short;
            16位无符号,例如unsigned short;
            32位有符号,例如int;
            32位无符号,例如unsigned int;
      这里要实现的是(已给出参考实现):

typedef unsigned int	UINT;	/* int must be 16-bit or 32-bit */
typedef unsigned char	BYTE;	/* char must be 8-bit */
typedef unsigned short	WORD;	/* 16-bit unsigned integer */
typedef unsigned long	DWORD;	/* 32-bit unsigned integer */
typedef WORD			WCHAR;	/* UTF-16 character type */

2、一些跟系统相关的常用函数接口ffsystem.c
      内存相关:

#if FF_USE_LFN == 3	/* Dynamic memory allocation */
/* Allocate a memory block                                                */
/*------------------------------------------------------------------------*/

void* ff_memalloc (	/* Returns pointer to the allocated memory block (null if not enough core) */
	UINT msize		/* Number of bytes to allocate */
)
{
   
	return malloc(msize);	/* Allocate a new memory block with POSIX API */
}
/*------------------------------------------------------------------------*/
/* Free a memory block                                                    */
/*------------------------------------------------------------------------*/

void ff_memfree (
	void* mblock	/* Pointer to the memory block to free (nothing to do if null) */
)
{
   
	free(mblock);	/* Free the memory block with POSIX API */
}
#endif

      资源互斥:

#if FF_FS_REENTRANT
int ff_cre_syncobj (	/* 1:Function succeeded, 0:Could not create the sync object */
	BYTE vol,			/* Corresponding volume (logical drive number) */
	FF_SYNC_t* sobj		/* Pointer to return the created sync object */
);

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值