rtt更新

This commit is contained in:
2025-01-18 13:25:25 +08:00
parent c6a7554b51
commit d6009a0773
726 changed files with 103376 additions and 6270 deletions

View File

@@ -12,7 +12,7 @@
- `static int init(void)`**可选** 的初始化操作
- `static int read(long offset, uint8_t *buf, size_t size)`:读取操作
- `static int read(long offset, rt_uint8_t *buf, rt_size_t size)`:读取操作
|参数 |描述|
|:----- |:----|
@@ -21,7 +21,7 @@
|size |待读取数据的大小|
|return |返回实际读取的数据大小|
- `static int write(long offset, const uint8_t *buf, size_t size)` :写入操作
- `static int write(long offset, const rt_uint8_t *buf, rt_size_t size)` :写入操作
| 参数 | 描述 |
| :----- | :------------------------ |
@@ -30,7 +30,7 @@
| size | 待写入数据的大小 |
| return | 返回实际写入的数据大小 |
- `static int erase(long offset, size_t size)` :擦除操作
- `static int erase(long offset, rt_size_t size)` :擦除操作
| 参数 | 描述 |
| :----- | :------------------------ |

View File

@@ -13,7 +13,7 @@
#ifdef FAL_USING_SFUD_PORT
#ifdef RT_USING_SFUD
#include <spi_flash_sfud.h>
#include <dev_spi_flash_sfud.h>
#endif
#ifndef FAL_USING_NOR_FLASH_DEV_NAME
@@ -21,9 +21,9 @@
#endif
static int init(void);
static int read(long offset, uint8_t *buf, size_t size);
static int write(long offset, const uint8_t *buf, size_t size);
static int erase(long offset, size_t size);
static int read(long offset, rt_uint8_t *buf, rt_size_t size);
static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
static int erase(long offset, rt_size_t size);
static sfud_flash_t sfud_dev = NULL;
struct fal_flash_dev nor_flash0 =
@@ -60,19 +60,19 @@ static int init(void)
return 0;
}
static int read(long offset, uint8_t *buf, size_t size)
static int read(long offset, rt_uint8_t *buf, rt_size_t size)
{
assert(sfud_dev);
assert(sfud_dev->init_ok);
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
sfud_read(sfud_dev, nor_flash0.addr + offset, size, buf);
return size;
}
static int write(long offset, const uint8_t *buf, size_t size)
static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
{
assert(sfud_dev);
assert(sfud_dev->init_ok);
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
if (sfud_write(sfud_dev, nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
{
return -1;
@@ -81,10 +81,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
return size;
}
static int erase(long offset, size_t size)
static int erase(long offset, rt_size_t size)
{
assert(sfud_dev);
assert(sfud_dev->init_ok);
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
if (sfud_erase(sfud_dev, nor_flash0.addr + offset, size) != SFUD_SUCCESS)
{
return -1;

View File

@@ -13,18 +13,18 @@
#include <stm32f2xx.h>
/* base address of the flash sectors */
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base address of Sector 0, 16 K bytes */
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base address of Sector 1, 16 K bytes */
#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base address of Sector 2, 16 K bytes */
#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base address of Sector 3, 16 K bytes */
#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base address of Sector 4, 64 K bytes */
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base address of Sector 5, 128 K bytes */
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base address of Sector 6, 128 K bytes */
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base address of Sector 7, 128 K bytes */
#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base address of Sector 8, 128 K bytes */
#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base address of Sector 9, 128 K bytes */
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base address of Sector 10, 128 K bytes */
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base address of Sector 11, 128 K bytes */
#define ADDR_FLASH_SECTOR_0 ((rt_uint32_t)0x08000000) /* Base address of Sector 0, 16 K bytes */
#define ADDR_FLASH_SECTOR_1 ((rt_uint32_t)0x08004000) /* Base address of Sector 1, 16 K bytes */
#define ADDR_FLASH_SECTOR_2 ((rt_uint32_t)0x08008000) /* Base address of Sector 2, 16 K bytes */
#define ADDR_FLASH_SECTOR_3 ((rt_uint32_t)0x0800C000) /* Base address of Sector 3, 16 K bytes */
#define ADDR_FLASH_SECTOR_4 ((rt_uint32_t)0x08010000) /* Base address of Sector 4, 64 K bytes */
#define ADDR_FLASH_SECTOR_5 ((rt_uint32_t)0x08020000) /* Base address of Sector 5, 128 K bytes */
#define ADDR_FLASH_SECTOR_6 ((rt_uint32_t)0x08040000) /* Base address of Sector 6, 128 K bytes */
#define ADDR_FLASH_SECTOR_7 ((rt_uint32_t)0x08060000) /* Base address of Sector 7, 128 K bytes */
#define ADDR_FLASH_SECTOR_8 ((rt_uint32_t)0x08080000) /* Base address of Sector 8, 128 K bytes */
#define ADDR_FLASH_SECTOR_9 ((rt_uint32_t)0x080A0000) /* Base address of Sector 9, 128 K bytes */
#define ADDR_FLASH_SECTOR_10 ((rt_uint32_t)0x080C0000) /* Base address of Sector 10, 128 K bytes */
#define ADDR_FLASH_SECTOR_11 ((rt_uint32_t)0x080E0000) /* Base address of Sector 11, 128 K bytes */
/**
* Get the sector of a given address
@@ -33,9 +33,9 @@
*
* @return The sector of a given address
*/
static uint32_t stm32_get_sector(uint32_t address)
static rt_uint32_t stm32_get_sector(rt_uint32_t address)
{
uint32_t sector = 0;
rt_uint32_t sector = 0;
if ((address < ADDR_FLASH_SECTOR_1) && (address >= ADDR_FLASH_SECTOR_0))
{
@@ -96,8 +96,8 @@ static uint32_t stm32_get_sector(uint32_t address)
*
* @return sector size
*/
static uint32_t stm32_get_sector_size(uint32_t sector) {
assert(IS_FLASH_SECTOR(sector));
static rt_uint32_t stm32_get_sector_size(rt_uint32_t sector) {
RT_ASSERT(IS_FLASH_SECTOR(sector));
switch (sector) {
case FLASH_Sector_0: return 16 * 1024;
@@ -120,23 +120,23 @@ static int init(void)
/* do nothing now */
}
static int read(long offset, uint8_t *buf, size_t size)
static int read(long offset, rt_uint8_t *buf, rt_size_t size)
{
size_t i;
uint32_t addr = stm32f2_onchip_flash.addr + offset;
rt_size_t i;
rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
for (i = 0; i < size; i++, addr++, buf++)
{
*buf = *(uint8_t *) addr;
*buf = *(rt_uint8_t *) addr;
}
return size;
}
static int write(long offset, const uint8_t *buf, size_t size)
static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
{
size_t i;
uint32_t read_data;
uint32_t addr = stm32f2_onchip_flash.addr + offset;
rt_size_t i;
rt_uint32_t read_data;
rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
FLASH_Unlock();
FLASH_ClearFlag(
@@ -146,7 +146,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
{
/* write data */
FLASH_ProgramByte(addr, *buf);
read_data = *(uint8_t *) addr;
read_data = *(rt_uint8_t *) addr;
/* check data */
if (read_data != *buf)
{
@@ -158,12 +158,12 @@ static int write(long offset, const uint8_t *buf, size_t size)
return size;
}
static int erase(long offset, size_t size)
static int erase(long offset, rt_size_t size)
{
FLASH_Status flash_status;
size_t erased_size = 0;
uint32_t cur_erase_sector;
uint32_t addr = stm32f2_onchip_flash.addr + offset;
rt_size_t erased_size = 0;
rt_uint32_t cur_erase_sector;
rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
/* start erase */
FLASH_Unlock();