This commit is contained in:
刘可亮
2025-07-22 11:15:46 +08:00
parent d164b333ed
commit 11c97ef399
2870 changed files with 951307 additions and 26675 deletions

View File

@@ -466,7 +466,11 @@ int dfs_elm_close(struct dfs_fd *file)
fd = (FIL *)(file->data);
RT_ASSERT(fd != RT_NULL);
result = f_close(fd);
if (file->fs && file->fs->data)
{
/* close file if fs is not unmount */
result = f_close(fd);
}
if (result == FR_OK)
{
/* release memory */

View File

@@ -60,6 +60,7 @@ struct dfs_filesystem
struct dfs_partition
{
uint8_t type; /* file system type */
char name[PARTITION_NAME_MAX]; /* partition name */
off_t offset; /* partition start offset */
size_t size; /* partition size */
rt_sem_t lock;

View File

@@ -154,7 +154,7 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da
no = ((unsigned long)tx_tosnd - (unsigned long)tx_fifo->buffer) / sizeof(struct rt_can_sndbxinx_list);
tx_tosnd->result = RT_CAN_SND_RESULT_WAIT;
if ((can->ops->sendmsg(can, data, no) != RT_EOK) || (rt_completion_wait(&(tx_tosnd->completion), 100) != RT_EOK))
if (can->ops->sendmsg(can, data, no) != RT_EOK)
{
/* send failed. */
level = rt_hw_interrupt_disable();
@@ -165,6 +165,7 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da
}
can->status.sndchange = 1;
rt_completion_wait(&(tx_tosnd->completion), RT_WAITING_FOREVER);
level = rt_hw_interrupt_disable();
result = tx_tosnd->result;

View File

@@ -182,6 +182,9 @@ struct rt_can_ops;
#define RT_CAN_CMD_SET_CANFD 0x1A
#define RT_CAN_CMD_SET_BAUD_FD 0x1B
#define RT_CAN_CMD_SET_BITTIMING 0x1C
#define RT_CAN_STOP_DMA 0x1E
#define RT_CAN_CONFIG_DMA_TX 0x20
#define RT_CAN_CONFIG_DMA_RX 0x21
#define RT_DEVICE_CAN_INT_ERR 0x1000

View File

@@ -218,6 +218,7 @@ void rt_pm_device_unregister(struct rt_device *device);
void rt_pm_notify_set(void (*notify)(rt_uint8_t event, rt_uint8_t mode, void *data), void *data);
void rt_pm_default_set(rt_uint8_t sleep_mode);
rt_uint8_t rt_pm_read_mode_cnt(rt_uint8_t sleep_mode);
void rt_system_pm_init(const struct rt_pm_ops *ops,
rt_uint8_t timer_mask,

View File

@@ -102,6 +102,7 @@ struct rt_spi_ops
rt_err_t (*nonblock)(struct rt_spi_device *device, rt_uint32_t nonblock);
rt_uint32_t (*gstatus)(struct rt_spi_device *device);
void (*delaymode)(struct rt_spi_device *device, rt_uint32_t delaymode);
rt_err_t (*wait_completion)(struct rt_spi_device *device);
};
/**
@@ -228,6 +229,9 @@ rt_uint32_t rt_spi_get_transfer_status(struct rt_spi_device *device);
void rt_spi_set_rx_delay_mode(struct rt_spi_device *device,
rt_uint32_t mode);
/* wait completion */
rt_err_t rt_spi_wait_completion(struct rt_spi_device *device);
/* send data then receive data from SPI device */
rt_err_t rt_spi_send_then_recv(struct rt_spi_device *device,
const void *send_buf,

View File

@@ -78,6 +78,7 @@ struct rt_touch_info
struct rt_touch_config
{
rt_uint8_t rst_pin;
#ifdef RT_TOUCH_PIN_IRQ
struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */
#endif

View File

@@ -18,6 +18,10 @@
#include <stdlib.h>
#include <aic_io.h>
#ifdef PM_ENABLE_DEBUG
#include <aic_osal.h>
#endif
#ifdef RT_USING_PM
/* tickless threshold time */
@@ -399,6 +403,37 @@ RT_WEAK rt_uint8_t pm_get_sleep_threshold_mode(rt_uint8_t cur_mode, rt_tick_t ti
return cur_mode;
}
#ifdef PM_ENABLE_DEBUG
void pm_dump_wakeup_source(void)
{
uint32_t i;
uint32_t pending;
uint32_t enable;
#ifdef ARCH_RISCV32
for (i = 0; i < MAX_IRQn; i++)
{
pending = csi_vic_get_pending_irq(i);
enable = csi_vic_get_enabled_irq(i);
if (pending && enable)
{
rt_kprintf("The wakeup source interrupt ID: %d\n", i);
}
}
#elif defined(ARCH_RISCV64)
for (i = 0; i < MAX_IRQn; i++)
{
pending = csi_plic_get_pending_irq(PLIC_BASE, i);
enable = csi_plic_get_enabled_irq(PLIC_BASE, i);
if (pending && enable)
{
rt_kprintf("The wakeup source interrupt ID: %d\n", i);
}
}
#endif
}
#endif
/**
* This function changes the power sleep mode base on the result of selection
*/
@@ -453,6 +488,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
#else
_pm_device_suspend(pm->sleep_mode);
#endif
/* Tickless*/
if (pm->timer_mask & (0x01 << pm->sleep_mode))
{
@@ -489,6 +525,10 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
}
}
#ifdef PM_ENABLE_DEBUG
pm_dump_wakeup_source();
#endif
/* resume all device */
_pm_device_resume(pm->sleep_mode);
@@ -922,6 +962,16 @@ void rt_pm_default_set(rt_uint8_t sleep_mode)
_pm_default_deepsleep = sleep_mode;
}
rt_uint8_t rt_pm_read_mode_cnt(rt_uint8_t sleep_mode)
{
if (sleep_mode >= PM_SLEEP_MODE_MAX)
{
return 0;
}
return _pm.modes[sleep_mode];
}
/**
* RT-Thread device interface for PM device
*/

View File

@@ -491,25 +491,35 @@ static struct mmcsd_blk_device * rt_mmcsd_create_blkdev(struct rt_mmcsd_card *ca
{
LOG_D("Try to mount %s\n", blk_dev->dev.parent.name);
#ifdef AIC_AB_SYSTEM_INTERFACE
rt_int32_t id = 0;
char ro_target[32] = { 0 };
char rw_target[32] = { 0 };
enum boot_device boot_dev = aic_get_boot_device();
if (boot_dev == BD_SDMC0) {
//skip the spl/env partition
if (strcmp("mmc0p0", blk_dev->dev.parent.name) != 0 &&
strcmp("mmc0p1", blk_dev->dev.parent.name) != 0 &&
strcmp("mmc0p2", blk_dev->dev.parent.name) != 0) {
id = (aic_get_boot_device() == BD_SDMC0) ? 0 : 1;
/* Check if the current device is a boot device */
if (blk_dev->card->host->id == id) {
/* Check if the current device partition is rodata */
if (!strncmp("rodata", blk_dev->part.name, 6)) {
aic_ota_status_update();
/* Try to get the rodata device name or partition name from env */
aic_get_rodata_to_mount(ro_target);
aic_get_data_to_mount(rw_target);
if (strcmp(ro_target, blk_dev->dev.parent.name) == 0) {
if (dfs_mount(ro_target, "/rodata", "elm", 0, 0) == 0)
LOG_I("mount fs[elm] device[%s] to /rodata ok.\n", ro_target);
if (!strcmp(ro_target, blk_dev->part.name) ||
!strcmp(ro_target, blk_dev->dev.parent.name)) {
/* Try to mount the rodata device */
if (dfs_mount(blk_dev->dev.parent.name, "/rodata", "elm", 0, 0) == 0)
LOG_I("mount fs[elm] device[%s] to /rodata ok.\n", blk_dev->dev.parent.name);
}
if (strcmp(rw_target, blk_dev->dev.parent.name) == 0) {
if (dfs_mount(rw_target, "/data", "elm", 0, 0) == 0)
LOG_I("mount fs[elm] device[%s] to /data ok.\n", rw_target);
}
/* Check if the current device partition is data */
if (!strncmp("data", blk_dev->part.name, 4)) {
aic_ota_status_update();
/* Try to get the data device name or partition name from env */
aic_get_data_to_mount(rw_target);
if (!strcmp(rw_target, blk_dev->part.name) ||
!strcmp(rw_target, blk_dev->dev.parent.name)) {
/* Try to mount the data device */
if (dfs_mount(blk_dev->dev.parent.name, "/data", "elm", 0, 0) == 0)
LOG_I("mount fs[elm] device[%s] to /data ok.\n", blk_dev->dev.parent.name);
}
}
}
@@ -582,6 +592,18 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
/* Initial blk_device link-list. */
rt_list_init(&card->blk_devices);
/* Always create the super node, given name is with allocated host id. */
if (card->card_type == CARD_TYPE_MMC)
rt_snprintf(dname, sizeof(dname), "mmc%d", host_id);
else
rt_snprintf(dname, sizeof(dname), "sd%d", host_id);
blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, NULL);
if ( blk_dev == RT_NULL )
{
err = -RT_ENOMEM;
goto exit_rt_mmcsd_blk_probe;
}
struct aic_partition *parts, *p;
struct blk_desc dev_desc;
struct disk_blk_ops ops;
@@ -595,14 +617,15 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
parts = aic_disk_get_parts(&dev_desc);
p = parts;
i = 0;
memset(&part, 0, sizeof(part));
while (p) {
/* Given name is with allocated host id and its partition index. */
if (card->card_type == CARD_TYPE_MMC)
rt_snprintf(dname, sizeof(dname), "mmc%dp%d", host_id, i);
else
rt_snprintf(dname, sizeof(dname), "sd%dp%d", host_id, i);
memset(&part, 0, sizeof(part));
part.type = 0;
memcpy(part.name, p->name, strlen(p->name));
part.offset = p->start / card->card_blksize;
part.size = p->size / card->card_blksize;
blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, &part);
@@ -617,18 +640,6 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
}
if (parts)
aic_part_free(parts);
/* Always create the super node, given name is with allocated host id. */
if (card->card_type == CARD_TYPE_MMC)
rt_snprintf(dname, sizeof(dname), "mmc%d", host_id);
else
rt_snprintf(dname, sizeof(dname), "sd%d", host_id);
blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, NULL);
if ( blk_dev == RT_NULL )
{
err = -RT_ENOMEM;
goto exit_rt_mmcsd_blk_probe;
}
}
else
{

View File

@@ -269,10 +269,12 @@ rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func,
while (left_size > func->cur_blk_size)
{
blks = left_size / func->cur_blk_size;
#if !(defined(AIC_WLAN_ASR) || defined(AIC_WLAN_AIC8800D40L))
#ifndef AIC_SDMC_DRV
if (blks > max_blks)
blks = max_blks;
#endif
len = blks * func->cur_blk_size;
ret = sdio_io_rw_extended(func->card, rw, func->num,

View File

@@ -147,6 +147,27 @@ void rt_spi_set_rx_delay_mode(struct rt_spi_device *device,
}
}
rt_err_t rt_spi_wait_completion(struct rt_spi_device *device)
{
rt_err_t result = -RT_EINVAL;
RT_ASSERT(device != RT_NULL);
if (device->bus != RT_NULL)
{
result = rt_mutex_take(&(device->bus->lock), RT_WAITING_FOREVER);
if (result == RT_EOK)
{
result = device->bus->ops->wait_completion(device);
/* release lock */
rt_mutex_release(&(device->bus->lock));
}
}
return result;
}
rt_err_t rt_spi_send_then_send(struct rt_spi_device *device,
const void *send_buf1,
rt_size_t send_length1,

View File

@@ -278,6 +278,56 @@ const static struct rt_device_ops rt_touch_ops =
};
#endif
#ifdef RT_USING_PM
static int aic_touch_suspend(const struct rt_device *device, rt_uint8_t mode)
{
rt_touch_t touch;
RT_ASSERT(device != RT_NULL);
touch = (rt_touch_t)device;
switch (mode)
{
case PM_SLEEP_MODE_IDLE:
break;
case PM_SLEEP_MODE_LIGHT:
case PM_SLEEP_MODE_DEEP:
case PM_SLEEP_MODE_STANDBY:
touch->ops->touch_control(touch, RT_TOUCH_CTRL_POWER_OFF, NULL);
break;
default:
break;
}
return 0;
}
static void aic_touch_resume(const struct rt_device *device, rt_uint8_t mode)
{
rt_touch_t touch;
RT_ASSERT(device != RT_NULL);
touch = (rt_touch_t)device;
switch (mode)
{
case PM_SLEEP_MODE_IDLE:
break;
case PM_SLEEP_MODE_LIGHT:
case PM_SLEEP_MODE_DEEP:
case PM_SLEEP_MODE_STANDBY:
touch->ops->touch_control(touch, RT_TOUCH_CTRL_POWER_ON, NULL);
break;
default:
break;
}
}
static struct rt_device_pm_ops aic_touch_pm_ops =
{
SET_DEVICE_PM_OPS(aic_touch_suspend, aic_touch_resume)
NULL,
};
#endif
/*
* touch register
*/
@@ -315,6 +365,16 @@ int rt_hw_touch_register(rt_touch_t touch,
return result;
}
#ifdef RT_USING_PM
#ifdef AIC_TOUCH_PANEL_WAKE_UP
rt_pm_set_pin_wakeup_source(touch->config.irq_pin.pin);
rt_device_wakeup_enable(device, RT_TRUE);
#endif
rt_pm_device_register(device, &aic_touch_pm_ops);
#endif
LOG_I("rt_touch init success");
return RT_EOK;

View File

@@ -868,7 +868,7 @@ static void rt_wlan_join_scan_callback(int event, struct rt_wlan_buff *buff, voi
tgt_info->rssi = info->rssi;
tgt_info->hidden = info->hidden;
/* hwaddr */
rt_memcmp(tgt_info->bssid,info->bssid,RT_WLAN_BSSID_MAX_LENGTH);
rt_memcpy(tgt_info->bssid,info->bssid,RT_WLAN_BSSID_MAX_LENGTH);
}
}
}
@@ -913,7 +913,8 @@ rt_err_t rt_wlan_connect(const char *ssid, const char *password)
rt_memcpy(&info.ssid.val[0],ssid,rt_strlen(ssid));
info.ssid.len = rt_strlen(ssid);
#ifdef RT_WLAN_JOIN_SCAN_BY_MGNT
#if 1 //def RT_WLAN_JOIN_SCAN_BY_MGNT
info.rssi = -100;
err = rt_wlan_register_event_handler(RT_WLAN_EVT_SCAN_REPORT,rt_wlan_join_scan_callback,&info);
if(err != RT_EOK)
{

View File

@@ -46,6 +46,7 @@ typedef struct
#define HAVE_DIRENT_STRUCTURE
#define DIRENT_NAME_MAX 256
#define PARTITION_NAME_MAX 144
struct dirent
{