mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-29 01:06:56 +00:00
v1.0.3
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_elm.h>
|
||||
|
||||
static rt_device_t disk[FF_VOLUMES] = {0};
|
||||
|
||||
@@ -147,12 +148,12 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
|
||||
|
||||
/* open the root directory to test whether the fatfs is valid */
|
||||
result = f_opendir(dir, drive);
|
||||
rt_free(dir);
|
||||
if (result != FR_OK)
|
||||
goto __err;
|
||||
|
||||
/* mount succeed! */
|
||||
fs->data = fat;
|
||||
rt_free(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -955,7 +956,7 @@ DWORD get_fattime(void)
|
||||
(DWORD)tm_now.tm_mday << 16 |
|
||||
(DWORD)tm_now.tm_hour << 11 |
|
||||
(DWORD)tm_now.tm_min << 5 |
|
||||
(DWORD)tm_now.tm_sec / 2 ;
|
||||
(DWORD)tm_now.tm_sec / 2;
|
||||
|
||||
return fat_time;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ struct rt_adc_ops
|
||||
rt_uint32_t channel);
|
||||
rt_uint32_t (*get_irq_count)(struct rt_adc_device *device,
|
||||
rt_uint32_t channel);
|
||||
rt_uint32_t (*get_obtaining_data_mode)(struct rt_adc_device *device,
|
||||
rt_uint32_t channel);
|
||||
#endif
|
||||
rt_uint8_t (*get_resolution)(struct rt_adc_device *device);
|
||||
rt_int16_t (*get_vref) (struct rt_adc_device *device);
|
||||
@@ -47,6 +49,7 @@ typedef enum
|
||||
RT_ADC_CMD_IRQ_COUNT = RT_DEVICE_CTRL_BASE(ADC) + 5,
|
||||
RT_ADC_CMD_GET_DMA_DATA = RT_DEVICE_CTRL_BASE(ADC) + 6,
|
||||
RT_ADC_CMD_CONFIG_DMA = RT_DEVICE_CTRL_BASE(ADC) + 7,
|
||||
RT_ADC_CMD_OBTAIN_DATA_MODE = RT_DEVICE_CTRL_BASE(ADC) + 8,
|
||||
#endif
|
||||
} rt_adc_cmd_t;
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ struct rt_mtd_nand_device {
|
||||
const struct rt_mtd_nand_driver_ops *ops;
|
||||
|
||||
void *priv;
|
||||
|
||||
rt_uint8_t attr;
|
||||
};
|
||||
typedef struct rt_mtd_nand_device *rt_mtd_nand_t;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define PWM_CMD_SET_FIFO (RT_DEVICE_CTRL_BASE(PWM) + 8)
|
||||
#define PWM_CMD_SET_FIFO_NUM (RT_DEVICE_CTRL_BASE(PWM) + 9)
|
||||
#define PWM_CMD_GET_FIFO (RT_DEVICE_CTRL_BASE(PWM) + 10)
|
||||
#define PWM_CMD_SET_PUL (RT_DEVICE_CTRL_BASE(PWM) + 11)
|
||||
|
||||
struct rt_pwm_configuration
|
||||
{
|
||||
@@ -37,6 +38,10 @@ struct rt_pwm_configuration
|
||||
*/
|
||||
rt_bool_t complementary;
|
||||
|
||||
#if defined(AIC_PWM_DRV) || defined(AIC_EPWM_DRV)
|
||||
rt_uint32_t irq_mode;
|
||||
rt_uint32_t pul_cnt;
|
||||
#endif
|
||||
#ifdef AIC_XPWM_DRV
|
||||
rt_uint32_t pulse_cnt; /* 0:PWM mode, 1-n:XPWM pulse cnt */
|
||||
rt_uint32_t fifo_num;
|
||||
@@ -67,6 +72,9 @@ rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name,
|
||||
|
||||
rt_err_t rt_pwm_enable(struct rt_device_pwm *device, int channel);
|
||||
rt_err_t rt_pwm_disable(struct rt_device_pwm *device, int channel);
|
||||
#if defined(AIC_PWM_DRV) || defined(AIC_EPWM_DRV)
|
||||
rt_err_t rt_pwm_set_pul(struct rt_device_pwm *device, int channel, rt_uint32_t irq_mode, rt_uint32_t period, rt_uint32_t pulse, rt_uint32_t pul_cnt);
|
||||
#endif
|
||||
#ifdef AIC_XPWM_DRV
|
||||
rt_err_t rt_pwm_set(struct rt_device_pwm *device, int channel, rt_uint32_t period, rt_uint32_t pulse, rt_uint32_t pulse_cnt);
|
||||
#else
|
||||
|
||||
@@ -48,6 +48,9 @@ extern "C" {
|
||||
#define RT_TOUCH_CTRL_POWER_ON (RT_DEVICE_CTRL_BASE(Touch) + 8) /* Touch Power On */
|
||||
#define RT_TOUCH_CTRL_POWER_OFF (RT_DEVICE_CTRL_BASE(Touch) + 9) /* Touch Power Off */
|
||||
#define RT_TOUCH_CTRL_GET_STATUS (RT_DEVICE_CTRL_BASE(Touch) + 10) /* Get Touch Power Status */
|
||||
#ifdef AIC_RTP_DRV
|
||||
#define RT_TOUCH_CTRL_PDEB_VALID_CHECK (RT_DEVICE_CTRL_BASE(Touch) + 11) /* Determine if the pdeb value is valid*/
|
||||
#endif
|
||||
|
||||
/* Touch event */
|
||||
#define RT_TOUCH_EVENT_NONE (0) /* Touch none */
|
||||
|
||||
@@ -78,6 +78,10 @@ static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
return adc->ops->get_irq_count(adc, (rt_uint32_t)(long)args);
|
||||
}
|
||||
else if (cmd == RT_ADC_CMD_OBTAIN_DATA_MODE && adc->ops->get_obtaining_data_mode)
|
||||
{
|
||||
return adc->ops->get_obtaining_data_mode(adc, (rt_uint32_t)(long)args);
|
||||
}
|
||||
#endif
|
||||
else if (cmd == RT_ADC_CMD_GET_VREF && adc->ops->get_vref && args)
|
||||
{
|
||||
|
||||
@@ -309,6 +309,29 @@ rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *c
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(AIC_PWM_DRV) || defined(AIC_EPWM_DRV)
|
||||
rt_err_t rt_pwm_set_pul(struct rt_device_pwm *device, int channel, rt_uint32_t irq_mode, rt_uint32_t period, rt_uint32_t pulse, rt_uint32_t pul_cnt)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
struct rt_pwm_configuration configuration = {0};
|
||||
|
||||
if (!device)
|
||||
{
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
configuration.channel = (channel > 0) ? (channel) : (-channel);
|
||||
configuration.irq_mode = irq_mode;
|
||||
configuration.period = period;
|
||||
configuration.pulse = pulse;
|
||||
configuration.pul_cnt = pul_cnt;
|
||||
result = rt_device_control(&device->parent, PWM_CMD_SET_PUL, &configuration);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -415,6 +438,21 @@ static int pwm(int argc, char **argv)
|
||||
rt_kprintf("Get info of device: [%s] error.\n", pwm_device);
|
||||
}
|
||||
}
|
||||
#if defined(AIC_PWM_DRV) || defined(AIC_EPWM_DRV)
|
||||
else if (!strcmp(argv[1], "set_pul"))
|
||||
{
|
||||
if(argc == 7)
|
||||
{
|
||||
result = rt_pwm_set_pul(pwm_device, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]));
|
||||
rt_kprintf("pwm pul set on %s at channel %d\n",pwm_device,atoi(argv[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Set pul of device: [%s] error\n", pwm_device);
|
||||
rt_kprintf("Usage: pwm set_pul <channel> <irq_mode> <period> <pulse> <pulse cnt>\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (!strcmp(argv[1], "set"))
|
||||
{
|
||||
#ifdef AIC_XPWM_DRV
|
||||
@@ -533,10 +571,13 @@ static int pwm(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
rt_kprintf("Usage: \n");
|
||||
rt_kprintf("pwm probe <device name> - probe pwm by name\n");
|
||||
rt_kprintf("pwm enable <channel> - enable pwm channel\n");
|
||||
rt_kprintf("pwm disable <channel> - disable pwm channel\n");
|
||||
rt_kprintf("pwm get <channel> - get pwm channel info\n");
|
||||
rt_kprintf("pwm probe <device name> - probe pwm by name\n");
|
||||
rt_kprintf("pwm enable <channel> - enable pwm channel\n");
|
||||
rt_kprintf("pwm disable <channel> - disable pwm channel\n");
|
||||
rt_kprintf("pwm get <channel> - get pwm channel info\n");
|
||||
#if defined(AIC_PWM_DRV) || defined(AIC_EPWM_DRV)
|
||||
rt_kprintf("pwm set_pul <channel> <irq_mode> <period> <pulse> <pulse cnt> - set pwm pulse\n");
|
||||
#endif
|
||||
#ifdef AIC_XPWM_DRV
|
||||
rt_kprintf("pwm set <channel> <period> <pulse> <pulse cnt> - set pwm channel info\n");
|
||||
rt_kprintf("pwm set_fifo_num <channel> <fifo_num> - set xpwm fifo count\n");
|
||||
@@ -546,7 +587,7 @@ static int pwm(int argc, char **argv)
|
||||
rt_kprintf("pwm dma_test <channel> <loop_times> - xpwm dma test\n");
|
||||
#endif
|
||||
#else
|
||||
rt_kprintf("pwm set <channel> <period> <pulse> - set pwm channel info\n");
|
||||
rt_kprintf("pwm set <channel> <period> <pulse> - set pwm channel info\n");
|
||||
#endif
|
||||
result = - RT_ERROR;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <dfs_fs.h>
|
||||
#include <disk_part.h>
|
||||
|
||||
#include <drivers/mmcsd_core.h>
|
||||
|
||||
@@ -340,7 +341,7 @@ static rt_int32_t mmcsd_set_blksize(struct rt_mmcsd_card *card)
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops mmcsd_blk_ops =
|
||||
static const struct rt_device_ops mmcsd_blk_ops =
|
||||
{
|
||||
rt_mmcsd_init,
|
||||
rt_mmcsd_open,
|
||||
@@ -421,6 +422,28 @@ static struct mmcsd_blk_device * rt_mmcsd_create_blkdev(struct rt_mmcsd_card *ca
|
||||
return blk_dev;
|
||||
}
|
||||
|
||||
static unsigned long mmcsd_write(struct blk_desc *blk_dev, u64 start,
|
||||
u64 blkcnt, void *buffer)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = rt_mmcsd_req_blk(blk_dev->priv, start, buffer, blkcnt, 1);
|
||||
if (err == RT_EOK)
|
||||
return blkcnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long mmcsd_read(struct blk_desc *blk_dev, u64 start, u64 blkcnt,
|
||||
const void *buffer)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = rt_mmcsd_req_blk(blk_dev->priv, start, (void *)buffer, blkcnt, 0);
|
||||
if (err == RT_EOK)
|
||||
return blkcnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
|
||||
{
|
||||
rt_int32_t err = 0;
|
||||
@@ -456,29 +479,40 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
|
||||
/* Initial blk_device link-list. */
|
||||
rt_list_init(&card->blk_devices);
|
||||
|
||||
for (i = 0; i < RT_MMCSD_MAX_PARTITION; i++)
|
||||
{
|
||||
/* Get the first partition */
|
||||
status = dfs_filesystem_get_partition(&part, sector, i);
|
||||
if (status == RT_EOK)
|
||||
{
|
||||
struct aic_partition *parts, *p;
|
||||
struct blk_desc dev_desc;
|
||||
struct disk_blk_ops ops;
|
||||
|
||||
ops.blk_write = mmcsd_write;
|
||||
ops.blk_read = mmcsd_read;
|
||||
aic_disk_part_set_ops(&ops);
|
||||
dev_desc.blksz = card->card_blksize;
|
||||
dev_desc.lba_count = card->card_capacity * (1024 / card->card_blksize);
|
||||
dev_desc.priv = card;
|
||||
parts = aic_disk_get_parts(&dev_desc);
|
||||
p = parts;
|
||||
i = 0;
|
||||
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);
|
||||
part.type = 0;
|
||||
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);
|
||||
if ( blk_dev == RT_NULL )
|
||||
{
|
||||
err = -RT_ENOMEM;
|
||||
aic_part_free(parts);
|
||||
goto exit_rt_mmcsd_blk_probe;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
p = p->next;
|
||||
i++;
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -605,6 +605,9 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
/* this device has more reference count */
|
||||
if (dev->ref_count > 0) return RT_EOK;
|
||||
|
||||
LOG_D("open serial device: 0x%08x with open flag: 0x%04x",
|
||||
dev, oflag);
|
||||
/* check device flag with the open flag */
|
||||
@@ -751,7 +754,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
/* this device has more reference count */
|
||||
if (dev->ref_count > 1) return RT_EOK;
|
||||
if (dev->ref_count > 0) return RT_EOK;
|
||||
|
||||
if (dev->open_flag & RT_DEVICE_FLAG_INT_RX)
|
||||
{
|
||||
@@ -834,7 +837,6 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
#endif /* RT_SERIAL_USING_DMA */
|
||||
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL);
|
||||
dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ if GetDepend(['RT_WLAN_CFG_ENABLE']):
|
||||
if GetDepend(['RT_WLAN_WORK_THREAD_ENABLE']):
|
||||
src += ['wlan_workqueue.c']
|
||||
|
||||
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_WIFI'], CPPPATH = CPPPATH)
|
||||
mycflags = (' -w')
|
||||
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_WIFI'], CPPPATH
|
||||
= CPPPATH, LOCAL_CFLAGS = mycflags)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -17,11 +17,14 @@
|
||||
#include <string.h>
|
||||
|
||||
/* ========================== block device ======================== */
|
||||
struct fal_blk_device
|
||||
{
|
||||
struct fal_blk_device {
|
||||
struct rt_device parent;
|
||||
struct rt_device_blk_geometry geometry;
|
||||
const struct fal_partition *fal_part;
|
||||
#ifdef AIC_FATFS_ENABLE_WRITE_IN_SPINOR
|
||||
rt_uint32_t length;
|
||||
rt_uint8_t *buf;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* RT-Thread device interface */
|
||||
@@ -47,12 +50,13 @@ static rt_err_t blk_dev_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
|
||||
memcpy(geometry, &part->geometry, sizeof(struct rt_device_blk_geometry));
|
||||
}
|
||||
#ifndef FAL_BLK_DEVICE_RDONLY
|
||||
else if (cmd == RT_DEVICE_CTRL_BLK_ERASE)
|
||||
{
|
||||
rt_uint32_t *addrs = (rt_uint32_t *) args, start_addr = addrs[0], end_addr = addrs[1], phy_start_addr;
|
||||
rt_size_t phy_size;
|
||||
|
||||
log_d("start_addr = %d end_addr = %d.\n", start_addr, end_addr);
|
||||
|
||||
if (addrs == RT_NULL || start_addr > end_addr)
|
||||
{
|
||||
return -RT_ERROR;
|
||||
@@ -71,7 +75,6 @@ static rt_err_t blk_dev_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -99,33 +102,55 @@ static rt_size_t blk_dev_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_si
|
||||
|
||||
static rt_size_t blk_dev_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
|
||||
{
|
||||
#ifndef AIC_FATFS_ENABLE_WRITE_IN_SPINOR
|
||||
log_e("This config only supports read!\n");
|
||||
return size;
|
||||
#else
|
||||
int ret = 0;
|
||||
struct fal_blk_device *part;
|
||||
rt_off_t phy_pos;
|
||||
rt_size_t phy_size;
|
||||
rt_off_t phy_pos, buf_pos;
|
||||
rt_size_t phy_size, buf_size;
|
||||
rt_uint32_t align_sector = 0;
|
||||
rt_uint8_t align_cnt = 0;
|
||||
|
||||
part = (struct fal_blk_device*) dev;
|
||||
assert(part != RT_NULL);
|
||||
|
||||
/* change the block device's logic address to physical address */
|
||||
phy_pos = pos * part->geometry.bytes_per_sector;
|
||||
phy_size = size * part->geometry.bytes_per_sector;
|
||||
align_sector = pos - pos % 8;
|
||||
align_cnt = pos % 8 + size;
|
||||
align_cnt = (align_cnt + 7) / 8 * 8;
|
||||
|
||||
if (dev->flag & RT_DEVICE_FLAG_RDONLY) {
|
||||
log_e("The block device read only.\n");
|
||||
return size;
|
||||
}
|
||||
log_d("pos = %ld size = %d!\n", pos, size);
|
||||
log_d("align_sector = %ld align_cnt = %d!\n", align_sector, align_cnt);
|
||||
|
||||
ret = fal_partition_erase(part->fal_part, phy_pos, phy_size);
|
||||
phy_pos = align_sector * part->geometry.bytes_per_sector;
|
||||
phy_size = align_cnt * part->geometry.bytes_per_sector;
|
||||
buf_pos = pos % 8 * part->geometry.bytes_per_sector;
|
||||
buf_size = size * part->geometry.bytes_per_sector;
|
||||
|
||||
if (ret == (int) phy_size)
|
||||
{
|
||||
ret = fal_partition_write(part->fal_part, phy_pos, buffer, phy_size);
|
||||
}
|
||||
memset(part->buf, 0xFF, part->length);
|
||||
|
||||
ret = fal_partition_read(part->fal_part, phy_pos, part->buf, phy_size);
|
||||
if (ret != (int) phy_size)
|
||||
{
|
||||
ret = 0;
|
||||
log_e("fal partition read data size failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
rt_memcpy(part->buf + buf_pos, buffer, buf_size);
|
||||
|
||||
ret = fal_partition_erase(part->fal_part, phy_pos, phy_size);
|
||||
if (ret != (int) phy_size)
|
||||
{
|
||||
log_e("fal partition erase data size failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = fal_partition_write(part->fal_part, phy_pos, part->buf, phy_size);
|
||||
if (ret != (int) phy_size)
|
||||
{
|
||||
log_e("fal partition write data size failed!\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -133,11 +158,12 @@ static rt_size_t blk_dev_write(rt_device_t dev, rt_off_t pos, const void* buffer
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops blk_dev_ops =
|
||||
{
|
||||
static const struct rt_device_ops blk_dev_ops = {
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
@@ -177,20 +203,23 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
|
||||
blk_dev = (struct fal_blk_device*) rt_malloc(sizeof(struct fal_blk_device));
|
||||
if (blk_dev)
|
||||
{
|
||||
#ifdef AIC_FATFS_ENABLE_WRITE_IN_SPINOR
|
||||
blk_dev->length = AIC_USING_FS_IMAGE_TYPE_FATFS_CLUSTER_SIZE * 512 * 2;
|
||||
blk_dev->buf = (uint8_t *)rt_malloc(blk_dev->length);
|
||||
if (!blk_dev->buf) {
|
||||
log_e("Error: no memory for create SPI NOR block buf");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
blk_dev->fal_part = fal_part;
|
||||
|
||||
#ifdef FAL_BLK_DEVICE_RDONLY
|
||||
/*To solve the problem of space waste when the sector is set to 4096*/
|
||||
/*bytes_per_sector and block_size must set to 512,
|
||||
the fatfs partition info can be recognized normally*/
|
||||
blk_dev->geometry.bytes_per_sector = 512;
|
||||
blk_dev->geometry.block_size = blk_dev->geometry.bytes_per_sector;
|
||||
blk_dev->geometry.sector_count = fal_part->len / blk_dev->geometry.bytes_per_sector;
|
||||
#else
|
||||
blk_dev->geometry.bytes_per_sector = fal_flash->blk_size;
|
||||
blk_dev->geometry.block_size = fal_flash->blk_size;
|
||||
blk_dev->geometry.sector_count = fal_part->len / fal_flash->blk_size;
|
||||
#endif
|
||||
|
||||
/* register device */
|
||||
blk_dev->parent.type = RT_Device_Class_Block;
|
||||
@@ -211,11 +240,8 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
|
||||
|
||||
rt_sprintf(str, "blk_%s", fal_part->name);
|
||||
log_d("The FAL block device (%s) created successfully", str);
|
||||
#ifdef FAL_BLK_DEVICE_RDONLY
|
||||
rt_device_register(RT_DEVICE(blk_dev), str, RT_DEVICE_FLAG_RDONLY | RT_DEVICE_FLAG_STANDALONE);
|
||||
#else
|
||||
|
||||
rt_device_register(RT_DEVICE(blk_dev), str, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -409,8 +435,7 @@ static rt_size_t char_dev_write(rt_device_t dev, rt_off_t pos, const void *buffe
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops char_dev_ops =
|
||||
{
|
||||
static const struct rt_device_ops char_dev_ops = {
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
@@ -952,7 +977,7 @@ static void fal(uint8_t argc, char **argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(fal, FAL (Flash Abstraction Layer) operate.);
|
||||
MSH_CMD_EXPORT(fal, FAL (Flash Abstraction Layer) operate);
|
||||
|
||||
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
|
||||
#endif /* RT_VER_NUM */
|
||||
|
||||
@@ -69,6 +69,8 @@ static const short __spm[13] =
|
||||
ALIGN(4) static const char *days = "Sun Mon Tue Wed Thu Fri Sat ";
|
||||
ALIGN(4) static const char *months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
|
||||
|
||||
extern uint64_t aic_get_time_us(void);
|
||||
|
||||
static int __isleap(int year)
|
||||
{
|
||||
/* every fourth year is a leap year except for century years that are
|
||||
@@ -618,8 +620,15 @@ RTM_EXPORT(clock_getres);
|
||||
int clock_gettime(clockid_t clockid, struct timespec *tp)
|
||||
{
|
||||
#ifndef RT_USING_RTC
|
||||
RTC_LOG_WARNING
|
||||
return -1;
|
||||
uint64_t us = 0;
|
||||
rt_base_t level;
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
us = aic_get_time_us();
|
||||
tp->tv_sec = us / (1000*1000);
|
||||
tp->tv_nsec = (us % (1000*1000))*1000;
|
||||
rt_hw_interrupt_enable(level);
|
||||
return 0;
|
||||
#else
|
||||
int ret = 0;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt
|
||||
if (phdr[index].p_vaddr > vend_addr + 16)
|
||||
{
|
||||
/* There should not be too much padding in the object files. */
|
||||
LOG_W("warning: too much padding before segment %d", index);
|
||||
LOG_D("warning: too much padding before segment %d", index);
|
||||
}
|
||||
|
||||
vend_addr = phdr[index].p_vaddr + phdr[index].p_memsz;
|
||||
@@ -94,6 +94,7 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt
|
||||
module->nref = 0;
|
||||
|
||||
/* allocate module space */
|
||||
module_size = ALIGN_UP(module_size, CACHE_LINE_SIZE);
|
||||
module->mem_space = rt_malloc_align(module_size, CACHE_LINE_SIZE);
|
||||
if (module->mem_space == RT_NULL)
|
||||
{
|
||||
@@ -311,6 +312,7 @@ rt_err_t dlmodule_load_relocated_object(struct rt_dlmodule* module, void *module
|
||||
module->vstart_addr = 0;
|
||||
|
||||
/* allocate module space */
|
||||
module_size = ALIGN_UP(module_size, CACHE_LINE_SIZE);
|
||||
module->mem_space = rt_malloc_align(module_size, CACHE_LINE_SIZE);
|
||||
if (module->mem_space == RT_NULL)
|
||||
{
|
||||
|
||||
@@ -146,6 +146,7 @@ static void _dlmodule_thread_entry(void* parameter)
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv[RT_MODULE_ARG_MAX];
|
||||
int ret = 0;
|
||||
|
||||
struct rt_dlmodule *module = (struct rt_dlmodule*)parameter;
|
||||
|
||||
@@ -168,10 +169,11 @@ static void _dlmodule_thread_entry(void* parameter)
|
||||
module->cmd_line);
|
||||
|
||||
if (module->entry_addr)
|
||||
module->entry_addr(argc, argv);
|
||||
ret = module->entry_addr(argc, argv);
|
||||
|
||||
__exit:
|
||||
_dlmodule_exit();
|
||||
if (ret != RT_DLMODULE_DEAMON)
|
||||
_dlmodule_exit();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -505,6 +507,8 @@ struct rt_dlmodule* dlmodule_load(const char* filename)
|
||||
/* increase module reference count */
|
||||
module->nref ++;
|
||||
|
||||
LOG_I("Module: load %s to 0x%lx succeed.", filename, module->mem_space);
|
||||
|
||||
/* deal with cache */
|
||||
#ifdef RT_USING_CACHE
|
||||
rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, module->mem_space, module->mem_size);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#define RT_DLMODULE_STAT_CLOSING 0x02
|
||||
#define RT_DLMODULE_STAT_CLOSED 0x03
|
||||
|
||||
#define RT_DLMODULE_DEAMON 0xDEA305
|
||||
|
||||
struct rt_dlmodule;
|
||||
typedef void* rt_addr_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user