mirror of
https://github.com/sengeiou/realtek_ameba_mp_sdk.git
synced 2026-07-07 03:55:42 +00:00
ameba micropython sdk first commit
This commit is contained in:
commit
8508ee6139
5619 changed files with 1874619 additions and 0 deletions
156
sdk/component/common/file_system/ftl/ftl.h
Normal file
156
sdk/component/common/file_system/ftl/ftl.h
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/**
|
||||
****************************************************************************************************
|
||||
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
|
||||
****************************************************************************************************
|
||||
* @file ftl.h
|
||||
* @brief flash transport layer is used as abstraction layer for user application to save read/write
|
||||
* parameters in flash.
|
||||
* @note ftl is dedicate block in flash, only used for save read/write value, and offset here is
|
||||
* logical offset which is defined for whole ftl section.If value is only for one time read,
|
||||
* refer to fs_load_app_data_8 or other APIs in flash_device.h
|
||||
* @author Brenda_li
|
||||
* @date 2016-12-27
|
||||
* @version v1.0
|
||||
* **************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _FTL_H_
|
||||
#define _FTL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/** @defgroup FTL Flash Transport Layer
|
||||
* @brief simple implementation of file system for flash
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup FTL_Exported_Macros FTL Exported Macros
|
||||
* @brief
|
||||
* @{
|
||||
*/
|
||||
#define FTL_WRITE_SUCCESS (0x00)
|
||||
#define FTL_WRITE_ERROR_IN_INTR (0x01)
|
||||
#define FTL_WRITE_ERROR_INVALID_ADDR (0x02)
|
||||
#define FTL_WRITE_ERROR_OUT_OF_SPACE (0x03)
|
||||
#define FTL_WRITE_ERROR_READ_BACK (0x04)
|
||||
#define FTL_WRITE_ERROR_VERIFY (0x05)
|
||||
#define FTL_WRITE_ERROR_INVALID_PARAMETER (0x06)
|
||||
#define FTL_WRITE_ERROR_ERASE_FAIL (0x07)
|
||||
#define FTL_WRITE_ERROR_NOT_INIT (0x08)
|
||||
#define FTL_WRITE_ERROR_NEED_GC (0x09)
|
||||
#define FTL_READ_SUCCESS (0x00)
|
||||
#define FTL_READ_ERROR_INVALID_LOGICAL_ADDR (0x01)
|
||||
#define FTL_READ_ERROR_READ_NOT_FOUND (0x02)
|
||||
#define FTL_READ_ERROR_PARSE_ERROR (0x03)
|
||||
#define FTL_READ_ERROR_INVALID_PARAMETER (0x04)
|
||||
#define FTL_READ_ERROR_NOT_INIT (0x05)
|
||||
|
||||
#define FTL_INIT_ERROR_ERASE_FAIL (0x01)
|
||||
/** End of FTL_Exported_Macros
|
||||
* @}
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
FTL_LEVEL_ERROR = 0, /**< Error */
|
||||
FTL_LEVEL_WARN = 1, /**< Warning */
|
||||
FTL_LEVEL_INFO = 2, /**< Information */
|
||||
FTL_LEVEL_TRACE = 3, /**< Trace Data */
|
||||
FTL_LEVEL_NUMs = 4 /**< Level Number */
|
||||
} FTL_LEVEL_DEFINE;
|
||||
|
||||
/*============================================================================*
|
||||
* Types
|
||||
*============================================================================*/
|
||||
/** @defgroup FTL_Exported_Types Flash Transport Layer Exported Types
|
||||
* @brief
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FTL_IOCTL_DEBUG = 0, /**< IO code for ftl debug */
|
||||
FTL_IOCTL_CLEAR_ALL = 2, /**< IO code for clear ftl section*/
|
||||
FTL_IOCTL_ERASE_INVALID_PAGE = 3, /**< IO code to erase invalid page*/
|
||||
FTL_IOCTL_ENABLE_GC_IN_IDLE = 4, /**< IO code to enable garbage collection in idle task*/
|
||||
FTL_IOCTL_DISABLE_GC_IN_IDLE = 5, /**< IO code to disable garbage collection in idle task*/
|
||||
FTL_IOCTL_DO_GC_IN_APP = 6, /**< IO code to do garbage collection in app*/
|
||||
} T_FTL_IOCTL_CODE;
|
||||
|
||||
/** End of FTL_Exported_Types
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* Functions
|
||||
*============================================================================*/
|
||||
/** @defgroup FTL_Exported_Functions Flash Transport Layer Exported Functions
|
||||
* @brief
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Save specified value to specified ftl offset
|
||||
* @param pdata specify data buffer
|
||||
* @param offset specify FTL offset to store
|
||||
* @arg Min: 0
|
||||
* @arg Max: 2044
|
||||
* @param size size to store
|
||||
* @arg Min: 4
|
||||
* @arg Max: 2048
|
||||
* @return status
|
||||
* @retval 0 status successful
|
||||
* @retval otherwise fail
|
||||
* @note FTL offset is pre-defined and no conflict
|
||||
*/
|
||||
//uint32_t ftl_save(void *pdata, uint16_t offset, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Load specified ftl offset parameter to specified buffer
|
||||
* @param pdata specify data buffer
|
||||
* @param offset specify FTL offset to load
|
||||
* @arg Min: 0
|
||||
* @arg Max: 2044
|
||||
* @param size size to load
|
||||
* @arg Min: 4
|
||||
* @arg Max: 2048
|
||||
* @return status
|
||||
* @retval 0 status successful
|
||||
* @retval otherwise fail
|
||||
* @note FTL offset is pre-defined and no conflict
|
||||
*/
|
||||
//uint32_t ftl_load(void *pdata, uint16_t offset, uint16_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Control function entry for ftl
|
||||
* @param cmd command code for different operation
|
||||
* @param p1 command parameter @ref FTL_IO_CTL_CODE
|
||||
* @param p2 extended command parameters
|
||||
* @return results of control
|
||||
* @retval 0 status successful
|
||||
* @retval otherwise fail
|
||||
*/
|
||||
uint32_t ftl_ioctl(uint32_t cmd, uint32_t p1, uint32_t p2);
|
||||
|
||||
/** @} */ /* End of group FTL_Exported_Functions */
|
||||
|
||||
static inline void flash_set_bit(uint32_t *addr, uint32_t bit)
|
||||
{
|
||||
(*addr) &= ~bit;
|
||||
}
|
||||
|
||||
static inline bool flash_get_bit(uint32_t flag, uint32_t bit)
|
||||
{
|
||||
return (flag & bit) ? false : true;
|
||||
}
|
||||
|
||||
/** @} */ /* End of group FTL */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _FTL_H_
|
||||
81
sdk/component/common/file_system/ftl/ftl_int.h
Normal file
81
sdk/component/common/file_system/ftl/ftl_int.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
*****************************************************************************************
|
||||
* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
|
||||
*****************************************************************************************
|
||||
* @file ftl_rom.h
|
||||
* @brief ftl header file for rom project
|
||||
* @details
|
||||
* @author
|
||||
* @date
|
||||
* @version
|
||||
**************************************************************************************
|
||||
* @attention
|
||||
* <h2><center>© COPYRIGHT 2017 Realtek Semiconductor Corporation</center></h2>
|
||||
* *************************************************************************************
|
||||
*/
|
||||
|
||||
/*============================================================================*
|
||||
* Define to prevent recursive inclusion
|
||||
*============================================================================*/
|
||||
|
||||
#ifndef _FTL_ROM_H_
|
||||
#define _FTL_ROM_H_
|
||||
|
||||
/*============================================================================*
|
||||
* Header Files
|
||||
*============================================================================*/
|
||||
#include "ftl.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FTL_SUCCESS (0x00)
|
||||
#define FTL_ERROR_INVALID_LOGICAL_ADDR 0xF0
|
||||
#define FTL_ERROR_OUT_OF_SPACE (0xF1)
|
||||
#define FTL_ERROR_PAGE_FORMAT (0xF2)
|
||||
#define FTL_ERROR_PAGE_END_FORMAT (0xF3)
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* Types
|
||||
*============================================================================*/
|
||||
|
||||
/*============================================================================*
|
||||
* Functions
|
||||
*============================================================================*/
|
||||
uint32_t ftl_init(uint32_t u32PageStartAddr, uint8_t pagenum);
|
||||
/**
|
||||
* @brief Save specified value to specified ftl offset
|
||||
* @param pdata specify data buffer
|
||||
* @param offset specify FTL offset to store
|
||||
* @param size size to store
|
||||
* @return status
|
||||
* @retval 0 status successful
|
||||
* @retval otherwise fail
|
||||
* @note FTL offset is pre-defined and no confict with ROM
|
||||
*/
|
||||
uint32_t ftl_save_to_storage(void *pdata, uint16_t offset, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Load specified ftl offset parameter to specified buffer
|
||||
* @param pdata specify data buffer
|
||||
* @param offset specify FTL offset to load
|
||||
* @param size size to load
|
||||
* @return status
|
||||
* @retval 0 status successful
|
||||
* @retval otherwise fail
|
||||
* @note FTL offset is pre-defined and no confict with ROM
|
||||
*/
|
||||
uint32_t ftl_load_from_storage(void *pdata, uint16_t offset, uint16_t size);
|
||||
|
||||
void ftl_garbage_collect_in_idle(void);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _FTL_ROM_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue