|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
CH32 闪存驱动实现 / CH32 flash driver implementation. More...
#include <ch32_flash.hpp>
Public Member Functions | |
| CH32Flash (const FlashRegion *regions, size_t region_count, uint32_t start_address) | |
| 构造闪存对象 / Construct flash object | |
| CH32Flash (const FlashRegion *regions, size_t region_count) | |
| 用末尾两个扇区构造,供 DatabaseRaw 的主块和备份块使用 / Construct with the last two sectors, for the main and backup blocks of DatabaseRaw | |
| ErrorCode | Erase (size_t offset, size_t size) override |
| 擦除闪存的指定区域 / Erases a section of the flash memory. | |
| ErrorCode | Write (size_t offset, ConstRawData data) override |
| 向闪存写入数据 / Writes data to the flash memory. | |
Public Member Functions inherited from LibXR::Flash | |
| Flash (size_t min_erase_size, size_t min_write_size, RawData flash_area) | |
| 构造函数,初始化闪存属性。 Constructs a Flash object with specified properties. | |
| virtual ErrorCode | Read (size_t offset, RawData data) |
| 从闪存中读取数据 / Reads data from the flash memory. | |
| size_t | MinEraseSize () const |
| 获取最小可擦除块大小(字节)。 Returns the minimum erasable block size in bytes. | |
| size_t | MinWriteSize () const |
| 获取最小可写块大小(字节) / Returns the minimum writable block size in bytes. | |
| size_t | Size () const |
| 获取闪存存储区域的大小 / Returns the size of the flash memory area. | |
Static Public Member Functions | |
| static constexpr size_t | MinWriteSize () |
| 最小写入粒度(半字) / Minimum write size (half-word) | |
| static constexpr uint32_t | PageSize () |
| 快速擦除页大小 / Page erase size in fast erase mode | |
Static Public Attributes | |
| static constexpr size_t | MIN_WRITE_SIZE = 2 |
最小写入单位(字节,半字编程);可直接作为 DatabaseRaw 的模板参数 / Minimum write unit in bytes (half-word programming); usable directly as the DatabaseRaw template argument | |
CH32 闪存驱动实现 / CH32 flash driver implementation.
Definition at line 20 of file ch32_flash.hpp.
| CH32Flash::CH32Flash | ( | const FlashRegion * | regions, |
| size_t | region_count, | ||
| uint32_t | start_address ) |
构造闪存对象 / Construct flash object
| regions | 扇区表 / Sector table |
| region_count | 扇区表的段数 / Number of runs in the sector table |
| start_address | 存储区的起始地址,须正好是某个扇区的起点;存储区一直到 Flash 末尾 / Start address of the storage area; must be exactly the start of a sector; the area extends to the end of the Flash |
Definition at line 159 of file ch32_flash.cpp.
| CH32Flash::CH32Flash | ( | const FlashRegion * | regions, |
| size_t | region_count ) |
用末尾两个扇区构造,供 DatabaseRaw 的主块和备份块使用 / Construct with the last two sectors, for the main and backup blocks of DatabaseRaw
| regions | 扇区表 / Sector table |
| region_count | 扇区表的段数 / Number of runs in the sector table |
Definition at line 176 of file ch32_flash.cpp.
|
overridevirtual |
擦除闪存的指定区域 / Erases a section of the flash memory.
| offset | 要擦除的起始偏移地址 / The starting offset of the section to erase. |
| size | 要擦除的区域大小 / The size of the section to erase. |
Implements LibXR::Flash.
Definition at line 181 of file ch32_flash.cpp.
|
inlinestaticconstexpr |
最小写入粒度(半字) / Minimum write size (half-word)
Definition at line 51 of file ch32_flash.hpp.
|
inlinestaticconstexpr |
快速擦除页大小 / Page erase size in fast erase mode
Definition at line 56 of file ch32_flash.hpp.
|
overridevirtual |
向闪存写入数据 / Writes data to the flash memory.
| offset | 数据写入的起始偏移地址 / The starting offset to write data. |
| data | 需要写入的数据 / The data to be written. |
Implements LibXR::Flash.
Definition at line 216 of file ch32_flash.cpp.
|
staticconstexpr |
最小写入单位(字节,半字编程);可直接作为 DatabaseRaw 的模板参数 / Minimum write unit in bytes (half-word programming); usable directly as the DatabaseRaw template argument
Definition at line 28 of file ch32_flash.hpp.