mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 02:18:54 +00:00
v1.0.3
This commit is contained in:
0
application/freertos/helloworld/Kconfig
Normal file
0
application/freertos/helloworld/Kconfig
Normal file
21
application/freertos/helloworld/SConscript
Normal file
21
application/freertos/helloworld/SConscript
Normal file
@@ -0,0 +1,21 @@
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd, ]
|
||||
|
||||
CFLAGS = ' -c -ffunction-sections'
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CFLAGS=CFLAGS)
|
||||
|
||||
lst = os.listdir(cwd)
|
||||
|
||||
for item in lst:
|
||||
ipath = '{}/SConscript'.format(item)
|
||||
if os.path.isfile(cwd + '/' + ipath) == False:
|
||||
continue
|
||||
group = group + SConscript(ipath)
|
||||
|
||||
Return('group')
|
||||
15
application/freertos/helloworld/cmd/SConscript
Normal file
15
application/freertos/helloworld/cmd/SConscript
Normal file
@@ -0,0 +1,15 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
|
||||
Import('rtconfig')
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
|
||||
CPPPATH = [cwd]
|
||||
ASFLAGS = ''
|
||||
|
||||
group = DefineGroup('BLCMD', src, depend = [''], CPPPATH = CPPPATH, ASFLAGS = ASFLAGS)
|
||||
|
||||
Return('group')
|
||||
119
application/freertos/helloworld/cmd/hexdump.c
Normal file
119
application/freertos/helloworld/cmd/hexdump.c
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <aic_common.h>
|
||||
|
||||
static void hex_dump_1(unsigned char *buf, unsigned long len)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i && (i % 16) == 0)
|
||||
printf("\n");
|
||||
if ((i % 16) == 0)
|
||||
printf("0x%08lx : ", (unsigned long)&buf[i]);
|
||||
printf("%02x ", buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void hex_dump_2(unsigned char *buf, unsigned long len)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned short data;
|
||||
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
if (i && (i % 16) == 0)
|
||||
printf("\n");
|
||||
if ((i % 16) == 0)
|
||||
printf("0x%08lx : ", (unsigned long)&buf[i]);
|
||||
data = 0;
|
||||
if ((i + 2) <= len) {
|
||||
memcpy(&data, &buf[i], 2);
|
||||
i += 2;
|
||||
} else {
|
||||
memcpy(&data, &buf[i], 1);
|
||||
i += 1;
|
||||
}
|
||||
printf("%04x ", data);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void hex_dump_4(unsigned char *buf, unsigned long len)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned long data;
|
||||
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
if (i && (i % 16) == 0)
|
||||
printf("\n");
|
||||
if ((i % 16) == 0)
|
||||
printf("0x%08lx : ", (unsigned long)&buf[i]);
|
||||
data = 0;
|
||||
if ((i + 4) <= len) {
|
||||
memcpy(&data, &buf[i], 4);
|
||||
i += 4;
|
||||
} else {
|
||||
memcpy(&data, &buf[i], len - i);
|
||||
i += (len - i);
|
||||
}
|
||||
printf("%08lx ", data);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void hex_dump_8(unsigned char *buf, unsigned long len)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned long long data;
|
||||
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
if (i && (i % 16) == 0)
|
||||
printf("\n");
|
||||
if ((i % 16) == 0)
|
||||
printf("0x%08lx : ", (unsigned long)&buf[i]);
|
||||
data = 0;
|
||||
if ((i + 8) <= len) {
|
||||
memcpy(&data, &buf[i], 8);
|
||||
i += 8;
|
||||
} else {
|
||||
memcpy(&data, &buf[i], len - i);
|
||||
i += (len - i);
|
||||
}
|
||||
printf("%16llx ", data);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void hexdump(unsigned char *buf, unsigned long len, int groupsize)
|
||||
{
|
||||
if (groupsize <= 1) {
|
||||
hex_dump_1(buf, len);
|
||||
} else if (groupsize <= 2) {
|
||||
hex_dump_2(buf, len);
|
||||
} else if (groupsize <= 4) {
|
||||
hex_dump_4(buf, len);
|
||||
} else if (groupsize <= 8) {
|
||||
hex_dump_8(buf, len);
|
||||
} else {
|
||||
hex_dump_1(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
void show_speed(char *msg, u32 len, u32 us)
|
||||
{
|
||||
u32 tmp, speed;
|
||||
|
||||
/* Split to serval step to avoid overflow */
|
||||
tmp = 1000 * len;
|
||||
tmp = tmp / us;
|
||||
tmp = 1000 * tmp;
|
||||
speed = tmp / 1024;
|
||||
|
||||
printf("%s: %d byte, %d us -> %d KB/s\n", msg, len, us, speed);
|
||||
}
|
||||
|
||||
21
application/freertos/helloworld/cmd/hexdump.h
Normal file
21
application/freertos/helloworld/cmd/hexdump.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __BL_HEXDUMP_H_
|
||||
#define __BL_HEXDUMP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void hexdump(unsigned char *buf, unsigned long len, int groupsize);
|
||||
void show_speed(char *msg, u32 len, u32 us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BL_HEXDUMP_H_ */
|
||||
113
application/freertos/helloworld/cmd/mem.c
Normal file
113
application/freertos/helloworld/cmd/mem.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Wu Dehuang <dehuang.wu@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <console.h>
|
||||
#include <aic_common.h>
|
||||
#include <hexdump.h>
|
||||
|
||||
#define MD_HELP \
|
||||
"memory display command:\n" \
|
||||
" p <addr> <count> [mode]\n" \
|
||||
" addr: hex address string\n" \
|
||||
" count: display unit count\n" \
|
||||
" mode: should be 1/2/4 (default is 4)\n" \
|
||||
" e.g.: \n" \
|
||||
" p 0x40000000 64\n" \
|
||||
" p 0x40000000 64 1\n" \
|
||||
" p 0x40000000 64 2\n"
|
||||
|
||||
static void mem_display_help(void)
|
||||
{
|
||||
puts(MD_HELP);
|
||||
}
|
||||
|
||||
static int do_mem_display(int argc, char *argv[])
|
||||
{
|
||||
int groupsize;
|
||||
unsigned long addr, cnt;
|
||||
|
||||
cnt = 1;
|
||||
if (argc < 3) {
|
||||
goto help;
|
||||
}
|
||||
|
||||
if (argc > 3) {
|
||||
addr = strtol(argv[1], NULL, 0);
|
||||
cnt = strtol(argv[2], NULL, 0);
|
||||
groupsize = strtol(argv[3], NULL, 0);
|
||||
if ((groupsize != 1) && (groupsize != 2) && (groupsize != 4))
|
||||
goto help;
|
||||
} else {
|
||||
groupsize = 4;
|
||||
addr = strtol(argv[1], NULL, 0);
|
||||
cnt = strtol(argv[2], NULL, 0);
|
||||
}
|
||||
|
||||
hexdump((void *)addr, cnt * groupsize, groupsize);
|
||||
|
||||
return 0;
|
||||
|
||||
help:
|
||||
mem_display_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define MW_HELP \
|
||||
"memory write command:\n" \
|
||||
" m <addr> <value> [mode]\n" \
|
||||
" addr: hex address string\n" \
|
||||
" value: value going to write\n" \
|
||||
" mode: should be 1/2/4 (default is 4)\n" \
|
||||
" e.g.: \n" \
|
||||
" m 0x40000000 0x64\n" \
|
||||
" m 0x40000000 0x64 1\n" \
|
||||
" m 0x40000000 0x64 2\n"
|
||||
|
||||
static void mem_write_help(void)
|
||||
{
|
||||
puts(MW_HELP);
|
||||
}
|
||||
|
||||
static int do_mem_write(int argc, char *argv[])
|
||||
{
|
||||
unsigned long addr, val;
|
||||
unsigned char *p;
|
||||
int groupsize;
|
||||
|
||||
val = 0;
|
||||
if (argc < 3) {
|
||||
goto help;
|
||||
}
|
||||
|
||||
if (argc > 3) {
|
||||
addr = strtol(argv[1], NULL, 0);
|
||||
val = strtol(argv[2], NULL, 0);
|
||||
groupsize = strtol(argv[3], NULL, 0);
|
||||
if ((groupsize != 1) && (groupsize != 2) && (groupsize != 4))
|
||||
goto help;
|
||||
} else {
|
||||
groupsize = 4;
|
||||
addr = strtol(argv[1], NULL, 0);
|
||||
val = strtol(argv[2], NULL, 0);
|
||||
}
|
||||
|
||||
p = (unsigned char *)addr;
|
||||
memcpy(p, &val, groupsize);
|
||||
return 0;
|
||||
|
||||
help:
|
||||
mem_write_help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
CONSOLE_CMD(p, do_mem_display, "Memory display");
|
||||
CONSOLE_CMD(m, do_mem_write, "Memory write");
|
||||
50
application/freertos/helloworld/cmd/reset.c
Normal file
50
application/freertos/helloworld/cmd/reset.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Wu Dehuang <dehuang.wu@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <console.h>
|
||||
#include <aic_core.h>
|
||||
#include <aic_common.h>
|
||||
#include <aic_errno.h>
|
||||
#include <aic_hal.h>
|
||||
#include <hal_rtc.h>
|
||||
#include <wdt.h>
|
||||
|
||||
static int do_reset_boot(int argc, char *argv[])
|
||||
{
|
||||
#ifdef AIC_WDT_DRV
|
||||
wdt_init();
|
||||
printf("Going to reboot ...\n");
|
||||
#endif
|
||||
#ifdef AIC_WRI_DRV
|
||||
aic_set_reboot_reason(REBOOT_REASON_CMD_REBOOT);
|
||||
#endif
|
||||
#ifdef AIC_WDT_DRV
|
||||
wdt_expire_now();
|
||||
while(1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
CONSOLE_CMD(reset, do_reset_boot, "Reboot device.");
|
||||
CONSOLE_CMD(reboot, do_reset_boot, "Reboot device.");
|
||||
|
||||
static int cmd_aicupg(int argc, char **argv)
|
||||
{
|
||||
#ifdef AIC_WRI_DRV
|
||||
aic_set_reboot_reason(REBOOT_REASON_UPGRADE);
|
||||
#endif
|
||||
do_reset_boot(0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CONSOLE_CMD(aicupg, cmd_aicupg, "Reboot to the upgrade mode.");
|
||||
|
||||
219
application/freertos/helloworld/main.c
Normal file
219
application/freertos/helloworld/main.c
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2022, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: weilin.peng@artinchip.com
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <board.h>
|
||||
#include <hal_syscfg.h>
|
||||
#include <aic_core.h>
|
||||
#include <aic_drv_bare.h>
|
||||
#include <artinchip_fb.h>
|
||||
#include "aic_hal_ve.h"
|
||||
#include "aic_reboot_reason.h"
|
||||
#include <aic_log.h>
|
||||
#ifdef AIC_DMA_DRV
|
||||
#include "drv_dma.h"
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_CHERRYUSB_HOST
|
||||
#include <usbh_core.h>
|
||||
#include <usbh_hub.h>
|
||||
#include <usb_hc.h>
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_USING_DFS
|
||||
#include <dfs.h>
|
||||
#include <dfs_fs.h>
|
||||
#ifdef LPKG_USING_DFS_ELMFAT
|
||||
#include <dfs_elm.h>
|
||||
#endif
|
||||
#ifdef LPKG_USING_DFS_ROMFS
|
||||
#include <dfs_romfs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef AIC_SDMC_DRV
|
||||
#include "mmc.h"
|
||||
#endif
|
||||
|
||||
#ifdef AIC_LVGL_DEMO
|
||||
#include "lvgl.h"
|
||||
|
||||
extern void lv_port_disp_init(void);
|
||||
extern void lv_port_indev_init(void);
|
||||
extern void lv_user_gui_init(void);
|
||||
#endif
|
||||
|
||||
void show_banner(void)
|
||||
{
|
||||
printf("%s\n", BANNER);
|
||||
printf("Welcome to ArtInChip Luban-Lite %d.%d [FreeRTOS - Built on %s %s]\n",
|
||||
LL_VERSION, LL_SUBVERSION, __DATE__, __TIME__);
|
||||
}
|
||||
|
||||
static void console_loop_thread(void *arg)
|
||||
{
|
||||
#ifdef AIC_CONSOLE_BARE_DRV
|
||||
/* Console shell loop */
|
||||
console_init();
|
||||
console_loop();
|
||||
#endif
|
||||
|
||||
/* FreeRTOS Task exit */
|
||||
aicos_thread_delete(NULL);
|
||||
}
|
||||
|
||||
static int board_init(void)
|
||||
{
|
||||
int cons_uart;
|
||||
aicos_thread_t tshell = NULL;
|
||||
|
||||
hal_syscfg_probe();
|
||||
|
||||
aicos_local_irq_enable();
|
||||
|
||||
cons_uart = AIC_BAREMETAL_CONSOLE_UART;
|
||||
uart_init(cons_uart);
|
||||
stdio_set_uart(cons_uart);
|
||||
|
||||
show_banner();
|
||||
|
||||
#ifdef AIC_CONSOLE_BARE_DRV
|
||||
tshell = aicos_thread_create("shell", 4096, configMAX_PRIORITIES-20, console_loop_thread, NULL);
|
||||
if (tshell == NULL) {
|
||||
pr_err("Failed to create shell thread\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LV_USE_LOG
|
||||
static void lv_rt_log(const char *buf)
|
||||
{
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
#endif /* LV_USE_LOG */
|
||||
|
||||
extern void lwip_test_example_main_loop(void * data);
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
|
||||
#ifdef AIC_DMA_DRV
|
||||
drv_dma_init();
|
||||
#endif
|
||||
|
||||
#ifdef TLSF_MEM_HEAP
|
||||
aic_tlsf_heap_test();
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_USING_DFS
|
||||
dfs_init();
|
||||
#ifdef LPKG_USING_DFS_ROMFS
|
||||
dfs_romfs_init();
|
||||
#endif
|
||||
#ifdef LPKG_USING_DFS_ELMFAT
|
||||
elm_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_USING_DFS_ROMFS
|
||||
if (dfs_mount(NULL, "/", "rom", 0, &romfs_root) < 0)
|
||||
pr_err("Failed to mount romfs\n");
|
||||
#endif
|
||||
|
||||
#ifdef AIC_SDMC_DRV
|
||||
mmc_init(1);
|
||||
sdcard_hotplug_init();
|
||||
#endif
|
||||
|
||||
#if defined(LPKG_USING_DFS_ELMFAT) && defined(AIC_SDMC_DRV)
|
||||
if (dfs_mount("sd1", "/sdcard", "elm", 0, DEVICE_TYPE_SDMC_DISK) < 0)
|
||||
pr_err("Failed to mount sdmc with FatFS\n");
|
||||
#endif
|
||||
|
||||
#if defined(AIC_SPINAND_DRV) || defined(AIC_SPINOR_DRV)
|
||||
mtd_probe();
|
||||
#endif
|
||||
|
||||
#if defined(LPKG_USING_DFS_ELMFAT) && defined(AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_0)
|
||||
#if defined(AIC_SPINAND_DRV)
|
||||
if (dfs_mount("rodata", "/rodata", "elm", 0, DEVICE_TYPE_SPINAND_DISK) < 0)
|
||||
pr_err("Failed to mount spinand with FatFS\n");
|
||||
#endif
|
||||
#if defined(AIC_SPINOR_DRV)
|
||||
if (dfs_mount("rodata", "/rodata", "elm", 0, DEVICE_TYPE_SPINOR_DISK) < 0)
|
||||
pr_err("Failed to mount spinor with FatFS\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef AIC_DISPLAY_DRV
|
||||
aicfb_probe();
|
||||
#endif
|
||||
#ifdef AIC_GE_DRV
|
||||
hal_ge_init();
|
||||
#endif
|
||||
#ifdef AIC_VE_DRV
|
||||
hal_ve_probe();
|
||||
#endif
|
||||
#ifdef AIC_WRI_DRV
|
||||
aic_get_reboot_reason();
|
||||
aic_show_startup_time();
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_CHERRYUSB_DEVICE
|
||||
#ifdef LPKG_CHERRYUSB_DEVICE_MSC_TEMPLATE
|
||||
extern void msc_ram_init(void);
|
||||
msc_ram_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_CHERRYUSB_HOST
|
||||
usbh_init();
|
||||
while(1)
|
||||
{
|
||||
usbh_hub_poll();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_LWIP_EXAMPLES
|
||||
/* LwIP test loop */
|
||||
lwip_test_example_main_loop(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef AIC_LVGL_DEMO
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(lv_rt_log);
|
||||
#endif /* LV_USE_LOG */
|
||||
lv_init();
|
||||
lv_port_disp_init();
|
||||
lv_user_gui_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
lv_task_handler();
|
||||
}
|
||||
#endif /* AIC_LVGL_DEMO */
|
||||
|
||||
#ifdef AIC_VE_TEST
|
||||
extern int do_pic_dec_test(int argc, char **argv);
|
||||
/* Main loop */
|
||||
aicos_mdelay(2000);
|
||||
while (1) {
|
||||
do_pic_dec_test(0,NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FreeRTOS Task exit */
|
||||
aicos_thread_delete(NULL);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user