This commit is contained in:
刘可亮
2024-10-30 16:50:31 +08:00
parent 0ef85b55da
commit 661e71562d
458 changed files with 46555 additions and 12133 deletions

View File

@@ -39,6 +39,11 @@ menuconfig RT_USING_SERIAL
bool "Enable serial DMA mode"
default y
config RT_SERIAL_USING_FLOWCTRL
bool "Enable serial flow control mode"
depends on AIC_SERIAL_USING_FLOWCTRL
default y
config RT_SERIAL_RB_BUFSZ
int "Set RX buffer size"
depends on !RT_USING_SERIAL_V2
@@ -123,7 +128,7 @@ config RT_USING_ADC
config RT_USING_DAC
bool "Using DAC device drivers"
default n
config RT_USING_PWM
bool "Using PWM device drivers"
default n
@@ -261,23 +266,23 @@ config RT_USING_SPI
config RT_SFUD_USING_SFDP
bool "Using auto probe flash JEDEC SFDP parameter"
default y
config RT_SFUD_USING_FLASH_INFO_TABLE
bool "Using defined supported flash chip information table"
default y
config RT_SFUD_USING_QSPI
bool "Using QSPI mode support"
select RT_USING_QSPI
default n
config RT_SFUD_SPI_MAX_HZ
int "Default spi maximum speed(HZ)"
range 0 50000000
default 50000000
help
Read the JEDEC SFDP command must run at 50 MHz or less,and you also can use rt_spi_configure(); to config spi speed.
config RT_DEBUG_SFUD
bool "Show more SFUD debug information"
default n
@@ -301,7 +306,7 @@ config RT_USING_WDT
config RT_USING_AUDIO
bool "Using Audio device drivers"
default n
if RT_USING_AUDIO
config RT_AUDIO_REPLAY_MP_BLOCK_SIZE
int "Replay memory pool block size"

View File

@@ -366,9 +366,9 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus,
return RT_EOK;
}
static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
{
struct rt_i2c_msg *msg;
struct rt_i2c_bit_ops *ops = (struct rt_i2c_bit_ops *)bus->priv;

View File

@@ -168,19 +168,24 @@ rt_size_t rt_i2c_write_reg(struct rt_i2c_bus_device *bus,
rt_uint8_t *buf,
rt_uint32_t count)
{
rt_size_t ret = 0;
rt_uint8_t cmd[AIC_I2C_CMD_BUF_LEN] = {0};
RT_ASSERT(bus != RT_NULL);
RT_ASSERT(buf != RT_NULL);
if (count == 0 || count > (AIC_I2C_CMD_BUF_LEN - 1)) {
LOG_E("rt_i2c_write_reg: write buf len out of range\n");
return -RT_EINVAL;
return 0;
}
cmd[0] = reg;
rt_memcpy(&cmd[1], buf, count);
return rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 1);
ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 1);
if (ret != (count + 1))
return 0;
return count;
}
rt_size_t rt_i2c_write_reg16(struct rt_i2c_bus_device *bus,
@@ -189,20 +194,25 @@ rt_size_t rt_i2c_write_reg16(struct rt_i2c_bus_device *bus,
rt_uint8_t *buf,
rt_uint32_t count)
{
rt_size_t ret = 0;
rt_uint8_t cmd[AIC_I2C_CMD_BUF_LEN] = {0};
RT_ASSERT(bus != RT_NULL);
RT_ASSERT(buf != RT_NULL);
if (count == 0 || count > (AIC_I2C_CMD_BUF_LEN - 2)) {
LOG_E("rt_i2c_write_reg16: write buf len out of range\n");
return -RT_EINVAL;
return 0;
}
cmd[0] = (rt_uint8_t)(reg >> 8);
cmd[1] = (rt_uint8_t)(reg & 0xff);
rt_memcpy(&cmd[2], buf, count);
return rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 2);
ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, cmd, count + 2);
if (ret != (count + 2))
return 0;
return count;
}
rt_size_t rt_i2c_read_reg(struct rt_i2c_bus_device *bus,
@@ -217,7 +227,7 @@ rt_size_t rt_i2c_read_reg(struct rt_i2c_bus_device *bus,
if (count == 0) {
LOG_E("rt_i2c_read_reg: read buf len out of range\n");
return -RT_EINVAL;
return 0;
}
ret = rt_i2c_master_send(bus, addr, RT_I2C_WR, &reg, 1);
@@ -240,7 +250,7 @@ rt_size_t rt_i2c_read_reg16(struct rt_i2c_bus_device *bus,
if (count == 0) {
LOG_E("rt_i2c_read_reg16: read buf len out of range\n");
return -RT_EINVAL;
return 0;
}
cmd[0] = (rt_uint8_t)(reg >> 8);

View File

@@ -29,6 +29,10 @@ struct rt_i2c_bit_ops
rt_uint32_t timeout; /* in tick */
};
rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num);
rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus,
const char *bus_name);

View File

@@ -134,8 +134,6 @@ void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key)
queue_list = &(queue->waiting_list);
level = rt_hw_interrupt_disable();
/* set wakeup flag in the queue */
queue->flag = RT_WQ_FLAG_WAKEUP;
if (!(rt_list_isempty(queue_list)))
{
@@ -159,6 +157,8 @@ void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key)
LOG_D("%s: Thread resume failed", __func__);
}
node = node->next;
rt_wqueue_remove(entry);
}
else
{
@@ -211,12 +211,6 @@ int rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec)
/* reset thread error */
tid->error = RT_EOK;
if (queue->flag == RT_WQ_FLAG_WAKEUP)
{
/* already wakeup */
goto __exit_wakeup;
}
rt_wqueue_add(queue, &__wait);
rt_thread_suspend(tid);
@@ -233,13 +227,5 @@ int rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec)
rt_schedule();
level = rt_hw_interrupt_disable();
__exit_wakeup:
queue->flag = RT_WQ_FLAG_CLEAN;
rt_hw_interrupt_enable(level);
rt_wqueue_remove(&__wait);
return tid->error;
}

View File

@@ -23,7 +23,7 @@
#include <rtdbg.h>
#ifdef AIC_AB_SYSTEM_INTERFACE
#include <absystem.h>
#include <absystem_os.h>
#include <boot_param.h>
#endif
@@ -622,7 +622,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
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, &part);
blk_dev = rt_mmcsd_create_blkdev(card, (const char*)dname, NULL);
if ( blk_dev == RT_NULL )
{
err = -RT_ENOMEM;

View File

@@ -305,6 +305,7 @@ rt_inline int _serial_int_rx(struct rt_serial_device *serial, rt_uint8_t *data,
ch = rx_fifo->buffer[rx_fifo->get_index];
rx_fifo->get_index += 1;
#ifdef RT_SERIAL_USING_FLOWCTRL
if (serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL )
@@ -314,9 +315,7 @@ rt_inline int _serial_int_rx(struct rt_serial_device *serial, rt_uint8_t *data,
rt_flowctrl_low_detect(serial, 1, RT_SERIAL_INT_FCL_BUFFER);
}
}
#endif
if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0;
if (rx_fifo->is_full == RT_TRUE)
@@ -411,6 +410,7 @@ static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial)
}
#endif /* RT_USING_POSIX_STDIO || RT_SERIAL_USING_DMA */
#ifdef RT_SERIAL_USING_FLOWCTRL
/**
* Flow control high level detect.
*
@@ -486,6 +486,7 @@ void rt_flowctrl_low_detect(struct rt_serial_device *serial, rt_size_t len, rt_s
}
}
}
#endif
#ifdef RT_SERIAL_USING_DMA
/**
@@ -624,7 +625,7 @@ rt_inline int _serial_dma_rx(struct rt_serial_device *serial, rt_uint8_t *data,
rt_memcpy(data + serial->config.bufsz - rx_fifo->get_index, rx_fifo->buffer,
recv_len + rx_fifo->get_index - serial->config.bufsz);
}
#ifdef RT_SERIAL_USING_FLOWCTRL
if (serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL)
@@ -634,7 +635,7 @@ rt_inline int _serial_dma_rx(struct rt_serial_device *serial, rt_uint8_t *data,
rt_flowctrl_low_detect(serial, recv_len, RT_SERIAL_DMA_FCL_BUFFER);
}
}
#endif
rt_dma_recv_update_get_index(serial, recv_len);
rt_hw_interrupt_enable(level);
return recv_len;
@@ -1444,6 +1445,7 @@ void rt_serial_rx_ind(struct rt_serial_device *serial)
rx_fifo->put_index += 1;
if (rx_fifo->put_index >= serial->config.bufsz) rx_fifo->put_index = 0;
#ifdef RT_SERIAL_USING_FLOWCTRL
if ((serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_HW_FLOW_CTRL) &&
@@ -1458,7 +1460,7 @@ void rt_serial_rx_ind(struct rt_serial_device *serial)
{
serial->ops->control(serial, RT_SERIAL_SW_RECEIVE_ON_OFF, &ch);
}
#endif
/* if the next position is read index, discard this 'read char' */
if (rx_fifo->put_index == rx_fifo->get_index)
{
@@ -1562,7 +1564,7 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
{
/* disable interrupt */
level = rt_hw_interrupt_disable();
#ifdef RT_SERIAL_USING_FLOWCTRL
/* flow control high level detect */
if ((serial->config.function == RT_SERIAL_RS232_UNAUTO_FLOW_CTRL ||
serial->config.function == RT_SERIAL_RS232_SW_FLOW_CTRL ||
@@ -1571,6 +1573,7 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
{
rt_flowctrl_high_detect(serial, length, RT_SERIAL_DMA_FCH_BUFFER);
}
#endif
/* update fifo put index */
rt_dma_recv_update_put_index(serial, length);
/* calculate received total length */

View File

@@ -126,9 +126,6 @@ static rt_size_t rt_touch_read(rt_device_t dev, rt_off_t pos, void *buf, rt_size
{
rt_touch_t touch;
rt_size_t result = 0;
rt_uint8_t index;
rt_uint16_t temp = 0;
struct rt_touch_data *read_data = RT_NULL;
RT_ASSERT(dev != RT_NULL);
touch = (rt_touch_t)dev;
@@ -138,32 +135,6 @@ static rt_size_t rt_touch_read(rt_device_t dev, rt_off_t pos, void *buf, rt_size
}
result = touch->ops->touch_readpoint(touch, buf, len);
read_data = (struct rt_touch_data *)buf;
for (index = 0; index < len; index++) {
#ifdef AIC_TOUCH_X_FILP
read_data[index].x_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE -
read_data[index].x_coordinate;
#endif
#ifdef AIC_TOUCH_Y_FILP
read_data[index].y_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE -
read_data[index].y_coordinate;
#endif
#ifdef AIC_TOUCH_90_DEGREE_ROTATION
temp = read_data[index].x_coordinate;
read_data[index].x_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE -
read_data[index].y_coordinate;
read_data[index].y_coordinate = temp;
#endif
#ifdef AIC_TOUCH_270_DEGREE_ROTATION
temp = read_data[index].x_coordinate;
read_data[index].x_coordinate = read_data[index].y_coordinate;
read_data[index].y_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - temp;
#endif
(void)read_data;
(void)temp;
}
return result;
}

View File

@@ -44,6 +44,58 @@ def is_pkg_special_config(config_str):
return True
return False
def get_config_val(src, name):
try:
config = open(src, 'r')
except:
print('open config:%s failed' % src)
return None
for line in config:
line = line.lstrip(' ').replace('\n', '').replace('\r', '')
if len(line) == 0:
continue
if line[0] == '#':
continue
else:
setting = line.split('=')
if len(setting) >= 2:
if setting[0] == name:
return setting[1]
return None
def get_heap_base(filename):
heap_size = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_HEAP_SIZE')
if get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE') and \
int(get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE'), 16) > 0:
ram_base = get_config_val(filename, 'CONFIG_CPU_PSRAM_BASE')
ram_size = get_config_val(filename, 'CONFIG_AIC_PSRAM_SIZE')
elif get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE') and \
int(get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE'), 16) > 0:
ram_base = get_config_val(filename, 'CONFIG_CPU_DRAM_BASE')
ram_size = get_config_val(filename, 'CONFIG_AIC_DRAM_TOTAL_SIZE')
elif get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE') and \
int(get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE'), 16) > 0:
ram_base = get_config_val(filename, 'CONFIG_CPU_SRAM_BASE')
ram_size = get_config_val(filename, 'CONFIG_AIC_SRAM_TOTAL_SIZE')
elif get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE') and \
int(get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE'), 16) > 0:
ram_base = get_config_val(filename, 'CONFIG_CPU_SRAM_BASE')
ram_size = get_config_val(filename, 'CONFIG_AIC_SRAM_SIZE')
return (int(ram_base, 16) + int(ram_size, 16) - int(heap_size, 16))
def get_text_base(filename):
text_size = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_TEXT_SIZE')
heap_base = get_heap_base(filename)
return (heap_base - int(text_size, 16))
def mk_rtconfig(filename):
try:
config = open(filename, 'r')
@@ -98,6 +150,24 @@ def mk_rtconfig(filename):
if os.path.isfile('rtconfig_project.h'):
rtconfig.write('#include "rtconfig_project.h"\n')
# Auto calc bootloader memory
val = get_config_val(filename, 'CONFIG_AIC_BOOTLOADER_MEM_AUTO')
if val == 'y':
heap_base = get_heap_base(filename)
text_base = get_text_base(filename)
comment = '\n/* Automatically calc generated */\n\n'
heap_base_def = '#define AIC_BOOTLOADER_HEAP_BASE (0x%x)\n' % (heap_base)
text_base_def = '#define AIC_BOOTLOADER_TEXT_BASE (0x%x)\n' % (text_base)
rtconfig.write(comment)
rtconfig.write(heap_base_def)
rtconfig.write(text_base_def)
print('Insert macro definition into rtconfig.h\n')
print(heap_base_def)
print(text_base_def)
rtconfig.write('\n')
rtconfig.write('#endif\n')
rtconfig.close()
@@ -257,6 +327,7 @@ def menuconfig(RTT_ROOT):
fn_old = '.config.old'
kconfig_cmd = os.path.join(RTT_ROOT, 'tools', 'kconfig-frontends', 'kconfig-mconf')
print(kconfig_cmd + ' Kconfig')
os.system(kconfig_cmd + ' Kconfig')
if os.path.isfile(fn):