1 /*
2 * Copyright (c) 2022 Talkweb Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "littlefs.h"
16 #include <stdio.h>
17 #include <string.h>
18 #include "los_memory.h"
19
LittlefsRead(const struct lfs_config * cfg,lfs_block_t block,lfs_off_t off,void * buffer,lfs_size_t size)20 int LittlefsRead(const struct lfs_config *cfg, lfs_block_t block,
21 lfs_off_t off, void *buffer, lfs_size_t size)
22 {
23 W25x_BufferRead(buffer, cfg->context + cfg->block_size * block + off, size);
24 return LFS_ERR_OK;
25 }
26
LittlefsProg(const struct lfs_config * cfg,lfs_block_t block,lfs_off_t off,const void * buffer,lfs_size_t size)27 int LittlefsProg(const struct lfs_config *cfg, lfs_block_t block,
28 lfs_off_t off, const void *buffer, lfs_size_t size)
29 {
30 W25x_BufferWrite((uint8_t *)buffer, cfg->context + cfg->block_size * block + off,size);
31 return LFS_ERR_OK;
32 }
33
LittlefsErase(const struct lfs_config * cfg,lfs_block_t block)34 int LittlefsErase(const struct lfs_config *cfg, lfs_block_t block)
35 {
36 W25x_SectorErase(cfg->context + cfg->block_size * block);
37 return LFS_ERR_OK;
38 }
39
LittlefsSync(const struct lfs_config * cfg)40 int LittlefsSync(const struct lfs_config *cfg)
41 {
42 return LFS_ERR_OK;
43 }
44