You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/23 19:06:45 UTC
[2/8] incubator-mynewt-core git commit: Add initial FAT support
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dd639f3/fs/fatfs/src/mynewt_glue.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
new file mode 100644
index 0000000..1e65885
--- /dev/null
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -0,0 +1,75 @@
+#include <assert.h>
+#include <hal/hal_flash.h>
+#include <flash_map/flash_map.h>
+#include <stdio.h>
+
+#include <fatfs/diskio.h>
+
+DSTATUS
+disk_initialize(BYTE pdrv)
+{
+ /* Don't need to do anything while using hal_flash */
+ return RES_OK;
+}
+
+DSTATUS
+disk_status(BYTE pdrv)
+{
+ /* Always OK on native emulated flash */
+ return RES_OK;
+}
+
+DRESULT
+disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
+{
+ int rc;
+ uint32_t address;
+ uint32_t num_bytes;
+
+ /* NOTE: safe to assume sector size as 512 for now, see ffconf.h */
+ address = (uint32_t) sector * 512;
+ num_bytes = (uint32_t) count * 512;
+ rc = hal_flash_read(pdrv, address, (void *) buff, num_bytes);
+ if (rc < 0) {
+ return STA_NOINIT;
+ }
+
+ return RES_OK;
+}
+
+DRESULT
+disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count)
+{
+ int rc;
+ uint32_t address;
+ uint32_t num_bytes;
+
+ /* NOTE: safe to assume sector size as 512 for now, see ffconf.h */
+ address = (uint32_t) sector * 512;
+ num_bytes = (uint32_t) count * 512;
+ rc = hal_flash_write(pdrv, address, (const void *) buff, num_bytes);
+ if (rc < 0) {
+ return STA_NOINIT;
+ }
+
+ return RES_OK;
+}
+
+DRESULT
+disk_ioctl(BYTE pdrv, BYTE cmd, void* buff)
+{
+ return RES_OK;
+}
+
+/* FIXME: _FS_NORTC=1 because there is not hal_rtc interface */
+DWORD
+get_fattime(void)
+{
+ return 0;
+}
+
+void
+fatfs_pkg_init(void)
+{
+ /* Nothing to do for now */
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dd639f3/fs/fatfs/src/option/unicode.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/option/unicode.c b/fs/fatfs/src/option/unicode.c
new file mode 100644
index 0000000..9ba18c4
--- /dev/null
+++ b/fs/fatfs/src/option/unicode.c
@@ -0,0 +1,17 @@
+#include <fatfs/ff.h>
+
+#if _USE_LFN != 0
+
+#if _CODE_PAGE == 932 /* Japanese Shift_JIS */
+#include "cc932.c"
+#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
+#include "cc936.c"
+#elif _CODE_PAGE == 949 /* Korean */
+#include "cc949.c"
+#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
+#include "cc950.c"
+#else /* Single Byte Character-Set */
+#include "ccsbcs.c"
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8dd639f3/fs/fatfs/syscfg.yml
----------------------------------------------------------------------
diff --git a/fs/fatfs/syscfg.yml b/fs/fatfs/syscfg.yml
new file mode 100644
index 0000000..45de725
--- /dev/null
+++ b/fs/fatfs/syscfg.yml
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: fs/fatfs
+
+syscfg.defs:
+ NFFS_FLASH_AREA:
+ description: 'TBD'
+ type: flash_owner
+ value:
+ restrictions:
+ - $notnull
+
+ NFFS_DETECT_FAIL:
+ description: 'TBD'
+ value: 'NFFS_DETECT_FAIL_FORMAT'