Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
19
project/BinScript.BinScript
Normal file
19
project/BinScript.BinScript
Normal file
@@ -0,0 +1,19 @@
|
||||
memset(ibuf, ff);
|
||||
read(hex, project.hex);
|
||||
remap(v_ax, 0, v_lx);
|
||||
memmode(obuf, 32, lit);
|
||||
reset(ibuf);
|
||||
read(bin, txw82xcore.bin);
|
||||
remap(0, 1000, v_lx);
|
||||
write(bin, txw82xApp.bin);
|
||||
|
||||
reset(ibuf);
|
||||
reset(obuf);
|
||||
read(bin, txw82xApp.bin);
|
||||
def16_at(v_param_len, 180);
|
||||
read(bin, parameter.cfg);
|
||||
memmode(ibuf, 32, lit);
|
||||
remap(210, 0, v_param_len);
|
||||
setbuf16(0, v_param_len);
|
||||
outrange(0, v_param_len, 10);
|
||||
write(bin, param.bin);
|
||||
BIN
project/BinScript.exe
Normal file
BIN
project/BinScript.exe
Normal file
Binary file not shown.
15
project/BinScript2.BinScript
Normal file
15
project/BinScript2.BinScript
Normal file
@@ -0,0 +1,15 @@
|
||||
memset(ibuf, ff);
|
||||
read(bin, loader.bin);
|
||||
def(LOADER_LEN, v_lx);
|
||||
read(bin, program.bin);
|
||||
remap(0, LOADER_LEN, v_lx);
|
||||
reset(ibuf);
|
||||
memset(ibuf, ff);
|
||||
read(bin, loader.bin);
|
||||
remap(0, 0, v_lx);
|
||||
memmode(obuf, 8, lit);
|
||||
write(bin, project_merge.bin);
|
||||
|
||||
|
||||
|
||||
|
||||
43
project/BuildBIN.sh
Normal file
43
project/BuildBIN.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -e tmp ]; then
|
||||
files=$(ls tmp)
|
||||
for f in $files
|
||||
do
|
||||
ff=$(cat tmp/$f)
|
||||
mv -f $ff.bak $ff
|
||||
done
|
||||
rm -rf tmp
|
||||
fi
|
||||
|
||||
cp ./Obj/*.elf project.elf
|
||||
cp ./Lst/*.map project.map
|
||||
cp ./Obj/*.ihex project.hex
|
||||
|
||||
|
||||
|
||||
if [ -e parameter.bincfg ]; then
|
||||
cp -f ./parameter.bincfg parameter.cfg
|
||||
fi
|
||||
if [ -e parameter_ui.setcfg ]; then
|
||||
cp -f ./parameter_ui.setcfg parameter_ui.cfg
|
||||
fi
|
||||
|
||||
[ ! -f BinScript.exe ] && cp ../../../../tools/makecode/BinScript.exe BinScript.exe
|
||||
[ ! -f crc.exe ] && cp ../../../../tools/makecode/crc.exe crc.exe
|
||||
[ ! -f makecode.exe ] && cp ../../../../tools/makecode/makecode.exe makecode.exe
|
||||
|
||||
|
||||
cp parameter.bincfg parameter.cfg
|
||||
#[ ! -f loader.bin ] && cp ../../../../sdk/chip/txw81x/loader.bin loader.bin
|
||||
|
||||
crc.exe crc_check_corebin.ini
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "!!!txw82xcore code is distroyed!"
|
||||
exit $?
|
||||
else
|
||||
BinScript.exe BinScript.BinScript
|
||||
makecode.exe
|
||||
#crc.exe crc.ini
|
||||
#BinScript.exe BinScript_Bin2Hex.BinScript
|
||||
fi
|
||||
465
project/app/app_bbm_cam.c
Normal file
465
project/app/app_bbm_cam.c
Normal file
@@ -0,0 +1,465 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "intercom/intercom.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
#include "lib/audio/audio_proc/audio_proc.h"
|
||||
#include "lib/audio/wsola/wsola_process.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
#include "video_app/video_msi.h"
|
||||
|
||||
#include "lib/lvgl_rotate_rpc/lvgl_rotate_msi.h"
|
||||
#include "debug_log_msi.h"
|
||||
#include "log_save_msi.h"
|
||||
#include "fpv_mem.h"
|
||||
|
||||
#include "babyprotocol_playback.h"
|
||||
#include "babyprotocol_record.h"
|
||||
|
||||
int32 atcmd_recv(uint8 *data, int32 len);
|
||||
void user_workqueue_init(uint16 pri,void *stack,uint16 stack_size);
|
||||
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
struct fpv_status {
|
||||
uint32_t dbg_av_heap:1,
|
||||
dbg_av_psram_heap:1,
|
||||
dbg_sram_heap:1,
|
||||
dbg_psram_heap:1;
|
||||
};
|
||||
|
||||
static struct fpv_status g_fpv_status;
|
||||
//fpv工程增加AT命令
|
||||
const static void *r_heap[] =
|
||||
{
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
(void*)&av_psram_heap,
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP) && defined(PSRAM_HEAP)
|
||||
(void*)&av_heap,
|
||||
#endif
|
||||
(void*)&sram_heap,
|
||||
(void*)&psram_heap,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int32 fpv_atcmd_check_heap(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
int i = 0;
|
||||
uint8_t mode;
|
||||
if(argc == 1)
|
||||
{
|
||||
mode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = os_atoi(argv[1]);
|
||||
}
|
||||
struct sys_heap *heap = (struct sys_heap *)r_heap[i];
|
||||
while(heap)
|
||||
{
|
||||
if (os_strcasecmp(arg, heap->name) == 0)
|
||||
{
|
||||
if(mode == 0)
|
||||
{
|
||||
os_printf(KERN_ALERT"%s heap free size:%d\n",heap->name, sysheap_freesize(heap));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
sysheap_status(heap, s_buf, sizeof(s_buf)/sizeof(uint32_t), 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
heap = (struct sys_heap *)r_heap[i];
|
||||
}
|
||||
if(!heap)
|
||||
{
|
||||
os_printf(KERN_ALERT"no found heap %s\n",arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32 fpv_atcmd_dbg(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
if (argc == 2) {
|
||||
if (os_strcasecmp(arg, "av_sram") == 0) {
|
||||
g_fpv_status.dbg_av_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "av_psram") == 0) {
|
||||
g_fpv_status.dbg_av_psram_heap = os_atoi(argv[1]);
|
||||
}
|
||||
if (os_strcasecmp(arg, "sram") == 0) {
|
||||
g_fpv_status.dbg_sram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "psram") == 0) {
|
||||
g_fpv_status.dbg_psram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
spook_init();
|
||||
config_Viidure(80);
|
||||
}
|
||||
|
||||
// 应用程序初始化
|
||||
__init static void fpv_app_init(void)
|
||||
{
|
||||
#if TAKEPHOTO_EN || JPG_EN
|
||||
int8_t takephoto_from = 0;
|
||||
int8_t takephoto1_from = -1;
|
||||
#endif
|
||||
#ifdef PSRAM_HEAP
|
||||
cJSON_Hooks hook;
|
||||
hook.malloc_fn = _os_malloc_psram;
|
||||
hook.free_fn = _os_free_psram;
|
||||
cJSON_InitHooks(&hook);
|
||||
#endif
|
||||
|
||||
|
||||
eloop_init();
|
||||
os_task_create("eloop_run", user_eloop_run, NULL, OS_TASK_PRIORITY_NORMAL + 2, 0, NULL, 2048);
|
||||
os_sleep_ms(1);
|
||||
ota_Tcp_Server();
|
||||
|
||||
//独立的文件保存msi(独立线程,后续可以所有的fb需要保存都发到这个msi去执行)
|
||||
extern struct msi *file_msi_init(const char *msi_name);
|
||||
file_msi_init(R_FILE_MSI);
|
||||
#ifndef FORCE_SCALE_TO_H264
|
||||
#if H264_EN == 1
|
||||
extern struct msi *auto_h264_msi_init(const char *auto_h264_name, uint8_t src_from0, uint16_t w0, uint16_t h0, uint8_t src_from1, uint16_t w1, uint16_t h1);
|
||||
#if SUB_STREAM_EN == 1
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,GEN420_DATA,640,360);
|
||||
#else
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,~0,0,0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uint8_t get_vpp_scale_w_h(uint16_t *w, uint16_t *h);
|
||||
uint16_t scale_w,scale_h;
|
||||
int scale_ret = get_vpp_scale_w_h(&scale_w,&scale_h);
|
||||
if(!scale_ret)
|
||||
{
|
||||
os_printf(KERN_INFO"scale_w:%d\tscale_h:%d\n",scale_w,scale_h);
|
||||
auto_h264_msi_init(AUTO_H264,SCALER_DATA,scale_w,scale_h,GEN420_DATA,640,360);
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf(KERN_ERR"scale cfg err,scale_ret:%d\n",scale_ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// 支持拍照和缩略图,暂时默认启动,(紧紧支持录风者模式)
|
||||
#if TAKEPHOTO_EN
|
||||
// 正常拍照和缩略图
|
||||
{
|
||||
extern uint8_t get_vpp_w_h(uint16_t *w, uint16_t *h);
|
||||
extern void takephoto_with_thumb_init(const char *thumb_msi_name);
|
||||
extern void takephoto_with_thumb_over_dpi_init(const char *thumb_msi_name, uint8_t jpg_num);
|
||||
extern void takephoto_720P_with_thumb_init(const char *thumb_msi_name);
|
||||
uint16_t camera_w, camera_h;
|
||||
get_vpp_w_h(&camera_w, &camera_h);
|
||||
// 没有识别到摄像头
|
||||
if (!camera_w || !camera_h)
|
||||
{
|
||||
}
|
||||
// 如果是720P摄像头,支持原分辨率以及大分辨拍照
|
||||
else if (camera_w == 1280 && camera_h == 720)
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID0);
|
||||
takephoto_from = VPP_DATA0;
|
||||
}
|
||||
// 其他摄像头,主要是为了拍照720P的图片,1080P摄像头从VPP_DATA1,不支持大分辨率拍照
|
||||
else
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID1);
|
||||
takephoto_from = VPP_DATA1;
|
||||
takephoto1_from = VPP_DATA0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
if(takephoto_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID0, takephoto_from);
|
||||
}
|
||||
|
||||
if(takephoto1_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID1, takephoto1_from);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if USB_JPG_ADD_WATERMARK
|
||||
usb_to_recode_init(JPGID1);
|
||||
#endif
|
||||
/*
|
||||
添加其他应用代码初始化
|
||||
...
|
||||
*/
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h);
|
||||
isp_tunning_init(1920, 1080);
|
||||
#endif
|
||||
user_protocol();
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void scale2_mutex_init();
|
||||
static void hardware_init(uint8_t vcam)
|
||||
{
|
||||
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
#if KEY_MODULE_EN == 1
|
||||
keyWork_init(10);
|
||||
#endif
|
||||
|
||||
gen420_hardware_msi_init();
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if DEBUG_LOG_FILE_SAVE_EN
|
||||
//默认写入到SD卡,不支持中断打印保存
|
||||
//默认每10秒同步写卡,每60秒新建一个文件保存
|
||||
creat_log_save_stream(R_DEBUG_STREAM, 1000, 60*1000);
|
||||
struct msi *dbg_msi = dbg_log_msi(S_DEBUG_STREAM);
|
||||
if(dbg_msi)
|
||||
{
|
||||
print_redirect((osprint_hook)hgprntf_debug_log_msi, dbg_msi->priv, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
struct mipi_csi_debug mipi_debug;
|
||||
os_memset(&mipi_debug, 0, sizeof(struct mipi_csi_debug));
|
||||
mipi_debug.debug_enable = 0;
|
||||
mipi_debug.debug_io0 = PD_4;
|
||||
mipi_debug.debug_io1 = PD_5;
|
||||
mipi_debug.debug_io2 = PD_6;
|
||||
mipi_debug.debug_io3 = PD_7;
|
||||
mipi_debug.debug_type0 = 6;
|
||||
mipi_debug.debug_type1 = 7;
|
||||
mipi_debug.debug_type2 = 8;
|
||||
mipi_debug.debug_type3 = 9;
|
||||
int mipi_csi_hardware_config(uint32_t csi_dev_id, uint8_t init_en, uint8_t csi_data_lane_num, uint8_t dual_en, uint8_t dual_sensor_type, uint8_t mclk,struct mipi_csi_debug *p_debug);
|
||||
#if DVP_EN
|
||||
int ret;
|
||||
ret = mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, ret?SENSOR_TYPE_SLAVE1:SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
#else
|
||||
mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24, &mipi_debug);
|
||||
//mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0, 24, &mipi_debug);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PARA_IN_EN
|
||||
para_in_hareware_init();
|
||||
#endif
|
||||
|
||||
#if ISP_EN
|
||||
// debug_config();
|
||||
isp_cfg_dev();
|
||||
#endif
|
||||
|
||||
#if VPP_EN
|
||||
|
||||
extern uint8_t set_vpp_bu1_shrink(uint16_t w, uint16_t shrink_w);
|
||||
extern void get_single_mipi(uint32_t csi_dev_id,uint16_t *w,uint16_t *h);
|
||||
uint16_t w = 0,h = 0;
|
||||
get_single_mipi(HG_MIPI_CSI_DEVID,&w,&h);
|
||||
os_printf(KERN_INFO"vpp_cfg w:%d h:%d\n",w,h);
|
||||
#ifdef SUB_STREAM_WIDTH
|
||||
set_vpp_bu1_shrink(w,SUB_STREAM_WIDTH);
|
||||
#endif
|
||||
vpp_cfg(w, h, VPP_INPUT_FROM);
|
||||
#endif
|
||||
|
||||
#if AUDIO_EN
|
||||
reg_auproc_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_wsola_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_aucoder_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
aucode_mutex_init();
|
||||
audio_adc_init(AUSYS_AUAD, 8000, 1, 4, 1);
|
||||
audio_dac_init();
|
||||
#endif
|
||||
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
static struct os_work fpv_wk;
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
if(g_fpv_status.dbg_sram_heap)
|
||||
{
|
||||
sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
if(g_fpv_status.dbg_psram_heap)
|
||||
{
|
||||
sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
if(g_fpv_status.dbg_av_psram_heap)
|
||||
{
|
||||
sysheap_status(&av_psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
if(g_fpv_status.dbg_av_heap)
|
||||
{
|
||||
sysheap_status(&av_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//部分控制at命令
|
||||
static void fpv_at_dbg()
|
||||
{
|
||||
//是否打开对应sdk的dbg
|
||||
atcmd_recv((uint8_t*)"at+print=1,7",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=av_psram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=av_sram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=sram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=psram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+SYSDBG=top,0",0);
|
||||
|
||||
#if 0
|
||||
//一次性命令
|
||||
atcmd_recv("AT+FPV_HEAP=av_psram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=av_sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=psram,0",0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_bbm_cam_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
//初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH,NULL,2048);
|
||||
hardware_init(vcam);
|
||||
fpv_app_init();
|
||||
intercom_init();
|
||||
fpv_at_dbg();
|
||||
OS_WORK_INIT(&fpv_wk, sys_fpv_loop, 0);
|
||||
os_run_work_delay(&fpv_wk, 1000);
|
||||
return 0;
|
||||
}
|
||||
463
project/app/app_bbm_lcd.c
Normal file
463
project/app/app_bbm_lcd.c
Normal file
@@ -0,0 +1,463 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "intercom/intercom.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
#include "lib/audio/audio_proc/audio_proc.h"
|
||||
#include "lib/audio/wsola/wsola_process.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
#include "video_app/video_msi.h"
|
||||
|
||||
#include "lib/lvgl_rotate_rpc/lvgl_rotate_msi.h"
|
||||
#include "debug_log_msi.h"
|
||||
#include "log_save_msi.h"
|
||||
#include "fpv_mem.h"
|
||||
|
||||
#include "babyprotocol_playback.h"
|
||||
#include "babyprotocol_record.h"
|
||||
|
||||
int32 atcmd_recv(uint8 *data, int32 len);
|
||||
void user_workqueue_init(uint16 pri,void *stack,uint16 stack_size);
|
||||
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
struct fpv_status {
|
||||
uint32_t dbg_av_heap:1,
|
||||
dbg_av_psram_heap:1,
|
||||
dbg_sram_heap:1,
|
||||
dbg_psram_heap:1;
|
||||
};
|
||||
|
||||
static struct fpv_status g_fpv_status;
|
||||
//fpv工程增加AT命令
|
||||
const static void *r_heap[] =
|
||||
{
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
(void*)&av_psram_heap,
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP) && defined(PSRAM_HEAP)
|
||||
(void*)&av_heap,
|
||||
#endif
|
||||
(void*)&sram_heap,
|
||||
(void*)&psram_heap,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int32 fpv_atcmd_check_heap(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
int i = 0;
|
||||
uint8_t mode;
|
||||
if(argc == 1)
|
||||
{
|
||||
mode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = os_atoi(argv[1]);
|
||||
}
|
||||
struct sys_heap *heap = (struct sys_heap *)r_heap[i];
|
||||
while(heap)
|
||||
{
|
||||
if (os_strcasecmp(arg, heap->name) == 0)
|
||||
{
|
||||
if(mode == 0)
|
||||
{
|
||||
os_printf(KERN_ALERT"%s heap free size:%d\n",heap->name, sysheap_freesize(heap));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
sysheap_status(heap, s_buf, sizeof(s_buf)/sizeof(uint32_t), 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
heap = (struct sys_heap *)r_heap[i];
|
||||
}
|
||||
if(!heap)
|
||||
{
|
||||
os_printf(KERN_ALERT"no found heap %s\n",arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32 fpv_atcmd_dbg(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
if (argc == 2) {
|
||||
if (os_strcasecmp(arg, "av_sram") == 0) {
|
||||
g_fpv_status.dbg_av_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "av_psram") == 0) {
|
||||
g_fpv_status.dbg_av_psram_heap = os_atoi(argv[1]);
|
||||
}
|
||||
if (os_strcasecmp(arg, "sram") == 0) {
|
||||
g_fpv_status.dbg_sram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "psram") == 0) {
|
||||
g_fpv_status.dbg_psram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
spook_init();
|
||||
config_Viidure(80);
|
||||
}
|
||||
|
||||
// 应用程序初始化
|
||||
__init static void fpv_app_init(void)
|
||||
{
|
||||
#if TAKEPHOTO_EN || JPG_EN
|
||||
int8_t takephoto_from = 0;
|
||||
int8_t takephoto1_from = -1;
|
||||
#endif
|
||||
#ifdef PSRAM_HEAP
|
||||
cJSON_Hooks hook;
|
||||
hook.malloc_fn = _os_malloc_psram;
|
||||
hook.free_fn = _os_free_psram;
|
||||
cJSON_InitHooks(&hook);
|
||||
#endif
|
||||
|
||||
|
||||
eloop_init();
|
||||
os_task_create("eloop_run", user_eloop_run, NULL, OS_TASK_PRIORITY_NORMAL + 2, 0, NULL, 2048);
|
||||
os_sleep_ms(1);
|
||||
ota_Tcp_Server();
|
||||
|
||||
//独立的文件保存msi(独立线程,后续可以所有的fb需要保存都发到这个msi去执行)
|
||||
extern struct msi *file_msi_init(const char *msi_name);
|
||||
file_msi_init(R_FILE_MSI);
|
||||
#ifndef FORCE_SCALE_TO_H264
|
||||
#if H264_EN == 1
|
||||
extern struct msi *auto_h264_msi_init(const char *auto_h264_name, uint8_t src_from0, uint16_t w0, uint16_t h0, uint8_t src_from1, uint16_t w1, uint16_t h1);
|
||||
#if SUB_STREAM_EN == 1
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,GEN420_DATA,640,360);
|
||||
#else
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,~0,0,0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uint8_t get_vpp_scale_w_h(uint16_t *w, uint16_t *h);
|
||||
uint16_t scale_w,scale_h;
|
||||
int scale_ret = get_vpp_scale_w_h(&scale_w,&scale_h);
|
||||
if(!scale_ret)
|
||||
{
|
||||
os_printf(KERN_INFO"scale_w:%d\tscale_h:%d\n",scale_w,scale_h);
|
||||
auto_h264_msi_init(AUTO_H264,SCALER_DATA,scale_w,scale_h,GEN420_DATA,640,360);
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf(KERN_ERR"scale cfg err,scale_ret:%d\n",scale_ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// 支持拍照和缩略图,暂时默认启动,(紧紧支持录风者模式)
|
||||
#if TAKEPHOTO_EN
|
||||
// 正常拍照和缩略图
|
||||
{
|
||||
extern uint8_t get_vpp_w_h(uint16_t *w, uint16_t *h);
|
||||
extern void takephoto_with_thumb_init(const char *thumb_msi_name);
|
||||
extern void takephoto_with_thumb_over_dpi_init(const char *thumb_msi_name, uint8_t jpg_num);
|
||||
extern void takephoto_720P_with_thumb_init(const char *thumb_msi_name);
|
||||
uint16_t camera_w, camera_h;
|
||||
get_vpp_w_h(&camera_w, &camera_h);
|
||||
// 没有识别到摄像头
|
||||
if (!camera_w || !camera_h)
|
||||
{
|
||||
}
|
||||
// 如果是720P摄像头,支持原分辨率以及大分辨拍照
|
||||
else if (camera_w == 1280 && camera_h == 720)
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID0);
|
||||
takephoto_from = VPP_DATA0;
|
||||
}
|
||||
// 其他摄像头,主要是为了拍照720P的图片,1080P摄像头从VPP_DATA1,不支持大分辨率拍照
|
||||
else
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID1);
|
||||
takephoto_from = VPP_DATA1;
|
||||
takephoto1_from = VPP_DATA0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
if(takephoto_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID0, takephoto_from);
|
||||
}
|
||||
|
||||
if(takephoto1_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID1, takephoto1_from);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if USB_JPG_ADD_WATERMARK
|
||||
usb_to_recode_init(JPGID1);
|
||||
#endif
|
||||
/*
|
||||
添加其他应用代码初始化
|
||||
...
|
||||
*/
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h);
|
||||
isp_tunning_init(1920, 1080);
|
||||
#endif
|
||||
user_protocol();
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void scale2_mutex_init();
|
||||
static void hardware_init(uint8_t vcam)
|
||||
{
|
||||
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
#if KEY_MODULE_EN == 1
|
||||
keyWork_init(10);
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
extern int32 jpg_mutex_init();
|
||||
extern void jpg_mem_init(int num);
|
||||
jpg_mutex_init();
|
||||
jpg_mem_init(32);
|
||||
#endif
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if DEBUG_LOG_FILE_SAVE_EN
|
||||
//默认写入到SD卡,不支持中断打印保存
|
||||
//默认每10秒同步写卡,每60秒新建一个文件保存
|
||||
creat_log_save_stream(R_DEBUG_STREAM, 1000, 60*1000);
|
||||
struct msi *dbg_msi = dbg_log_msi(S_DEBUG_STREAM);
|
||||
if(dbg_msi)
|
||||
{
|
||||
print_redirect((osprint_hook)hgprntf_debug_log_msi, dbg_msi->priv, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if LCD_EN
|
||||
uint16_t osd_w, osd_h;
|
||||
uint16_t screen_w, screen_h;
|
||||
uint16_t video_w, video_h;
|
||||
uint8_t rotate, video_rotate;
|
||||
lcd_hardware_init(&osd_w, &osd_h, &rotate, &screen_w, &screen_h,&video_w, &video_h, &video_rotate);
|
||||
lcd_arg_setting(osd_w, osd_h, rotate, screen_w, screen_h,video_w,video_h, video_rotate);
|
||||
lcd_driver_init(R_OSD_ENCODE, R_LCD_OSD, R_VIDEO_P0, R_VIDEO_P1);
|
||||
#endif
|
||||
|
||||
#if TOUCH_PAD_EN
|
||||
touch_pad_hareware_init();
|
||||
#endif
|
||||
|
||||
#if AUDIO_EN
|
||||
reg_auproc_alloc(av_malloc, av_zalloc, av_calloc, av_realloc, av_free);
|
||||
reg_wsola_alloc(av_malloc, av_zalloc, av_calloc, av_realloc, av_free);
|
||||
reg_aucoder_alloc(av_malloc, av_zalloc, av_calloc, av_realloc, av_free);
|
||||
aucode_mutex_init();
|
||||
audio_adc_init(AUSYS_AUAD, 8000, 1, 4, 1);
|
||||
audio_dac_init();
|
||||
#endif
|
||||
|
||||
#if LCD_EN
|
||||
void lcd_demo_thread(int32_t d);
|
||||
void lvgl_init_msi(uint16_t w, uint16_t h, uint8_t rotate);
|
||||
|
||||
#if LVGL_HW_ROTATE_RPC_EN
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = _os_malloc,
|
||||
.realloc = _os_realloc,
|
||||
.zalloc = _os_zalloc,
|
||||
.free = _os_free,
|
||||
};
|
||||
#else
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = av_psram_malloc,
|
||||
.realloc = av_psram_realloc,
|
||||
.zalloc = av_psram_zalloc,
|
||||
.free = av_psram_free,
|
||||
};
|
||||
#endif
|
||||
hg_lv_mem_register(&hook);
|
||||
|
||||
lvgl_init_msi(osd_w, osd_h, rotate);
|
||||
lcd_demo_thread(2);
|
||||
#endif
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
static struct os_work fpv_wk;
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
if(g_fpv_status.dbg_sram_heap)
|
||||
{
|
||||
sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
if(g_fpv_status.dbg_psram_heap)
|
||||
{
|
||||
sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
if(g_fpv_status.dbg_av_psram_heap)
|
||||
{
|
||||
sysheap_status(&av_psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
if(g_fpv_status.dbg_av_heap)
|
||||
{
|
||||
sysheap_status(&av_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//部分控制at命令
|
||||
static void fpv_at_dbg()
|
||||
{
|
||||
//是否打开对应sdk的dbg
|
||||
atcmd_recv((uint8_t*)"at+print=1,7",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=av_psram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=av_sram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=sram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+FPV_DBG=psram,0",0);
|
||||
atcmd_recv((uint8_t*)"AT+SYSDBG=top,0",0);
|
||||
|
||||
#if 0
|
||||
//一次性命令
|
||||
atcmd_recv("AT+FPV_HEAP=av_psram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=av_sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=psram,0",0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_bbm_lcd_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
//初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH,NULL,2048);
|
||||
hardware_init(vcam);
|
||||
fpv_app_init();
|
||||
intercom_init();
|
||||
fpv_at_dbg();
|
||||
OS_WORK_INIT(&fpv_wk, sys_fpv_loop, 0);
|
||||
os_run_work_delay(&fpv_wk, 1000);
|
||||
return 0;
|
||||
}
|
||||
258
project/app/app_demo.c
Normal file
258
project/app/app_demo.c
Normal file
@@ -0,0 +1,258 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
#include "video_demo/video_demo.h"
|
||||
#include "fpv_mem.h"
|
||||
|
||||
void user_workqueue_init(uint16 pri, void *stack, uint16 stack_size);
|
||||
extern void dorg_double_sensor(uint32 src0_w,uint32 src0_h,uint32 src1_w,uint32 src1_h,uint32 src0_raw_num,uint32 src1_raw_num,uint8_t dvp_type,uint8_t csi0_type,uint8_t csi1_type);
|
||||
extern struct msi *file_msi_init(const char *msi_name);
|
||||
extern void scale2_mutex_init();
|
||||
extern int32 jpg_mutex_init();
|
||||
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
spook_init();
|
||||
config_Viidure(80);
|
||||
}
|
||||
|
||||
// 应用程序初始化
|
||||
__init static void app_demo_init(void)
|
||||
{
|
||||
#ifdef PSRAM_HEAP
|
||||
cJSON_Hooks hook;
|
||||
hook.malloc_fn = _os_malloc_psram;
|
||||
hook.free_fn = _os_free_psram;
|
||||
cJSON_InitHooks(&hook);
|
||||
#endif
|
||||
|
||||
|
||||
eloop_init();
|
||||
os_task_create("eloop_run", user_eloop_run, NULL, OS_TASK_PRIORITY_BELOW_NORMAL, 0, NULL, 2048);
|
||||
os_sleep_ms(1);
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void hardware_init(uint8_t vcam)
|
||||
{
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
|
||||
#if JPG_EN == 1
|
||||
jpg_mutex_init();
|
||||
#endif
|
||||
//默认打开gen420的模块
|
||||
gen420_hardware_msi_init();
|
||||
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
struct mipi_csi_debug mipi_debug;
|
||||
os_memset(&mipi_debug, 0, sizeof(struct mipi_csi_debug));
|
||||
mipi_debug.debug_enable = 0;
|
||||
mipi_debug.debug_io0 = PD_4;
|
||||
mipi_debug.debug_io1 = PD_5;
|
||||
mipi_debug.debug_io2 = PD_6;
|
||||
mipi_debug.debug_io3 = PD_7;
|
||||
mipi_debug.debug_type0 = 6;
|
||||
mipi_debug.debug_type1 = 7;
|
||||
mipi_debug.debug_type2 = 8;
|
||||
mipi_debug.debug_type3 = 9;
|
||||
int mipi_csi_hardware_config(uint32_t csi_dev_id, uint8_t init_en, uint8_t csi_data_lane_num, uint8_t dual_en, uint8_t dual_sensor_type, uint8_t mclk,struct mipi_csi_debug *p_debug);
|
||||
#if DVP_EN
|
||||
int ret;
|
||||
ret = mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, ret?SENSOR_TYPE_SLAVE1:SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
#else
|
||||
mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24,&mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0, 24,&mipi_debug);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if ISP_EN
|
||||
// debug_config();
|
||||
isp_cfg_dev();
|
||||
#endif
|
||||
|
||||
#if VPP_EN
|
||||
{
|
||||
extern uint8_t set_vpp_bu1_shrink(uint16_t w, uint16_t shrink_w);
|
||||
extern void get_single_mipi(uint32_t csi_dev_id,uint16_t *w,uint16_t *h);
|
||||
uint16_t w = 0,h = 0;
|
||||
get_single_mipi(HG_MIPI_CSI_DEVID,&w,&h);
|
||||
os_printf(KERN_INFO"vpp_cfg w:%d h:%d\n",w,h);
|
||||
#ifdef SUB_STREAM_WIDTH
|
||||
set_vpp_bu1_shrink(w,SUB_STREAM_WIDTH);
|
||||
#endif
|
||||
vpp_cfg(w, h, VPP_INPUT_FROM);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if RTT_USB_EN
|
||||
#ifdef RT_USING_USB_DEVICE
|
||||
extern rt_err_t rt_usbd_core_device_list_init();
|
||||
rt_usbd_core_device_list_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB11_EN && RTT_USB_EN)
|
||||
#if USB11_HOST_EN
|
||||
extern rt_err_t hg_usb11h_register(rt_uint32_t devid);
|
||||
hg_usb11h_register(HG_USB11_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usb11d_class_driver_register();
|
||||
extern int hg_usb11d_register(rt_uint32_t devid);
|
||||
hg_usb11d_class_driver_register();
|
||||
hg_usb11d_register(HG_USB11_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB_EN && RTT_USB_EN)
|
||||
#if (USB_DETECT_EN && !USB_HOST_EN)
|
||||
extern void hg_usb_connect_detect_init(void);
|
||||
hg_usb_connect_detect_init();
|
||||
#else
|
||||
#if USB_HOST_EN
|
||||
extern rt_err_t hg_usbh_register(rt_uint32_t devid);
|
||||
hg_usbh_register(HG_USB_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usbd_class_driver_register();
|
||||
extern int hg_usbd_register(rt_uint32_t devid);
|
||||
hg_usbd_class_driver_register();
|
||||
hg_usbd_register(HG_USB_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
av_psram_heap_status(s_buf, sizeof(s_buf) / 4);
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
av_heap_status(s_buf, sizeof(s_buf) / 4);
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_demo_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
//初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH,NULL,2048);
|
||||
hardware_init(vcam);
|
||||
app_demo_init();
|
||||
|
||||
file_msi_init(R_FILE_MSI);
|
||||
video_demo_thread(H264_ENCODE_DEMO_FROM_VPP_DATA1);
|
||||
return 0;
|
||||
}
|
||||
597
project/app/app_fpv.c
Normal file
597
project/app/app_fpv.c
Normal file
@@ -0,0 +1,597 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "intercom/intercom.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
#include "lib/audio/audio_proc/audio_proc.h"
|
||||
#include "lib/audio/wsola/wsola_process.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
#include "video_app/video_msi.h"
|
||||
|
||||
#include "lib/lvgl_rotate_rpc/lvgl_rotate_msi.h"
|
||||
#include "debug_log_msi.h"
|
||||
#include "log_save_msi.h"
|
||||
#include "fpv_mem.h"
|
||||
#include "hal/i2s.h"
|
||||
#include "scale/scale_common.h"
|
||||
#if PRINTER_EN
|
||||
#include "printer.h"
|
||||
#endif
|
||||
|
||||
int32 atcmd_recv(uint8 *data, int32 len);
|
||||
void user_workqueue_init(uint16 pri, void *stack, uint16 stack_size);
|
||||
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
struct fpv_status
|
||||
{
|
||||
uint32_t dbg_av_heap : 1, dbg_av_psram_heap : 1, dbg_sram_heap : 1, dbg_psram_heap : 1;
|
||||
};
|
||||
|
||||
static struct fpv_status g_fpv_status;
|
||||
// fpv工程增加AT命令
|
||||
const void *r_heap[] = {
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
(void *) &av_psram_heap,
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP) && defined(PSRAM_HEAP)
|
||||
(void *) &av_heap,
|
||||
#endif
|
||||
(void *) &sram_heap, (void *) &psram_heap, NULL,
|
||||
};
|
||||
|
||||
int32 fpv_atcmd_check_heap(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
int i = 0;
|
||||
uint8_t mode;
|
||||
if (argc == 1)
|
||||
{
|
||||
mode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = os_atoi(argv[1]);
|
||||
}
|
||||
struct sys_heap *heap = (struct sys_heap *) r_heap[i];
|
||||
while (heap)
|
||||
{
|
||||
if (os_strcasecmp(arg, heap->name) == 0)
|
||||
{
|
||||
if (mode == 0)
|
||||
{
|
||||
os_printf(KERN_ALERT "%s heap free size:%d\n", heap->name, sysheap_freesize(heap));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
sysheap_status(heap, s_buf, sizeof(s_buf) / sizeof(uint32_t), 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
heap = (struct sys_heap *) r_heap[i];
|
||||
}
|
||||
if (!heap)
|
||||
{
|
||||
os_printf(KERN_ALERT "no found heap %s\n", arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 fpv_atcmd_dbg(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *arg = argv[0];
|
||||
if (argc == 2)
|
||||
{
|
||||
if (os_strcasecmp(arg, "av_sram") == 0)
|
||||
{
|
||||
g_fpv_status.dbg_av_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "av_psram") == 0)
|
||||
{
|
||||
g_fpv_status.dbg_av_psram_heap = os_atoi(argv[1]);
|
||||
}
|
||||
if (os_strcasecmp(arg, "sram") == 0)
|
||||
{
|
||||
g_fpv_status.dbg_sram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
if (os_strcasecmp(arg, "psram") == 0)
|
||||
{
|
||||
g_fpv_status.dbg_psram_heap = (os_atoi(argv[1]) == 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
spook_init();
|
||||
config_Viidure(80);
|
||||
}
|
||||
|
||||
// 应用程序初始化
|
||||
__init static void fpv_app_init(void)
|
||||
{
|
||||
#if TAKEPHOTO_EN || JPG_EN
|
||||
int8_t takephoto_from = 0;
|
||||
int8_t takephoto1_from = -1;
|
||||
#endif
|
||||
#ifdef PSRAM_HEAP
|
||||
cJSON_Hooks hook;
|
||||
hook.malloc_fn = _os_malloc_psram;
|
||||
hook.free_fn = _os_free_psram;
|
||||
cJSON_InitHooks(&hook);
|
||||
#endif
|
||||
|
||||
eloop_init();
|
||||
os_task_create("eloop_run", user_eloop_run, NULL, OS_TASK_PRIORITY_NORMAL + 2, 0, NULL, 2048);
|
||||
os_sleep_ms(1);
|
||||
ota_Tcp_Server();
|
||||
|
||||
// 独立的文件保存msi(独立线程,后续可以所有的fb需要保存都发到这个msi去执行)
|
||||
extern struct msi *file_msi_init(const char *msi_name);
|
||||
file_msi_init(R_FILE_MSI);
|
||||
#ifndef FORCE_SCALE_TO_H264
|
||||
#if H264_EN == 1
|
||||
extern struct msi *auto_h264_msi_init(const char *auto_h264_name, uint8_t src_from0, uint16_t w0, uint16_t h0, uint8_t src_from1, uint16_t w1, uint16_t h1);
|
||||
#if SUB_STREAM_EN == 1
|
||||
{
|
||||
uint16_t h264_w, h264_h;
|
||||
uint8_t h264_ret = get_vpp1_w_h(&h264_w, &h264_h);
|
||||
if (!h264_ret)
|
||||
{
|
||||
auto_h264_msi_init(AUTO_H264, VPP_DATA0, 0, 0, GEN420_DATA, h264_w, h264_h);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto_h264_msi_init(AUTO_H264, VPP_DATA0, 0, 0, ~0, 0, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
auto_h264_msi_init(AUTO_H264, VPP_DATA0, 0, 0, ~0, 0, 0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uint8_t get_vpp_scale_w_h(uint16_t *w, uint16_t *h);
|
||||
uint16_t scale_w, scale_h;
|
||||
int scale_ret = get_vpp_scale_w_h(&scale_w, &scale_h);
|
||||
if (!scale_ret)
|
||||
{
|
||||
os_printf(KERN_INFO "scale_w:%d\tscale_h:%d\n", scale_w, scale_h);
|
||||
#if SUB_STREAM_EN == 1
|
||||
{
|
||||
uint16_t h264_w, h264_h;
|
||||
uint8_t h264_ret = get_vpp1_w_h(&h264_w, &h264_h);
|
||||
if (!h264_ret)
|
||||
{
|
||||
auto_h264_msi_init(AUTO_H264, SCALER_DATA, 0, 0, GEN420_DATA, h264_w, h264_h);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto_h264_msi_init(AUTO_H264, SCALER_DATA, 0, 0, ~0, 0, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
auto_h264_msi_init(AUTO_H264, SCALER_DATA, 0, 0, ~0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf(KERN_ERR "scale cfg err,scale_ret:%d\n", scale_ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// 支持拍照和缩略图,暂时默认启动,(紧紧支持录风者模式)
|
||||
#if TAKEPHOTO_EN
|
||||
// 正常拍照和缩略图
|
||||
{
|
||||
extern uint8_t get_vpp_w_h(uint16_t *w, uint16_t *h);
|
||||
extern void takephoto_with_thumb_init(const char *thumb_msi_name);
|
||||
extern void takephoto_with_thumb_over_dpi_init(const char *thumb_msi_name, uint8_t jpg_num);
|
||||
extern void takephoto_720P_with_thumb_init(const char *thumb_msi_name);
|
||||
uint16_t camera_w, camera_h;
|
||||
get_vpp_w_h(&camera_w, &camera_h);
|
||||
// 没有识别到摄像头
|
||||
if (!camera_w || !camera_h)
|
||||
{
|
||||
}
|
||||
// 如果是720P摄像头,支持原分辨率以及大分辨拍照
|
||||
else if (camera_w == 1280 && camera_h == 720)
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID0);
|
||||
takephoto_from = VPP_DATA0;
|
||||
}
|
||||
// 其他摄像头,主要是为了拍照720P的图片,1080P摄像头从VPP_DATA1,不支持大分辨率拍照
|
||||
else
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID1);
|
||||
takephoto_from = VPP_DATA1;
|
||||
takephoto1_from = VPP_DATA0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
if (takephoto_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID0, takephoto_from);
|
||||
}
|
||||
|
||||
if (takephoto1_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG1, JPGID1, takephoto1_from);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USB_JPG_ADD_WATERMARK
|
||||
usb_to_recode_init(JPGID1);
|
||||
#endif
|
||||
/*
|
||||
添加其他应用代码初始化
|
||||
...
|
||||
*/
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h);
|
||||
isp_tunning_init(1920, 1080);
|
||||
#endif
|
||||
user_protocol();
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void scale2_mutex_init();
|
||||
void hardware_init(uint8_t vcam)
|
||||
{
|
||||
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
scale_mutex_init(); // scale相关锁初始化
|
||||
#if KEY_MODULE_EN == 1
|
||||
keyWork_init(10);
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
extern int32 jpg_mutex_init();
|
||||
extern void jpg_mem_init(int num);
|
||||
jpg_mutex_init();
|
||||
jpg_mem_init(32);
|
||||
#endif
|
||||
// 默认打开gen420的模块
|
||||
gen420_hardware_msi_init();
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if DEBUG_LOG_FILE_SAVE_EN
|
||||
// 默认写入到SD卡,不支持中断打印保存
|
||||
// 默认每10秒同步写卡,每60秒新建一个文件保存
|
||||
creat_log_save_stream(R_DEBUG_STREAM, 1000, 60 * 1000);
|
||||
struct msi *dbg_msi = dbg_log_msi(S_DEBUG_STREAM);
|
||||
if (dbg_msi)
|
||||
{
|
||||
print_redirect((osprint_hook) hgprntf_debug_log_msi, dbg_msi->priv, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_ret = 0;
|
||||
bool csi_cfg();
|
||||
csi_ret = csi_cfg();
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_open();
|
||||
if (csi_ret)
|
||||
{
|
||||
csi_open();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
struct mipi_csi_debug mipi_debug;
|
||||
os_memset(&mipi_debug, 0, sizeof(struct mipi_csi_debug));
|
||||
mipi_debug.debug_enable = 0;
|
||||
mipi_debug.debug_io0 = PD_4;
|
||||
mipi_debug.debug_io1 = PD_5;
|
||||
mipi_debug.debug_io2 = PD_6;
|
||||
mipi_debug.debug_io3 = PD_7;
|
||||
mipi_debug.debug_type0 = 6;
|
||||
mipi_debug.debug_type1 = 7;
|
||||
mipi_debug.debug_type2 = 8;
|
||||
mipi_debug.debug_type3 = 9;
|
||||
int mipi_csi_hardware_config(uint32_t csi_dev_id, uint8_t init_en, uint8_t csi_data_lane_num, uint8_t dual_en, uint8_t dual_sensor_type, uint8_t mclk, struct mipi_csi_debug *p_debug);
|
||||
#if DVP_EN
|
||||
int ret;
|
||||
ret = mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0, 24, &mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, ret ? SENSOR_TYPE_SLAVE1 : SENSOR_TYPE_SLAVE0, 24, &mipi_debug);
|
||||
#else
|
||||
mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24, &mipi_debug);
|
||||
// mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0, 24, &mipi_debug);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PARA_IN_EN
|
||||
para_in_hareware_init();
|
||||
#endif
|
||||
|
||||
#if ISP_EN
|
||||
// debug_config();
|
||||
isp_cfg_dev();
|
||||
#endif
|
||||
#if VPP_EN
|
||||
{
|
||||
extern uint8_t set_vpp_bu1_shrink(uint16_t w, uint16_t shrink_w);
|
||||
extern void get_single_mipi(uint32_t csi_dev_id, uint16_t *w, uint16_t *h);
|
||||
uint16_t w = 0, h = 0;
|
||||
get_single_mipi(HG_MIPI_CSI_DEVID, &w, &h);
|
||||
os_printf(KERN_INFO "vpp_cfg w:%d h:%d\n", w, h);
|
||||
#ifdef SUB_STREAM_WIDTH
|
||||
set_vpp_bu1_shrink(w, SUB_STREAM_WIDTH);
|
||||
#endif
|
||||
vpp_cfg(w, h, VPP_INPUT_FROM);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LCD_EN
|
||||
|
||||
uint16_t osd_w, osd_h;
|
||||
uint16_t screen_w, screen_h;
|
||||
uint16_t video_w, video_h;
|
||||
uint8_t rotate, video_rotate;
|
||||
lcd_hardware_init(&osd_w, &osd_h, &rotate, &screen_w, &screen_h, &video_w, &video_h, &video_rotate);
|
||||
lcd_arg_setting(osd_w, osd_h, rotate, screen_w, screen_h, video_w, video_h, video_rotate);
|
||||
lcd_driver_init(R_OSD_ENCODE, R_LCD_OSD, R_VIDEO_P0, R_VIDEO_P1);
|
||||
|
||||
#endif
|
||||
|
||||
#if TOUCH_PAD_EN
|
||||
touch_pad_hareware_init();
|
||||
#endif
|
||||
|
||||
#if DUAL_EN
|
||||
void dorg_double_sensor(uint32 src0_w, uint32 src0_h, uint32 src1_w, uint32 src1_h, uint32 src0_raw_num, uint32 src1_raw_num, uint8_t dvp_type, uint8_t csi0_type, uint8_t csi1_type);
|
||||
dorg_double_sensor(1280, 720, 1280, 720, RAW8, RAW10, 1, 2, 3);
|
||||
#endif
|
||||
|
||||
#if AUDIO_EN
|
||||
reg_auproc_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_wsola_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_aucoder_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
aucode_mutex_init();
|
||||
audio_adc_init(AUSYS_AUAD, 8000, 1, 4, 0);
|
||||
audio_dac_init();
|
||||
#endif
|
||||
|
||||
#if RTT_USB_EN
|
||||
#ifdef RT_USING_USB_DEVICE
|
||||
extern rt_err_t rt_usbd_core_device_list_init();
|
||||
rt_usbd_core_device_list_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB11_EN && RTT_USB_EN)
|
||||
#if USB11_HOST_EN
|
||||
extern rt_err_t hg_usb11h_register(rt_uint32_t devid);
|
||||
hg_usb11h_register(HG_USB11_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usb11d_class_driver_register();
|
||||
extern int hg_usb11d_register(rt_uint32_t devid);
|
||||
hg_usb11d_class_driver_register();
|
||||
hg_usb11d_register(HG_USB11_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB_EN && RTT_USB_EN)
|
||||
#if (USB_DETECT_EN && !USB_HOST_EN)
|
||||
extern void hg_usb_connect_detect_init(void);
|
||||
hg_usb_connect_detect_init();
|
||||
#else
|
||||
#if USB_HOST_EN
|
||||
extern rt_err_t hg_usbh_register(rt_uint32_t devid);
|
||||
hg_usbh_register(HG_USB_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usbd_class_driver_register();
|
||||
extern int hg_usbd_register(rt_uint32_t devid);
|
||||
hg_usbd_class_driver_register();
|
||||
hg_usbd_register(HG_USB_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PRINTER_EN
|
||||
printer_thread_init();
|
||||
#endif
|
||||
|
||||
#if LCD_EN
|
||||
void lcd_demo_thread(int32_t d);
|
||||
void lvgl_init_msi(uint16_t w, uint16_t h, uint8_t rotate);
|
||||
|
||||
#if LVGL_HW_ROTATE_RPC_EN
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = _os_malloc,
|
||||
.realloc = _os_realloc,
|
||||
.zalloc = _os_zalloc,
|
||||
.free = _os_free,
|
||||
};
|
||||
#else
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = av_psram_malloc,
|
||||
.realloc = av_psram_realloc,
|
||||
.zalloc = av_psram_zalloc,
|
||||
.free = av_psram_free,
|
||||
};
|
||||
#endif
|
||||
hg_lv_mem_register(&hook);
|
||||
|
||||
lvgl_init_msi(osd_w, osd_h, rotate);
|
||||
// lcd_demo_thread(2);
|
||||
#endif
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
static struct os_work fpv_wk;
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
if (g_fpv_status.dbg_sram_heap)
|
||||
{
|
||||
sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
if (g_fpv_status.dbg_psram_heap)
|
||||
{
|
||||
sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
if (g_fpv_status.dbg_av_psram_heap)
|
||||
{
|
||||
sysheap_status(&av_psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
if (g_fpv_status.dbg_av_heap)
|
||||
{
|
||||
sysheap_status(&av_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 部分控制at命令
|
||||
void fpv_at_dbg()
|
||||
{
|
||||
// 是否打开对应sdk的dbg
|
||||
atcmd_recv((uint8_t *) "at+print=1,7", 0);
|
||||
atcmd_recv((uint8_t *) "AT+FPV_DBG=av_psram,0", 0);
|
||||
atcmd_recv((uint8_t *) "AT+FPV_DBG=av_sram,0", 0);
|
||||
atcmd_recv((uint8_t *) "AT+FPV_DBG=sram,0", 0);
|
||||
atcmd_recv((uint8_t *) "AT+FPV_DBG=psram,0", 0);
|
||||
atcmd_recv((uint8_t *) "AT+SYSDBG=top,0", 0);
|
||||
|
||||
#if 0
|
||||
//一次性命令
|
||||
atcmd_recv("AT+FPV_HEAP=av_psram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=av_sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=sram,0",0);
|
||||
atcmd_recv("AT+FPV_HEAP=psram,0",0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_fpv_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
// 初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH, NULL, 2048);
|
||||
hardware_init(vcam);
|
||||
fpv_app_init();
|
||||
fpv_at_dbg();
|
||||
OS_WORK_INIT(&fpv_wk, sys_fpv_loop, 0);
|
||||
os_run_work_delay(&fpv_wk, 1000);
|
||||
return 0;
|
||||
}
|
||||
306
project/app/app_tunning.c
Normal file
306
project/app/app_tunning.c
Normal file
@@ -0,0 +1,306 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "intercom/intercom.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
#include "lib/audio/audio_proc/audio_proc.h"
|
||||
#include "lib/audio/wsola/wsola_process.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
//#include "video_app/video_msi.h"
|
||||
#include "lib/lvgl_rotate_rpc/lvgl_rotate_msi.h"
|
||||
#include "fpv_mem.h"
|
||||
|
||||
int32 atcmd_recv(uint8 *data, int32 len);
|
||||
void user_workqueue_init(uint16 pri,void *stack,uint16 stack_size);
|
||||
extern void get_single_mipi(uint32_t csi_dev_id,uint16_t *w,uint16_t *h);
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
extern struct msi *auto_h264_msi_init(const char *auto_h264_name, uint8_t src_from0, uint16_t w0, uint16_t h0, uint8_t src_from1, uint16_t w1, uint16_t h1);
|
||||
extern struct msi *auto_jpg_msi_init(const char *auto_jpg_name, uint8_t which_jpg, uint8_t src_from);
|
||||
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
spook_init();
|
||||
config_Viidure(80);
|
||||
}
|
||||
|
||||
__init static void app_tunning_init(void)
|
||||
{
|
||||
#if JPG_EN == 1
|
||||
uint8_t takephoto_from = 0;
|
||||
#endif
|
||||
#if H264_EN == 1
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,~0,0,0);
|
||||
#endif
|
||||
|
||||
|
||||
#if JPG_EN == 1
|
||||
auto_jpg_msi_init(AUTO_JPG,JPGID0,takephoto_from);
|
||||
#endif
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h);
|
||||
isp_tunning_init(0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void scale2_mutex_init();
|
||||
static void hardware_init(uint8_t vcam)
|
||||
{
|
||||
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
#if KEY_MODULE_EN == 1
|
||||
keyWork_init(10);
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
extern int32 jpg_mutex_init();
|
||||
jpg_mutex_init();
|
||||
#endif
|
||||
//默认打开gen420的模块
|
||||
gen420_hardware_msi_init();
|
||||
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_ret = 0;
|
||||
bool csi_cfg();
|
||||
csi_ret = csi_cfg();
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_open();
|
||||
if (csi_ret)
|
||||
csi_open();
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
struct mipi_csi_debug mipi_debug;
|
||||
os_memset(&mipi_debug, 0, sizeof(struct mipi_csi_debug));
|
||||
mipi_debug.debug_enable = 0;
|
||||
mipi_debug.debug_io0 = PD_4;
|
||||
mipi_debug.debug_io1 = PD_5;
|
||||
mipi_debug.debug_io2 = PD_6;
|
||||
mipi_debug.debug_io3 = PD_7;
|
||||
mipi_debug.debug_io4 = PD_12;
|
||||
mipi_debug.debug_io5 = PD_13;
|
||||
mipi_debug.debug_type0 = 6;
|
||||
mipi_debug.debug_type1 = 7;
|
||||
mipi_debug.debug_type2 = 8;
|
||||
mipi_debug.debug_type3 = 9;
|
||||
mipi_debug.debug_type4 = 10;
|
||||
mipi_debug.debug_type5 = 11;
|
||||
int mipi_csi_hardware_config(uint32_t csi_dev_id, uint8_t init_en, uint8_t csi_data_lane_num, uint8_t dual_en, uint8_t dual_sensor_type, uint8_t mclk,struct mipi_csi_debug *p_debug);
|
||||
#if DVP_EN
|
||||
int ret;
|
||||
ret = mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, ret?SENSOR_TYPE_SLAVE1:SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
#else
|
||||
mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24, &mipi_debug);
|
||||
// mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24,&mipi_debug);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PARA_IN_EN
|
||||
para_in_hareware_init();
|
||||
#endif
|
||||
|
||||
#if ISP_EN
|
||||
// debug_config();
|
||||
isp_cfg_dev();
|
||||
#endif
|
||||
#if VPP_EN
|
||||
{
|
||||
uint16_t w = 0,h = 0;
|
||||
get_single_mipi(HG_MIPI_CSI_DEVID,&w,&h);
|
||||
os_printf(KERN_INFO"vpp_cfg w:%d h:%d\n",w,h);
|
||||
vpp_cfg(w, h, VPP_INPUT_FROM);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TOUCH_PAD_EN
|
||||
touch_pad_hareware_init();
|
||||
#endif
|
||||
|
||||
#if DUAL_EN
|
||||
{
|
||||
uint16_t w = 0,h = 0;
|
||||
get_single_mipi(HG_MIPI_CSI_DEVID,&w,&h);
|
||||
void dorg_double_sensor(uint32 src0_w,uint32 src0_h,uint32 src1_w,uint32 src1_h,uint32 src0_raw_num,uint32 src1_raw_num,uint8_t dvp_type,uint8_t csi0_type,uint8_t csi1_type);
|
||||
dorg_double_sensor(w, h, 0, 0, INPUT_MODE, 0,0,1,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AUDIO_EN
|
||||
reg_auproc_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_wsola_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_aucoder_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
aucode_mutex_init();
|
||||
audio_adc_init(AUSYS_AUAD, 8000, 1, 4, 0);
|
||||
audio_dac_init();
|
||||
#endif
|
||||
|
||||
#if RTT_USB_EN
|
||||
#ifdef RT_USING_USB_DEVICE
|
||||
extern rt_err_t rt_usbd_core_device_list_init();
|
||||
rt_usbd_core_device_list_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB11_EN && RTT_USB_EN)
|
||||
#if USB11_HOST_EN
|
||||
extern rt_err_t hg_usb11h_register(rt_uint32_t devid);
|
||||
hg_usb11h_register(HG_USB11_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usb11d_class_driver_register();
|
||||
extern int hg_usb11d_register(rt_uint32_t devid);
|
||||
hg_usb11d_class_driver_register();
|
||||
hg_usb11d_register(HG_USB11_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB_EN && RTT_USB_EN)
|
||||
#if (USB_DETECT_EN && !USB_HOST_EN)
|
||||
extern void hg_usb_connect_detect_init(void);
|
||||
hg_usb_connect_detect_init();
|
||||
#else
|
||||
#if USB_HOST_EN
|
||||
extern rt_err_t hg_usbh_register(rt_uint32_t devid);
|
||||
hg_usbh_register(HG_USB_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usbd_class_driver_register();
|
||||
extern int hg_usbd_register(rt_uint32_t devid);
|
||||
hg_usbd_class_driver_register();
|
||||
hg_usbd_register(HG_USB_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
static struct os_work fpv_wk;
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
uint32_t s_buf[256];
|
||||
sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
sysheap_status(&av_psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
sysheap_status(&av_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_isp_tunning_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
//初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH,NULL,2048);
|
||||
hardware_init(vcam);
|
||||
app_tunning_init();
|
||||
OS_WORK_INIT(&fpv_wk, sys_fpv_loop, 0);
|
||||
os_run_work_delay(&fpv_wk, 1000);
|
||||
return 0;
|
||||
}
|
||||
463
project/app/app_walkie_talkie.c
Normal file
463
project/app/app_walkie_talkie.c
Normal file
@@ -0,0 +1,463 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/net/eloop/eloop.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/mipi_csi/mipi_csi.h"
|
||||
#include "lib/video/h264/h264_drv.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/para_in/para_in_dev.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "stream_define.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#include "app_lcd/app_lcd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
|
||||
#include "audio_msi/audio_adc.h"
|
||||
#include "audio_msi/audio_dac.h"
|
||||
#include "intercom/intercom.h"
|
||||
#include "lib/audio/audio_code/audio_code.h"
|
||||
#include "lib/audio/audio_proc/audio_proc.h"
|
||||
#include "lib/audio/wsola/wsola_process.h"
|
||||
|
||||
#if RTT_USB_EN
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#include "lib/heap/av_psram_heap.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
#include "app/spook/spook.h"
|
||||
#include "app/recorder/recorder_viidure.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "ota.h"
|
||||
|
||||
#include "cjson/cJSON.h"
|
||||
#include "scale_msi/scale_msi.h"
|
||||
#include "lib/touch/touch_pad.h"
|
||||
#include "gen420_hardware_msi.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "hg_lv_mem.h"
|
||||
#include "keyWork.h"
|
||||
#include "video_app/video_msi.h"
|
||||
|
||||
#include "lib/lvgl_rotate_rpc/lvgl_rotate_msi.h"
|
||||
#include "debug_log_msi.h"
|
||||
#include "log_save_msi.h"
|
||||
#include "fpv_mem.h"
|
||||
#include "lib/flashdisk/flashdisk.h"
|
||||
#include "lib/lmac/lmac.h"
|
||||
|
||||
|
||||
int32 atcmd_recv(uint8 *data, int32 len);
|
||||
void user_workqueue_init(uint16 pri,void *stack,uint16 stack_size);
|
||||
|
||||
extern uint32 psrampool_start;
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
extern uint32 srampool_start;
|
||||
extern uint32 srampool_end;
|
||||
|
||||
|
||||
__weak void user_protocol()
|
||||
{
|
||||
// spook_init();
|
||||
// config_Viidure(80);
|
||||
}
|
||||
|
||||
// 应用程序初始化
|
||||
__init static void fpv_app_init(void)
|
||||
{
|
||||
#if TAKEPHOTO_EN || JPG_EN
|
||||
int8_t takephoto_from = 0;
|
||||
int8_t takephoto1_from = -1;
|
||||
#endif
|
||||
#ifdef PSRAM_HEAP
|
||||
cJSON_Hooks hook;
|
||||
hook.malloc_fn = _os_malloc_psram;
|
||||
hook.free_fn = _os_free_psram;
|
||||
cJSON_InitHooks(&hook);
|
||||
#endif
|
||||
|
||||
|
||||
eloop_init();
|
||||
os_task_create("eloop_run", user_eloop_run, NULL, OS_TASK_PRIORITY_NORMAL + 2, 0, NULL, 2048);
|
||||
os_sleep_ms(1);
|
||||
ota_Tcp_Server();
|
||||
|
||||
//独立的文件保存msi(独立线程,后续可以所有的fb需要保存都发到这个msi去执行)
|
||||
extern struct msi *file_msi_init(const char *msi_name);
|
||||
file_msi_init(R_FILE_MSI);
|
||||
#ifndef FORCE_SCALE_TO_H264
|
||||
#if H264_EN == 1
|
||||
extern struct msi *auto_h264_msi_init(const char *auto_h264_name, uint8_t src_from0, uint16_t w0, uint16_t h0, uint8_t src_from1, uint16_t w1, uint16_t h1);
|
||||
#if SUB_STREAM_EN == 1
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,GEN420_DATA,640,360);
|
||||
#else
|
||||
auto_h264_msi_init(AUTO_H264,VPP_DATA0,0,0,~0,0,0);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uint8_t get_vpp_scale_w_h(uint16_t *w, uint16_t *h);
|
||||
uint16_t scale_w,scale_h;
|
||||
int scale_ret = get_vpp_scale_w_h(&scale_w,&scale_h);
|
||||
if(!scale_ret)
|
||||
{
|
||||
os_printf(KERN_INFO"scale_w:%d\tscale_h:%d\n",scale_w,scale_h);
|
||||
auto_h264_msi_init(AUTO_H264,SCALER_DATA,scale_w,scale_h,GEN420_DATA,640,360);
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf(KERN_ERR"scale cfg err,scale_ret:%d\n",scale_ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// 支持拍照和缩略图,暂时默认启动,(紧紧支持录风者模式)
|
||||
#if TAKEPHOTO_EN
|
||||
// 正常拍照和缩略图
|
||||
{
|
||||
extern uint8_t get_vpp_w_h(uint16_t *w, uint16_t *h);
|
||||
extern void takephoto_with_thumb_init(const char *thumb_msi_name);
|
||||
extern void takephoto_with_thumb_over_dpi_init(const char *thumb_msi_name, uint8_t jpg_num);
|
||||
extern void takephoto_720P_with_thumb_init(const char *thumb_msi_name);
|
||||
uint16_t camera_w, camera_h;
|
||||
get_vpp_w_h(&camera_w, &camera_h);
|
||||
// 没有识别到摄像头
|
||||
if (!camera_w || !camera_h)
|
||||
{
|
||||
}
|
||||
// 如果是720P摄像头,支持原分辨率以及大分辨拍照
|
||||
else if (camera_w == 1280 && camera_h == 720)
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID0);
|
||||
takephoto_from = VPP_DATA0;
|
||||
}
|
||||
// 其他摄像头,主要是为了拍照720P的图片,1080P摄像头从VPP_DATA1,不支持大分辨率拍照
|
||||
else
|
||||
{
|
||||
takephoto_with_thumb_init(R_THUMB);
|
||||
takephoto_with_thumb_over_dpi_init(SR_OVER_DPI_THUMB_JPG, JPGID1);
|
||||
takephoto_from = VPP_DATA1;
|
||||
takephoto1_from = VPP_DATA0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
if(takephoto_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID0, takephoto_from);
|
||||
}
|
||||
|
||||
if(takephoto1_from >= 0)
|
||||
{
|
||||
auto_jpg_msi_init(AUTO_JPG, JPGID1, takephoto1_from);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if USB_JPG_ADD_WATERMARK
|
||||
usb_to_recode_init(JPGID1);
|
||||
#endif
|
||||
/*
|
||||
添加其他应用代码初始化
|
||||
...
|
||||
*/
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h);
|
||||
isp_tunning_init(1920, 1080);
|
||||
#endif
|
||||
#if !USE_CALLING_DEMO
|
||||
user_protocol();
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak void user_hardware_config()
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t vcam_en(void)
|
||||
{
|
||||
uint8_t ret = TRUE;
|
||||
#if VCAM_EN
|
||||
pmu_vcam_dis();
|
||||
os_sleep_ms(1);
|
||||
pmu_set_vcam_vol(VCAM_VOL_2V80);
|
||||
pmu_vcam_oc_set(VCAM_OC_200MA);
|
||||
pmu_vcam_lc_en();
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_vcam_discharge_dis();
|
||||
pmu_vcam_pg_dis();
|
||||
#ifdef VCAM_33
|
||||
pmu_set_vcam_vol(VCAM_VOL_3V25);
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
pmu_vcam_pg_en();
|
||||
#else
|
||||
pmu_vcam_en();
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
|
||||
pmu_vcam_oc_pending_clr();
|
||||
|
||||
pmu_vcam_oc_int_dis();
|
||||
pmu_lvd_oe_en();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void scale2_mutex_init();
|
||||
static void hardware_init(uint8_t vcam)
|
||||
{
|
||||
|
||||
void eff_stop();
|
||||
eff_stop();
|
||||
iic_thread_init();
|
||||
sensor_info_init();
|
||||
scale2_mutex_init();
|
||||
#if KEY_MODULE_EN == 1
|
||||
keyWork_init(10);
|
||||
#endif
|
||||
|
||||
#if JPG_EN == 1
|
||||
extern int32 jpg_mutex_init();
|
||||
extern void jpg_mem_init(int num);
|
||||
jpg_mutex_init();
|
||||
jpg_mem_init(32);
|
||||
#endif
|
||||
//默认打开gen420的模块
|
||||
gen420_hardware_msi_init();
|
||||
|
||||
#if SDH_EN && FS_EN
|
||||
extern bool fatfs_register();
|
||||
sd_open();
|
||||
fatfs_register();
|
||||
file_ota();
|
||||
#endif
|
||||
|
||||
#if FLASHDISK_EN
|
||||
flash_fatfs_init();
|
||||
#endif
|
||||
|
||||
#if DEBUG_LOG_FILE_SAVE_EN
|
||||
//默认写入到SD卡,不支持中断打印保存
|
||||
//默认每10秒同步写卡,每60秒新建一个文件保存
|
||||
creat_log_save_stream(R_DEBUG_STREAM, 1000, 60*1000);
|
||||
struct msi *dbg_msi = dbg_log_msi(S_DEBUG_STREAM);
|
||||
if(dbg_msi)
|
||||
{
|
||||
print_redirect((osprint_hook)hgprntf_debug_log_msi, dbg_msi->priv, 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_ret = 0;
|
||||
bool csi_cfg();
|
||||
csi_ret = csi_cfg();
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
bool csi_open();
|
||||
if (csi_ret)
|
||||
csi_open();
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
struct mipi_csi_debug mipi_debug;
|
||||
os_memset(&mipi_debug, 0, sizeof(struct mipi_csi_debug));
|
||||
mipi_debug.debug_enable = 0;
|
||||
mipi_debug.debug_io0 = PD_4;
|
||||
mipi_debug.debug_io1 = PD_5;
|
||||
mipi_debug.debug_io2 = PD_6;
|
||||
mipi_debug.debug_io3 = PD_7;
|
||||
mipi_debug.debug_type0 = 6;
|
||||
mipi_debug.debug_type1 = 7;
|
||||
mipi_debug.debug_type2 = 8;
|
||||
mipi_debug.debug_type3 = 9;
|
||||
int mipi_csi_hardware_config(uint32_t csi_dev_id, uint8_t init_en, uint8_t csi_data_lane_num, uint8_t dual_en, uint8_t dual_sensor_type, uint8_t mclk,struct mipi_csi_debug *p_debug);
|
||||
#if DVP_EN
|
||||
int ret;
|
||||
ret = mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, ret?SENSOR_TYPE_SLAVE1:SENSOR_TYPE_SLAVE0,24, &mipi_debug);
|
||||
#else
|
||||
mipi_csi_hardware_config(HG_MIPI_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_MASTER, 24, &mipi_debug);
|
||||
//mipi_csi_hardware_config(HG_MIPI1_CSI_DEVID, 1, 1, DUAL_EN, SENSOR_TYPE_SLAVE0, 24, &mipi_debug);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PARA_IN_EN
|
||||
para_in_hareware_init();
|
||||
#endif
|
||||
|
||||
#if ISP_EN
|
||||
// debug_config();
|
||||
isp_cfg_dev();
|
||||
#endif
|
||||
#if VPP_EN
|
||||
{
|
||||
extern uint8_t set_vpp_bu1_shrink(uint16_t w, uint16_t shrink_w);
|
||||
extern void get_single_mipi(uint32_t csi_dev_id,uint16_t *w,uint16_t *h);
|
||||
extern void get_single_dvp(uint16_t *w,uint16_t *h);
|
||||
uint16_t w = 0,h = 0;
|
||||
// get_single_mipi(HG_MIPI_CSI_DEVID,&w,&h);
|
||||
get_single_dvp(&w,&h);
|
||||
os_printf(KERN_INFO"vpp_cfg w:%d h:%d\n",w,h);
|
||||
#ifdef SUB_STREAM_WIDTH
|
||||
set_vpp_bu1_shrink(w,SUB_STREAM_WIDTH);
|
||||
#endif
|
||||
vpp_cfg(w, h, VPP_INPUT_FROM);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if LCD_EN
|
||||
|
||||
uint16_t osd_w, osd_h;
|
||||
uint16_t screen_w, screen_h;
|
||||
uint16_t video_w, video_h;
|
||||
uint8_t rotate, video_rotate;
|
||||
lcd_hardware_init(&osd_w, &osd_h, &rotate, &screen_w, &screen_h,&video_w, &video_h, &video_rotate);
|
||||
lcd_arg_setting(osd_w, osd_h, rotate, screen_w, screen_h,video_w,video_h, video_rotate);
|
||||
lcd_driver_init(R_OSD_ENCODE, R_LCD_OSD, R_VIDEO_P0, R_VIDEO_P1);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if TOUCH_PAD_EN
|
||||
touch_pad_hareware_init();
|
||||
#endif
|
||||
|
||||
#if DUAL_EN
|
||||
void dorg_double_sensor(uint32 src0_w,uint32 src0_h,uint32 src1_w,uint32 src1_h,uint32 src0_raw_num,uint32 src1_raw_num,uint8_t dvp_type,uint8_t csi0_type,uint8_t csi1_type);
|
||||
dorg_double_sensor(1280, 720, 1280, 720, RAW8, RAW10,1,2,3);
|
||||
#endif
|
||||
|
||||
#if AUDIO_EN
|
||||
reg_auproc_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_wsola_alloc(av_psram_malloc, av_psram_zalloc, av_psram_calloc, av_psram_realloc, av_psram_free);
|
||||
reg_aucoder_alloc(av_malloc, av_zalloc, av_calloc, av_realloc, av_free);
|
||||
aucode_mutex_init();
|
||||
audio_adc_init(AUSYS_AUAD, 8000, 1, 4, 1);
|
||||
audio_dac_init();
|
||||
#endif
|
||||
|
||||
#if RTT_USB_EN
|
||||
#ifdef RT_USING_USB_DEVICE
|
||||
extern rt_err_t rt_usbd_core_device_list_init();
|
||||
rt_usbd_core_device_list_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB11_EN && RTT_USB_EN)
|
||||
#if USB11_HOST_EN
|
||||
extern rt_err_t hg_usb11h_register(rt_uint32_t devid);
|
||||
hg_usb11h_register(HG_USB11_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usb11d_class_driver_register();
|
||||
extern int hg_usb11d_register(rt_uint32_t devid);
|
||||
hg_usb11d_class_driver_register();
|
||||
hg_usb11d_register(HG_USB11_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (USB_EN && RTT_USB_EN)
|
||||
#if (USB_DETECT_EN && !USB_HOST_EN)
|
||||
extern void hg_usb_connect_detect_init(void);
|
||||
hg_usb_connect_detect_init();
|
||||
#else
|
||||
#if USB_HOST_EN
|
||||
extern rt_err_t hg_usbh_register(rt_uint32_t devid);
|
||||
hg_usbh_register(HG_USB_HOST_CONTROLLER_DEVID);
|
||||
#else
|
||||
extern void hg_usbd_class_driver_register();
|
||||
extern int hg_usbd_register(rt_uint32_t devid);
|
||||
hg_usbd_class_driver_register();
|
||||
hg_usbd_register(HG_USB_DEV_CONTROLLER_DEVID);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if LCD_EN
|
||||
void lcd_demo_thread(int32_t d);
|
||||
void lvgl_init_msi(uint16_t w, uint16_t h, uint8_t rotate);
|
||||
|
||||
#if LVGL_HW_ROTATE_RPC_EN
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = _os_malloc,
|
||||
.realloc = _os_realloc,
|
||||
.zalloc = _os_zalloc,
|
||||
.free = _os_free,
|
||||
};
|
||||
#else
|
||||
struct hg_lv_mem_hooks hook = {
|
||||
.malloc = av_psram_malloc,
|
||||
.realloc = av_psram_realloc,
|
||||
.zalloc = av_psram_zalloc,
|
||||
.free = av_psram_free,
|
||||
};
|
||||
#endif
|
||||
hg_lv_mem_register(&hook);
|
||||
|
||||
lvgl_init_msi(osd_w, osd_h, rotate);
|
||||
// lcd_demo_thread(2);
|
||||
#endif
|
||||
user_hardware_config();
|
||||
}
|
||||
|
||||
static struct os_work fpv_wk;
|
||||
extern void print_status(uint32_t *s_buf, uint32_t size);
|
||||
static int32 sys_fpv_loop(struct os_work *work)
|
||||
{
|
||||
//uint32_t s_buf[256];
|
||||
|
||||
//sysheap_status(&sram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
//sysheap_status(&psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
//sysheap_status(&av_psram_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#endif
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
//sysheap_status(&av_heap, s_buf, sizeof(s_buf) / 4, 0);
|
||||
#endif
|
||||
|
||||
os_run_work_delay(work, 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* print_level设置打印的等级,7是将所有打印都打开(调试的时候可以打开)
|
||||
* 例子:对应不同等级参考string.h
|
||||
* os_printf(KERN_DEBUG"ABC"); //等级7
|
||||
* os_printf(KERN_EMERG"ABC"); //等级1
|
||||
* disable_print_color 是否关闭打印颜色(特定串口工具)
|
||||
*******************************************************************/
|
||||
int sys_app_walkie_talkie_init(void)
|
||||
{
|
||||
print_level(7);
|
||||
disable_print_color(1);
|
||||
uint8_t vcam;
|
||||
user_heap_init();
|
||||
vcam = vcam_en();
|
||||
pmu_vcam2_ldo_en(1, VCC_LDO_VOL_1V80);
|
||||
msi_core_init();
|
||||
//初始化fpv应用用的workqueue,注意这个workqueu是应用,尽量不要执行过长时间
|
||||
user_workqueue_init(OS_TASK_PRIORITY_HIGH,NULL,2048);
|
||||
hardware_init(vcam);
|
||||
fpv_app_init();
|
||||
|
||||
lmac_set_beacon_modulation(NULL, LMAC_RATE_NON_HT_RATE0);
|
||||
lmac_set_supp_rate(NULL, WIFI_TX_SUPP_RATE & 0xFFFFFFF0);
|
||||
|
||||
#if !USE_CALLING_DEMO
|
||||
intercom_send_enable(0);
|
||||
intercom_init();
|
||||
add_keycallback((key_callback)intercom_ctrl_key, NULL);
|
||||
#endif
|
||||
|
||||
OS_WORK_INIT(&fpv_wk, sys_fpv_loop, 0);
|
||||
os_run_work_delay(&fpv_wk, 1000);
|
||||
return 0;
|
||||
}
|
||||
146
project/app/fpv_mem.c
Normal file
146
project/app/fpv_mem.c
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* @file fpv_mem.c
|
||||
* @brief FPV 内存管理初始化模块
|
||||
* @details 本文件负责在系统启动时初始化用户空间的多个专用内存堆:
|
||||
* - av_psram_heap: 从片外 PSRAM 中分配,专用于音视频大数据缓冲
|
||||
* - av_heap: 从片内 SRAM 中分配,专用于音视频快速处理
|
||||
* 采用内存池(MPOOL_ALLOC)模式,在编译期确定各堆大小,
|
||||
* 运行时从系统堆中切分出专用区域,以减少内存碎片并提高分配效率。
|
||||
*/
|
||||
|
||||
#include "sys_config.h" // 包含系统配置宏定义,如 MPOOL_ALLOC、AV_PSRAM_HEAP 等
|
||||
#include "basic_include.h" // 包含基础类型定义(uint32 等)和基础宏
|
||||
#include "osal/string.h" // 包含操作系统抽象层字符串/打印接口(os_printf 等)
|
||||
#include "lib/heap/av_psram_heap.h" // 包含音视频 PSRAM 堆的初始化接口声明
|
||||
#include "lib/heap/av_heap.h" // 包含音视频 SRAM 堆的初始化接口声明
|
||||
|
||||
// 通用用户空间内存初始化
|
||||
// 通用用户空间内存初始化入口函数
|
||||
|
||||
/**
|
||||
* @brief 用户空间内存堆初始化
|
||||
* @details 在系统启动阶段调用,依次完成以下工作:
|
||||
* 1. 若启用了 PSRAM 音视频堆(AV_PSRAM_HEAP),从片外 PSRAM 分配一大块连续内存,
|
||||
* 作为音视频专用的 psram 堆,支持大容量缓冲(如视频帧缓冲区)。
|
||||
* 2. 若启用了 SRAM 音视频堆(AV_HEAP),从片内 SRAM 分配一块内存,
|
||||
* 作为音视频专用的 sram 堆,利用 SRAM 的高速访问特性进行音视频编解码处理。
|
||||
* 为使 av_heap 尽量位于 SRAM 高地址区域(避免与系统堆碎片混合),
|
||||
* 先申请一大块占位空间,再释放该空间。
|
||||
* @param 无参数
|
||||
* @return 无返回值
|
||||
*/
|
||||
void user_heap_init()
|
||||
{
|
||||
_os_printf("\r\n"); // 打印空行,作为内存初始化信息输出的起始分隔
|
||||
os_printf("--------------------------------------------------------------------\r\n"); // 打印分隔线,便于在串口日志中识别内存初始化区域
|
||||
|
||||
/*
|
||||
* ==================== 第一部分:PSRAM 音视频堆初始化 ====================
|
||||
* 条件编译:仅当同时定义了以下三个宏时才编译此段代码:
|
||||
* MPOOL_ALLOC - 启用内存池分配模式
|
||||
* AV_PSRAM_HEAP - 启用音视频 PSRAM 堆
|
||||
* PSRAM_HEAP - 系统支持 PSRAM 堆
|
||||
* PSRAM(Pseudo-SRAM)是片外扩展内存,容量大但速度比片内 SRAM 慢,
|
||||
* 适合存放视频帧数据等大块缓冲区。
|
||||
*/
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
{
|
||||
// 设置堆的属性标志:
|
||||
// SYSHEAP_FLAGS_MEM_ALIGN_32 - 所有分配的内存按 32 字节对齐,
|
||||
// 适配 DMA 传输和 SIMD 指令的对其要求
|
||||
// SYSHEAP_FLAGS_MEM_LEAK_TRACE - 启用内存泄漏追踪,
|
||||
// 在调试阶段记录每次分配/释放,便于排查泄漏
|
||||
uint32 flags = SYSHEAP_FLAGS_MEM_ALIGN_32 | SYSHEAP_FLAGS_MEM_LEAK_TRACE;
|
||||
|
||||
// 从 PSRAM 系统堆中分配一块大小为 CONFIG_PSRAM_AVHEAP_SIZE 的连续内存,
|
||||
// 用于后续初始化为音视频专用的 PSRAM 堆
|
||||
void *av_psram_buf = os_malloc_psram(CONFIG_PSRAM_AVHEAP_SIZE);
|
||||
|
||||
// 保存分配到的 PSRAM 内存块大小,供后续初始化函数和日志打印使用
|
||||
uint32_t av_psram_size = CONFIG_PSRAM_AVHEAP_SIZE;
|
||||
|
||||
// 打印 PSRAM 音视频堆的地址范围和大小信息,
|
||||
// 方便开发者在串口日志中确认内存分配是否正确
|
||||
os_printf("| CPU0 AV_PSRAM_HEAP : %p ~ %p, Size:%-8d |\r\n", av_psram_buf, av_psram_buf+av_psram_size, av_psram_size);
|
||||
|
||||
// 检查 PSRAM 内存是否分配成功,只有成功时才进行堆初始化
|
||||
if (av_psram_buf)
|
||||
{
|
||||
// 使用分配到的 PSRAM 内存块和指定的标志位,初始化音视频 PSRAM 堆,
|
||||
// 初始化后可通过 av_psram_malloc() 等接口从此堆中分配内存
|
||||
av_psram_heap_init((void *) av_psram_buf, av_psram_size, flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ==================== 第二部分:SRAM 音视频堆初始化 ====================
|
||||
* 条件编译:仅当同时定义了以下两个宏时才编译此段代码:
|
||||
* MPOOL_ALLOC - 启用内存池分配模式
|
||||
* AV_HEAP - 启用音视频 SRAM 堆
|
||||
* SRAM 是片内高速内存,容量小但访问速度快,
|
||||
* 适合存放音视频编解码过程中的临时数据结构和控制信息。
|
||||
*
|
||||
* 关键技巧:为了让 av_heap 尽量位于 SRAM 高地址区域,避免与系统运行时
|
||||
* 动态分配的碎片化内存混在一起,这里采用"占位-释放"策略:
|
||||
* 1. 先查询 SRAM 系统堆剩余总空间
|
||||
* 2. 如果剩余空间远大于所需 av_heap 大小,先申请一大块"占位"空间
|
||||
* 3. 然后再申请 av_heap 所需的空间(此时 av_heap 就被推到了高地址)
|
||||
* 4. 最后释放占位空间,归还给系统堆
|
||||
*/
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
{
|
||||
// 设置 SRAM 音视频堆的属性标志:
|
||||
// SYSHEAP_FLAGS_MEM_ALIGN_32 - 32 字节对齐,满足 DMA 和缓存行对齐要求
|
||||
// 注意:此处未启用 SYSHEAP_FLAGS_MEM_LEAK_TRACE,因为 SRAM 堆用于高频
|
||||
// 临时分配,启用追踪会显著影响性能
|
||||
uint32 flags = SYSHEAP_FLAGS_MEM_ALIGN_32;
|
||||
|
||||
// 占位空间的指针,初始为 NULL,稍后根据剩余空间情况决定是否分配
|
||||
void *rev_mem_head = NULL;
|
||||
|
||||
// 获取配置中定义的音视频 SRAM 堆大小(字节数)
|
||||
uint32_t sram_size = CONFIG_AVHEAP_SIZE;
|
||||
|
||||
//计算SRAM_HEAP剩余空间
|
||||
// 查询当前 SRAM 系统堆(sram_heap)中剩余可用的总字节数,
|
||||
// 用于判断是否有足够空间分配 av_heap 以及是否需要占位
|
||||
uint32_t total_mem_remain_size = sysheap_freesize(&sram_heap);
|
||||
|
||||
// 如果剩余空间大于 av_heap 所需大小 + 1024 字节(预留安全余量),
|
||||
// 则先分配占位空间,将 av_heap 推向高地址区域
|
||||
if(total_mem_remain_size > sram_size + 1024)
|
||||
{
|
||||
//申请空间,尽量将av_sram空间放到最后
|
||||
// 计算占位空间大小 = 剩余总量 - av_heap所需 - 1024(安全余量),
|
||||
// 申请这块空间后,后续 av_heap 的分配就会被挤到 SRAM 的高地址端
|
||||
rev_mem_head = (void*)os_malloc(total_mem_remain_size - sram_size - 1024);
|
||||
}
|
||||
|
||||
// 正式分配音视频 SRAM 堆所需的内存块,
|
||||
// 由于前面可能已有占位分配,此块内存将位于 SRAM 较高地址区域
|
||||
uint8_t *sram_buf = (uint8_t*)os_malloc(sram_size);
|
||||
|
||||
// 打印 SRAM 音视频堆的地址范围和大小信息
|
||||
os_printf("| CPU0 AV_HEAP : %p ~ %p, Size:%-8d |\r\n", sram_buf, sram_buf+sram_size, sram_size);
|
||||
|
||||
// 检查 SRAM 内存是否分配成功,只有成功时才进行堆初始化
|
||||
if(sram_buf)
|
||||
{
|
||||
// 使用分配到的 SRAM 内存块和指定的标志位,初始化音视频 SRAM 堆,
|
||||
// 初始化后可通过 av_malloc() 等接口从此堆中分配高速内存
|
||||
av_heap_init((void *) sram_buf, sram_size, flags);
|
||||
}
|
||||
|
||||
// 如果之前分配了占位空间,现在释放它,归还给 SRAM 系统堆,
|
||||
// 这样系统堆仍可使用这块低地址空间,而 av_heap 已固定在高地址
|
||||
if(rev_mem_head)
|
||||
{
|
||||
os_free(rev_mem_head);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
os_printf("--------------------------------------------------------------------\r\n"); // 打印分隔线,标记内存初始化信息输出结束
|
||||
}
|
||||
4
project/app/fpv_mem.h
Normal file
4
project/app/fpv_mem.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef __FPV_MEM_H
|
||||
#define __FPV_MEM_H
|
||||
void user_heap_init();
|
||||
#endif
|
||||
10
project/app/user_app.h
Normal file
10
project/app/user_app.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __USER_APP_H
|
||||
#define __USER_APP_H
|
||||
int sys_app_bbm_cam_init(void);
|
||||
int sys_app_bbm_lcd_init(void);
|
||||
int sys_app_walkie_talkie_init(void);
|
||||
int sys_app_fpv_init(void);
|
||||
|
||||
void sys_wifi_pair_init();
|
||||
|
||||
#endif
|
||||
123
project/atcmd.c
Normal file
123
project/atcmd.c
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "syscfg.h"
|
||||
#include "media_test_demo/media_test_demo.h"
|
||||
#include "print_audio/print_audio.h"
|
||||
extern int32 fpv_atcmd_check_heap(const char *cmd, char *argv[], uint32 argc);
|
||||
int32 fpv_atcmd_dbg(const char *cmd, char *argv[], uint32 argc);
|
||||
extern int32 cpu1_atcmd_recv(char *data, uint32 len);
|
||||
|
||||
#ifdef SYS_APP_BBM_LCD
|
||||
int32 atcmd_babyprotocol_change_larger(const char *cmd, char *argv[], uint32 argc);
|
||||
int32 atcmd_babyprotocol_switch_device(const char *cmd, char *argv[], uint32 argc);
|
||||
int32 atcmd_intercom_switch_device(const char *cmd, char *argv[], uint32 argc);
|
||||
#endif
|
||||
#ifdef SYS_APP_BBM_CAM
|
||||
int32 atcmd_bbm_client_playback(const char *cmd, char *argv[], uint32 argc);
|
||||
int32 atcmd_bbm_client_record(const char *cmd, char *argv[], uint32 argc);
|
||||
#endif
|
||||
|
||||
int32 sys_empty_atcmd(const char *cmd, char *argv[], uint32 argc)
|
||||
{
|
||||
char *str = argv[0];
|
||||
int32 len = argc;
|
||||
if(os_strncmp("xxx", str, 3) == 0){ //自定义cmd
|
||||
//执行自定义AT命令
|
||||
}else{ //默认传递给cpu1
|
||||
if(os_strncasecmp(str, "AT1+", 4) == 0){
|
||||
str[1]='A'; str[2]='T';
|
||||
str++; len--;
|
||||
}
|
||||
cpu1_atcmd_recv(str, len);
|
||||
}
|
||||
return ATCMD_RESULT_DONE;
|
||||
}
|
||||
|
||||
static const struct hgic_atcmd static_atcmds[] = {
|
||||
///////////////////////////////////////////////////
|
||||
/* 常用调试 AT指令 */
|
||||
{ "AT+RST", sys_atcmd_reset },
|
||||
{ "AT+JTAG", sys_atcmd_jtag },
|
||||
{ "AT+SYSDBG", sys_atcmd_sysdbg },
|
||||
{ "AT+SYSCFG", sys_syscfg_dump_hdl },
|
||||
{ "AT+FWUPG", xmodem_fwupgrade_hdl },
|
||||
{ "AT+ERRLOG", sys_atcmd_errlog },
|
||||
{ "AT+LOADDEF", sys_atcmd_loaddef },
|
||||
{ "AT+HEAP", sys_heap_dump_hdl },
|
||||
{ "AT+INMAP", sys_get_gpio_imap},
|
||||
{ "AT+OUTMAP", sys_get_gpio_omap},
|
||||
{ NULL, sys_empty_atcmd}, //用于调用cpu1的atcmd
|
||||
|
||||
/* WiFi参数设置 AT指令 */
|
||||
{ "AT+CHANNEL", sys_wifi_atcmd_set_channel },
|
||||
{ "AT+BSSID", sys_wifi_atcmd_set_bssid },
|
||||
{ "AT+ENCRYPT", sys_wifi_atcmd_set_encrypt },
|
||||
{ "AT+SSID", sys_wifi_atcmd_set_ssid },
|
||||
{ "AT+KEY", sys_wifi_atcmd_set_key },
|
||||
{ "AT+WIFIMODE", sys_wifi_atcmd_set_wifimode },
|
||||
{ "AT+SCAN", sys_wifi_atcmd_scan },
|
||||
{ "AT+PAIR", sys_wifi_atcmd_pair },
|
||||
{ "AT+APHIDE", sys_wifi_atcmd_aphide },
|
||||
{ "AT+HWMODE", sys_wifi_atcmd_hwmode },
|
||||
|
||||
#if BLE_SUPPORT
|
||||
{ "AT+BLENC", sys_ble_atcmd_blenc },
|
||||
{ "AT+BLE_COEXIST", sys_ble_atcmd_set_coexist_en },
|
||||
#endif
|
||||
// { "AT+WIFICSA", sys_wifi_atcmd_wificsa },
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/* 应用/测试 AT指令 */
|
||||
{ "AT+PING", sys_atcmd_ping },
|
||||
{ "AT+IPERF2", sys_atcmd_iperf2},
|
||||
//{ "AT+TCPTEST", tcp_test_atcmd_hdl },
|
||||
{ "AT+ICMP_MNTR", sys_atcmd_icmp_mntr },
|
||||
|
||||
// { "AT+PCAP", sys_wifi_atcmd_pcap },
|
||||
|
||||
{ "AT+SAVE_AUDIO", atcmd_save_audio },
|
||||
{ "AT+PLAY_AUDIO", atcmd_play_audio },
|
||||
{ "AT+PRINT_AUDIO", atcmd_print_audio_enable },
|
||||
/*
|
||||
继续添加其他AT命令
|
||||
....
|
||||
*/
|
||||
///////////////////////////////////////////////////
|
||||
#ifdef CONFIG_SLEEP
|
||||
/* 休眠相关AT指令 */
|
||||
// { "AT+SLEEP_DBG", atcmd_sleep_dbg_hdl },
|
||||
{ "AT+SLEEP", atcmd_sleep_hdl },
|
||||
// { "AT+DTIM", atcmd_dtim_hdl },
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_FPV
|
||||
{ "AT+FPV_HEAP", fpv_atcmd_check_heap },
|
||||
{ "AT+FPV_DBG", fpv_atcmd_dbg },
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_BBM_LCD
|
||||
{ "AT+SWITCH_VIDEO", atcmd_babyprotocol_switch_device },
|
||||
{ "AT+SWITCH_AUDIO", atcmd_intercom_switch_device },
|
||||
{ "AT+CHANGE_LARGE", atcmd_babyprotocol_change_larger },
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_BBM_CAM
|
||||
{ "AT+RECORD", atcmd_bbm_client_record },
|
||||
{ "AT+PLAYBACK", atcmd_bbm_client_playback },
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
__init void sys_atcmd_init(void)
|
||||
{
|
||||
struct atcmd_settings setting;
|
||||
os_memset(&setting, 0, sizeof(setting));
|
||||
setting.args_count = ATCMD_ARGS_COUNT;
|
||||
setting.printbuf_size = ATCMD_PRINT_BUF_SIZE;
|
||||
setting.static_atcmds = static_atcmds;
|
||||
setting.static_cmdcnt = ARRAY_SIZE(static_atcmds);
|
||||
atcmd_uart_init(ATCMD_UARTDEV, 921600, 5, &setting);
|
||||
}
|
||||
|
||||
67
project/ble_netconfig.c
Normal file
67
project/ble_netconfig.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/net/skmonitor/skmonitor.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
#include "lib/net/uhttpd/uhttpd.h"
|
||||
#include "lib/umac/ieee80211.h"
|
||||
#include "lib/net/utils.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "lwip/apps/netbiosns.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "syscfg.h"
|
||||
#include "lib/bluetooth/uble/ble_demo.h"
|
||||
|
||||
/* BLE 配网 */
|
||||
#if SYS_APP_BLENC
|
||||
#define BLE_NETCONFIG_OK "network_connect_succ"
|
||||
|
||||
void sys_event_ble_netconfig(uint32 event_id, uint32 data, uint32 priv)
|
||||
{
|
||||
switch (event_id) {
|
||||
case SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_CONNECTTED):
|
||||
#if BLE_PROV_MODE == 2
|
||||
os_printf(KERN_NOTICE"WiFi Connected, BLE Notify: %s\r\n", BLE_NETCONFIG_OK);
|
||||
uble_gatt_notify(10, (uint8 *)BLE_NETCONFIG_OK, os_strlen(BLE_NETCONFIG_OK));
|
||||
os_sleep(1);
|
||||
os_printf(KERN_NOTICE"BLE Close!\r\n");
|
||||
ble_set_mode(0, 38); //close BLE
|
||||
ble_set_coexist_en(0, 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SYS_EVENT(SYS_EVENT_BLE, SYSEVT_BLE_NETWORK_CONFIGURED):
|
||||
wpa_passphrase(sys_cfgs.ssid, (char *)sys_cfgs.passwd, sys_cfgs.psk);
|
||||
sys_cfgs.wifi_mode = WIFI_MODE_STA;
|
||||
syscfg_save();
|
||||
|
||||
ieee80211_iface_stop(WIFI_MODE_AP);
|
||||
ieee80211_iface_stop(WIFI_MODE_STA);
|
||||
wificfg_flush(WIFI_MODE_STA);
|
||||
netdev_set_wifi_mode((struct netdev *)dev_get(HG_WIFI0_DEVID), WIFI_MODE_STA);
|
||||
ieee80211_iface_start(WIFI_MODE_STA);
|
||||
#if BLE_PROV_MODE == 1
|
||||
ble_set_mode(0, 38);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
__init void sys_ble_netconfig_init()
|
||||
{
|
||||
ble_demo_init();
|
||||
#if BLE_PROV_MODE == 1
|
||||
ble_set_mode(1, 38);
|
||||
#elif BLE_PROV_MODE == 2
|
||||
ble_set_coexist_en(1, 0);
|
||||
ble_set_mode(3, 38);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
24
project/cdkws.mk
Normal file
24
project/cdkws.mk
Normal file
@@ -0,0 +1,24 @@
|
||||
.PHONY: clean All Project_Title Project_PreBuild Project_Build Project_PostBuild
|
||||
|
||||
All: Project_Title Project_PreBuild Project_Build Project_PostBuild
|
||||
|
||||
Project_Title:
|
||||
@echo "----------Building project:[ txw82xApp - FLASH ]----------"
|
||||
|
||||
Project_PreBuild:
|
||||
@echo Executing Pre Build commands ...
|
||||
@export CDKPath="C:/Users/xtell/AppData/Roaming/C-Sky/CDK" CDK_VERSION="V2.24.19" CPU="E804DF" ProjectName="txw82xApp" ProjectPath="C:/Users/xtell/Downloads/TXW82x_FPV-v2.7.0.7-42229_20260430172604/TXW82x_FPV-v2.7.0.7-42229/TXW82x_FPV-v2.7.0.7-42229/project/" && C:/Users/xtell/Downloads/TXW82x_FPV-v2.7.0.7-42229_20260430172604/TXW82x_FPV-v2.7.0.7-42229/TXW82x_FPV-v2.7.0.7-42229/project/prebuild.sh $<
|
||||
@echo Done
|
||||
|
||||
Project_Build:
|
||||
@make -r -f txw82xApp.mk -j 8 -C ./
|
||||
|
||||
Project_PostBuild:
|
||||
@echo Executing Post Build commands ...
|
||||
@export CDKPath="C:/Users/xtell/AppData/Roaming/C-Sky/CDK" CDK_VERSION="V2.24.19" CPU="E804DF" ProjectName="txw82xApp" ProjectPath="C:/Users/xtell/Downloads/TXW82x_FPV-v2.7.0.7-42229_20260430172604/TXW82x_FPV-v2.7.0.7-42229/TXW82x_FPV-v2.7.0.7-42229/project/" && C:/Users/xtell/Downloads/TXW82x_FPV-v2.7.0.7-42229_20260430172604/TXW82x_FPV-v2.7.0.7-42229/TXW82x_FPV-v2.7.0.7-42229/project/BuildBIN.sh
|
||||
@echo Done
|
||||
|
||||
|
||||
clean:
|
||||
@echo "----------Cleaning project:[ txw82xApp - FLASH ]----------"
|
||||
|
||||
38
project/cfg/TXW827_C08_GC2053_IPC_V1.0_20250829.cfg
Normal file
38
project/cfg/TXW827_C08_GC2053_IPC_V1.0_20250829.cfg
Normal file
@@ -0,0 +1,38 @@
|
||||
// 双斜杠是注释
|
||||
// 如果为空,则会赋值为0xff,或者写 PIN_DEFAULT
|
||||
// 这里的配置要与pin_param.h的一样,否则可能不会配置成功
|
||||
|
||||
//这个配置的版号:TXW827_C08_GC2053_IPC_V1.0_20250829
|
||||
|
||||
//串口的io
|
||||
PIN_UART0_TX = PC_1
|
||||
PIN_UART0_RX = PC_0
|
||||
|
||||
//sd卡的io
|
||||
PIN_SDH_CLK = PD_5
|
||||
PIN_SDH_CMD = PD_4
|
||||
PIN_SDH_DAT0 = PD_6
|
||||
PIN_SDH_DAT1 = PD_7
|
||||
PIN_SDH_DAT2 = PD_2
|
||||
PIN_SDH_DAT3 = PD_3
|
||||
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_RESET = PC_12
|
||||
//摄像头mclk的io
|
||||
PIN_PWM_CHANNEL_0 = PC_9
|
||||
|
||||
PIN_CSI0_PDN = PC_13
|
||||
|
||||
//mipi的io
|
||||
PIN_MIPI_CSI0_CLKN = PA_5
|
||||
PIN_MIPI_CSI0_CLKP = PA_4
|
||||
PIN_MIPI_CSI0_D0N = PA_3
|
||||
PIN_MIPI_CSI0_D0P = PA_2
|
||||
PIN_MIPI_CSI0_D1N_CSI1_D0N = PA_1
|
||||
PIN_MIPI_CSI0_D1P_CSI1_D0P = PA_0
|
||||
|
||||
|
||||
//mipi0摄像头的iic
|
||||
PIN_MIPI0_IIC_CLK = PC_11
|
||||
PIN_MIPI0_IIC_SDA = PC_10
|
||||
@@ -0,0 +1,54 @@
|
||||
//串口的io
|
||||
PIN_UART0_TX = PC_6
|
||||
PIN_UART0_RX = PC_7
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_PDN = PC_9
|
||||
|
||||
//DVP
|
||||
PIN_DVP_HSYNC = PB_7
|
||||
PIN_DVP_VSYNC = PB_6
|
||||
PIN_DVP_PCLK = PB_12
|
||||
PIN_DVP_MCLK = PB_9
|
||||
PIN_DVP_DATA0 = PB_14
|
||||
PIN_DVP_DATA1 = PC_0
|
||||
PIN_DVP_DATA2 = PC_1
|
||||
PIN_DVP_DATA3 = PB_15
|
||||
PIN_DVP_DATA4 = PB_13
|
||||
PIN_DVP_DATA5 = PB_11
|
||||
PIN_DVP_DATA6 = PB_10
|
||||
PIN_DVP_DATA7 = PB_8
|
||||
|
||||
|
||||
//DVP摄像头IIC
|
||||
PIN_DVP0_IIC_SDA = PC_10
|
||||
PIN_DVP0_IIC_CLK = PC_11
|
||||
|
||||
//LCD的配置
|
||||
PIN_MIPI_DSI_CLKN = PD_7
|
||||
PIN_MIPI_DSI_CLKP = PD_6
|
||||
PIN_MIPI_DSI_D0N = PD_5
|
||||
PIN_MIPI_DSI_D0P = PD_4
|
||||
PIN_MIPI_DSI_D1N = PD_3
|
||||
PIN_MIPI_DSI_D1P = PD_2
|
||||
|
||||
LCD_VS_CS = PD_7
|
||||
LCD_HS_DC = PD_6
|
||||
LCD_DOTCLK_RWR = PD_5
|
||||
LCD_D0 = PD_4
|
||||
LCD_D1 = PD_3
|
||||
LCD_D2 = PD_2
|
||||
LCD_D3 = PD_1
|
||||
LCD_D4 = PD_0
|
||||
LCD_D5 = PA_0
|
||||
LCD_D6 = PA_1
|
||||
LCD_D7 = PA_2
|
||||
|
||||
PIN_ADKEY1 = PA_15
|
||||
BAT_ADC_IO = PA_4
|
||||
|
||||
PIN_LMAC_FEM_RF_TX_EN = PC_12
|
||||
PIN_LMAC_FEM_RF_RX_EN = PC_13
|
||||
|
||||
LCD_BACKLIGHT_IO = PA_3
|
||||
MUTE_PORT_IO = PC_8
|
||||
37
project/cfg/ipc_NO25_444.cfg
Normal file
37
project/cfg/ipc_NO25_444.cfg
Normal file
@@ -0,0 +1,37 @@
|
||||
// 双斜杠是注释
|
||||
// 如果为空,则会赋值为0xff,或者写 PIN_DEFAULT
|
||||
// 这里的配置要与pin_param.h的一样,否则可能不会配置成功
|
||||
|
||||
//这个配置的版号:NO.25-444
|
||||
|
||||
//串口的io
|
||||
PIN_UART0_TX = PA_7
|
||||
PIN_UART0_RX = PA_6
|
||||
|
||||
//sd卡的io
|
||||
PIN_SDH_CLK = PB_9
|
||||
PIN_SDH_CMD = PC_0
|
||||
PIN_SDH_DAT0 = PC_1
|
||||
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_PDN = PC_9
|
||||
//摄像头mclk的io
|
||||
PIN_PWM_CHANNEL_0 = PC_10
|
||||
|
||||
|
||||
|
||||
//mipi的io
|
||||
PIN_MIPI_CSI0_CLKN = PA_5
|
||||
PIN_MIPI_CSI0_CLKP = PA_4
|
||||
PIN_MIPI_CSI0_D0N = PA_3
|
||||
PIN_MIPI_CSI0_D0P = PA_2
|
||||
PIN_MIPI_CSI0_D1N_CSI1_D0N = PD_0
|
||||
PIN_MIPI_CSI0_D1P_CSI1_D0P = PD_1
|
||||
PIN_MIPI_CSI1_CLKN = PA_1
|
||||
PIN_MIPI_CSI1_CLKP = PA_0
|
||||
|
||||
|
||||
//mipi0摄像头的iic
|
||||
PIN_MIPI0_IIC_CLK = PC_12
|
||||
PIN_MIPI0_IIC_SDA = PC_11
|
||||
37
project/cfg/ipc_NO25_458.cfg
Normal file
37
project/cfg/ipc_NO25_458.cfg
Normal file
@@ -0,0 +1,37 @@
|
||||
// 双斜杠是注释
|
||||
// 如果为空,则会赋值为0xff,或者写 PIN_DEFAULT
|
||||
// 这里的配置要与pin_param.h的一样,否则可能不会配置成功
|
||||
|
||||
//这个配置的版号:NO.25-458
|
||||
|
||||
//串口的io
|
||||
PIN_UART0_TX = PC_7
|
||||
PIN_UART0_RX = PC_6
|
||||
|
||||
//sd卡的io
|
||||
PIN_SDH_CLK = PC_15
|
||||
PIN_SDH_CMD = PC_14
|
||||
PIN_SDH_DAT0 = PD_14
|
||||
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_RESET = PC_12
|
||||
//摄像头mclk的io
|
||||
PIN_PWM_CHANNEL_0 = PC_9
|
||||
|
||||
|
||||
|
||||
//mipi的io
|
||||
PIN_MIPI_CSI0_CLKN = PA_5
|
||||
PIN_MIPI_CSI0_CLKP = PA_4
|
||||
PIN_MIPI_CSI0_D0N = PA_3
|
||||
PIN_MIPI_CSI0_D0P = PA_2
|
||||
PIN_MIPI_CSI0_D1N_CSI1_D0N = PD_0
|
||||
PIN_MIPI_CSI0_D1P_CSI1_D0P = PD_1
|
||||
PIN_MIPI_CSI1_CLKN = PA_1
|
||||
PIN_MIPI_CSI1_CLKP = PA_0
|
||||
|
||||
|
||||
//mipi0摄像头的iic
|
||||
PIN_MIPI0_IIC_CLK = PC_10
|
||||
PIN_MIPI0_IIC_SDA = PC_11
|
||||
83
project/cfg/学习板_NO25_439.cfg
Normal file
83
project/cfg/学习板_NO25_439.cfg
Normal file
@@ -0,0 +1,83 @@
|
||||
//这个配置是学习板,板号:NO.25-439
|
||||
//这个配置是双摄像头的配置,配置了lcd
|
||||
|
||||
//串口的io
|
||||
PIN_UART0_TX = PA_11
|
||||
PIN_UART0_RX = PA_12
|
||||
|
||||
//sd卡的io
|
||||
PIN_SDH_CLK = PA_13
|
||||
PIN_SDH_CMD = PA_6
|
||||
PIN_SDH_DAT0 = PA_7
|
||||
//SDH CLK 驱动能力 GPIO_DS_G2
|
||||
PIN_SDH_CLK_DRI_STRENGTH = PA_2
|
||||
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_PDN = PC_9
|
||||
|
||||
//DVP
|
||||
PIN_DVP_HSYNC = PB_7
|
||||
PIN_DVP_VSYNC = PB_6
|
||||
PIN_DVP_PCLK = PB_12
|
||||
PIN_DVP_MCLK = PB_9
|
||||
PIN_DVP_DATA0 = PB_14
|
||||
PIN_DVP_DATA1 = PC_0
|
||||
PIN_DVP_DATA2 = PC_1
|
||||
PIN_DVP_DATA3 = PB_15
|
||||
PIN_DVP_DATA4 = PB_13
|
||||
PIN_DVP_DATA5 = PB_11
|
||||
PIN_DVP_DATA6 = PB_10
|
||||
PIN_DVP_DATA7 = PB_8
|
||||
|
||||
//摄像头mclk的io
|
||||
PIN_PWM_CHANNEL_0 = PE_0
|
||||
|
||||
|
||||
|
||||
//mipi的io
|
||||
PIN_MIPI_CSI0_CLKN = PA_2
|
||||
PIN_MIPI_CSI0_CLKP = PA_3
|
||||
PIN_MIPI_CSI0_D0N = PA_5
|
||||
PIN_MIPI_CSI0_D0P = PA_4
|
||||
PIN_MIPI_CSI0_D1N_CSI1_D0N = PD_0
|
||||
PIN_MIPI_CSI0_D1P_CSI1_D0P = PD_1
|
||||
PIN_MIPI_CSI1_CLKN = PA_1
|
||||
PIN_MIPI_CSI1_CLKP = PA_0
|
||||
|
||||
|
||||
//mipi0摄像头的iic
|
||||
PIN_MIPI0_IIC_CLK = PC_15
|
||||
PIN_MIPI0_IIC_SDA = PD_14
|
||||
|
||||
PIN_MIPI1_IIC_CLK = PD_15
|
||||
PIN_MIPI1_IIC_SDA = PD_14
|
||||
|
||||
//DVP摄像头IIC
|
||||
PIN_DVP0_IIC_SDA = PD_14
|
||||
PIN_DVP0_IIC_CLK = PC_15
|
||||
|
||||
//LCD的配置
|
||||
PIN_MIPI_DSI_CLKN = PD_7
|
||||
PIN_MIPI_DSI_CLKP = PD_6
|
||||
PIN_MIPI_DSI_D0N = PD_5
|
||||
PIN_MIPI_DSI_D0P = PD_4
|
||||
PIN_MIPI_DSI_D1N = PD_3
|
||||
PIN_MIPI_DSI_D1P = PD_2
|
||||
|
||||
PIN_ADKEY1 = PA_15
|
||||
PIN_TP_I2C_SCL = PC_11
|
||||
PIN_TP_I2C_SDA = PC_12
|
||||
PIN_TP_INT = PC_10
|
||||
|
||||
PIN_MIPI_FSYNC = PC_14
|
||||
|
||||
//打印机的CLK、DATA引脚
|
||||
PIN_SPI1_CLK = PB_11
|
||||
PIN_SPI1_IO0 = PB_13
|
||||
|
||||
//步进电机引脚
|
||||
PIN_SPI2_IO0 = PB_14
|
||||
PIN_SPI2_IO1 = PB_15
|
||||
PIN_SPI2_IO2 = PC_1
|
||||
PIN_SPI2_IO3 = PC_0
|
||||
3
project/cfg/说明.txt
Normal file
3
project/cfg/说明.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
这个文件夹主要是备份不同的板子的参数,文件名以板子的编号命名
|
||||
1、这个文件夹主要是保存各个板子的配置参数,如果功能一样,板子io更换,可以直接通过修改cfg文件来达到固件更新(命令:.\pin_bin.exe .\APP.bin .\pin_param.h xxx.cfg,如果没有写xxx.cfg,则默认读取的是config.cfg)
|
||||
2、这个cfg需要匹配pin_param.h,所以如果需要兼容,pin_param.h新增加的宏需要放在末尾,否则就是不兼容
|
||||
111
project/config.cfg
Normal file
111
project/config.cfg
Normal file
@@ -0,0 +1,111 @@
|
||||
//这个配置是学习板,板号:NO.25-439
|
||||
//这个配置是双摄像头的配置,配置了lcd
|
||||
|
||||
//串口的io
|
||||
PIN_UART0_TX = PA_11
|
||||
PIN_UART0_RX = PA_12
|
||||
PIN_UART4_TX = PC_0
|
||||
|
||||
//sd卡的io
|
||||
PIN_SDH_CLK = PA_13
|
||||
PIN_SDH_CMD = PA_6
|
||||
PIN_SDH_DAT0 = PA_7
|
||||
//SDH CLK 驱动能力 GPIO_DS_G2
|
||||
PIN_SDH_CLK_DRI_STRENGTH = PA_2
|
||||
|
||||
|
||||
//摄像头的io
|
||||
PIN_CSI0_PDN = PC_9
|
||||
|
||||
//DVP
|
||||
PIN_DVP_HSYNC = PB_7
|
||||
PIN_DVP_VSYNC = PB_6
|
||||
PIN_DVP_PCLK = PB_12
|
||||
PIN_DVP_MCLK = PB_9
|
||||
PIN_DVP_DATA0 = PB_14
|
||||
PIN_DVP_DATA1 = PC_0
|
||||
PIN_DVP_DATA2 = PC_1
|
||||
PIN_DVP_DATA3 = PB_15
|
||||
PIN_DVP_DATA4 = PB_13
|
||||
PIN_DVP_DATA5 = PB_11
|
||||
PIN_DVP_DATA6 = PB_10
|
||||
PIN_DVP_DATA7 = PB_8
|
||||
|
||||
//摄像头mclk的io
|
||||
PIN_PWM_CHANNEL_0 = PE_0
|
||||
|
||||
|
||||
|
||||
//mipi的io
|
||||
PIN_MIPI_CSI0_CLKN = PA_2
|
||||
PIN_MIPI_CSI0_CLKP = PA_3
|
||||
PIN_MIPI_CSI0_D0N = PA_5
|
||||
PIN_MIPI_CSI0_D0P = PA_4
|
||||
PIN_MIPI_CSI0_D1N_CSI1_D0N = PD_0
|
||||
PIN_MIPI_CSI0_D1P_CSI1_D0P = PD_1
|
||||
PIN_MIPI_CSI1_CLKN = PA_1
|
||||
PIN_MIPI_CSI1_CLKP = PA_0
|
||||
|
||||
|
||||
//mipi0摄像头的iic
|
||||
PIN_MIPI0_IIC_CLK = PC_15
|
||||
PIN_MIPI0_IIC_SDA = PD_14
|
||||
|
||||
PIN_MIPI1_IIC_CLK = PD_15
|
||||
PIN_MIPI1_IIC_SDA = PD_14
|
||||
|
||||
//DVP摄像头IIC
|
||||
PIN_DVP0_IIC_SDA = PD_14
|
||||
PIN_DVP0_IIC_CLK = PC_15
|
||||
|
||||
//LCD的配置
|
||||
PIN_MIPI_DSI_CLKN = PD_7
|
||||
PIN_MIPI_DSI_CLKP = PD_6
|
||||
PIN_MIPI_DSI_D0N = PD_5
|
||||
PIN_MIPI_DSI_D0P = PD_4
|
||||
PIN_MIPI_DSI_D1N = PD_3
|
||||
PIN_MIPI_DSI_D1P = PD_2
|
||||
|
||||
PIN_ADKEY1 = PA_15
|
||||
PIN_TP_I2C_SCL = PC_11
|
||||
PIN_TP_I2C_SDA = PC_12
|
||||
PIN_TP_INT = PC_10
|
||||
|
||||
//FEM的IO配置
|
||||
PIN_LMAC_FEM_RF_TX_EN = PC_0
|
||||
PIN_LMAC_FEM_RF_RX_EN = PC_1
|
||||
|
||||
LCD_VS_CS = PB_6
|
||||
LCD_HS_DC = PB_7
|
||||
LCD_D0 = PB_8
|
||||
LCD_DOTCLK_RWR = PB_9
|
||||
|
||||
PIN_MIPI_FSYNC = PC_14
|
||||
|
||||
//打印机的CLK、DATA引脚
|
||||
PIN_SPI1_CLK = PB_11
|
||||
PIN_SPI1_IO0 = PB_13
|
||||
|
||||
//步进电机引脚
|
||||
PIN_SPI2_IO0 = PB_14
|
||||
PIN_SPI2_IO1 = PB_15
|
||||
PIN_SPI2_IO2 = PC_1
|
||||
PIN_SPI2_IO3 = PC_0
|
||||
|
||||
//红外夜视引脚
|
||||
PIN_IRCUT_IN1 = 255//PB_12
|
||||
PIN_IRCUT_IN2 = 255//PB_13
|
||||
PIN_IRCUT_DETECT = 255//PA_15
|
||||
PIN_IRCUT_LED = 255//PD_1
|
||||
PIN_WHITE_LED = 255//PD_0
|
||||
|
||||
//GMAC
|
||||
PIN_GMAC_RMII_REF_CLKIN = PB_10
|
||||
PIN_GMAC_RMII_RXD0 = PB_8
|
||||
PIN_GMAC_RMII_RXD1 = PB_9
|
||||
PIN_GMAC_RMII_TXD0 = PB_11
|
||||
PIN_GMAC_RMII_TXD1 = PB_12
|
||||
PIN_GMAC_RMII_CRS_DV = PB_14
|
||||
PIN_GMAC_RMII_TX_EN = PB_13
|
||||
PIN_GMAC_RMII_MDIO = PB_6
|
||||
PIN_GMAC_RMII_MDC = PB_7
|
||||
108
project/cpu1_mem.c
Normal file
108
project/cpu1_mem.c
Normal file
@@ -0,0 +1,108 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "osal/string.h"
|
||||
struct cpu1_mem_info
|
||||
{
|
||||
void *skb_heap;
|
||||
void *cpu1_heap;
|
||||
void *rxbuf_heap;
|
||||
uint32_t skb_heap_size;
|
||||
uint32_t cpu1_heap_size;
|
||||
uint32_t rxbuf_heap_size;
|
||||
};
|
||||
struct cpu1_mem_info *cpu1_mem_info_msg = NULL;
|
||||
|
||||
void *cpu1_skb_buf()
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
cpu1_mem_info_msg = os_malloc(sizeof(struct cpu1_mem_info));
|
||||
}
|
||||
|
||||
cpu1_mem_info_msg->skb_heap = os_malloc_psram(CONFIG_CORE_SKB_POOL_SIZE);
|
||||
cpu1_mem_info_msg->skb_heap_size = CONFIG_CORE_SKB_POOL_SIZE;
|
||||
return cpu1_mem_info_msg->skb_heap;
|
||||
}
|
||||
|
||||
void *cpu1_mem_heap()
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
cpu1_mem_info_msg = os_malloc(sizeof(struct cpu1_mem_info));
|
||||
}
|
||||
cpu1_mem_info_msg->cpu1_heap = os_malloc(CONFIG_CORE_HEAP_SIZE);
|
||||
cpu1_mem_info_msg->cpu1_heap_size = CONFIG_CORE_HEAP_SIZE;
|
||||
|
||||
return cpu1_mem_info_msg->cpu1_heap;
|
||||
}
|
||||
|
||||
void *cpu1_RXBUF_heap()
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
cpu1_mem_info_msg = os_malloc(sizeof(struct cpu1_mem_info));
|
||||
}
|
||||
cpu1_mem_info_msg->rxbuf_heap = os_malloc(CONFIG_CORE_RXBUF_SIZE);
|
||||
cpu1_mem_info_msg->rxbuf_heap_size = CONFIG_CORE_RXBUF_SIZE;
|
||||
return os_malloc(CONFIG_CORE_RXBUF_SIZE);
|
||||
}
|
||||
|
||||
void *cpu1_skb_heap_get(uint32_t *size)
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
if(size)
|
||||
{
|
||||
*size = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if(size)
|
||||
{
|
||||
*size = cpu1_mem_info_msg->skb_heap_size;
|
||||
}
|
||||
return cpu1_mem_info_msg->skb_heap;
|
||||
}
|
||||
|
||||
void *cpu1_heap_get(uint32_t *size)
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
if(size)
|
||||
{
|
||||
*size = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if(size)
|
||||
{
|
||||
*size = cpu1_mem_info_msg->cpu1_heap_size;
|
||||
}
|
||||
return cpu1_mem_info_msg->cpu1_heap;
|
||||
}
|
||||
|
||||
void *cpu1_RXBUF_heap_get(uint32_t *size)
|
||||
{
|
||||
if(!cpu1_mem_info_msg)
|
||||
{
|
||||
if(size)
|
||||
{
|
||||
*size = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if(size)
|
||||
{
|
||||
*size = cpu1_mem_info_msg->rxbuf_heap_size;
|
||||
}
|
||||
return cpu1_mem_info_msg->rxbuf_heap;
|
||||
}
|
||||
|
||||
void cpu1_info_free()
|
||||
{
|
||||
if(cpu1_mem_info_msg)
|
||||
{
|
||||
os_free(cpu1_mem_info_msg);
|
||||
cpu1_mem_info_msg = NULL;
|
||||
}
|
||||
}
|
||||
10
project/cpu1_mem.h
Normal file
10
project/cpu1_mem.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __CPU1_MEM_H
|
||||
#define __CPU1_MEM_H
|
||||
void cpu1_info_free();
|
||||
void *cpu1_skb_buf();
|
||||
void *cpu1_mem_heap();
|
||||
void *cpu1_RXBUF_heap();
|
||||
void *cpu1_RXBUF_heap_get(uint32_t *size);
|
||||
void *cpu1_heap_get(uint32_t *size);
|
||||
void *cpu1_skb_heap_get(uint32_t *size);
|
||||
#endif
|
||||
BIN
project/crc.exe
Normal file
BIN
project/crc.exe
Normal file
Binary file not shown.
30
project/crc_check_corebin.ini
Normal file
30
project/crc_check_corebin.ini
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
; MemEndianLE : 1(little endian), 0(big endian)
|
||||
; CrcType : 0 (crc4_itu)
|
||||
; 1 (crc5_epc)
|
||||
; 2 (crc5_itu)
|
||||
; 3 (crc5_usb)
|
||||
; 4 (crc6_itu)
|
||||
; 5 (crc7_mmc)
|
||||
; 6 (crc8)
|
||||
; 7 (crc8_itu)
|
||||
; 8 (crc8_rohc)
|
||||
; 9 (crc8_maxim)
|
||||
; 10( crc16_ibm)
|
||||
; 11( crc16_maxim)
|
||||
; 12( crc16_usb)
|
||||
; 13( crc16_modbus)
|
||||
; 14( crc16_ccitt)
|
||||
; 15( crc16_ccitt_false)
|
||||
; 16( crc16_x25)
|
||||
; 17( crc16_xmodem)
|
||||
; 18( crc16_dnp)
|
||||
; 19( crc32)
|
||||
; 20( crc32_mpeg_2)
|
||||
|
||||
[COMMON]
|
||||
CodeFile=txw82xcore.bin
|
||||
CrcType=119
|
||||
CrcReverse=1
|
||||
MemEndianLE=1
|
||||
MemAlignSize=4
|
||||
725
project/device.c
Normal file
725
project/device.c
Normal file
@@ -0,0 +1,725 @@
|
||||
#include "basic_include.h"
|
||||
|
||||
#include "hal/i2c.h"
|
||||
#include "hal/i2s.h"
|
||||
#include "hal/timer_device.h"
|
||||
#include "hal/pwm.h"
|
||||
#include "hal/capture.h"
|
||||
#include "hal/netdev.h"
|
||||
#include "hal/spi.h"
|
||||
#include "hal/spi_nor.h"
|
||||
|
||||
#include "lib/ota/fw.h"
|
||||
#include "lib/rpc/cpurpc.h"
|
||||
|
||||
#include "dev/uart/hguart_v2.h"
|
||||
#include "dev/uart/hguart_v4.h"
|
||||
#include "dev/dma/dw_dmac.h"
|
||||
#include "dev/gpio/hggpio_v4.h"
|
||||
#include "dev/dma/hg_m2m_dma.h"
|
||||
#include "dev/crc/hg_crc.h"
|
||||
#include "dev/timer/hgtimer_v4.h"
|
||||
#include "dev/timer/hgtimer_v7.h"
|
||||
#include "dev/vpp/hgvpp.h"
|
||||
#include "dev/prc/hgprc.h"
|
||||
#include "dev/csi/hgdvp.h"
|
||||
#include "dev/of/hgof.h"
|
||||
#include "dev/csc/hgcsc.h"
|
||||
#include "dev/lcdc/hglcdc.h"
|
||||
#include "dev/lcdc/hgdsi.h"
|
||||
#include "dev/jpg/hgjpg.h"
|
||||
#include "dev/scale/hgscale.h"
|
||||
#include "lib/rpc/cpurpc.h"
|
||||
#include "hal/i2c.h"
|
||||
#include "dev/gen/hggen420.h"
|
||||
#include "dev/gen/hggen422.h"
|
||||
#include "dev/spi/hgspi_v3.h"
|
||||
#include "dev/spi/hgspi_xip.h"
|
||||
#include "dev/h264/hg264.h"
|
||||
#include "dev/dual/hgdual_org.h"
|
||||
#include "dev/mipi_csi/hgmipi_csi.h"
|
||||
#include "dev/i2c/hgi2c_v1.h"
|
||||
#include "dev/i2s/hgi2s_v0.h"
|
||||
#include "dev/osd_enc/hgosd_enc.h"
|
||||
#include "lib/sdhost/sdhost.h"
|
||||
#include "dev/isp/hgisp_v0.h"
|
||||
//#include "dev/isp/hgftusb3_v0.h"
|
||||
#include "dev/pwm/hgpwm_v0.h"
|
||||
#include "dev/dma2d/hg_dma2d_v0.h"
|
||||
#include "lib/syscfg/syscfg.h"
|
||||
#include "syscfg.h"
|
||||
#include "dev/usb/hgusb20_v1_dev_api.h"
|
||||
#include "dev/sysaes/hg_sysaes_v3.h"
|
||||
#include "dev/adc/hgadc_v1.h"
|
||||
#include "dev/usb/usb11_v0/hgusb11_v0_dev_api.h"
|
||||
#include "dev/usb/usb11_v0/hgusb11_v0_host_api.h"
|
||||
#include "dev/audio/components/hg_audio_v0.h"
|
||||
#include "dev/para_in/hgpara_in.h"
|
||||
#include "dev/sha/hgsha_v1.h"
|
||||
#include "dev/xspi/hg_xspi_psram.h"
|
||||
#include "lib/net/ethphy/eth_mdio_bus.h"
|
||||
#include "lib/net/ethphy/eth_phy.h"
|
||||
#include "lib/net/ethphy/phy/ip101g.h"
|
||||
#include "dev/emac/hg_gmac_eva_v2.h"
|
||||
|
||||
|
||||
#define DEV_SENSOR_MASTER_IIC_DEVID (ISP_CSI0_ID)
|
||||
#define DEV_SENSOR_SLAVE_IIC_DEVID (ISP_CSI1_ID)
|
||||
|
||||
extern struct dma_device *m2mdma;
|
||||
extern void *console_handle;
|
||||
extern void device_burst_set(void);
|
||||
|
||||
|
||||
struct hgusb20_dev usb20_dev = {
|
||||
.usb_hw = (void *)USB20_BASE,
|
||||
.ep_irq_num = USB20MC_IRQn,
|
||||
.dma_irq_num = USB20DMA_IRQn,
|
||||
//.flags = BIT(HGUSB20_FLAGS_FULL_SPEED),
|
||||
};
|
||||
|
||||
struct hgusb11_dev usb11_dev = {
|
||||
.usb_hw = (void *)USB11_BASE,
|
||||
.ep_irq_num = USB11_MC_IRQn,
|
||||
.dma_irq_num = USB11_DMA_IRQn,
|
||||
.p_comm = &usb11_dev.comm_dat,
|
||||
};
|
||||
|
||||
struct hgusb11_host usb11_host = {
|
||||
.usb_hw = (void *)USB11_BASE,
|
||||
.ep_irq_num = USB11_MC_IRQn,
|
||||
.dma_irq_num = USB11_DMA_IRQn,
|
||||
.p_comm = &usb11_dev.comm_dat,
|
||||
};
|
||||
|
||||
struct hgpara_in para_in = {
|
||||
.hw = (void *)PARA_IN_BASE,
|
||||
.irq_num = PARA_IN_IRQn,
|
||||
};
|
||||
|
||||
struct hg_crc crc32_module = {
|
||||
.hw = (void *)CRC_BASE,
|
||||
.irq_num = CRC_IRQn,
|
||||
};
|
||||
|
||||
struct hg_sysaes_v3 sysaes = {
|
||||
.hw = (void *)SYS_AES_BASE,
|
||||
.irq_num = SYS_AES_IRQn,
|
||||
};
|
||||
|
||||
struct hguart_v2 uart0 = {
|
||||
.hw = UART0_BASE,
|
||||
.irq_num = UART0_IRQn
|
||||
};
|
||||
|
||||
struct hguart_v2 uart1 = {
|
||||
.hw = UART1_BASE,
|
||||
.irq_num = UART1_IRQn,
|
||||
};
|
||||
|
||||
struct hguart_v4 uart4 = {
|
||||
.hw = UART4_BASE,
|
||||
.irq_num = UART4_IRQn,
|
||||
};
|
||||
|
||||
struct hguart_v4 uart5 = {
|
||||
.hw = UART5_BASE,
|
||||
.irq_num = UART5_IRQn,
|
||||
};
|
||||
|
||||
struct hguart_v4 uart6 = {
|
||||
.hw = UART6_BASE,
|
||||
.irq_num = UART6_IRQn,
|
||||
};
|
||||
|
||||
struct hggpio_v4 gpioa = {
|
||||
.hw = GPIOA_BASE,
|
||||
.irq_num = GPIOA_IRQn,
|
||||
.pin_num = {PA_0, PA_15},
|
||||
};
|
||||
|
||||
struct hggpio_v4 gpiob = {
|
||||
.hw = GPIOB_BASE,
|
||||
.irq_num = GPIOB_IRQn,
|
||||
.pin_num = {PB_0, PB_15},
|
||||
};
|
||||
|
||||
struct hggpio_v4 gpioc = {
|
||||
.hw = GPIOC_BASE,
|
||||
.irq_num = GPIOC_IRQn,
|
||||
.pin_num = {PC_0, PC_15},
|
||||
};
|
||||
|
||||
struct hggpio_v4 gpiod = {
|
||||
.hw = GPIOD_BASE,
|
||||
.irq_num = GPIOD_IRQn,
|
||||
.pin_num = {PD_0, PD_15},
|
||||
};
|
||||
|
||||
struct hggpio_v4 gpioe = {
|
||||
.hw = GPIOE_BASE,
|
||||
.irq_num = GPIOE_IRQn,
|
||||
.pin_num = {PE_0, PE_3},
|
||||
};
|
||||
|
||||
struct mem_dma_dev mem_dma = {
|
||||
.hw = (void *)M2M_DMA_BASE,
|
||||
#if CONFI_CORE_M2M_DMA
|
||||
.irq_num = {M2M_DMA0_IRQn, M2M_DMA1_IRQn},
|
||||
#else
|
||||
.irq_num = {M2M_DMA0_IRQn, M2M_DMA1_IRQn, M2M_DMA2_IRQn},
|
||||
#endif
|
||||
};
|
||||
|
||||
struct hgadc_v1 adc0 = {
|
||||
.hw = ADKEY_BASE,
|
||||
.irq_num = ADKEY0_IRQn,
|
||||
};
|
||||
|
||||
struct hglcdc lcdc = {
|
||||
.hw = LCDC_BASE,
|
||||
.irq_num = LCD_IRQn,
|
||||
};
|
||||
|
||||
struct hgdsi dsic = {
|
||||
.hw = MIPI_DSI_BASE,
|
||||
.irq_num = 0,
|
||||
};
|
||||
|
||||
struct hgjpg jpg0 = {
|
||||
.hw = MJPEG0_BASE,
|
||||
#ifdef FPGA_SUPPORT
|
||||
.thw = MJPEG0_TAB_BASE,
|
||||
#else
|
||||
.thw = MJPEG0_TAB_BASE,
|
||||
#endif
|
||||
.huf_hw = MJPEG_HUFF_BASE,
|
||||
|
||||
.irq_num = MJPEG01_IRQn,
|
||||
};
|
||||
|
||||
struct hgjpg jpg1 = {
|
||||
.hw = MJPEG1_BASE,
|
||||
#ifdef FPGA_SUPPORT
|
||||
.thw = MJPEG1_TAB_BASE,
|
||||
#else
|
||||
.thw = MJPEG1_TAB_BASE,
|
||||
#endif
|
||||
.huf_hw = MJPEG_HUFF_BASE,
|
||||
|
||||
.irq_num = MJPEG01_IRQn,
|
||||
};
|
||||
|
||||
struct hgsdh sdh = {
|
||||
.hw = SDHOST_BASE,
|
||||
.irq_num = SDHOST_IRQn,
|
||||
};
|
||||
|
||||
struct hgdvp dvp = {
|
||||
.hw = DVP_BASE,
|
||||
.irq_num = DVP_IRQn,
|
||||
};
|
||||
|
||||
struct hgmipi_csi csi0 = {
|
||||
.hw = MIPI_CSI0_BASE,
|
||||
.irq_num = MIPI_CSI2_IRQn,
|
||||
};
|
||||
|
||||
struct hgmipi_csi csi1 = {
|
||||
.hw = MIPI_CSI1_BASE,
|
||||
.irq_num = MIPI1_CSI2_IRQn,
|
||||
};
|
||||
|
||||
struct hgvpp vpp = {
|
||||
.hw = VPP_BASE,
|
||||
.irq_num = VPP_IRQn,
|
||||
};
|
||||
|
||||
struct hgprc prc = {
|
||||
.hw = PRC_BASE,
|
||||
.irq_num = PRC_IRQn,
|
||||
};
|
||||
|
||||
struct hgscale scale1 = {
|
||||
.hw = SCALE1_BASE,
|
||||
.irq_num = SCALE1_IRQn,
|
||||
};
|
||||
|
||||
struct hgscale scale2 = {
|
||||
.hw = SCALE2_BASE,
|
||||
.irq_num = SCALE2_IRQn,
|
||||
};
|
||||
|
||||
struct hgscale scale3 = {
|
||||
.hw = SCALE3_BASE,
|
||||
.irq_num = SCALE3_IRQn,
|
||||
};
|
||||
|
||||
struct hggen420 gen420 = {
|
||||
.hw = GEN420_BASE,
|
||||
.irq_num = GEN420_IRQn,
|
||||
};
|
||||
|
||||
struct hggen422 gen422 = {
|
||||
.hw = GEN422_BASE,
|
||||
.irq_num = GEN422_IRQn,
|
||||
};
|
||||
|
||||
struct hg264 h264 = {
|
||||
.hw = H264_REG_BASE,
|
||||
.irq_num = H264ENC_IRQn,
|
||||
};
|
||||
|
||||
struct hgdual dual = {
|
||||
.hw = DUAL_ORG_BASE,
|
||||
.irq_num = DUAL_ORG_IRQn,
|
||||
};
|
||||
|
||||
struct hgosd osdenc = {
|
||||
.hw = OSD_ENC_BASE,
|
||||
.irq_num = OSD_ENC_IRQn,
|
||||
};
|
||||
|
||||
struct hgcsc csc = {
|
||||
.hw = CSC_BASE,
|
||||
.irq_num = CSC_IRQn,
|
||||
};
|
||||
|
||||
struct hgtimer_v4 timer0 = {
|
||||
.hw = TIMER0_BASE,
|
||||
.irq_num = TIM0_IRQn,
|
||||
};
|
||||
|
||||
struct hgtimer_v4 timer1 = {
|
||||
.hw = TIMER1_BASE,
|
||||
.irq_num = TIM1_IRQn,
|
||||
};
|
||||
|
||||
struct hgtimer_v4 timer2 = {
|
||||
.hw = TIMER2_BASE,
|
||||
.irq_num = TIM2_IRQn,
|
||||
};
|
||||
|
||||
struct hgtimer_v4 timer3 = {
|
||||
.hw = TIMER3_BASE,
|
||||
.irq_num = TIM3_IRQn,
|
||||
};
|
||||
|
||||
|
||||
struct hgtimer_v7 simple_timer5 = {
|
||||
.hw = SIMPLE_TIMER5_BASE,
|
||||
.irq_num = STMR5_IRQn,
|
||||
};
|
||||
|
||||
struct hgspi_v3 spi0 = {
|
||||
.hw = SPI0_BASE,
|
||||
.irq_num = SPI0_IRQn,
|
||||
};
|
||||
|
||||
struct hgspi_v3 spi1 = {
|
||||
.hw = SPI1_BASE,
|
||||
.irq_num = SPI1_IRQn,
|
||||
};
|
||||
|
||||
struct hgspi_v3 spi2 = {
|
||||
.hw = SPI2_BASE,
|
||||
.irq_num = SPI2_IRQn,
|
||||
};
|
||||
|
||||
struct hgspi_xip spi7 = {
|
||||
.hw = QSPI_BASE,
|
||||
.ddr = 0,
|
||||
.xip = 1,
|
||||
};
|
||||
|
||||
struct hgcqspi cqspi = {
|
||||
.hw = (void *)QSPI_BASE,
|
||||
.irq_num = QSPI_IRQn,
|
||||
.opened = 0,
|
||||
};
|
||||
|
||||
struct hgi2c_v1 iic1 = {
|
||||
.hw = IIC1_BASE,
|
||||
.irq_num = SPI1_IRQn,
|
||||
};
|
||||
|
||||
struct hgi2c_v1 iic2 = {
|
||||
.hw = IIC2_BASE,
|
||||
.irq_num = SPI2_IRQn,
|
||||
};
|
||||
|
||||
struct hgpwm_v0 pwm = {
|
||||
.channel[0] = (void *) &timer0,
|
||||
.channel[1] = (void *) &timer1,
|
||||
.channel[2] = (void *) &timer2,
|
||||
};
|
||||
|
||||
struct hgisp_v0 isp = {
|
||||
.hw = IMAGE_ISP_BASE,
|
||||
.data_hw = ISP_R_GAMMA_BASE,
|
||||
.irq_num = IMG_ISP_IRQn,
|
||||
};
|
||||
|
||||
struct hgdma2d_v0 dma2d = {
|
||||
.hw = DMA2D_BASE,
|
||||
.fgclut = DMA2D_FGCLUT_BASE,
|
||||
.bgclut = DMA2D_BGCLUT_BASE,
|
||||
.irq_num = DMA2D_IRQn,
|
||||
};
|
||||
|
||||
struct spi_nor_flash flash0 = {
|
||||
.spidev = (struct spi_device *)&spi7,
|
||||
.spi_config = {12000000, SPI_CLK_MODE_0, SPI_WIRE_NORMAL_MODE, 0},
|
||||
.vendor_id = 0,
|
||||
.product_id = 0,
|
||||
.size = 0x200000, /* Special External-Flash Size */
|
||||
.block_size = 0x10000,
|
||||
.sector_size = 0x1000,
|
||||
.page_size = 4096,
|
||||
.mode = SPI_NOR_XIP_MODE,
|
||||
|
||||
};
|
||||
|
||||
struct hg_audio_v0 auadc = {
|
||||
.hw = AUDIO_BASE,
|
||||
.irq_num = AUDIO_SUBSYS1_IRQn,
|
||||
.p_comm = (void *)&auadc.comm_dat,
|
||||
.comm_dat.comm_bits.ana_rfb_level = 0, //set_rfb = (1 << ana_rfb_level)
|
||||
.comm_dat.comm_bits.ana_rin_level = 1, //set_rin = (1 << ana_rin_level)
|
||||
// .comm_dat.comm_bits.ana_driver_version = 1,
|
||||
.dev_type = AUDIO_TYPE_AUADC,
|
||||
};
|
||||
|
||||
struct hg_audio_v0 audac = {
|
||||
.hw = AUDIO_BASE,
|
||||
.irq_num = AUDIO_SUBSYS0_IRQn,
|
||||
.p_comm = (void *)&auadc.comm_dat,
|
||||
.dev_type = AUDIO_TYPE_AUDAC,
|
||||
};
|
||||
|
||||
struct hg_audio_v0 auasrc = {
|
||||
.hw = AUDIO_ASRC_BASE,
|
||||
.p_comm = (void *)&auadc.comm_dat,
|
||||
.dev_type = AUDIO_TYPE_AUASRC,
|
||||
};
|
||||
|
||||
struct hg_audio_v0 aueq = {
|
||||
.hw = AUDIO_EQ_BASE,
|
||||
.p_comm = (void *)&auadc.comm_dat,
|
||||
.dev_type = AUDIO_TYPE_AUEQ,
|
||||
};
|
||||
|
||||
struct hg_audio_v0 aufade = {
|
||||
.hw = AUDIO_BASE,
|
||||
.p_comm = (void *)&auadc.comm_dat,
|
||||
.dev_type = AUDIO_TYPE_AUFADE,
|
||||
};
|
||||
|
||||
struct hgi2s_v0 i2s0 = {
|
||||
.hw = IIS0_BASE,
|
||||
.irq_num = IIS0_IRQn,
|
||||
};
|
||||
|
||||
struct hgi2s_v0 i2s1 = {
|
||||
.hw = IIS1_BASE,
|
||||
.irq_num = IIS1_IRQn,
|
||||
};
|
||||
|
||||
struct hgsha_v1 sha = {
|
||||
.hw = (void *)SHA_BASE,
|
||||
.irq_num = SHA_IRQn,
|
||||
};
|
||||
|
||||
struct ethernet_mdio_bus mdio_bus0;
|
||||
|
||||
struct ethernet_phy_device ethernet_phy0 = {
|
||||
.addr = 0x01,
|
||||
.drv = &ip101g_driver,
|
||||
};
|
||||
|
||||
struct hg_gmac_eva_v2 gmac = {
|
||||
.hw = GMAC_BASE,
|
||||
.irq_num = GMAC_IRQn,
|
||||
.tx_buf_size = 4 * 1024,
|
||||
.rx_buf_size = 8 * 1024,
|
||||
.modbus_devid = HG_ETH_MDIOBUS0_DEVID,
|
||||
.phy_devid = HG_ETHPHY0_DEVID,
|
||||
.mdio_pin = PB_6,
|
||||
.mdc_pin = PB_7,
|
||||
.rgmii_en = 0,
|
||||
};
|
||||
|
||||
static void core_vdd_voltage()
|
||||
{
|
||||
uint32 core_vdd_voltage = 0;
|
||||
sar_adc_sample_one_channel(ADC_CHANNEL_CORE_VDD, &core_vdd_voltage);
|
||||
os_printf("CoreVdd Voltage:%.2fV\r\n", ((double)core_vdd_voltage/2048.0)*3.0);
|
||||
}
|
||||
|
||||
void device_init(void)
|
||||
{
|
||||
extern uint32_t get_flash_cap();
|
||||
uint32_t flash_size = get_flash_cap();
|
||||
if (flash_size > 0) {
|
||||
flash0.size = flash_size;
|
||||
}
|
||||
|
||||
hg_crc_attach(HG_CRC_DEVID, &crc32_module);
|
||||
hg_sysaes_v3_attach(HG_HWAES0_DEVID, &sysaes);
|
||||
hggpio_v4_attach(HG_GPIOA_DEVID, &gpioa);
|
||||
hggpio_v4_attach(HG_GPIOB_DEVID, &gpiob);
|
||||
pmu_vccsd_power_set(1, VCCSD_33);
|
||||
hggpio_v4_attach(HG_GPIOC_DEVID, &gpioc);
|
||||
hggpio_v4_attach(HG_GPIOD_DEVID, &gpiod);
|
||||
hggpio_v4_attach(HG_GPIOE_DEVID, &gpioe);
|
||||
hgadc_v1_attach(HG_ADC0_DEVID, &adc0);
|
||||
hguart_v2_attach(HG_UART0_DEVID, &uart0);
|
||||
hguart_v2_attach(HG_UART1_DEVID, &uart1);
|
||||
hguart_v4_attach(HG_UART4_DEVID, &uart4);
|
||||
hgtimer_v4_attach(HG_TIMER0_DEVID, &timer0);
|
||||
hgtimer_v4_attach(HG_TIMER1_DEVID, &timer1);
|
||||
hgtimer_v4_attach(HG_TIMER2_DEVID, &timer2);
|
||||
hgtimer_v4_attach(HG_TIMER3_DEVID, &timer3);
|
||||
hgtimer_v7_attach(HG_SIMTMR5_DEVID, &simple_timer5);
|
||||
|
||||
|
||||
hgi2s_v0_attach(HG_IIS0_DEVID, &i2s0);
|
||||
hgi2s_v0_attach(HG_IIS1_DEVID, &i2s1);
|
||||
|
||||
#ifndef SINGLE_CORE
|
||||
sysctrl_cpu1_softrst_en();
|
||||
sysctrl_cpu1_clk_en();
|
||||
cpu_splock_init(CPU0_SPLCK_BASE, CPU_SPINLOCK_IRQn);
|
||||
#endif
|
||||
uart_open((struct uart_device *)&uart0, 921600); //for CPU0
|
||||
uart_open((struct uart_device *)&uart1, 921600); //for CPU1
|
||||
|
||||
#if USB_EN
|
||||
#if USB_HOST_EN
|
||||
hgusb20_host_attach(HG_USBDEV_DEVID, &usb20_dev);
|
||||
#else
|
||||
hgusb20_dev_attach(HG_USBDEV_DEVID, &usb20_dev);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USB11_EN
|
||||
hgusb11_v0_dev_attach(HG_USB11DEV_DEVID, &usb11_dev);
|
||||
hgusb11_v0_host_attch(HG_USB11HOST_DEVID, &usb11_host);
|
||||
#endif
|
||||
|
||||
#if LCD_EN
|
||||
hglcdc_attach(HG_LCDC_DEVID,&lcdc);
|
||||
hgdsi_attach(HG_DSI_DEVID,&dsic);
|
||||
#endif
|
||||
hgosdenc_attach(HG_OSD_ENC_DEVID,&osdenc);
|
||||
|
||||
#if ISP_EN
|
||||
hgisp_v0_attach(HG_ISP_DEVID, &isp);
|
||||
#endif
|
||||
|
||||
#if DVP_EN
|
||||
hgdvp_attach(HG_DVP_DEVID,&dvp);
|
||||
#endif
|
||||
|
||||
#if MIPI_CSI_EN
|
||||
hgmipi_csi_attach(HG_MIPI_CSI_DEVID,&csi0);
|
||||
hgmipi_csi_attach(HG_MIPI1_CSI_DEVID,&csi1);
|
||||
#endif
|
||||
|
||||
#if VPP_EN
|
||||
hgvpp_attach(HG_VPP_DEVID,&vpp);
|
||||
#endif
|
||||
|
||||
#if H264_EN
|
||||
hg264_attach(HG_H264_DEVID, &h264);
|
||||
#endif
|
||||
|
||||
#if SDH_EN
|
||||
hgsdh_attach(HG_SDIOHOST_DEVID, &sdh);
|
||||
#endif
|
||||
|
||||
#if SCALE_EN
|
||||
hgscale1_attach(HG_SCALE1_DEVID, &scale1);
|
||||
hgscale2_attach(HG_SCALE2_DEVID, &scale2);
|
||||
hgscale3_attach(HG_SCALE3_DEVID, &scale3);
|
||||
#endif
|
||||
|
||||
#if DMA2D_EN
|
||||
hgdma2d_v0_attach(HG_DMA2D_DEVID, &dma2d);
|
||||
#endif
|
||||
|
||||
#if PARA_IN_EN
|
||||
hgpara_in_attach(HG_PARA_IN_DEVID, ¶_in);
|
||||
#endif
|
||||
|
||||
#if GMAC_EN
|
||||
eth_mdio_bus_attach(HG_ETH_MDIOBUS0_DEVID, &mdio_bus0);
|
||||
eth_phy_attach(HG_ETHPHY0_DEVID, ðernet_phy0);
|
||||
hg_gmac_v2_attach(HG_GMAC_DEVID, &gmac);
|
||||
#endif
|
||||
|
||||
hgpwm_v0_attach(HG_PWM0_DEVID, &pwm);
|
||||
|
||||
hgdual_attach(HG_DUALORG_DEVID,&dual);
|
||||
hgcsc_attach(HG_CSC_DEVID,&csc);
|
||||
|
||||
hggen420_attach(HG_GEN420_DEVID,&gen420);
|
||||
hggen422_attach(HG_GEN422_DEVID,&gen422);
|
||||
hgprc_attach(HG_PRC_DEVID,&prc);
|
||||
|
||||
|
||||
console_handle = &uart0;
|
||||
|
||||
#if SD_MODE_TYPE != 2
|
||||
hgspi_v3_attach(HG_SPI0_DEVID, &spi0);
|
||||
#endif
|
||||
|
||||
hgspi_v3_attach(HG_SPI1_DEVID, &spi1);
|
||||
hgspi_v3_attach(HG_SPI2_DEVID, &spi2);
|
||||
|
||||
hgspi_xip_attach(HG_SPI7_DEVID, &spi7);
|
||||
|
||||
spi_nor_attach(&flash0, HG_FLASH0_DEVID);
|
||||
|
||||
|
||||
|
||||
hgi2c_v1_attach(HG_I2C1_DEVID, &iic1);
|
||||
#if SD_MODE_TYPE != 3
|
||||
hgi2c_v1_attach(HG_I2C2_DEVID, &iic2);
|
||||
#endif
|
||||
hg_audio_v0_attach(HG_AUADC_DEVID, &auadc);
|
||||
hg_audio_v0_attach(HG_AUDAC_DEVID, &audac);
|
||||
hg_audio_v0_attach(HG_AUASRC_DEVID, &auasrc);
|
||||
hg_audio_v0_attach(HG_AUEQ_DEVID, &aueq);
|
||||
hg_audio_v0_attach(HG_AUFADE_DEVID, &aufade);
|
||||
|
||||
hgsha_v1_attach(HG_SHA_DEVID, &sha);
|
||||
|
||||
hg_m2m_dma_dev_attach(HG_M2MDMA_DEVID, &mem_dma);
|
||||
|
||||
m2mdma = (struct dma_device *)&mem_dma;
|
||||
|
||||
void sysctrl_mipi_lcd_h264_mjpeg_clk_init(void);
|
||||
sysctrl_mipi_lcd_h264_mjpeg_clk_init();
|
||||
|
||||
#if JPG_EN
|
||||
hgjpg_attach(HG_JPG0_DEVID, &jpg0);
|
||||
hgjpg_attach(HG_JPG1_DEVID, &jpg1);
|
||||
#endif
|
||||
|
||||
extern struct hg_xspi ospi;
|
||||
hg_xspi_attach(HG_XSPI_DEVID, &ospi);
|
||||
|
||||
device_burst_set();
|
||||
os_printf(KERN_INFO"CPU0 init!\r\n");
|
||||
core_vdd_voltage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void device_burst_set(void)
|
||||
{
|
||||
*(unsigned int *) 0x400201d0 = 0xffffffff;
|
||||
*(unsigned int *) 0x400201d4 = 0xffffffff;
|
||||
|
||||
// SYSCTRL->AHB2AHB_FIFO_CTRL = 0X1FFFFF7;
|
||||
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_DUAL_ORG0_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_DUAL_ORG1_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_DUAL_ORG_RD, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_ROTATE_IN_RD, DMA2AHB_BURST_SIZE_32);
|
||||
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_M2M0_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_M2M0_RD, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_M2M1_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_M2M1_RD, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_SDHOST1_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_M2M2_RD, DMA2AHB_BURST_SIZE_256);
|
||||
|
||||
//ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_SCALE3_Y_WR, DMA2AHB_BURST_SIZE_256);
|
||||
//ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_SCALE3_U_WR, DMA2AHB_BURST_SIZE_256);
|
||||
//ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_SCALE3_V_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_VPP_Y_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_VPP_U_WR, DMA2AHB_BURST_SIZE_256);
|
||||
ll_sysctrl_dma2ahb_burst_set(DMA2AHB_BURST_CH_GMAC_RX_WR, DMA2AHB_BURST_SIZE_256);
|
||||
|
||||
SCHED->BW_STA_CYCLE = DEFAULT_SYS_CLK; //SCHED BW static
|
||||
SCHED->CTRL_CON |= BIT(0) | BIT(1) | BIT(6);
|
||||
|
||||
// gpio_iomap_output(PC_0, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_0); //CS
|
||||
// gpio_iomap_output(PC_1, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_1); //CLK
|
||||
// gpio_iomap_output(PC_2, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_2); //CS
|
||||
// gpio_iomap_output(PC_3, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_3); //CLK
|
||||
// gpio_iomap_output(PC_4, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_4); //CS
|
||||
// gpio_iomap_output(PC_9, GPIO_IOMAP_OUT_QSPI_OSPI_MNT_O_5); //CLK
|
||||
//SYSCTRL->IOFUNCMASK8 |= BIT(1);
|
||||
|
||||
}
|
||||
|
||||
struct gpio_device *gpio_get(uint32 pin)
|
||||
{
|
||||
if (pin >= gpioa.pin_num[0] && pin <= gpioa.pin_num[1]) {
|
||||
return (struct gpio_device *)&gpioa;
|
||||
} else if (pin >= gpiob.pin_num[0] && pin <= gpiob.pin_num[1]) {
|
||||
return (struct gpio_device *)&gpiob;
|
||||
} else if (pin >= gpioc.pin_num[0] && pin <= gpioc.pin_num[1]) {
|
||||
return (struct gpio_device *)&gpioc;
|
||||
} else if (pin >= gpiod.pin_num[0] && pin <= gpiod.pin_num[1]) {
|
||||
return (struct gpio_device *)&gpiod;
|
||||
}else if (pin >= gpioe.pin_num[0] && pin <= gpioe.pin_num[1]) {
|
||||
return (struct gpio_device *)&gpioe;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32 syscfg_info_get(struct syscfg_info *pinfo, const char *name)
|
||||
{
|
||||
#if SYSCFG_ENABLE
|
||||
if (strcmp(name, "syscfg") == 0) {
|
||||
pinfo->flash1 = &flash0;
|
||||
pinfo->flash2 = &flash0;
|
||||
pinfo->size = pinfo->flash1->sector_size;
|
||||
pinfo->addr1 = pinfo->flash1->size - (2 * pinfo->size);
|
||||
pinfo->addr2 = pinfo->flash1->size - pinfo->size;
|
||||
printf("syscfg: pinfo->size:%d sys_config:%d sector_size:%d\r\n",pinfo->size,sizeof(struct sys_config),pinfo->flash1->sector_size);
|
||||
ASSERT((pinfo->addr1 & ~(pinfo->flash1->sector_size - 1)) == pinfo->addr1);
|
||||
ASSERT((pinfo->addr2 & ~(pinfo->flash2->sector_size - 1)) == pinfo->addr2);
|
||||
ASSERT((pinfo->size >= sizeof(struct sys_config)) &&
|
||||
(pinfo->size == (pinfo->size & ~(pinfo->flash1->sector_size - 1))));
|
||||
} else if (strcmp(name, "bluetooth") == 0) {
|
||||
pinfo->flash1 = &flash0;
|
||||
pinfo->flash2 = &flash0;
|
||||
pinfo->size = pinfo->flash1->sector_size;
|
||||
pinfo->addr1 = pinfo->flash1->size - (pinfo->size << 2);
|
||||
pinfo->addr2 = pinfo->flash1->size - ((pinfo->size << 1) + pinfo->size);
|
||||
printf("bluetooth: pinfo->size:%d sector_size:%d\r\n",pinfo->size, pinfo->flash1->sector_size);
|
||||
ASSERT((pinfo->addr1 & ~(pinfo->flash1->sector_size - 1)) == pinfo->addr1);
|
||||
ASSERT((pinfo->addr2 & ~(pinfo->flash2->sector_size - 1)) == pinfo->addr2);
|
||||
} else if (strcmp(name, "recorder") == 0) {
|
||||
pinfo->flash1 = &flash0;
|
||||
pinfo->flash2 = &flash0;
|
||||
pinfo->size = pinfo->flash1->sector_size;
|
||||
pinfo->addr1 = pinfo->flash1->size - (6 * pinfo->size);
|
||||
pinfo->addr2 = pinfo->flash1->size - (5 * pinfo->size);
|
||||
printf("recorder: pinfo->size:%d sector_size:%d\r\n",pinfo->size, pinfo->flash1->sector_size);
|
||||
ASSERT((pinfo->addr1 & ~(pinfo->flash1->sector_size - 1)) == pinfo->addr1);
|
||||
ASSERT((pinfo->addr2 & ~(pinfo->flash2->sector_size - 1)) == pinfo->addr2);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 ota_fwinfo_get(struct ota_fwinfo *pinfo)
|
||||
{
|
||||
uint32_t loader_bytes = get_boot_loader_offset();
|
||||
pinfo->flash0 = &flash0;
|
||||
pinfo->flash1 = &flash0;
|
||||
pinfo->addr0 = 0 + loader_bytes;
|
||||
pinfo->addr1 = (flash0.size / 2) + loader_bytes;
|
||||
return 0;
|
||||
}
|
||||
314
project/events.c
Normal file
314
project/events.c
Normal file
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* @file events.c
|
||||
* @brief 系统事件处理模块 —— WiFi / 网络 / LTE 事件分发与处理
|
||||
*
|
||||
* 本文件是 TXW82x FPV SDK 的核心事件处理单元,主要包含:
|
||||
* - sys_event_hdl() : 全局系统事件处理分发函数(任务上下文,可执行耗时操作)
|
||||
* - sys_event_hdl_dhcp() : DHCP 客户端生命周期管理(WiFi 连接后启动 DHCP,DHCP 完成后记录 IP)
|
||||
* - sys_event_hdl_lte() : LTE/4G 网卡与 WiFi 之间的网络切换逻辑
|
||||
* - sys_wifi_event_cb() : WiFi 协议栈事件回调(在协议栈任务/中断上下文中执行,禁止耗时操作)
|
||||
* - sys_wifi_event_hdl_default() : 更新 sys_status 结构体中的 WiFi 状态信息
|
||||
*/
|
||||
|
||||
#include "sys_config.h" // 系统总配置头文件,包含各功能模块的宏开关
|
||||
#include "basic_include.h" // 基础头文件集合(os_printf、os_memcpy 等基础 API)
|
||||
#include "lib/net/skmonitor/skmonitor.h" // socket 监控库,用于网络连接状态监控
|
||||
#include "lib/net/dhcpd/dhcpd.h" // DHCP 服务器端库(本文件未直接使用,但头文件引用保留以备扩展)
|
||||
#include "lib/net/uhttpd/uhttpd.h" // 超轻量 HTTP 服务器库(本文件未直接使用,保留以备扩展)
|
||||
#include "lib/umac/ieee80211.h" // IEEE 802.11 协议定义(WiFi 事件枚举、模式宏等)
|
||||
#include "lib/net/utils.h" // 网络工具函数(如 lwip_netif_set_dhcp2 等)
|
||||
#include "lwip/err.h" // LwIP 错误码定义
|
||||
#include "lwip/sockets.h" // LwIP BSD socket 兼容层
|
||||
#include "lwip/netdb.h" // LwIP 网络数据库函数(gethostbyname 等)
|
||||
#include "lwip/sys.h" // LwIP 系统抽象层(线程、信号量等)
|
||||
#include "lwip/ip_addr.h" // LwIP IP 地址操作宏(IPSTR、IP2STR_N 等)
|
||||
#include "lwip/tcpip.h" // LwIP TCP/IP 协议栈核心接口
|
||||
#include "lwip/dns.h" // LwIP DNS 解析接口(dns_getserver 等)
|
||||
#include "netif/ethernetif.h" // 以太网网络接口驱动层
|
||||
#include "lwip/apps/netbiosns.h" // LwIP NetBIOS 名称服务(本文件未直接使用,保留以备扩展)
|
||||
#include "lwip/dns.h" // LwIP DNS 头文件(重复包含,无副作用,保留原始代码不变)
|
||||
#include "syscfg.h" // 系统配置持久化存储接口(syscfg_save 等)
|
||||
#include "lib/bluetooth/uble/ble_demo.h" // BLE 蓝牙低功耗演示模块(用于蓝牙配网功能)
|
||||
#include "sysevt_usb/sysevt_usb.h" // USB 主机事件处理(视频 USB 设备相关)
|
||||
|
||||
/**
|
||||
* @brief WiFi 配对模块的事件处理函数(外部定义)
|
||||
* 处理 WiFi 配对(pair)相关的协议栈事件
|
||||
*/
|
||||
extern int32 sys_wifi_event_hdl_wifi_pair(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2);
|
||||
|
||||
/**
|
||||
* @brief 配对指示灯模块的事件处理函数(外部定义)
|
||||
* 根据 WiFi 配对状态控制 LED 指示灯
|
||||
*/
|
||||
extern int32 sys_wifi_event_hdl_pairled(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2);
|
||||
|
||||
/**
|
||||
* @brief 配对指示灯模块的事件处理函数(重复声明,保留原始代码不变)
|
||||
*/
|
||||
extern int32 sys_wifi_event_hdl_pairled(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2);
|
||||
|
||||
/**
|
||||
* @brief 对讲机模块的事件处理函数(外部定义)
|
||||
* 处理 WiFi 对讲机(walkie-talkie)相关的协议栈事件
|
||||
*/
|
||||
extern int32 sys_wifi_event_hdl_walkietalkie(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2);
|
||||
|
||||
/**
|
||||
* @brief WiFi 配对的系统事件处理函数(外部定义)
|
||||
* 在 sys_event_hdl() 任务上下文中处理配对相关逻辑(可执行耗时操作)
|
||||
*/
|
||||
extern void sys_event_hdl_wifi_pair(uint32 event_id, uint32 data, uint32 priv);
|
||||
|
||||
/**
|
||||
* @brief 对讲机模块的系统事件处理函数(外部定义)
|
||||
* 在 sys_event_hdl() 任务上下文中处理对讲机相关逻辑(可执行耗时操作)
|
||||
*/
|
||||
extern void sys_event_hdl_walkie_talkie(uint32 event_id, uint32 data, uint32 priv);
|
||||
|
||||
/**
|
||||
* @brief 处理 DHCP 相关系统事件(WiFi 连接后启动 DHCP 客户端,DHCP 完成后保存 IP 信息)
|
||||
*
|
||||
* 该函数由 sys_event_hdl() 调用,运行在系统事件任务上下文中,可以执行耗时操作。
|
||||
* 主要处理两个事件:
|
||||
* 1. WiFi 连接成功 → 启动 DHCP 客户端获取 IP 地址
|
||||
* 2. DHCP 客户端完成 → 将获取到的 IP/掩码/网关/DNS 保存到 sys_status
|
||||
*
|
||||
* @param event_id 系统事件 ID,由 SYS_EVENT(模块, 子事件) 宏组合而成
|
||||
* @param data 事件附带的数据(本函数未使用)
|
||||
* @param priv 事件附带的私有数据(本函数未使用)
|
||||
*/
|
||||
//更新 sys_status 信息 // Update sys_status information
|
||||
static void sys_event_hdl_dhcp(uint32 event_id, uint32 data, uint32 priv)
|
||||
{
|
||||
switch (event_id) {
|
||||
/* WiFi 连接成功事件 */
|
||||
case SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_CONNECTTED):
|
||||
/* 如果配置中启用了 DHCP 客户端,则启动 DHCP 流程获取 IP 地址 */
|
||||
if (sys_cfgs.dhcpc_en) {
|
||||
sys_status.dhcpc_done = 0; // 清零 DHCP 完成标志,表示正在进行 DHCP
|
||||
lwip_netif_set_dhcp2("w0", 1); // 在 "w0"(WiFi 接口)上启动 LwIP DHCP 客户端
|
||||
os_printf(KERN_NOTICE"wifi connected, start dhcp client ...\r\n"); // 打印日志:WiFi 已连接,启动 DHCP
|
||||
}
|
||||
/* 如果当前工作在 STA(Station 站点)模式,则保存当前连接的 AP 信息到持久化配置 */
|
||||
if(sys_cfgs.wifi_mode == WIFI_MODE_STA) {
|
||||
ieee80211_conf_get_ssid(sys_cfgs.wifi_mode, sys_cfgs.ssid); // 获取当前连接的 SSID 并存入配置
|
||||
ieee80211_conf_get_psk(sys_cfgs.wifi_mode, sys_cfgs.psk); // 获取当前连接的 PSK 密码并存入配置
|
||||
sys_cfgs.key_mgmt = ieee80211_conf_get_keymgmt(sys_cfgs.wifi_mode); // 获取当前密钥管理方式(WPA/WPA2/Open)
|
||||
syscfg_save(); // 将配置持久化保存到 Flash,下次开机自动连接
|
||||
}
|
||||
break;
|
||||
|
||||
/* DHCP 客户端完成事件(成功获取到 IP 地址) */
|
||||
case SYS_EVENT(SYS_EVENT_NETWORK, SYSEVT_LWIP_DHCPC_DONE): {
|
||||
struct netif *nif = netif_find("w0"); // 通过名称 "w0" 查找 WiFi 网络接口的 netif 结构体
|
||||
sys_status.dhcpc_done = 1; // 标记 DHCP 过程已完成
|
||||
sys_status.dhcpc_result.ipaddr = nif->ip_addr.addr; // 保存 DHCP 分配的 IP 地址
|
||||
sys_status.dhcpc_result.netmask = nif->netmask.addr; // 保存 DHCP 分配的子网掩码
|
||||
sys_status.dhcpc_result.svrip = 0; // DHCP 服务器 IP 未使用,置零保留
|
||||
sys_status.dhcpc_result.router = nif->gw.addr; // 保存 DHCP 分配的默认网关地址
|
||||
sys_status.dhcpc_result.dns1 = (dns_getserver(0))->addr; // 保存主 DNS 服务器地址(索引0)
|
||||
sys_status.dhcpc_result.dns2 = (dns_getserver(1))->addr; // 保存备用 DNS 服务器地址(索引1)
|
||||
os_printf(KERN_NOTICE"dhcp done, ip:"IPSTR", mask:"IPSTR", gw:"IPSTR"\r\n", // 打印获取到的 IP 信息
|
||||
IP2STR_N(nif->ip_addr.addr), IP2STR_N(nif->netmask.addr), IP2STR_N(nif->gw.addr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 处理 LTE/4G 网卡与 WiFi 之间的网络切换事件
|
||||
*
|
||||
* 当系统同时具备 WiFi 和 LTE(通过 USB RNDIS 网卡)两种网络通路时,
|
||||
* 本函数实现优先级切换策略:WiFi 优先,WiFi 断开时回退到 LTE。
|
||||
*
|
||||
* 切换逻辑:
|
||||
* - LTE 连接且 WiFi 未连接 → 使用 LTE 作为默认网口,启动 LTE 上的 DHCP
|
||||
* - WiFi 连接成功 → 关闭 LTE 网口,切换默认网口为 WiFi(WiFi 优先)
|
||||
* - WiFi 断开 → 重新启用 LTE 网口,回退到 LTE 网络
|
||||
*
|
||||
* @param event_id 系统事件 ID
|
||||
* @param data 事件附带的数据(本函数未使用)
|
||||
* @param priv 事件附带的私有数据(本函数未使用)
|
||||
*/
|
||||
void sys_event_hdl_lte(uint32 event_id, uint32 data, uint32 priv)
|
||||
{
|
||||
#if defined(RT_USBH_WIRELESS_RNDIS) && !defined(STATIC_RNDIS_NETDEV)
|
||||
// 只在启用了RNDIS功能且是动态申请网口时才需要事件进行切换
|
||||
// Only when RNDIS feature is enabled and netdev is dynamically allocated, event-based switching is needed
|
||||
switch (event_id) {
|
||||
/* LTE 网卡连接事件(USB RNDIS 网卡已就绪) */
|
||||
case SYS_EVENT(SYS_EVENT_LTE, SYSEVT_LTE_CONNECTED):
|
||||
os_printf("lte connected\r\n"); // 打印日志:LTE 已连接
|
||||
if (sys_status.wifi_connected == 0) { // 如果 WiFi 当前未连接,则使用 LTE 作为默认网络
|
||||
lwip_netif_set_default2("l0"); // 将 "l0"(LTE 网口)设置为 LwIP 默认路由接口
|
||||
lwip_netif_set_dhcp2("l0", 1); // 在 LTE 网口上启动 DHCP 客户端获取 IP
|
||||
os_printf("start dhcp client on l0 ...\r\n"); // 打印日志:在 LTE 接口启动 DHCP
|
||||
}
|
||||
break;
|
||||
/* WiFi 连接成功事件 —— WiFi 优先级高于 LTE,关闭 LTE 网口 */
|
||||
case SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_CONNECTTED):
|
||||
lwip_netif_updown2("l0", 0); // 关闭 "l0"(LTE 网口),参数0表示 down
|
||||
lwip_netif_set_default2("w0"); // 将 "w0"(WiFi 网口)设为默认路由接口
|
||||
os_printf("wifi connected, down lte netif ...\r\n"); // 打印日志:WiFi 已连接,关闭 LTE
|
||||
break;
|
||||
/* WiFi 断开事件 —— 回退到 LTE 网络 */
|
||||
case SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_DISCONNECT):
|
||||
lwip_netif_updown2("l0", 1); // 重新启用 "l0"(LTE 网口),参数1表示 up
|
||||
lwip_netif_set_default2("l0"); // 将默认路由切回 LTE 网口
|
||||
os_printf("wifi disconnected, up lte netif ...\r\n"); // 打印日志:WiFi 已断开,启用 LTE
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 全局系统事件处理分发函数(系统事件任务上下文入口)
|
||||
*
|
||||
* 该函数是系统事件处理的核心分发器,由系统事件任务循环调用。
|
||||
* 它依次调用各功能模块的事件处理函数,实现事件的广播式分发。
|
||||
*
|
||||
* 重要特性:
|
||||
* - 运行在独立的系统事件任务上下文中,可以执行耗时操作(如 DHCP、Flash 读写)
|
||||
* - 返回 SYSEVT_CONTINUE 表示事件继续传递给后续处理函数(不截断事件)
|
||||
* - 简单功能可直接在此函数中调用处理 API,复杂功能建议通过 sys_event_take() 注册独立处理函数
|
||||
*
|
||||
* @param event_id 系统事件 ID,由 SYS_EVENT(模块, 子事件) 宏组合而成
|
||||
* @param data 事件附带的数据
|
||||
* @param priv 事件附带的私有数据
|
||||
* @return sysevt_hdl_res 返回 SYSEVT_CONTINUE 表示事件继续传递
|
||||
*/
|
||||
sysevt_hdl_res sys_event_hdl(uint32 event_id, uint32 data, uint32 priv)
|
||||
{
|
||||
#if SYS_WIFI_PAIR
|
||||
sys_event_hdl_wifi_pair(event_id, data, priv); // WiFi 配对功能的事件处理
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_WALKIE_TALKIE
|
||||
sys_event_hdl_walkie_talkie(event_id, data, priv); // 对讲机功能的事件处理
|
||||
#endif
|
||||
/*
|
||||
* 继续添加其他模块的处理函数 ...
|
||||
* Continue adding other module handlers ...
|
||||
* 一些小功能的事件处理没必要使用 sys_event_take,在此添加API调用即可。
|
||||
* Small features can simply add API calls here without using sys_event_take.
|
||||
* 复杂功能的事件处理,可以使用 sys_event_take API 注册事件处理函数。
|
||||
* Complex features can use sys_event_take API to register event handlers.
|
||||
* 使用 sys_event_take 注册,每次会消耗16byte heap memory
|
||||
* Each sys_event_take registration consumes 16 bytes of heap memory
|
||||
*/
|
||||
#if SYS_APP_BLENC
|
||||
sys_event_ble_netconfig(event_id, data, priv); // BLE 蓝牙配网功能的事件处理
|
||||
#endif
|
||||
|
||||
sys_event_hdl_dhcp(event_id, data, priv); // DHCP 客户端生命周期管理
|
||||
sys_event_hdl_lte(event_id, data, priv); // LTE/WiFi 网络切换处理
|
||||
|
||||
system_event_usbh_video_hdl(event_id, data, priv); // USB 主机视频设备事件处理
|
||||
|
||||
return SYSEVT_CONTINUE; // 返回"继续传递",不截断事件,让后续处理函数也能收到该事件
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WiFi 协议栈事件默认处理函数 —— 更新 sys_status 结构体中的 WiFi 状态
|
||||
*
|
||||
* 该函数在 sys_wifi_event_cb() 中被调用,负责将 WiFi 协议栈上报的事件
|
||||
* 转换为 sys_status 结构体中的状态字段更新,供应用层查询当前 WiFi 状态。
|
||||
*
|
||||
* @param ifidx WiFi 接口索引(0=w0, 1=w1)
|
||||
* @param evt WiFi 协议栈事件类型(IEEE80211_EVENT_xxx)
|
||||
* @param param1 事件参数1(具体含义取决于事件类型)
|
||||
* @param param2 事件参数2(具体含义取决于事件类型)
|
||||
* @return int32 固定返回 0
|
||||
*/
|
||||
//更新 sys_status 信息 // Update sys_status information
|
||||
static int32 sys_wifi_event_hdl_default(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2)
|
||||
{
|
||||
switch (evt) {
|
||||
/* WiFi 连接成功事件 */
|
||||
case IEEE80211_EVENT_CONNECTED:
|
||||
sys_status.wifi_connected = 1; // 标记 WiFi 已连接
|
||||
sys_status.wifi_status_code = 0; // 连接状态码清零(0 = 成功)
|
||||
sys_status.channel = ieee80211_conf_get_channel(WIFI_MODE_STA); // 获取当前工作信道号
|
||||
os_memcpy(sys_status.bssid, param1, 6); // 拷贝 AP 的 MAC 地址(BSSID,6字节)到状态结构体
|
||||
break;
|
||||
/* RSSI(接收信号强度指示)更新事件 */
|
||||
case IEEE80211_EVENT_RSSI:
|
||||
sys_status.rssi = (int8)param1; // 将最新的 RSSI 值(有符号8位,单位 dBm)保存到状态
|
||||
break;
|
||||
/* EVM(误差向量幅度)更新事件,反映信号调制质量 */
|
||||
case IEEE80211_EVENT_EVM:
|
||||
sys_status.evm = (int8)param1; // 将最新的 EVM 值保存到状态,值越小信号质量越好
|
||||
break;
|
||||
/* WiFi 连接失败事件 */
|
||||
case IEEE80211_EVENT_CONNECT_FAIL:
|
||||
sys_status.wifi_connected = 0; // 标记 WiFi 未连接
|
||||
sys_status.wifi_status_code = param2; // 保存失败原因状态码,用于诊断连接失败原因
|
||||
break;
|
||||
/* WiFi 断开连接事件 */
|
||||
case IEEE80211_EVENT_DISCONNECTED:
|
||||
sys_status.wifi_connected = 0; // 标记 WiFi 未连接
|
||||
sys_status.wifi_reason_code = param2; // 保存断开原因码(如 beacon 超时、AP 主动断开等)
|
||||
break;
|
||||
/* WiFi 接口使能(启用)事件 */
|
||||
case IEEE80211_EVENT_INTERFACE_ENABLE:
|
||||
sys_status.wifi_mode = param1; // 记录当前 WiFi 工作模式(STA/AP/MONITOR 等)
|
||||
break;
|
||||
/* 信道切换事件(可能由 DFS 雷达检测触发,或手动切换信道) */
|
||||
case IEEE80211_EVENT_CHANNEL_CHANGE:
|
||||
sys_status.channel = param2; // 更新当前工作信道号到状态结构体
|
||||
sys_cfgs.channel = param2; // 同步更新配置中的信道号(可能是 DFS 信道切换)
|
||||
break;
|
||||
default:
|
||||
break; // 未处理的事件类型,忽略
|
||||
}
|
||||
|
||||
return 0; // 返回 0,表示处理完成
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WiFi 协议栈事件回调函数 —— 在协议栈任务上下文中执行的入口
|
||||
*
|
||||
* 该函数由 WiFi 协议栈在事件发生时直接调用,运行在协议栈任务(或中断)上下文中。
|
||||
*
|
||||
* 【重要约束】由于运行在协议栈任务上下文:
|
||||
* - 禁止执行耗时操作(如 DHCP 流程、Flash 读写、长循环等)
|
||||
* - 只能做轻量级操作(更新状态变量、设置标志位、发送信号量等)
|
||||
* - 需要执行耗时逻辑时,应通过 sys_event_post() 将事件转发到 sys_event_hdl() 处理
|
||||
*
|
||||
* 各子处理函数的返回值通过位或(|=)合并,用于向协议栈返回处理结果。
|
||||
*
|
||||
* @param ifidx WiFi 接口索引(0=w0, 1=w1)
|
||||
* @param evt WiFi 协议栈事件类型(IEEE80211_EVENT_xxx)
|
||||
* @param param1 事件参数1(如 BSSID 指针、RSSI 值等)
|
||||
* @param param2 事件参数2(如原因码、状态码等)
|
||||
* @return int32 各子处理函数返回值的位或结果
|
||||
*/
|
||||
//WiFi协议栈的事件回调函数 // WiFi protocol stack event callback function
|
||||
// 该callback是在WiFi协议栈的Task中执行,因此该callback中不能执行耗时的代码
|
||||
// This callback executes in the WiFi protocol stack Task, so time-consuming code is not allowed
|
||||
// 耗时的代码逻辑,可以使用sys_event_hdl来执行
|
||||
// Time-consuming logic should be dispatched to sys_event_hdl for execution
|
||||
int32 sys_wifi_event_cb(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2)
|
||||
{
|
||||
int32 ret = 0; // 初始化返回值为 0,后续通过位或累加各子处理函数的结果
|
||||
|
||||
#if SYS_WIFI_PAIR
|
||||
ret |= sys_wifi_event_hdl_wifi_pair(ifidx, evt, param1, param2); // WiFi 配对功能处理
|
||||
#endif
|
||||
|
||||
#if SYS_WIFI_PAIRLED
|
||||
ret |= sys_wifi_event_hdl_pairled(ifidx, evt, param1, param2); // 配对指示灯功能处理
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_WALKIE_TALKIE
|
||||
ret |= sys_wifi_event_hdl_walkietalkie(ifidx, evt, param1, param2); // 对讲机功能处理
|
||||
#endif
|
||||
/*
|
||||
* 继续添加其他模块的处理函数 ...
|
||||
* Continue adding other module handlers ...
|
||||
*/
|
||||
|
||||
ret |= sys_wifi_event_hdl_default(ifidx, evt, param1, param2); // 默认处理:更新 sys_status 状态
|
||||
return ret; // 返回合并后的处理结果
|
||||
}
|
||||
438
project/main.c
Normal file
438
project/main.c
Normal file
@@ -0,0 +1,438 @@
|
||||
/* 包含系统配置头文件,提供芯片时钟、电源管理等底层硬件配置 */
|
||||
#include "sys_config.h"
|
||||
/* 包含基础头文件集合,提供常用类型定义和宏 */
|
||||
#include "basic_include.h"
|
||||
/* 包含ADC(模数转换器)驱动头文件,用于模拟信号采集 */
|
||||
#include "hal/adc.h"
|
||||
/* 包含CPU间RPC(远程过程调用)通信库,用于CPU0和CPU1之间的消息传递 */
|
||||
#include "lib/rpc/cpurpc.h"
|
||||
/* 包含AT命令解析库,用于通过串口发送AT指令进行模块配置 */
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
/* 包含通用AT命令定义,提供系统常用的AT命令接口 */
|
||||
#include "lib/common/atcmd.h"
|
||||
/* 包含IEEE 802.11无线网络协议定义,提供WiFi MAC帧结构等 */
|
||||
#include "lib/umac/ieee80211.h"
|
||||
/* 包含低层MAC(LMAC)驱动,提供WiFi底层硬件访问接口 */
|
||||
#include "lib/lmac/lmac.h"
|
||||
/* 包含BLE(低功耗蓝牙)演示程序头文件,提供蓝牙配网等功能 */
|
||||
#include "lib/bluetooth/uble/ble_demo.h"
|
||||
|
||||
/* 包含lwIP(轻量级TCP/IP协议栈)错误码定义 */
|
||||
#include "lwip/err.h"
|
||||
/* 包含lwIP套接字接口,提供类似BSD socket的API */
|
||||
#include "lwip/sockets.h"
|
||||
/* 包含lwIP网络域名解析接口,提供gethostbyname等DNS功能 */
|
||||
#include "lwip/netdb.h"
|
||||
/* 包含lwIP系统抽象层,提供线程、信号量等操作系统抽象 */
|
||||
#include "lwip/sys.h"
|
||||
/* 包含lwIP IP地址操作接口,提供IP地址的解析和转换功能 */
|
||||
#include "lwip/ip_addr.h"
|
||||
/* 包含lwIP TCP/IP协议栈核心初始化接口 */
|
||||
#include "lwip/tcpip.h"
|
||||
/* 包含以太网网络接口驱动,提供以太网底层收发功能 */
|
||||
#include "netif/ethernetif.h"
|
||||
|
||||
/* 包含DHCP服务器头文件,用于设备作为AP时为客户端分配IP地址 */
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
/* 包含网络工具函数,提供IP地址转换等网络辅助功能 */
|
||||
#include "lib/net/utils.h"
|
||||
/* 包含网络Socket监控模块,用于监控socket状态和连接信息 */
|
||||
#include "lib/net/skmonitor/skmonitor.h"
|
||||
/* 包含系统配置管理头文件,提供系统参数的读写和存储功能 */
|
||||
#include "syscfg.h"
|
||||
/* 包含用户应用层头文件,提供FPV、对讲机等应用初始化接口 */
|
||||
#include "app/user_app.h"
|
||||
/* 包含CPU1内存管理头文件,提供CPU1侧的堆内存获取接口 */
|
||||
#include "cpu1_mem.h"
|
||||
|
||||
/* 外部引用:SRAM内存池的起始地址(由链接脚本定义) */
|
||||
extern uint32 srampool_start;
|
||||
/* 外部引用:SRAM内存池的结束地址(由链接脚本定义) */
|
||||
extern uint32 srampool_end;
|
||||
/* 外部引用:PSRAM(伪静态RAM)内存池的起始地址(由链接脚本定义) */
|
||||
extern uint32 psrampool_start;
|
||||
/* 外部引用:PSRAM内存池的结束地址(由链接脚本定义) */
|
||||
extern uint32 psrampool_end;
|
||||
|
||||
/* 定义主循环工作队列结构体,用于定时执行系统主循环任务 */
|
||||
static struct os_work main_wk;
|
||||
/* 定义全局系统状态结构体变量,保存系统运行时的各种状态标志 */
|
||||
struct system_status sys_status;
|
||||
|
||||
/* 外部引用:系统事件处理函数,处理WiFi连接、网络状态等系统事件 */
|
||||
extern sysevt_hdl_res sys_event_hdl(uint32 event_id, uint32 data, uint32 priv);
|
||||
/* 外部引用:WiFi设备状态查询函数,用于获取WiFi模块的调试信息 */
|
||||
extern void wifi_dev_status(uint32 dev_id);
|
||||
/* 外部引用:系统AT命令初始化函数,注册系统支持的AT命令 */
|
||||
extern void sys_atcmd_init(void);
|
||||
/* 外部引用:WiFi测试模式初始化函数,用于产线射频测试 */
|
||||
extern void sys_wifi_test_mode_init(void);
|
||||
/* 外部引用:WiFi模块初始化函数,初始化WiFi硬件和协议栈 */
|
||||
extern void sys_wifi_init(void);
|
||||
/* 外部引用:网络初始化函数,配置网络接口和协议参数 */
|
||||
extern void sys_network_init(void);
|
||||
/* 外部引用:DHCP服务器启动函数,在AP模式下为客户端分配IP */
|
||||
extern void sys_dhcpd_start(void);
|
||||
/* 外部引用:DHCP客户端检查函数,检查STA模式下是否成功获取IP */
|
||||
extern void sys_dhcpc_check(void);
|
||||
|
||||
/* CPU间RPC通信初始化函数,标记为__init表示仅在系统启动时执行一次 */
|
||||
static __init void sys_cpurpc_init()
|
||||
{
|
||||
/* 初始化CPU0的消息邮箱通信,指定邮箱基地址和收发中断号 */
|
||||
cpu_rpc_init(CPU0_MSGBOX_BASE, CPU_RECV_MAIL_IRQn, CPU_SEND_MAIL_IRQn);
|
||||
}
|
||||
|
||||
/* 系统配置加载函数,从Flash中读取保存的系统配置参数 */
|
||||
__init static void sys_cfg_load(void)
|
||||
{
|
||||
/* 尝试从Flash中加载名为"syscfg"的配置数据,如果成功则直接返回 */
|
||||
if (syscfg_init("syscfg", &sys_cfgs, sizeof(sys_cfgs)) == RET_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* 如果加载失败(首次启动或数据损坏),打印提示信息 */
|
||||
os_printf("use default params.\r\n");
|
||||
/* 使用默认的出厂配置参数填充sys_cfgs结构体 */
|
||||
syscfg_default();
|
||||
/* 将默认配置保存到Flash中,以便下次启动时可以直接加载 */
|
||||
syscfg_save();
|
||||
}
|
||||
|
||||
/* 系统调试时间打印函数,用于定时打印当前系统时间(SNTP同步后) */
|
||||
static void sys_print_dbgtime(uint32 *buff, uint32 size)
|
||||
{
|
||||
#if SYS_APP_SNTP
|
||||
/* 定义timeval结构体变量,用于获取当前的秒和微秒时间 */
|
||||
struct timeval tv;
|
||||
/* 调用gettimeofday获取当前系统时间 */
|
||||
gettimeofday(&tv, 0);
|
||||
/* 将时间加上8小时(东八区/北京时间)的偏移量 */
|
||||
tv.tv_sec += 8 * 3600;
|
||||
/* 将时间戳转换为可读的字符串格式并打印 */
|
||||
os_printf("system time: %s\r\n", ctime((const time_t *)&tv.tv_sec));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 系统调试Cache命中率打印函数,用于监控CPU Cache的效率 */
|
||||
static void sys_print_dbgcache(uint32 *buff, uint32 size)
|
||||
{
|
||||
/* 仅在调试开关打开时执行Cache统计信息打印 */
|
||||
if (sys_status.dbg_cache) {
|
||||
/* 获取CPU侧CSI(指令)Cache的未命中次数,参数1表示打印后重置统计 */
|
||||
uint32 csi_miss = sys_csi_cache_static(sysctrl_get_cpu_id(), 1);
|
||||
/* 获取CLD(数据)Cache的未命中次数,参数1表示打印后重置统计 */
|
||||
uint32 cld_miss = sys_cld_cache_static(1);
|
||||
/* 根据Cache未命中率动态调整PSRAM效率优化策略 */
|
||||
sys_psram_eff_static((cld_miss > 20) || (csi_miss > 30));
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统调试CPU使用率打印函数,用于监控各任务的CPU占用情况 */
|
||||
static void sys_print_dbgtop(uint32 *buff, uint32 size)
|
||||
{
|
||||
/* 仅在调试开关打开时执行CPU使用率打印 */
|
||||
if (sys_status.dbg_top) {
|
||||
/* 打印CPU各任务的使用率信息,参数1表示是否打印详细信息(dbg_top==2时) */
|
||||
cpu_loading_print(sys_status.dbg_top == 2, (struct os_task_info *)buff, size / sizeof(struct os_task_info));
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统调试Heap内存使用情况打印函数,用于监控SRAM和PSRAM的内存分配 */
|
||||
static void sys_print_dbgheap(uint32 *buff, uint32 size)
|
||||
{
|
||||
/* 仅在调试开关打开时执行Heap使用情况打印 */
|
||||
if (sys_status.dbg_heap) {
|
||||
/* 打印SRAM Heap的使用状况(空闲块数、最大连续空闲空间等) */
|
||||
sysheap_status(&sram_heap, buff, size / 4, 0);
|
||||
#ifdef PSRAM_HEAP
|
||||
/* 如果启用了PSRAM作为Heap,也打印PSRAM Heap的使用状况 */
|
||||
sysheap_status(&psram_heap, buff, size / 4, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统调试WiFi MAC层信息打印函数,用于排查WiFi连接问题 */
|
||||
static void sys_print_dbgumac(uint32 *buff, uint32 size)
|
||||
{
|
||||
/* 仅在调试开关打开时执行WiFi调试信息打印 */
|
||||
if (sys_status.dbg_umac) {
|
||||
/* 打印WiFi设备(设备ID为HG_WIFI0_DEVID)的当前状态信息 */
|
||||
wifi_dev_status(HG_WIFI0_DEVID);
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统调试网络信息打印函数,用于显示当前网络接口的IP地址和DHCP状态 */
|
||||
static void sys_print_dbgnet(uint32 *buff, uint32 size)
|
||||
{
|
||||
/* 定义指向网络接口结构体的指针 */
|
||||
struct netif *nif;
|
||||
|
||||
/* 仅在调试开关打开时执行网络信息打印 */
|
||||
if (sys_status.dbg_net){
|
||||
/* 打印分隔线,美化输出格式 */
|
||||
os_printf("-----------------------------------------------------\r\n");
|
||||
/* 打印网络信息标题 */
|
||||
os_printf("Network Info:\r\n");
|
||||
/* 查找名为"w0"的无线网络接口 */
|
||||
nif = netif_find("w0");
|
||||
/* 如果找到无线接口,打印其IP地址、子网掩码和网关地址 */
|
||||
if(nif){
|
||||
/* 打印WiFi接口的IP配置,同时显示是DHCP获取还是静态配置 */
|
||||
os_printf(" w0: (%s) "IPSTR"/"IPSTR"/"IPSTR"\r\n",
|
||||
(sys_cfgs.dhcpc_en && sys_status.dhcpc_done)?"DHCP":"Static",
|
||||
IP2STR_N(nif->ip_addr.addr), IP2STR_N(nif->netmask.addr), IP2STR_N(nif->gw.addr));
|
||||
}
|
||||
|
||||
/* 查找名为"e0"的有线以太网网络接口 */
|
||||
nif = netif_find("e0");
|
||||
/* 如果找到以太网接口,打印其IP地址、子网掩码和网关地址 */
|
||||
if(nif){
|
||||
/* 打印以太网接口的IP配置信息 */
|
||||
os_printf(" e0: (%s) "IPSTR"/"IPSTR"/"IPSTR"\r\n", sys_cfgs.dhcpc_en?"DHCP":"Static",
|
||||
IP2STR_N(nif->ip_addr.addr), IP2STR_N(nif->netmask.addr), IP2STR_N(nif->gw.addr));
|
||||
}
|
||||
|
||||
#if IP_NAT
|
||||
/* 如果启用了NAT(网络地址转换),打印NAT映射表状态 */
|
||||
os_printf("-----------------------------------------------------\r\n");
|
||||
ip4_nat_status();
|
||||
#endif
|
||||
|
||||
/* 如果启用了DHCP服务器,打印当前已分配的IP地址池信息 */
|
||||
if(sys_cfgs.dhcpd_en){
|
||||
os_printf("-----------------------------------------------------\r\n");
|
||||
dhcpd_dump_ippool();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统调试信息汇总打印函数,每隔5秒定时调用一次各子打印函数 */
|
||||
static void sys_dbginfo_print(void)
|
||||
{
|
||||
/* 静态变量记录打印间隔计数器,用于控制每5秒打印一次 */
|
||||
static int8 print_interval = 0;
|
||||
#if 0
|
||||
/* 静态缓冲区方案(常驻内存,不占用任务栈空间) */
|
||||
static uint32 _print_buf[256];
|
||||
#else
|
||||
/* 局部缓冲区方案(使用任务栈空间,函数返回后自动释放) */
|
||||
uint32 _print_buf[256];
|
||||
/* 断言检查:确保缓冲区大小不超过1600字节,防止任务栈溢出 */
|
||||
ASSERT(sizeof(_print_buf) < 1600);
|
||||
#endif
|
||||
|
||||
/* 计数器递增,当达到5时(即5秒后)执行一轮调试信息打印 */
|
||||
if (print_interval++ >= 5) {
|
||||
/* 打印Cache命中率和PSRAM效率统计 */
|
||||
sys_print_dbgcache(_print_buf, sizeof(_print_buf));
|
||||
/* 打印CPU各任务的使用率 */
|
||||
sys_print_dbgtop(_print_buf, sizeof(_print_buf));
|
||||
/* 打印SRAM和PSRAM的Heap内存使用情况 */
|
||||
sys_print_dbgheap(_print_buf, sizeof(_print_buf));
|
||||
/* 打印WiFi MAC层的调试信息 */
|
||||
sys_print_dbgumac(_print_buf, sizeof(_print_buf));
|
||||
/* 打印当前系统时间(SNTP同步后) */
|
||||
sys_print_dbgtime(_print_buf, sizeof(_print_buf));
|
||||
/* 打印网络接口的IP地址和DHCP信息 */
|
||||
sys_print_dbgnet(_print_buf, sizeof(_print_buf));
|
||||
/* 重置计数器,开始下一个5秒周期 */
|
||||
print_interval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 系统Heap内存布局信息打印函数,在启动时显示各内存区域的分配情况 */
|
||||
__init static void sys_heap_info()
|
||||
{
|
||||
/* 打印分隔线 */
|
||||
os_printf("------------------------------------------------------------\r\n");
|
||||
/* 打印系统Heap的总体信息:总大小和起始地址范围 */
|
||||
os_printf("System Heaps Info, Total: %d (%p ~ %p)\r\n", SRAM_POOL_SIZE, SRAM_POOL_START, SRAM_POOL_START+SRAM_POOL_SIZE);
|
||||
/* 定义CPU1 Heap内存区域的起始指针 */
|
||||
uint8_t *cpu1_heap;
|
||||
/* 定义CPU1 SKB(Socket缓冲区)内存池的起始指针 */
|
||||
uint8_t *skb_heap;
|
||||
/* 定义CPU1接收缓冲区内存池的起始指针 */
|
||||
uint8_t *rxbuf_heap;
|
||||
/* 定义CPU1 Heap内存区域的大小 */
|
||||
uint32_t cpu1_heap_size;
|
||||
/* 定义CPU1 SKB内存池的大小 */
|
||||
uint32_t skb_heap_size;
|
||||
/* 定义CPU1接收缓冲区内存池的大小 */
|
||||
uint32_t rxbuf_heap_size;
|
||||
|
||||
/* 获取CPU1 Heap内存区域的起始地址和大小 */
|
||||
cpu1_heap = (uint8_t*)cpu1_heap_get(&cpu1_heap_size);
|
||||
/* 获取CPU1 SKB(Socket Buffer)内存池的起始地址和大小 */
|
||||
skb_heap = (uint8_t*)cpu1_skb_heap_get(&skb_heap_size);
|
||||
/* 获取CPU1接收缓冲区内存池的起始地址和大小 */
|
||||
rxbuf_heap = (uint8_t*)cpu1_RXBUF_heap_get(&rxbuf_heap_size);
|
||||
/* 打印CPU1 Heap的地址范围和大小 */
|
||||
os_printf("| CPU1 HEAP : %p ~ %p, Size:%-8d |\r\n", cpu1_heap, cpu1_heap+cpu1_heap_size, cpu1_heap_size);
|
||||
/* 打印CPU1接收缓冲区的地址范围和大小 */
|
||||
os_printf("| CPU1 RXBUF : %p ~ %p, Size:%-8d |\r\n", rxbuf_heap, rxbuf_heap+rxbuf_heap_size, rxbuf_heap_size);
|
||||
/* 打印CPU1 SKB内存池的地址范围和大小 */
|
||||
os_printf("| CPU1 SKBPOOL: %p ~ %p, Size:%-8d |\r\n", skb_heap, skb_heap+skb_heap_size, skb_heap_size);
|
||||
/* 打印CPU0 AVHEAP(音视频堆)的地址范围和大小(已注释掉) */
|
||||
//os_printf("| CPU0 AVHEAP : %p ~ %p, Size:%-8d |\r\n", CONFIG_AVHEAP_START, CONFIG_AVHEAP_START+CONFIG_AVHEAP_SIZE, CONFIG_AVHEAP_SIZE);
|
||||
/* 打印CPU0系统Heap的地址范围和大小 */
|
||||
os_printf("| CPU0 HEAP : %p ~ %p, Size:%-8d |\r\n", SYS_HEAP_START, SYS_HEAP_START+SYS_HEAP_SIZE, SYS_HEAP_SIZE);
|
||||
/* 打印分隔线 */
|
||||
os_printf("------------------------------------------------------------\r\n");
|
||||
/* 释放CPU1信息查询时分配的内存资源 */
|
||||
cpu1_info_free();
|
||||
}
|
||||
|
||||
/* 系统主循环函数,每1000ms被工作队列调度执行一次 */
|
||||
static int32 sys_main_loop(struct os_work *work)
|
||||
{
|
||||
/* 喂MCU看门狗,防止系统死机时看门狗超时复位 */
|
||||
mcu_watchdog_feed();
|
||||
/* 调用调试信息打印函数,定时输出系统运行状态 */
|
||||
sys_dbginfo_print();
|
||||
|
||||
#if SYS_NETWORK_SUPPORT
|
||||
/* 如果系统支持网络功能,检查DHCP客户端是否成功获取IP地址 */
|
||||
sys_dhcpc_check();
|
||||
#endif
|
||||
|
||||
/* 将主循环工作项重新加入队列,1000ms后再次执行本函数 */
|
||||
os_run_work_delay(&main_wk, 1000);
|
||||
/* 返回0表示函数执行成功 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 系统应用层初始化函数,根据不同的宏配置启动对应的应用模块 */
|
||||
__init static void sys_app_init(void)
|
||||
{
|
||||
#if SYS_APP_DHCPD && SYS_NETWORK_SUPPORT
|
||||
/* 如果启用了DHCP服务器且支持网络,启动DHCP服务器为连接的客户端分配IP */
|
||||
sys_dhcpd_start();
|
||||
#endif
|
||||
|
||||
#if SYS_APP_SNTP && SYS_NETWORK_SUPPORT
|
||||
/* 如果启用了SNTP时间同步且支持网络,连接阿里云NTP服务器进行时间同步,超时2秒 */
|
||||
sntp_client_init("ntp.aliyun.com", 2);
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_FPV
|
||||
/* 如果启用了FPV(第一人称视角)图传应用,初始化FPV模块 */
|
||||
sys_app_fpv_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_DEMO
|
||||
/* 如果启用了通用Demo应用,初始化Demo模块 */
|
||||
sys_app_demo_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_IPC
|
||||
/* 如果启用了IPC(网络摄像头)应用,初始化IPC模块 */
|
||||
sys_app_ipc_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_BBM_LCD
|
||||
/* 如果启用了BBM(婴儿监视器)LCD显示端应用,初始化LCD显示模块 */
|
||||
sys_app_bbm_lcd_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_WALKIE_TALKIE
|
||||
/* 如果启用了对讲机应用,初始化对讲机模块 */
|
||||
sys_app_walkie_talkie_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_BBM_CAM
|
||||
/* 如果启用了BBM(婴儿监视器)摄像头端应用,初始化摄像头模块 */
|
||||
sys_app_bbm_cam_init();
|
||||
#endif
|
||||
|
||||
#if SYS_APP_BLENC
|
||||
/* 如果启用了BLE配网功能,初始化蓝牙网络配置模块 */
|
||||
sys_ble_netconfig_init();
|
||||
#endif
|
||||
|
||||
#if SYS_WIFI_PAIR
|
||||
/* 如果启用了WiFi配对功能,初始化WiFi配对模块 */
|
||||
sys_wifi_pair_init();
|
||||
#endif
|
||||
|
||||
#if SYS_WIFI_PAIR_LED
|
||||
/* 如果启用了WiFi配对LED指示灯功能,初始化配对状态的LED显示 */
|
||||
sys_wifi_pair_led_init();
|
||||
#endif
|
||||
|
||||
#ifdef SYS_APP_ISP_TUNNING
|
||||
/* 如果启用了ISP调参应用,初始化ISP图像调参模块 */
|
||||
sys_app_isp_tunning_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 用户应用初始化函数,用户可在此添加自定义的应用初始化代码 */
|
||||
__init static void usr_app_init(void)
|
||||
{
|
||||
/*
|
||||
添加用户App代码初始化
|
||||
*/
|
||||
}
|
||||
|
||||
/* 看门狗喂狗循环函数,仅在WiFi测试模式下使用,防止测试时看门狗复位 */
|
||||
static int32 watchdog_loop(struct os_work *work)
|
||||
{
|
||||
/* 喂MCU看门狗,保持系统运行 */
|
||||
mcu_watchdog_feed();
|
||||
/* 将看门狗喂狗工作项重新加入队列,1000ms后再次执行 */
|
||||
os_run_work_delay(&main_wk, 1000);
|
||||
/* 返回0表示函数执行成功 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 系统主入口函数,芯片上电后首先执行此函数 */
|
||||
int main(void)
|
||||
{
|
||||
/* 设置MCU看门狗超时时间为0(禁用MCU看门狗),防止调试时意外复位 */
|
||||
mcu_watchdog_timeout(0);
|
||||
/* 初始化CPU间RPC通信通道,建立CPU0和CPU1之间的消息传递机制 */
|
||||
sys_cpurpc_init();
|
||||
/* 打印系统各内存区域的布局信息(Heap、PSRAM、SKB池等) */
|
||||
sys_heap_info();
|
||||
/* 从Flash加载系统配置参数,如果加载失败则使用默认配置并保存 */
|
||||
sys_cfg_load();
|
||||
/* 初始化系统事件队列,设置队列深度为32个事件 */
|
||||
sys_event_init(32);
|
||||
/* 初始化系统AT命令模块,注册所有支持的AT命令 */
|
||||
sys_atcmd_init();
|
||||
|
||||
/* 检查系统是否处于WiFi产线测试模式 */
|
||||
if (system_is_wifi_test_mode()) {
|
||||
/* 进入WiFi测试模式,初始化射频测试所需的硬件和参数 */
|
||||
sys_wifi_test_mode_init();
|
||||
/* 测试完成后重启进入正常工作模式 */
|
||||
system_reboot_normal_mode();
|
||||
/* 初始化看门狗喂狗工作项,绑定watchdog_loop回调函数 */
|
||||
OS_WORK_INIT(&main_wk, watchdog_loop, 0);
|
||||
/* 延时1000ms后开始执行看门狗喂狗循环 */
|
||||
os_run_work_delay(&main_wk, 1000);
|
||||
}else{
|
||||
/* 正常工作模式:初始化WiFi硬件和协议栈 */
|
||||
sys_wifi_init();
|
||||
/* 初始化网络接口,配置IP地址和协议参数 */
|
||||
sys_network_init();
|
||||
/* 调用所有C++全局对象的构造函数(如果项目中包含C++代码) */
|
||||
do_global_ctors();
|
||||
/* 根据宏配置初始化对应的应用模块(FPV、对讲机等) */
|
||||
sys_app_init();
|
||||
/* 执行用户自定义的应用初始化代码 */
|
||||
usr_app_init();
|
||||
/* 启动系统事件处理循环,接收并分发系统事件(WiFi连接、断开等) */
|
||||
sys_event_take(0xffffffff, sys_event_hdl, 0);
|
||||
/* 初始化主循环工作项,绑定sys_main_loop回调函数 */
|
||||
OS_WORK_INIT(&main_wk, sys_main_loop, 0);
|
||||
/* 延时1000ms后开始执行系统主循环 */
|
||||
os_run_work_delay(&main_wk, 1000);
|
||||
}
|
||||
/* 设置PMU(电源管理单元)看门狗超时时间为0(禁用PMU看门狗),
|
||||
放在sys_wifi_init之后是因为WiFi初始化可能需要较长耗时 */
|
||||
pmu_watchdog_timeout(0);
|
||||
/* 主函数返回0(实际上RTOS环境下不会执行到此处) */
|
||||
return 0;
|
||||
}
|
||||
BIN
project/makecode.exe
Normal file
BIN
project/makecode.exe
Normal file
Binary file not shown.
81
project/makecode.ini
Normal file
81
project/makecode.ini
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
[COMMON]
|
||||
CodeFile=txw82xApp.bin
|
||||
KeyFilePath=
|
||||
CodeType=1 ; destination code type: 1(SPI), 2(EFLASH_NVR), 3(EFLASH)
|
||||
ParamOffset=230 ; code param address Offset
|
||||
ParamFile=
|
||||
MemEndianLE=1 ; code endian : little endian
|
||||
CPU_ID=0
|
||||
CHIP_ID=8401 ; chip id
|
||||
CustomerID=1001 ; customer id, when aes enabled, CustomerID is use to Authorization & code encrypt
|
||||
Post_Script= merge.bat
|
||||
|
||||
[SPI]
|
||||
CodeCRC16=1 ; spi code crc enable
|
||||
Flag=5A69 ; fixed
|
||||
Version=0x0100 ; code version
|
||||
CodeLoadToSramAddr=10000000 ; code load to sram start address
|
||||
CodeExeAddr=10000000 ; code run start address
|
||||
CodeAddrOffset=c00 ; code load from spi flash address Offset >= 1024 + param length
|
||||
CodeLoadLen=2000 ; code load to sram length
|
||||
SPI_SIZE=100000 ; spi flash size
|
||||
SPI_CLK_MHZ=3c ; spi clk : 13Mhz
|
||||
DriverStrength=0 ; DriverStrength : [0/1/2/3], bigger sign stronger
|
||||
PLL_SRC_MHZ=28 ;
|
||||
PLL_EN=1 ;
|
||||
DebugInfoEn=0 ;
|
||||
AesEnable=0 ; aes encrypt enable
|
||||
; advance config, !example:
|
||||
;03-> Dummy = 0, 1-1-1, wire4EN=0, SquenceEn=0
|
||||
;3B-> Dummy = 8, 1-1-2, wire4EN=0, SquenceEn=0
|
||||
;BB-> Dummy = 4, 1-2-2, wire4EN=0, SquenceEn=0
|
||||
;6b-> Dummy = 8, 1-1-4, wire4EN=1, SquenceEn=1
|
||||
;EB-> Dummy = 6, 1-4-4, wire4EN=1, SquenceEn=1
|
||||
ReadCmd=EB ; spi read cmd index : normal(03)/fast(0B)/dual(3B)/quad(6B)/QPI(EB)
|
||||
ReadCmdDummy=6 ; dummy clk
|
||||
ClockMode=0 ; clock mode [0,3]
|
||||
SampleDelay=55AA ; 16bit sample delay cnt in spi_clk_divor
|
||||
WireModeWhenCmd=1 ; wire mode : [1/2/4], 6 for 3wire mode
|
||||
WireModeWhenAddr=4 ; wire mode : [1/2/4], 6 for 3wire mode
|
||||
WireModeWhenData=4 ; wire mode : [1/2/4], 6 for 3wire mode
|
||||
WireMode4Select=0 ; 4wire mode : D2/D3 io select[0,2]
|
||||
WireMode4En=1 ; 4wire mode enable[0,1]
|
||||
SpecSquenceEn=1 ; spec cmd squence before cmd read, eg.use for dual/quad cmd
|
||||
SpecSquenceNumbers=6 ; spec cmd squence (format: cmd + dummy + data_lens + data) numbers
|
||||
SpecSquence0=50000000 ; spec cmd "write enable "
|
||||
SpecSquence1=0100020002 ; spec cmd "qual mode enable for winbond "
|
||||
SpecSquence2=05800101 ; spec cmd "wait busy "
|
||||
SpecSquence3=50000000 ; spec cmd "write enable "
|
||||
SpecSquence4=31000102 ; spec cmd "qual mode enable for winbond "
|
||||
SpecSquence5=05800101 ; spec cmd "wait busy "
|
||||
SpecSquence6=38000000 ; spec cmd "QPI enable"
|
||||
SpecSquence8=C0000133 ; spec cmd "Set Read Param"
|
||||
|
||||
|
||||
[EFLASH_NVR]
|
||||
CRC32_EN=1 ; code crc32 enable
|
||||
|
||||
[EFLASH]
|
||||
CHIP_ID=5002 ; chip id
|
||||
EXE_ADDR=10006000 ; code run start address
|
||||
CODE_COPIES=2 ; code copies
|
||||
CODE_LEN=8000 ; code length
|
||||
CRC32_EN=1 ; code crc32 enable
|
||||
NVR0_EW_EN=1 ; nvr0 erase & program enable
|
||||
NVR1_EW_EN=1 ; nvr1 erase & program enable
|
||||
NVR2_EW_EN=1 ; nvr2 erase & program enable
|
||||
MAIN_EW_EN_BITMAP=FFFFFFFF ; main erase & program enable : bitmap to all main array
|
||||
EXTERNAL_KEY_DIS=1 ; external key disable : 1(interal key), 0(external key)
|
||||
EXTERNAL_KEY=0 ; external key
|
||||
USERDATA_AREA_CNT=2 ; user data area size
|
||||
UART_BOOT_EN=1 ; uart boot enable
|
||||
NVR_CODE_BAK_EN=0 ; nvr code bak enable
|
||||
NVR_CODE_BAK_SECTOR_ADDR=120 ; nvr code bak addr
|
||||
UART_BOOT_PIN_SEL=13 ; uart boot pin select
|
||||
SWD_Remaping_en=0 ; swd remapping enable
|
||||
SYS_MCLR_EN=1 ; mclr pin enable
|
||||
SYS_SWD_EN=1 ; swd enable
|
||||
SYS_SWD_IO_PU_EN=1 ; swd io default pull-up enable 1:enable, 0:pull-down
|
||||
MAIN_CODE_CRC32_HWCHECK_EN=1 ; main code crc32 chip verify enable
|
||||
|
||||
17
project/makecode_post.bat
Normal file
17
project/makecode_post.bat
Normal file
@@ -0,0 +1,17 @@
|
||||
cd /d %~dp0
|
||||
|
||||
set dirname=%1
|
||||
set dirname=%dirname:~0,-4%
|
||||
|
||||
if not exist bakup md bakup
|
||||
if not exist bakup\%dirname% md bakup\%dirname%
|
||||
|
||||
copy .\Obj\txw80x.elf bakup\%dirname%\
|
||||
copy .\Lst\txw80x.map bakup\%dirname%\
|
||||
copy makedis.bat bakup\%dirname%\
|
||||
del /q/f loader.bin
|
||||
del /q/f code512.bin
|
||||
del /q/f param.bin
|
||||
del /q/f program.bin
|
||||
del /q/f project_merge.bin
|
||||
|
||||
18
project/merge.bat
Normal file
18
project/merge.bat
Normal file
@@ -0,0 +1,18 @@
|
||||
cd /d %~dp0
|
||||
|
||||
set dirname=%1
|
||||
set dirname2=%dirname:~0,-4%
|
||||
|
||||
del %dirname2%_PSRAM.bin
|
||||
del /q/f APP.bin
|
||||
del /q/f APP_PSRAM.bin
|
||||
|
||||
copy %dirname% APP.bin
|
||||
|
||||
pin_bin.exe script.cfg
|
||||
set dirname=%dirname:~0,-4%
|
||||
set dirname=%dirname%_%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
|
||||
if not exist bakup md bakup
|
||||
if not exist bakup\%dirname% md bakup\%dirname%
|
||||
copy Lst\* bakup\%dirname%\
|
||||
copy project.map bakup\%dirname%\
|
||||
190
project/module_code/gen422_user.c
Normal file
190
project/module_code/gen422_user.c
Normal file
@@ -0,0 +1,190 @@
|
||||
#include "sys_config.h"
|
||||
#include "tx_platform.h"
|
||||
#include "osal/string.h"
|
||||
#include <csi_kernel.h>
|
||||
#include "stream_frame.h"
|
||||
#include "osal/task.h"
|
||||
#include "osal_file.h"
|
||||
#include "video_app/video_app.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "utlist.h"
|
||||
#include "jpgdef.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "dhcpd_eloop/dhcpd_eloop.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/pwm.h"
|
||||
#include "hal/uart.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi.h"
|
||||
|
||||
#define MIN(a,b) ( (a)>(b)?b:a )
|
||||
#define MAX(a,b) ( (a)>(b)?a:b )
|
||||
#define JPG_DIR "0:/DCIM"
|
||||
#define JPG_FILE_NAME "jpg"
|
||||
|
||||
|
||||
extern Vpp_stream photo_msg;
|
||||
extern uint8 video_psram_config_mem[SCALE_CONFIG_W*SCALE_HIGH+SCALE_CONFIG_W*SCALE_HIGH/2];
|
||||
volatile uint8_t scale3_oe_select = 0;
|
||||
|
||||
static uint32_t a2i(char *str)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t indx =0;
|
||||
char str_buf[32];
|
||||
memset(str_buf,0,32);
|
||||
while(str[indx] != '\0'){
|
||||
if(str[indx] == '.') break;
|
||||
str_buf[indx] = str[indx];
|
||||
indx++;
|
||||
}
|
||||
//printf("str_buf:%s str:%s\r\n",str_buf,str);
|
||||
indx = 0;
|
||||
while(str_buf[indx] != '\0'){
|
||||
if(str_buf[indx] >= '0' && str_buf[indx] <='9'){
|
||||
ret = ret*10+str_buf[indx]-'0';
|
||||
}
|
||||
indx ++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void *creat_jpg_file(char *dir_name)
|
||||
{
|
||||
DIR avi_dir;
|
||||
FRESULT ret;
|
||||
FILINFO finfo;
|
||||
uint32_t indx= 0;
|
||||
void *fp;
|
||||
char filepath[64];
|
||||
ret = f_opendir(&avi_dir,dir_name);
|
||||
if(ret != FR_OK){
|
||||
f_mkdir(dir_name);
|
||||
f_opendir(&avi_dir,dir_name);
|
||||
}
|
||||
while(1){
|
||||
ret = f_readdir(&avi_dir,&finfo);
|
||||
if(ret != FR_OK || finfo.fname[0] == 0) break;
|
||||
indx = MAX(indx,a2i(finfo.fname));
|
||||
}
|
||||
f_closedir(&avi_dir);
|
||||
indx++;
|
||||
|
||||
sprintf(filepath,"%s/h%d.%s",dir_name,indx,JPG_FILE_NAME);
|
||||
//printf("filepath:%s\r\n",filepath);
|
||||
fp = osal_fopen(filepath,"wb+");
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
static int opcode_func(stream *s,void *priv,int opcode)
|
||||
{
|
||||
int res = 0;
|
||||
//_os_printf("%s:%d\topcode:%d\n",__FUNCTION__,__LINE__,opcode);
|
||||
switch(opcode)
|
||||
{
|
||||
case STREAM_OPEN_ENTER:
|
||||
break;
|
||||
case STREAM_OPEN_EXIT:
|
||||
{
|
||||
enable_stream(s,1);
|
||||
}
|
||||
break;
|
||||
case STREAM_OPEN_FAIL:
|
||||
break;
|
||||
default:
|
||||
//默认都返回成功
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
extern uint8 *yuvbuf;
|
||||
void jpg_user_demo_thread(){
|
||||
struct data_structure *get_f = NULL;
|
||||
struct stream_jpeg_data_s *dest_list;
|
||||
struct stream_jpeg_data_s *dest_list_tmp;
|
||||
struct stream_jpeg_data_s *el,*tmp;
|
||||
struct scale_device *scale_dev;
|
||||
struct scale_device *scale2_dev;
|
||||
struct scale_device *scale3_dev;
|
||||
struct vpp_device *vpp_dev;
|
||||
struct jpg_device *jpeg_dev;
|
||||
struct jpg_device *jpeg1_dev;
|
||||
scale_dev = (struct scale_device *)dev_get(HG_SCALE1_DEVID);
|
||||
scale2_dev = (struct scale_device *)dev_get(HG_SCALE2_DEVID);
|
||||
scale3_dev = (struct scale_device *)dev_get(HG_SCALE3_DEVID);
|
||||
vpp_dev = (struct vpp_device *)dev_get(HG_VPP_DEVID);
|
||||
jpeg_dev = (struct jpg_device *)dev_get(HG_JPG0_DEVID);
|
||||
jpeg1_dev = (struct jpg_device *)dev_get(HG_JPG1_DEVID);
|
||||
stream *s = NULL;
|
||||
uint32_t node_len;
|
||||
FRESULT res;
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
uint32_t flen;
|
||||
uint32_t num = 0;
|
||||
uint8_t *jpeg_buf_addr = NULL;
|
||||
void *fp;
|
||||
|
||||
os_sleep_ms(5000);
|
||||
printf(".........................................................gen422 start..................................................................\r\n");
|
||||
scale_close(scale3_dev);
|
||||
gen422_init(800,480,1);
|
||||
vpp_close(vpp_dev);
|
||||
vpp_cfg(800,480,IN_GEN422);
|
||||
scale_from_vpp(scale_dev,yuvbuf,800,480,1280,720);
|
||||
photo_msg.out0_w = 1280;
|
||||
photo_msg.out0_h = 720;
|
||||
|
||||
s = open_stream_available(R_RTP_JPEG,0,8,opcode_func,NULL);
|
||||
start_jpeg();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gen422_set_frame(video_psram_config_mem,NULL,800,480);
|
||||
printf("...kick gen422\r\n");
|
||||
// gen422_run();
|
||||
while(1){
|
||||
get_f = recv_real_data(s);
|
||||
if(get_f){
|
||||
dest_list = (struct stream_jpeg_data_s *)GET_DATA_BUF(get_f);
|
||||
dest_list_tmp = dest_list;
|
||||
flen = get_stream_real_data_len(get_f);
|
||||
node_len = GET_NODE_LEN(get_f);
|
||||
jpeg_buf_addr = (uint8_t *)GET_JPG_BUF(get_f);
|
||||
os_printf("**************************************************************************************jpgbuf:%08x flen:%d\r\n",jpeg_buf_addr,flen);
|
||||
fp = creat_jpg_file(JPG_DIR);
|
||||
osal_fwrite(jpeg_buf_addr,1,flen,fp);
|
||||
osal_fclose(fp);
|
||||
free_data(get_f);
|
||||
get_f = NULL;
|
||||
gen422_run();
|
||||
}else{
|
||||
os_sleep_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void user_hardware_config()
|
||||
{
|
||||
k_task_handle_t jpg_task_handle;
|
||||
csi_kernel_task_new((k_task_entry_t)jpg_user_demo_thread, "gen422_thread", NULL, 25, 0, NULL, 4096, &jpg_task_handle);
|
||||
}
|
||||
|
||||
|
||||
622
project/module_code/h264_user.c
Normal file
622
project/module_code/h264_user.c
Normal file
@@ -0,0 +1,622 @@
|
||||
#include "sys_config.h"
|
||||
#include "tx_platform.h"
|
||||
#include "osal/string.h"
|
||||
#include <csi_kernel.h>
|
||||
|
||||
#include "stream_frame.h"
|
||||
#include "osal/task.h"
|
||||
#include "osal_file.h"
|
||||
#include "video_app/video_app.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "utlist.h"
|
||||
#include "jpgdef.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "dhcpd_eloop/dhcpd_eloop.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/pwm.h"
|
||||
#include "hal/uart.h"
|
||||
#include "hal/csc.h"
|
||||
#include "dev/csc/hgcsc.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
|
||||
|
||||
#define MIN(a,b) ( (a)>(b)?b:a )
|
||||
#define MAX(a,b) ( (a)>(b)?a:b )
|
||||
#define H264_DIR "0:/DCIM"
|
||||
#define H264_FILE_NAME "264"
|
||||
|
||||
uint8_t name_rec_photo_h264[32];
|
||||
static uint32_t a2i(char *str)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t indx =0;
|
||||
char str_buf[32];
|
||||
memset(str_buf,0,32);
|
||||
while(str[indx] != '\0'){
|
||||
if(str[indx] == '.') break;
|
||||
str_buf[indx] = str[indx];
|
||||
indx++;
|
||||
}
|
||||
printf("str_buf:%s str:%s\r\n",str_buf,str);
|
||||
indx = 0;
|
||||
while(str_buf[indx] != '\0'){
|
||||
if(str_buf[indx] >= '0' && str_buf[indx] <='9'){
|
||||
ret = ret*10+str_buf[indx]-'0';
|
||||
}
|
||||
indx ++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *creat_h264_file(char *dir_name)
|
||||
{
|
||||
DIR avi_dir;
|
||||
FRESULT ret;
|
||||
FILINFO finfo;
|
||||
uint32_t indx= 0;
|
||||
void *fp;
|
||||
char filepath[64];
|
||||
ret = f_opendir(&avi_dir,dir_name);
|
||||
if(ret != FR_OK){
|
||||
f_mkdir(dir_name);
|
||||
f_opendir(&avi_dir,dir_name);
|
||||
}
|
||||
while(1){
|
||||
ret = f_readdir(&avi_dir,&finfo);
|
||||
if(ret != FR_OK || finfo.fname[0] == 0) break;
|
||||
indx = MAX(indx,a2i(finfo.fname));
|
||||
}
|
||||
f_closedir(&avi_dir);
|
||||
indx++;
|
||||
|
||||
sprintf(filepath,"%s/h%d.%s",dir_name,indx,H264_FILE_NAME);
|
||||
printf("filepath:%s\r\n",filepath);
|
||||
fp = osal_fopen(filepath,"wb+");
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
static int opcode_func(stream *s,void *priv,int opcode)
|
||||
{
|
||||
int res = 0;
|
||||
//_os_printf("%s:%d\topcode:%d\n",__FUNCTION__,__LINE__,opcode);
|
||||
switch(opcode)
|
||||
{
|
||||
case STREAM_OPEN_ENTER:
|
||||
break;
|
||||
case STREAM_OPEN_EXIT:
|
||||
{
|
||||
enable_stream(s,1);
|
||||
}
|
||||
break;
|
||||
case STREAM_OPEN_FAIL:
|
||||
break;
|
||||
default:
|
||||
//ĬÈ϶¼·µ»Ø³É¹¦
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t uart4_buf_h264[16];
|
||||
uint8_t uart4_buf_h264_result[16];
|
||||
static struct os_semaphore uart4_buf_sem = {0,NULL};
|
||||
static struct os_semaphore h264_buf_sem = {0,NULL};
|
||||
|
||||
void uart_user_sema_init()
|
||||
{
|
||||
os_sema_init(&uart4_buf_sem,0);
|
||||
}
|
||||
|
||||
void uart_user_sema_down(int32 tmo_ms)
|
||||
{
|
||||
os_sema_down(&uart4_buf_sem,tmo_ms);
|
||||
}
|
||||
|
||||
void uart_user_sema_up()
|
||||
{
|
||||
os_sema_up(&uart4_buf_sem);
|
||||
}
|
||||
|
||||
|
||||
void h264_user_sema_init()
|
||||
{
|
||||
os_sema_init(&h264_buf_sem,0);
|
||||
}
|
||||
|
||||
void h264_user_sema_down(int32 tmo_ms)
|
||||
{
|
||||
os_sema_down(&h264_buf_sem,tmo_ms);
|
||||
}
|
||||
|
||||
void h264_user_sema_up()
|
||||
{
|
||||
os_sema_up(&h264_buf_sem);
|
||||
}
|
||||
|
||||
|
||||
volatile uint8_t scale3_oe_select = 0;
|
||||
int32 uart_user_handler_irq(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2)
|
||||
{
|
||||
struct uart_device *rx_uart = (struct uart_device *)dev_get(HG_UART1_DEVID);
|
||||
memcpy(uart4_buf_h264_result,uart4_buf_h264,16);
|
||||
if(UART_IRQ_FLAG_TIME_OUT == irq){
|
||||
uart_gets(rx_uart,uart4_buf_h264,16);
|
||||
if(uart4_buf_h264[0]!=0xff){
|
||||
//rx_send_flag=1;
|
||||
}
|
||||
|
||||
printf("uart4_buf_result:%d\n",uart4_buf_h264_result[0]);
|
||||
if(uart4_buf_h264_result[0] == 0xfa){
|
||||
if(scale3_oe_select == 0){
|
||||
scale3_oe_select = 1;
|
||||
}else{
|
||||
scale3_oe_select = 0;
|
||||
}
|
||||
}else
|
||||
{
|
||||
uart_user_sema_up();
|
||||
}
|
||||
}
|
||||
|
||||
if(UART_IRQ_FLAG_DMA_RX_DONE == irq){
|
||||
uart_gets(rx_uart,uart4_buf_h264,16);
|
||||
//printf("uart4_buf111:%d\n",uart4_buf[0]);
|
||||
|
||||
uart_user_sema_up();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void h264_wakeup_from_net(){
|
||||
uart_user_sema_up();
|
||||
}
|
||||
|
||||
void uart_user_rx_config(){
|
||||
uart_user_sema_init();
|
||||
#if 1
|
||||
struct uart_device *rx_uart = (struct uart_device *)dev_get(HG_UART1_DEVID);
|
||||
//uart_open(rx_uart,921600);
|
||||
uart_open(rx_uart,921600);
|
||||
uart_ioctl(rx_uart,UART_IOCTL_CMD_SET_TIME_OUT,9216/5,1);
|
||||
uart_ioctl(rx_uart,UART_IOCTL_CMD_USE_DMA,1,0); //ÒªÊÖ¶¯¿ªÆôÊÇ·ñΪdma
|
||||
uart_request_irq(rx_uart,uart_user_handler_irq,UART_IRQ_FLAG_TIME_OUT|UART_IRQ_FLAG_DMA_RX_DONE,(uint32_t)64);
|
||||
uart_gets(rx_uart,uart4_buf_h264,16);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32 h264_write_len = 0;
|
||||
uint8 *buf1_goble;
|
||||
uint8 *buf2_goble;
|
||||
uint8 *buf_save_goble;
|
||||
uint8 buf_select = 0;
|
||||
|
||||
|
||||
|
||||
uint32_t h264_sram_buf[512];
|
||||
void h264_write_sdcard_thread(uint32 arg_bf){
|
||||
void *fp;
|
||||
uint8_t w_card = 1;
|
||||
uint32_t offset_wr = 0;
|
||||
|
||||
uint32_t ofset_len = 0;
|
||||
|
||||
|
||||
retry_create:
|
||||
fp = creat_h264_file(H264_DIR);
|
||||
if(fp == NULL){
|
||||
printf("create file 264 error\r\n");
|
||||
w_card = 0;
|
||||
}else{
|
||||
printf("create 264 file ok\r\n");
|
||||
w_card = 1;
|
||||
}
|
||||
|
||||
ofset_len = 0;
|
||||
|
||||
|
||||
while(1){
|
||||
h264_user_sema_down(-1);
|
||||
offset_wr = 0;
|
||||
if(w_card){
|
||||
printf("S(%d)",h264_write_len);
|
||||
ofset_len += h264_write_len;
|
||||
if(buf_select == 0){
|
||||
osal_fwrite(buf2_goble,1,h264_write_len,fp);
|
||||
}
|
||||
else{
|
||||
osal_fwrite(buf1_goble,1,h264_write_len,fp);
|
||||
}
|
||||
|
||||
printf("E(%d)",ofset_len);
|
||||
|
||||
if(ofset_len > 10*1024*1024){
|
||||
osal_fclose(fp);
|
||||
goto retry_create;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern volatile uint8 h264_error;
|
||||
|
||||
void h264_user_demo_thread(){
|
||||
struct h264_device *h264_dev;
|
||||
struct data_structure *get_f = NULL;
|
||||
struct stream_h264_data_s *dest_list;
|
||||
struct stream_h264_data_s *dest_list_tmp;
|
||||
struct stream_h264_data_s *el,*tmp;
|
||||
k_task_handle_t h264_write_task_handle;
|
||||
uint8 file_num = 0;
|
||||
uint8 *buf_cache;
|
||||
uint32 cache_len = 0;
|
||||
uint32 sd_save_len = 0;
|
||||
uint32 cache_num = 0;
|
||||
uint32 itk = 0;
|
||||
//uint8_t cnt_264;
|
||||
//uint8_t wdat;
|
||||
stream *s = NULL;
|
||||
void *fp;
|
||||
uint32_t node_len;
|
||||
uint32_t total_len = 0;
|
||||
FRESULT res;
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
uint32_t flen;
|
||||
uint32_t ofset_len = 0;
|
||||
uint32_t num = 0;
|
||||
uint8_t w_card = 1;
|
||||
uint8_t w_cache_run = 0;
|
||||
uint8_t *h264_buf_addr = NULL;
|
||||
buf1_goble = (uint8*)av_psram_malloc(512*1024);
|
||||
buf2_goble = (uint8*)av_psram_malloc(512*1024);
|
||||
//buf_save_goble = (uint8*)av_psram_malloc(2*1024*1024);
|
||||
h264_dev = (struct h264_device *)dev_get(HG_H264_DEVID);
|
||||
uart_user_rx_config();
|
||||
h264_user_sema_init();
|
||||
//csi_kernel_task_new((k_task_entry_t)h264_write_sdcard_thread, "h264_write_card_thread", NULL, 25, 0, NULL, 2048, &h264_write_task_handle);
|
||||
mp4_demo();
|
||||
|
||||
//h264_write_card:
|
||||
|
||||
|
||||
uart_user_sema_down(-1);
|
||||
printf("uart up..........................................................................................................\r\n");
|
||||
s = open_stream_available(R_RECORD_H264,0,8,opcode_func,NULL);
|
||||
h264_write_card:
|
||||
file_num++;
|
||||
h264_set_oe_select(h264_dev,1,file_num%2);
|
||||
h264_enc(VPP_DATA0,1280,720,0,0,0);
|
||||
//h264_enc(SCALER_DATA,1920,1088,0,0,0);
|
||||
|
||||
ofset_len = 0;
|
||||
|
||||
//cnt_264 = 0;
|
||||
//wdat = 0x55;
|
||||
|
||||
|
||||
cache_len = 0;
|
||||
cache_num = 0;
|
||||
w_cache_run = 0;
|
||||
buf_select = 0;
|
||||
start_h264();
|
||||
while(1){
|
||||
get_f = recv_real_data(s);
|
||||
if(get_f){
|
||||
printf("get_f(%08x)",get_f);
|
||||
dest_list = (struct stream_h264_data_s *)GET_DATA_BUF(get_f);
|
||||
dest_list_tmp = dest_list;
|
||||
flen = get_stream_real_data_len(get_f);
|
||||
node_len = GET_NODE_LEN(get_f);
|
||||
h264_buf_addr = (uint8_t *)GET_JPG_BUF(get_f);
|
||||
|
||||
#if 0
|
||||
for(itk = 0;itk < flen;itk++){
|
||||
h264_buf_addr[itk] = wdat;
|
||||
cnt_264++;
|
||||
if((cnt_264%4) == 0){
|
||||
wdat = 0x55;
|
||||
cnt_264 = 0;
|
||||
}
|
||||
else if((cnt_264%4) == 1)
|
||||
wdat = 0xAA;
|
||||
else if((cnt_264%4) == 2)
|
||||
wdat = 0x66;
|
||||
else if((cnt_264%4) == 3){
|
||||
wdat = 0xCC;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// printf("addr:%08x len:%d\r\n",h264_buf_addr,flen);
|
||||
if(buf_select == 0)
|
||||
hw_memcpy(buf1_goble + cache_len,h264_buf_addr,flen);
|
||||
else
|
||||
hw_memcpy(buf2_goble + cache_len,h264_buf_addr,flen);
|
||||
|
||||
|
||||
printf("F(%d)",flen);
|
||||
|
||||
sd_save_len += flen;
|
||||
cache_len += flen;
|
||||
cache_num++;
|
||||
if(cache_num == 8){
|
||||
w_cache_run = 1;
|
||||
}
|
||||
|
||||
if(w_cache_run)
|
||||
{
|
||||
if(buf_select == 0)
|
||||
printf("\r\nSBUF1\r\n");
|
||||
else
|
||||
printf("\r\nSBUF2\r\n");
|
||||
|
||||
buf_select ^= BIT(0);
|
||||
h264_write_len = cache_len;
|
||||
h264_user_sema_up();
|
||||
printf("W(%d)",h264_write_len);
|
||||
printf("ofset_len:%x\r\n",ofset_len);
|
||||
ofset_len += cache_len;
|
||||
|
||||
if(ofset_len > 10*1024*1024){
|
||||
w_card = 0;
|
||||
printf("CARD END:%d",ofset_len);
|
||||
stop_h264();
|
||||
free_data(get_f);
|
||||
while(get_f)
|
||||
{
|
||||
get_f = recv_real_data(s);
|
||||
free_data(get_f);
|
||||
}
|
||||
get_f = NULL;
|
||||
os_sleep_ms(1000);
|
||||
goto h264_write_card;
|
||||
}
|
||||
}
|
||||
|
||||
if(cache_num == 8){
|
||||
cache_num = 0;
|
||||
cache_len = 0;
|
||||
w_cache_run = 0;
|
||||
}
|
||||
|
||||
printf("free(%08x)",get_f);
|
||||
free_data(get_f);
|
||||
get_f = NULL;
|
||||
|
||||
}else{
|
||||
|
||||
if(h264_error == 1){
|
||||
w_card = 0;
|
||||
printf("CARD END");
|
||||
stop_h264();
|
||||
osal_fclose(fp);
|
||||
free_data(get_f);
|
||||
get_f = NULL;
|
||||
os_sleep_ms(1000);
|
||||
goto h264_write_card;
|
||||
}
|
||||
|
||||
os_sleep_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volatile uint8 csc_finish = 0;
|
||||
void csc_done(uint32 irq_flag,uint32 irq_data,uint32 param1){
|
||||
csc_finish = 1;
|
||||
}
|
||||
|
||||
__psram_data uint8 h264_dec_file[1*1024*1024] __aligned(32);
|
||||
extern uint8 *video_decode_mem;
|
||||
extern uint32 p1_w,p1_h;
|
||||
extern uint32 scale_p1_w;
|
||||
|
||||
void data_deal(uint8_t *src,uint8_t *des,uint32_t w,uint32_t h){
|
||||
uint8_t *r;
|
||||
uint8_t *g;
|
||||
uint8_t *b;
|
||||
uint32_t i;
|
||||
r = src;
|
||||
g = &src[w*h];
|
||||
b = &src[2*w*h];
|
||||
printf("r:%08x g:%08x b:%08x adr:%08x \r\n",r,g,b,des );
|
||||
for(i = 0;i < w*h;i++){
|
||||
|
||||
des[i*3] = b[i];
|
||||
des[i*3+1] = g[i];
|
||||
des[i*3+2] = r[i];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void h264_user_demo_dec_thread(){
|
||||
void *fp;
|
||||
uint8_t *buf;
|
||||
uint32_t offset_sps_start = 0;
|
||||
uint8_t *buf2;
|
||||
uint8_t *buf3;
|
||||
uint32_t itk = 0;
|
||||
uint32_t offset_sps_len = 0;
|
||||
uint32_t data_count;
|
||||
uint8_t frame_start_find;
|
||||
uint8_t *photo_sd_cache = NULL;
|
||||
uint32_t data_len;
|
||||
uint32_t file_ip_len;
|
||||
uint32_t offset_len;
|
||||
uint32_t tmep;
|
||||
uint8_t name[16];
|
||||
uint8_t *pt8;
|
||||
uint8_t *pt8_dec;
|
||||
struct h264_device *h264_dev;
|
||||
struct csc_device *csc_dev;
|
||||
struct scale_device *scale2_dev;
|
||||
struct scale_device *scale3_dev;
|
||||
csc_dev = (struct csc_device *)dev_get(HG_CSC_DEVID);
|
||||
h264_dev = (struct h264_device *)dev_get(HG_H264_DEVID);
|
||||
scale2_dev = (struct scale_device *)dev_get(HG_SCALE2_DEVID);
|
||||
scale3_dev = (struct scale_device *)dev_get(HG_SCALE3_DEVID);
|
||||
os_printf("csc_dev :%x\r\n", csc_dev);
|
||||
scale_from_h264_config(scale2_dev,1280,720,320,240,10);
|
||||
//scale_from_h264_config(scale2_dev,1280,720,320,240,10);
|
||||
jpeg_file_get(name,0,"H");
|
||||
printf("name:%s\r\n",name);
|
||||
sprintf((char *)name_rec_photo_h264,"%s%s","0:DCIM/",name);
|
||||
fp = osal_fopen((const char*)name_rec_photo_h264,"rb");
|
||||
if(!fp){
|
||||
_os_printf("f_open %s error\r\n",name_rec_photo_h264);
|
||||
goto h264_dec_end;
|
||||
}
|
||||
data_len = osal_fsize(fp);
|
||||
_os_printf("data_len:%d\r\n",data_len);
|
||||
photo_sd_cache = malloc(1024);
|
||||
|
||||
data_count = 1024;
|
||||
frame_start_find = 0;
|
||||
file_ip_len = 0;
|
||||
pt8_dec = h264_dec_file;
|
||||
while(data_len != 0){
|
||||
if(data_len > 1024){
|
||||
osal_fread(photo_sd_cache,1,data_count,fp);
|
||||
data_len = data_len - 1024;
|
||||
}
|
||||
else{
|
||||
osal_fread(photo_sd_cache,1,data_len,fp);
|
||||
data_count = data_len;
|
||||
data_len = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pt8 = photo_sd_cache;
|
||||
for(itk = 0;itk < data_count;itk++){
|
||||
if(pt8[itk] == 0x00){
|
||||
//if((pt8[itk+1] == 0x0100)&&(pt8[itk+2] == 0x4d67))
|
||||
if((pt8[itk+1] == 0x00)&&(pt8[itk+2] == 0x00)&&(pt8[itk+3] == 0x01)&&(pt8[itk+4] == 0x67)&&(pt8[itk+5] == 0x4d)){
|
||||
|
||||
if(offset_sps_start == 1){
|
||||
h264_dec_file[offset_sps_len] = 0x00;
|
||||
h264_dec_file[offset_sps_len+1] = 0x00;
|
||||
h264_dec_file[offset_sps_len+2] = 0x00;
|
||||
h264_dec_file[offset_sps_len+3] = 0x01;
|
||||
sys_dcache_clean_range(h264_dec_file,offset_sps_len+4);
|
||||
printf("dec len:%d\r\n",offset_sps_len);
|
||||
h264_dec_src_264(h264_dec_file,offset_sps_len,1280,720);
|
||||
printf("dec end close\r\n");
|
||||
}
|
||||
|
||||
|
||||
offset_sps_start = 1;
|
||||
offset_sps_len = 0;
|
||||
#if 0
|
||||
if(frame_start_find == 0){
|
||||
frame_start_find = 1;
|
||||
}else{
|
||||
frame_start_find = 0;
|
||||
offset_len = data_count - itk*2;
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(offset_sps_start == 1){
|
||||
pt8_dec[offset_sps_len] = pt8[itk];
|
||||
offset_sps_len++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(frame_start_find == 0){
|
||||
tmep = data_count - offset_len;
|
||||
hw_memcpy(h264_dec_file+file_ip_len,photo_sd_cache,tmep);
|
||||
file_ip_len = file_ip_len+tmep;
|
||||
os_printf("file_ip_len:%d\r\n",file_ip_len);
|
||||
h264_dec_file[file_ip_len] = 0x00;
|
||||
h264_dec_file[file_ip_len+1] = 0x00;
|
||||
h264_dec_file[file_ip_len+2] = 0x00;
|
||||
h264_dec_file[file_ip_len+3] = 0x01;
|
||||
sys_dcache_clean_range(h264_dec_file,file_ip_len);
|
||||
h264_dec_src_264(h264_dec_file,file_ip_len,1280,720);
|
||||
//h264_dec_src_264(h264_dec_file,file_ip_len,1280,720);
|
||||
hw_memcpy(h264_dec_file,photo_sd_cache+tmep,offset_len);
|
||||
file_ip_len = offset_len;
|
||||
frame_start_find = 1;
|
||||
|
||||
}else{
|
||||
hw_memcpy(h264_dec_file+file_ip_len,photo_sd_cache,data_count-offset_sps);
|
||||
//printf("data_count:%d\r\n",data_count);
|
||||
file_ip_len += data_count;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
osal_fclose(fp);
|
||||
|
||||
|
||||
|
||||
h264_dec_end:
|
||||
buf = (uint8*)av_psram_malloc(scale_p1_w*p1_h*3);
|
||||
buf3 = (uint8*)av_psram_malloc(scale_p1_w*p1_h*3);
|
||||
buf2= (uint8*)av_psram_malloc(160*120*3);
|
||||
//buf2 = (uint8*)av_psram_malloc(scale_p1_w*p1_h*3);
|
||||
|
||||
|
||||
#if 1
|
||||
csc_init(csc_dev);
|
||||
csc_set_type(csc_dev, 1);
|
||||
csc_set_photo_size(csc_dev, 320, 240);
|
||||
csc_set_format(csc_dev, CSC_YUV420P, CSC_YUV444P);
|
||||
csc_set_input_addr(csc_dev,video_decode_mem,video_decode_mem+scale_p1_w*p1_h,video_decode_mem+scale_p1_w*p1_h+scale_p1_w*p1_h/4);
|
||||
csc_set_output_addr(csc_dev,buf,buf+scale_p1_w*p1_h,buf+scale_p1_w*p1_h*2);
|
||||
csc_request_irq(csc_dev,CSC_DONE_IRQ,(csc_irq_hdl )&csc_done,(uint32)csc_dev);
|
||||
csc_finish = 0;
|
||||
printf("csc kick run..\r\n");
|
||||
csc_start_run(csc_dev);
|
||||
while(csc_finish == 0);
|
||||
printf("yuv420P %08x====> yuv444P finish %08x\r\n",video_decode_mem,buf);
|
||||
csc_init(csc_dev);
|
||||
csc_set_type(csc_dev, 0);
|
||||
csc_set_format(csc_dev, CSC_YUV444P, CSC_RGB565);
|
||||
csc_set_input_addr(csc_dev,buf,buf+scale_p1_w*p1_h,buf+scale_p1_w*p1_h*2);
|
||||
csc_set_output_addr(csc_dev,buf3,buf3+scale_p1_w*p1_h,buf3+scale_p1_w*p1_h*2);
|
||||
csc_finish = 0;
|
||||
csc_start_run(csc_dev);
|
||||
while(csc_finish == 0);
|
||||
printf("yuv444P %08x ====> rgb565 finish %08x\r\n",buf,buf3);
|
||||
scale2_all_frame(scale2_dev,FRAME_YUV420P,320,240,160,120,video_decode_mem,buf2);
|
||||
printf("yuv420P %08x ====> yuv420p finish %08x\r\n",video_decode_mem,buf2);
|
||||
#else
|
||||
scale3_all_frame(scale3_dev,320,240,160,120,0,1,video_decode_mem,buf);
|
||||
os_sleep_ms(10);
|
||||
scale2_all_frame(scale2_dev,FRAME_RGB888P,160,120,80,80,buf,buf2);
|
||||
#endif
|
||||
|
||||
while(1){
|
||||
os_sleep_ms(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void user_hardware_config()
|
||||
{
|
||||
k_task_handle_t h264_task_handle;
|
||||
|
||||
//csi_kernel_task_new((k_task_entry_t)h264_user_demo_dec_thread, "h264_thread", NULL, 25, 0, NULL, 2048, &h264_task_handle);
|
||||
csi_kernel_task_new((k_task_entry_t)h264_user_demo_thread, "h264_thread", NULL, 25, 0, NULL, 2048, &h264_task_handle);
|
||||
}
|
||||
|
||||
|
||||
113
project/module_code/jpg_user.c
Normal file
113
project/module_code/jpg_user.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "sys_config.h"
|
||||
#include "tx_platform.h"
|
||||
#include "osal/string.h"
|
||||
|
||||
#include "stream_frame.h"
|
||||
#include "osal/task.h"
|
||||
#include "osal_file.h"
|
||||
#include "video_app/video_app.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "utlist.h"
|
||||
#include "jpgdef.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "dhcpd_eloop/dhcpd_eloop.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/pwm.h"
|
||||
|
||||
static int opcode_func(stream *s,void *priv,int opcode)
|
||||
{
|
||||
int res = 0;
|
||||
//_os_printf("%s:%d\topcode:%d\n",__FUNCTION__,__LINE__,opcode);
|
||||
switch(opcode)
|
||||
{
|
||||
case STREAM_OPEN_ENTER:
|
||||
break;
|
||||
case STREAM_OPEN_EXIT:
|
||||
{
|
||||
enable_stream(s,1);
|
||||
}
|
||||
break;
|
||||
case STREAM_OPEN_FAIL:
|
||||
break;
|
||||
default:
|
||||
//默认都返回成功
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
volatile uint8_t scale3_oe_select = 0;
|
||||
extern volatile uint8_t jpg_auto_dec;
|
||||
void jpg_user_demo_thread(){
|
||||
struct data_structure *get_f = NULL;
|
||||
struct stream_jpeg_data_s *dest_list;
|
||||
struct stream_jpeg_data_s *dest_list_tmp;
|
||||
struct stream_jpeg_data_s *el,*tmp;
|
||||
struct scale_device *scale_dev;
|
||||
struct vpp_device *vpp_dev;
|
||||
struct jpg_device *jpeg_dev;
|
||||
struct jpg_device *jpeg1_dev;
|
||||
scale_dev = (struct scale_device *)dev_get(HG_SCALE2_DEVID);
|
||||
vpp_dev = (struct vpp_device *)dev_get(HG_VPP_DEVID);
|
||||
jpeg_dev = (struct jpg_device *)dev_get(HG_JPG0_DEVID);
|
||||
jpeg1_dev = (struct jpg_device *)dev_get(HG_JPG1_DEVID);
|
||||
stream *s = NULL;
|
||||
uint32_t node_len;
|
||||
FRESULT res;
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
uint32_t flen;
|
||||
uint32_t num = 0;
|
||||
uint8_t *jpeg_buf_addr = NULL;
|
||||
void *fp;
|
||||
s = open_stream_available(R_RTP_JPEG,0,8,opcode_func,NULL);
|
||||
start_jpeg();
|
||||
printf("open jpeg......\r\n");
|
||||
|
||||
//vpp_open(vpp_dev);
|
||||
#if SCALE2_DIRECT_TO_LCD
|
||||
scale_from_jpeg_config(scale_dev,1,1280,720,480,320,10);
|
||||
#endif
|
||||
while(1){
|
||||
get_f = recv_real_data(s);
|
||||
if(get_f){
|
||||
dest_list = (struct stream_jpeg_data_s *)GET_DATA_BUF(get_f);
|
||||
dest_list_tmp = dest_list;
|
||||
flen = get_stream_real_data_len(get_f);
|
||||
node_len = GET_NODE_LEN(get_f);
|
||||
jpeg_buf_addr = (uint8_t *)GET_JPG_BUF(get_f);
|
||||
os_printf("**************************************************************************************jpgbuf:%08x flen:%d\r\n",jpeg_buf_addr,flen);
|
||||
//vpp_close(vpp_dev);
|
||||
#if SCALE2_DIRECT_TO_LCD
|
||||
//jpg_auto_rekick_cfg(jpeg1_dev,1);
|
||||
jpg_auto_dec = 0;
|
||||
sys_dcache_clean_range(jpeg_buf_addr,flen);
|
||||
jpg_decode_to_lcd(jpeg_buf_addr,1280,720,480,320);
|
||||
|
||||
while(jpg_auto_dec != 1)
|
||||
os_sleep_ms(1);
|
||||
#endif
|
||||
free_data(get_f);
|
||||
get_f = NULL;
|
||||
|
||||
}else{
|
||||
os_sleep_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void user_hardware_config()
|
||||
{
|
||||
k_task_handle_t jpg_task_handle;
|
||||
csi_kernel_task_new((k_task_entry_t)jpg_user_demo_thread, "jpg_thread", NULL, 25, 0, NULL, 4096, &jpg_task_handle);
|
||||
}
|
||||
|
||||
190
project/module_code/prc_user.c
Normal file
190
project/module_code/prc_user.c
Normal file
@@ -0,0 +1,190 @@
|
||||
#include "sys_config.h"
|
||||
#include "tx_platform.h"
|
||||
#include "osal/string.h"
|
||||
|
||||
#include "stream_frame.h"
|
||||
#include "osal/task.h"
|
||||
#include "osal_file.h"
|
||||
#include "video_app/video_app.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "utlist.h"
|
||||
#include "jpgdef.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "dhcpd_eloop/dhcpd_eloop.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/pwm.h"
|
||||
#include "hal/uart.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
#include "lib/video/vpp/vpp_dev.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi.h"
|
||||
#include "hal/csc.h"
|
||||
#include "dev/csc/hgcsc.h"
|
||||
#include "dev/prc/hgprc.h"
|
||||
#include "hal/jpeg.h"
|
||||
|
||||
|
||||
|
||||
extern Vpp_stream photo_msg;
|
||||
extern uint8 video_psram_config_mem[SCALE_CONFIG_W*SCALE_HIGH+SCALE_CONFIG_W*SCALE_HIGH/2];
|
||||
volatile uint8_t scale3_oe_select = 0;
|
||||
volatile uint8_t *prc_buf;
|
||||
volatile uint8_t *prc_line_buf;
|
||||
volatile uint8_t prc_num = 0;
|
||||
|
||||
|
||||
static int opcode_func(stream *s,void *priv,int opcode)
|
||||
{
|
||||
int res = 0;
|
||||
//_os_printf("%s:%d\topcode:%d\n",__FUNCTION__,__LINE__,opcode);
|
||||
switch(opcode)
|
||||
{
|
||||
case STREAM_OPEN_ENTER:
|
||||
break;
|
||||
case STREAM_OPEN_EXIT:
|
||||
{
|
||||
enable_stream(s,1);
|
||||
}
|
||||
break;
|
||||
case STREAM_OPEN_FAIL:
|
||||
break;
|
||||
default:
|
||||
//默认都返回成功
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void prc_done_isr(uint32 irq,uint32 dev,uint32 param){
|
||||
|
||||
}
|
||||
|
||||
volatile uint8 csc_finish = 0;
|
||||
void csc_done(uint32 irq_flag,uint32 irq_data,uint32 param1){
|
||||
csc_finish = 1;
|
||||
}
|
||||
|
||||
void jpg_prc_pixel_done(uint32 irq_flag,uint32 irq_data,uint32 param1,uint32 param2){
|
||||
struct prc_device *prc_dev;
|
||||
prc_dev = (struct prc_device *)dev_get(HG_PRC_DEVID);
|
||||
//printf("P:(%d)",prc_num);
|
||||
hw_memcpy(prc_line_buf, prc_buf+prc_num*800*16*2, 800*16*2);
|
||||
prc_set_src_addr(prc_dev,prc_line_buf);
|
||||
prc_run(prc_dev);
|
||||
prc_num++;
|
||||
if(prc_num == 480/16){
|
||||
//printf("first kick\r\n");
|
||||
prc_num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void jpg_user_demo_thread(){
|
||||
uint8_t *buf;
|
||||
struct data_structure *get_f = NULL;
|
||||
struct stream_jpeg_data_s *dest_list;
|
||||
struct stream_jpeg_data_s *dest_list_tmp;
|
||||
struct stream_jpeg_data_s *el,*tmp;
|
||||
struct scale_device *scale3_dev;
|
||||
struct prc_device *prc_dev;
|
||||
struct csc_device *csc_dev;
|
||||
struct vpp_device *vpp_dev;
|
||||
struct jpg_device *jpeg_dev;
|
||||
uint8_t *prc_sram;
|
||||
uint8_t *prc_linesram;
|
||||
csc_dev = (struct csc_device *)dev_get(HG_CSC_DEVID);
|
||||
prc_dev = (struct prc_device *)dev_get(HG_PRC_DEVID);
|
||||
scale3_dev = (struct scale_device *)dev_get(HG_SCALE3_DEVID);
|
||||
vpp_dev = (struct vpp_device *)dev_get(HG_VPP_DEVID);
|
||||
jpeg_dev = (struct jpg_device *)dev_get(HG_JPG0_DEVID);
|
||||
stream *s = NULL;
|
||||
uint32_t node_len;
|
||||
FRESULT res;
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
uint32_t flen;
|
||||
uint32_t num = 0;
|
||||
uint8_t *jpeg_buf_addr = NULL;
|
||||
void *fp;
|
||||
|
||||
os_sleep_ms(10000);
|
||||
buf = (uint8*)av_psram_malloc(800*480*2);
|
||||
|
||||
csc_init(csc_dev);
|
||||
csc_set_type(csc_dev, 1);
|
||||
csc_set_photo_size(csc_dev, 800, 480);
|
||||
csc_set_format(csc_dev, CSC_YUV420P, CSC_YUYV422);
|
||||
csc_set_input_addr(csc_dev,video_psram_config_mem,video_psram_config_mem+800*480,video_psram_config_mem+800*480+800*480/4);
|
||||
csc_set_output_addr(csc_dev,buf,buf+800*480,buf+800*480+800*480/2);
|
||||
csc_request_irq(csc_dev,CSC_DONE_IRQ,(csc_irq_hdl )&csc_done,(uint32)csc_dev);
|
||||
csc_finish = 0;
|
||||
printf("csc kick run..\r\n");
|
||||
csc_start_run(csc_dev);
|
||||
while(csc_finish == 0);
|
||||
printf("yuv420P %08x====> yuv422 finish %08x\r\n",video_psram_config_mem,buf);
|
||||
|
||||
|
||||
printf(".........................................................prc start..................................................................\r\n");
|
||||
scale_close(scale3_dev);
|
||||
|
||||
prc_init(prc_dev);
|
||||
prc_set_width(prc_dev,800);
|
||||
prc_sram = malloc(800*16+800*16/2); //yuv420p
|
||||
prc_linesram = malloc(800*16+800*16); //yuv422
|
||||
prc_line_buf = prc_linesram;
|
||||
prc_set_yaddr(prc_dev,prc_sram);
|
||||
prc_set_uaddr(prc_dev,prc_sram+16*800);
|
||||
prc_set_vaddr(prc_dev,prc_sram+16*800+4*800);
|
||||
prc_set_yuv_mode(prc_dev,0);
|
||||
hw_memcpy(prc_line_buf, buf, 800*16*2);
|
||||
prc_set_src_addr(prc_dev,prc_line_buf);
|
||||
prc_num++;
|
||||
prc_buf = buf;
|
||||
prc_request_irq(prc_dev,PRC_ISR,(prc_irq_hdl )&prc_done_isr,prc_dev);
|
||||
|
||||
photo_msg.out0_w = 800;
|
||||
photo_msg.out0_h = 480;
|
||||
|
||||
s = open_stream_available(R_RTP_JPEG,0,8,opcode_func,NULL);
|
||||
jpg_request_irq(jpeg_dev,(jpg_irq_hdl )&jpg_prc_pixel_done,JPG_IRQ_FLAG_PIXEL_DONE,jpeg_dev);
|
||||
start_jpeg();
|
||||
|
||||
prc_first_start(prc_dev);
|
||||
prc_run(prc_dev);
|
||||
|
||||
while(1){
|
||||
get_f = recv_real_data(s);
|
||||
if(get_f){
|
||||
dest_list = (struct stream_jpeg_data_s *)GET_DATA_BUF(get_f);
|
||||
dest_list_tmp = dest_list;
|
||||
flen = get_stream_real_data_len(get_f);
|
||||
node_len = GET_NODE_LEN(get_f);
|
||||
jpeg_buf_addr = (uint8_t *)GET_JPG_BUF(get_f);
|
||||
os_printf("**************************************************************************************jpgbuf:%08x flen:%d\r\n",jpeg_buf_addr,flen);
|
||||
|
||||
free_data(get_f);
|
||||
get_f = NULL;
|
||||
|
||||
}else{
|
||||
os_sleep_ms(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void user_hardware_config()
|
||||
{
|
||||
k_task_handle_t jpg_task_handle;
|
||||
csi_kernel_task_new((k_task_entry_t)jpg_user_demo_thread, "prc_thread", NULL, 25, 0, NULL, 4096, &jpg_task_handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
226
project/network.c
Normal file
226
project/network.c
Normal file
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* @file network.c
|
||||
* @brief 网络栈初始化与 DHCP 管理
|
||||
*
|
||||
* 本文件是 TXW82x FPV SDK 的网络子系统初始化模块,负责:
|
||||
* - 初始化 LwIP TCP/IP 协议栈
|
||||
* - 注册 WiFi / 以太网网络接口
|
||||
* - 启动 DHCP 服务器(AP 模式下为客户端分配 IP)
|
||||
* - 周期性检查 DHCP 客户端状态并处理超时重试
|
||||
*/
|
||||
|
||||
/* ========================= 头文件包含 ========================= */
|
||||
|
||||
/* 系统配置与平台基础头文件 */
|
||||
#include "sys_config.h" // 系统总体配置宏定义(外设使能、功能开关等)
|
||||
#include "basic_include.h" // 基础类型和宏定义(uint8 等)
|
||||
#include "hal/adc.h" // ADC 硬件抽象层(可能用于电源监测等)
|
||||
#include "lib/rpc/cpurpc.h" // CPU 间 RPC 通信库(多核通信)
|
||||
#include "lib/atcmd/libatcmd.h" // AT 指令解析库
|
||||
#include "lib/common/atcmd.h" // AT 指令公共定义
|
||||
#include "lib/umac/ieee80211.h" // IEEE 802.11 协议定义(WiFi 上层 MAC)
|
||||
#include "lib/lmac/lmac.h" // 低层 MAC 驱动(WiFi 下层 MAC)
|
||||
#include "lib/bluetooth/uble/ble_demo.h" // BLE 蓝牙低功耗演示接口
|
||||
|
||||
/* LwIP 协议栈相关头文件 */
|
||||
#include "lwip/err.h" // LwIP 错误码定义
|
||||
#include "lwip/sockets.h" // LwIP POSIX socket 兼容层
|
||||
#include "lwip/netdb.h" // LwIP 网络主机数据库(DNS 解析等)
|
||||
#include "lwip/sys.h" // LwIP 系统抽象层(OS 适配)
|
||||
#include "lwip/ip_addr.h" // LwIP IP 地址操作工具
|
||||
#include "lwip/tcpip.h" // LwIP TCP/IP 核心初始化接口
|
||||
#include "netif/ethernetif.h" // 以太网网络接口适配层
|
||||
|
||||
/* 自定义网络工具与服务 */
|
||||
#include "lib/net/dhcpd/dhcpd.h" // DHCP 服务器实现
|
||||
#include "lib/net/utils.h" // 网络通用工具函数
|
||||
#include "lib/net/skmonitor/skmonitor.h" // Socket 监控器(检测 socket 状态/异常)
|
||||
#include "syscfg.h" // 用户可配置参数结构体(sys_cfgs)
|
||||
#include "app/user_app.h" // 用户应用层接口(sys_status 等)
|
||||
|
||||
/* ========================= 函数实现 ========================= */
|
||||
|
||||
/**
|
||||
* @brief 添加一个网络接口并注册到 LwIP 协议栈
|
||||
*
|
||||
* 根据 devid 获取对应的网络设备,设置静态 IP 或启用 DHCP 客户端,
|
||||
* 然后将该网络接口注册到 LwIP 中,使其可以收发 IP 报文。
|
||||
*
|
||||
* @param devid 设备 ID,例如 HG_WIFI0_DEVID(WiFi)或 HG_GMAC_DEVID(以太网)
|
||||
* @param name 接口名称字符串,如 "w0"(WiFi)、"e0"(以太网)
|
||||
* @param dhcpc 是否启用 DHCP 客户端:1 = 启用,0 = 使用静态 IP
|
||||
* @param setip 是否使用配置的静态 IP 地址:1 = 使用,0 = 使用默认(0.0.0.0)
|
||||
*
|
||||
* @note 该函数用 __init 修饰,表示仅在系统初始化阶段调用,
|
||||
* 运行完后其代码空间可被回收以节省 RAM。
|
||||
*/
|
||||
__init static void sys_network_add_netif(uint8 devid, char *name, uint8 dhcpc, uint8 setip)
|
||||
{
|
||||
/* 定义 IP 地址、子网掩码、默认网关三个地址变量 */
|
||||
ip_addr_t ipaddr, netmask, gw;
|
||||
|
||||
/* 根据 devid 从设备管理器中获取对应的 netdev 结构体指针 */
|
||||
struct netdev *ndev = (struct netdev *)dev_get(devid);
|
||||
|
||||
if (ndev) {
|
||||
/* 从全局配置 sys_cfgs 中读取预设的静态 IP 地址参数 */
|
||||
ipaddr.addr = sys_cfgs.ipaddr; // 本机 IP 地址
|
||||
netmask.addr = sys_cfgs.netmask; // 子网掩码
|
||||
gw.addr = sys_cfgs.gw_ip; // 默认网关地址
|
||||
|
||||
/* 打印接口名称和配置的 IP/掩码/网关信息,方便调试 */
|
||||
os_printf(KERN_INFO"netif %s setttings: "IPSTR"/"IPSTR"/"IPSTR"!\r\n", name, IP2STR_N(ipaddr.addr), IP2STR_N(netmask.addr), IP2STR_N(gw.addr));
|
||||
|
||||
/**
|
||||
* 将该网络接口添加到 LwIP 协议栈:
|
||||
* - 若 setip=1,传入 IP/掩码/网关指针,使用静态地址
|
||||
* - 若 setip=0,三个参数传 NULL,接口地址默认为 0.0.0.0
|
||||
* (后续通过 DHCP 获取)
|
||||
*/
|
||||
lwip_netif_add(ndev, name, (setip ? &ipaddr : NULL), (setip ? &netmask : NULL), (setip ? &gw : NULL));
|
||||
|
||||
if (dhcpc) {
|
||||
/* 标记 DHCP 客户端尚未完成,供 sys_dhcpc_check() 使用 */
|
||||
sys_status.dhcpc_done = 0; // 0 表示 DHCP 还未获取到地址
|
||||
|
||||
/* 启动该接口的 DHCP 客户端,向 DHCP 服务器请求 IP 地址 */
|
||||
lwip_netif_set_dhcp(ndev, 1); // 参数 1 表示开启 DHCP
|
||||
|
||||
/* 打印日志提示 DHCP 客户端已启动 */
|
||||
os_printf(KERN_INFO"netif %s start dhcp client!\r\n", name);
|
||||
}
|
||||
} else {
|
||||
/* 设备 ID 无效或对应设备未注册,打印错误信息 */
|
||||
os_printf(KERN_ERR"No Netdev: %d\r\n", devid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 系统网络初始化总入口
|
||||
*
|
||||
* 依次完成以下工作:
|
||||
* 1. 初始化 LwIP TCP/IP 协议栈
|
||||
* 2. 初始化 socket 监控器
|
||||
* 3. 注册 WiFi 接口 (w0),可选启用 DHCP 客户端
|
||||
* 4. 若以太网 (GMAC) 使能,注册以太网接口 (e0)
|
||||
* 5. 将 DHCP 客户端结果的初始值设为静态配置(作为 DHCP 失败时的回退)
|
||||
*
|
||||
* @note 由 main.c 在系统启动阶段调用,__init 修饰表示仅执行一次。
|
||||
*/
|
||||
__init void sys_network_init(void)
|
||||
{
|
||||
/* 初始化 LwIP TCP/IP 协议栈核心,传入 NULL 表示不使用回调通知 */
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
/* 初始化 socket 监控器,用于检测和管理 socket 连接状态 */
|
||||
sock_monitor_init();
|
||||
|
||||
/* 注册 WiFi 接口 "w0",根据 sys_cfgs.dhcpc_en 决定是否启用 DHCP 客户端,
|
||||
setip=1 表示同时设置静态 IP 作为回退地址 */
|
||||
sys_network_add_netif(HG_WIFI0_DEVID, "w0", sys_cfgs.dhcpc_en, 1);
|
||||
|
||||
/* 将 "w0" 设为 LwIP 的默认网络接口(用于路由选择) */
|
||||
lwip_netif_set_default2("w0");
|
||||
|
||||
#if GMAC_EN // 如果以太网 GMAC 功能在编译配置中启用
|
||||
/* 定义 6 字节数组用于存储 MAC 地址 */
|
||||
uint8_t mac[6];
|
||||
|
||||
/* 从 eFuse 中读取并计算 MAC 地址(每个芯片有唯一值) */
|
||||
sysctrl_efuse_mac_addr_calc(mac);
|
||||
|
||||
/**
|
||||
* 将 MAC 地址最后一字节最低两位置 1:
|
||||
* - bit0 = 1 表示本地管理地址(locally administered)
|
||||
* - bit1 = 1 使地址与 WiFi 接口的 MAC 区分开
|
||||
*/
|
||||
mac[5] |= 3;
|
||||
|
||||
/* 为以太网设备设置修改后的 MAC 地址 */
|
||||
netdev_set_macaddr((struct netdev *)dev_get(HG_GMAC_DEVID), mac);
|
||||
|
||||
/* 注册以太网接口 "e0",DHCP 设置与 WiFi 接口一致 */
|
||||
sys_network_add_netif(HG_GMAC_DEVID, "e0", sys_cfgs.dhcpc_en, 1);
|
||||
|
||||
/**
|
||||
* 将 "e0" 设为默认网络接口,覆盖之前 "w0" 的设置。
|
||||
* 这样做是因为有线连接通常比 WiFi 更稳定可靠,
|
||||
* 当两者同时存在时优先使用以太网。
|
||||
*/
|
||||
lwip_netif_set_default2("e0");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 将 DHCP 客户端结果的初始值设为静态配置中的 IP 参数。
|
||||
* 这在 DHCP 尚未完成或失败时,确保 sys_status 中有有效的 IP 信息可用。
|
||||
*/
|
||||
sys_status.dhcpc_result.ipaddr = sys_cfgs.ipaddr; // 默认 IP = 静态配置
|
||||
sys_status.dhcpc_result.netmask = sys_cfgs.netmask; // 默认掩码 = 静态配置
|
||||
sys_status.dhcpc_result.router = sys_cfgs.gw_ip; // 默认网关 = 静态配置
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 启动 DHCP 服务器
|
||||
*
|
||||
* 在 WiFi AP(接入点)模式下启动 DHCP 服务器,为连接到本设备的
|
||||
* 客户端(如手机、图传接收端)自动分配 IP 地址。
|
||||
*
|
||||
* @note 仅当配置中同时满足 dhcpd_en=1 且 wifi_mode=AP 时才启动。
|
||||
* 服务器运行在 "w0"(WiFi)接口上。
|
||||
*/
|
||||
//启动DHCP服务器 // Start DHCP server(中文:启动 DHCP 服务器)
|
||||
void sys_dhcpd_start()
|
||||
{
|
||||
/* DHCP 服务器参数结构体 */
|
||||
struct dhcpd_param param;
|
||||
|
||||
/* 仅在 DHCP 服务器已启用 且 WiFi 工作在 AP 模式时才执行 */
|
||||
if (sys_cfgs.dhcpd_en && sys_cfgs.wifi_mode == WIFI_MODE_AP) {
|
||||
/* 清零参数结构体,确保所有字段有确定的初始值 */
|
||||
os_memset(¶m, 0, sizeof(param));
|
||||
|
||||
/* 从全局配置中逐一读取 DHCP 服务器参数 */
|
||||
param.start_ip = sys_cfgs.dhcpd_startip; // DHCP 分配的起始 IP 地址
|
||||
param.end_ip = sys_cfgs.dhcpd_endip; // DHCP 分配的结束 IP 地址
|
||||
param.netmask = sys_cfgs.netmask; // 子网掩码
|
||||
param.lease_time = sys_cfgs.dhcpd_lease_time; // IP 租约时间(秒)
|
||||
param.dns1 = sys_cfgs.dhcpd_dns1; // 主 DNS 服务器地址
|
||||
param.dns2 = sys_cfgs.dhcpd_dns2; // 备用 DNS 服务器地址
|
||||
param.router = sys_cfgs.dhcpd_router; // 下发給客户端的默认网关地址
|
||||
|
||||
/* 在 "w0"(WiFi AP)接口上启动 DHCP 服务器,失败则打印错误 */
|
||||
if (dhcpd_start("w0", ¶m)) {
|
||||
os_printf("dhcpd start error\r\n"); // DHCP 服务器启动失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 周期性检查 DHCP 客户端状态
|
||||
*
|
||||
* 该函数应在主循环或定时器中被周期性调用。
|
||||
* 当 DHCP 客户端已启用但尚未获取到 IP 地址时,每调用约 7 次
|
||||
* (约 7 个周期)后重新发起 DHCP 请求,防止因网络抖动导致
|
||||
* DHCP 流程卡死。
|
||||
*
|
||||
* @note 使用 static 局部变量 __loop 计数,无需外部传入计数器。
|
||||
*/
|
||||
void sys_dhcpc_check(void)
|
||||
{
|
||||
/* 静态计数器,记录连续检查到 DHCP 未完成的次数 */
|
||||
static uint8 __loop;
|
||||
|
||||
/* 仅在 DHCP 客户端已启用 且 尚未成功获取 IP 时进入检查逻辑 */
|
||||
if (sys_cfgs.dhcpc_en && !sys_status.dhcpc_done) {
|
||||
if (__loop++ > 6) {
|
||||
/**
|
||||
* 连续超过 6 次检查仍未完成 DHCP,认为当前 DHCP 流程可能卡死,
|
||||
* 重新在 "w0" 接口上发起 DHCP 请求。
|
||||
*/
|
||||
lwip_netif_set_dhcp2("w0", 1); // 重新触发 DHCP 发现流程
|
||||
|
||||
/* 重置计数器,开始下一轮超时检测 */
|
||||
__loop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
project/param.bin
Normal file
BIN
project/param.bin
Normal file
Binary file not shown.
BIN
project/parameter.bincfg
Normal file
BIN
project/parameter.bincfg
Normal file
Binary file not shown.
BIN
project/parameter.cfg
Normal file
BIN
project/parameter.cfg
Normal file
Binary file not shown.
19
project/parameter_ui.cfg
Normal file
19
project/parameter_ui.cfg
Normal file
@@ -0,0 +1,19 @@
|
||||
[COMMON]
|
||||
version=V1.0.0
|
||||
itemNum=2
|
||||
|
||||
[ITEM1]
|
||||
offset=0
|
||||
name=total_size
|
||||
type=uint16
|
||||
size=1
|
||||
input=4
|
||||
storage=0400
|
||||
|
||||
[ITEM2]
|
||||
offset=2
|
||||
name=magic_num
|
||||
type=uint16
|
||||
size=1
|
||||
input=1A2B
|
||||
storage=2B1A
|
||||
BIN
project/pin_bin.exe
Normal file
BIN
project/pin_bin.exe
Normal file
Binary file not shown.
246
project/pin_param.h
Normal file
246
project/pin_param.h
Normal file
@@ -0,0 +1,246 @@
|
||||
#ifndef __PIN_PARAM_H
|
||||
#define __PIN_PARAM_H
|
||||
#include "project_config.h"
|
||||
#include "tx_platform.h"
|
||||
//这个是io配置的宏,后续sdk是通过这个宏去获取对应的io值,没有配置,则设置为0xff
|
||||
//坚守的原则,增加的宏增加到最后,不能插入到开头或者中间,也不能更换宏的位置,否则不同sdk之间参数区不匹配
|
||||
//所以SDK默认的宏最好不要动,用户自定义的话,也要保持该原则
|
||||
//为了兼容旧版的pin_function,这里的宏定义命名都是MACRO_PIN_DEFINE(XXXX)(XXXX是之前宏的名称)
|
||||
//新增的自定义宏依然采用PARAM_开头,后面的宏则采用自定义,默认都是往后增加即可保持新版本和旧版本兼容
|
||||
//如果需要pin_funciton在PIN_FROM_PARAM定义与不定义都兼容的话,则这里添加一个宏后,pin_name.h也要添加对应无PARAM_前缀的宏,否则编译报错
|
||||
//如果不需要兼容,则直接在这里添加即可
|
||||
#ifdef PIN_FROM_PARAM
|
||||
enum pin_cfg
|
||||
{
|
||||
//串口
|
||||
MACRO_PIN_DEFINE(PIN_UART0_TX),
|
||||
MACRO_PIN_DEFINE(PIN_UART0_RX),
|
||||
MACRO_PIN_DEFINE(PIN_UART1_TX),
|
||||
MACRO_PIN_DEFINE(PIN_UART1_RX),
|
||||
MACRO_PIN_DEFINE(PIN_UART4_TX),
|
||||
MACRO_PIN_DEFINE(PIN_UART4_RX),
|
||||
MACRO_PIN_DEFINE(PIN_UART5_TX),
|
||||
MACRO_PIN_DEFINE(PIN_UART5_RX),
|
||||
MACRO_PIN_DEFINE(PIN_UART6_TX),
|
||||
MACRO_PIN_DEFINE(PIN_UART6_RX),
|
||||
|
||||
//gmac
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_REF_CLKIN),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_RXD0),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_RXD1),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_TXD0),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_TXD1),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_CRS_DV),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_TX_EN),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_MDIO),
|
||||
MACRO_PIN_DEFINE(PIN_GMAC_RMII_MDC),
|
||||
|
||||
//sdio
|
||||
MACRO_PIN_DEFINE(PIN_SDCLK),
|
||||
MACRO_PIN_DEFINE(PIN_SDCMD),
|
||||
MACRO_PIN_DEFINE(PIN_SDDAT0),
|
||||
MACRO_PIN_DEFINE(PIN_SDDAT1),
|
||||
MACRO_PIN_DEFINE(PIN_SDDAT2),
|
||||
MACRO_PIN_DEFINE(PIN_SDDAT3),
|
||||
|
||||
|
||||
//spi
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_CS),
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_IO0),
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_IO1),
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_IO2),
|
||||
MACRO_PIN_DEFINE(PIN_SPI0_IO3),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_CS),
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_IO0),
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_IO1),
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_IO2),
|
||||
MACRO_PIN_DEFINE(PIN_SPI1_IO3),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_CS),
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_IO0),
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_IO1),
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_IO2),
|
||||
MACRO_PIN_DEFINE(PIN_SPI2_IO3),
|
||||
|
||||
//pdm
|
||||
MACRO_PIN_DEFINE(PIN_PDM_MCLK),
|
||||
MACRO_PIN_DEFINE(PIN_PDM_DATA),
|
||||
|
||||
//led
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG0),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG1),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG2),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG3),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG4),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG5),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG6),
|
||||
MACRO_PIN_DEFINE(PIN_LED_SEG7),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_LED_COM0),
|
||||
MACRO_PIN_DEFINE(PIN_LED_COM1),
|
||||
MACRO_PIN_DEFINE(PIN_LED_COM2),
|
||||
|
||||
//iic
|
||||
MACRO_PIN_DEFINE(PIN_IIC1_SCL),
|
||||
MACRO_PIN_DEFINE(PIN_IIC1_SDA),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_IIC2_SCL),
|
||||
MACRO_PIN_DEFINE(PIN_IIC2_SDA),
|
||||
|
||||
//timer
|
||||
MACRO_PIN_DEFINE(PIN_PWM_CHANNEL_0),
|
||||
MACRO_PIN_DEFINE(PIN_PWM_CHANNEL_1),
|
||||
MACRO_PIN_DEFINE(PIN_PWM_CHANNEL_2),
|
||||
MACRO_PIN_DEFINE(PIN_PWM_CHANNEL_3),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_CAPTURE_CHANNEL_0),
|
||||
MACRO_PIN_DEFINE(PIN_CAPTURE_CHANNEL_1),
|
||||
|
||||
//dvp
|
||||
MACRO_PIN_DEFINE(PIN_DVP_HSYNC),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_VSYNC),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_PCLK),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_MCLK),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA0),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA1),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA2),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA3),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA4),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA5),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA6),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA7),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA8),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA9),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA10),
|
||||
MACRO_PIN_DEFINE(PIN_DVP_DATA11),
|
||||
|
||||
//mipi csi
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_CLKN),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_CLKP),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_D0N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_D0P),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_D1N_CSI1_D0N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI0_D1P_CSI1_D0P),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI1_CLKN),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_CSI1_CLKP),
|
||||
|
||||
//mipi dsi
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_CLKN),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_CLKP),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D0N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D0P),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D1N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D1P),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D2N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D2P),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D3N),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_DSI_D3P),
|
||||
|
||||
//lcdc
|
||||
MACRO_PIN_DEFINE(LCD_VS_CS),
|
||||
MACRO_PIN_DEFINE(LCD_HS_DC),
|
||||
MACRO_PIN_DEFINE(LCD_DE_ERD),
|
||||
MACRO_PIN_DEFINE(LCD_DOTCLK_RWR),
|
||||
MACRO_PIN_DEFINE(LCD_TE),
|
||||
MACRO_PIN_DEFINE(LCD_D0),
|
||||
MACRO_PIN_DEFINE(LCD_D1),
|
||||
MACRO_PIN_DEFINE(LCD_D2),
|
||||
MACRO_PIN_DEFINE(LCD_D3),
|
||||
MACRO_PIN_DEFINE(LCD_D4),
|
||||
MACRO_PIN_DEFINE(LCD_D5),
|
||||
MACRO_PIN_DEFINE(LCD_D6),
|
||||
MACRO_PIN_DEFINE(LCD_D7),
|
||||
MACRO_PIN_DEFINE(LCD_D8),
|
||||
MACRO_PIN_DEFINE(LCD_D9),
|
||||
MACRO_PIN_DEFINE(LCD_D10),
|
||||
MACRO_PIN_DEFINE(LCD_D11),
|
||||
MACRO_PIN_DEFINE(LCD_D12),
|
||||
MACRO_PIN_DEFINE(LCD_D13),
|
||||
MACRO_PIN_DEFINE(LCD_D14),
|
||||
MACRO_PIN_DEFINE(LCD_D15),
|
||||
MACRO_PIN_DEFINE(LCD_D16),
|
||||
MACRO_PIN_DEFINE(LCD_D17),
|
||||
MACRO_PIN_DEFINE(LCD_D18),
|
||||
MACRO_PIN_DEFINE(LCD_D19),
|
||||
MACRO_PIN_DEFINE(LCD_D20),
|
||||
MACRO_PIN_DEFINE(LCD_D21),
|
||||
MACRO_PIN_DEFINE(LCD_D22),
|
||||
MACRO_PIN_DEFINE(LCD_D23),
|
||||
|
||||
//sdh
|
||||
MACRO_PIN_DEFINE(PIN_SDH_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_CMD),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_DAT0),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_DAT1),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_DAT2),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_DAT3),
|
||||
MACRO_PIN_DEFINE(PIN_SDH_CLK_DRI_STRENGTH),
|
||||
|
||||
//para_in
|
||||
MACRO_PIN_DEFINE(PIN_BT_HSYNC),
|
||||
MACRO_PIN_DEFINE(PIN_BT_VSYNC),
|
||||
MACRO_PIN_DEFINE(PIN_BT_PCLK),
|
||||
MACRO_PIN_DEFINE(PIN_BT_BLANK),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA0),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA1),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA2),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA3),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA4),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA5),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA6),
|
||||
MACRO_PIN_DEFINE(PIN_BT_DATA7),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_CSI0_PDN),
|
||||
MACRO_PIN_DEFINE(PIN_CSI1_PDN),
|
||||
MACRO_PIN_DEFINE(PIN_CSI0_RESET),
|
||||
MACRO_PIN_DEFINE(PIN_CSI1_RESET),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_MIPI0_IIC_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI0_IIC_SDA),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI1_IIC_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_MIPI1_IIC_SDA),
|
||||
MACRO_PIN_DEFINE(PIN_ADKEY1),
|
||||
MACRO_PIN_DEFINE(PIN_LCD_RESET),
|
||||
MACRO_PIN_DEFINE(PIN_TP_I2C_SCL),
|
||||
MACRO_PIN_DEFINE(PIN_TP_I2C_SDA),
|
||||
MACRO_PIN_DEFINE(PIN_TP_INT),
|
||||
MACRO_PIN_DEFINE(PIN_TP_RST),
|
||||
MACRO_PIN_DEFINE(PIN_DVP0_IIC_CLK),
|
||||
MACRO_PIN_DEFINE(PIN_DVP0_IIC_SDA),
|
||||
|
||||
//LMAC FEM
|
||||
MACRO_PIN_DEFINE(PIN_LMAC_FEM_RF_TX_EN),
|
||||
MACRO_PIN_DEFINE(PIN_LMAC_FEM_RF_RX_EN),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_SPI_PDN),
|
||||
MACRO_PIN_DEFINE(PIN_SPI_RESET),
|
||||
|
||||
//IIS
|
||||
MACRO_PIN_DEFINE(PIN_IIS0_MCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS0_BCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS0_WCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS0_DATA),
|
||||
MACRO_PIN_DEFINE(PIN_IIS1_MCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS1_BCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS1_WCLK),
|
||||
MACRO_PIN_DEFINE(PIN_IIS1_DATA),
|
||||
|
||||
|
||||
MACRO_PIN_DEFINE(BAT_ADC_IO),
|
||||
MACRO_PIN_DEFINE(LCD_BACKLIGHT_IO),
|
||||
MACRO_PIN_DEFINE(MUTE_PORT_IO),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_MIPI_FSYNC),
|
||||
|
||||
MACRO_PIN_DEFINE(PIN_IRCUT_LED),
|
||||
MACRO_PIN_DEFINE(PIN_WHITE_LED),
|
||||
MACRO_PIN_DEFINE(PIN_IRCUT_IN1),
|
||||
MACRO_PIN_DEFINE(PIN_IRCUT_IN2),
|
||||
MACRO_PIN_DEFINE(PIN_IRCUT_DETECT),
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
2
project/prebuild.sh
Normal file
2
project/prebuild.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
rm -f Obj/common_common.o
|
||||
5
project/precompile.sh
Normal file
5
project/precompile.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
[ ! -f precompile.exe ] && cp -v ../../../../tools/precompile/Debug/precompile.exe precompile.exe
|
||||
mkdir -p tmp
|
||||
precompile.exe ${ProjectPath} $1
|
||||
exit 0
|
||||
2049
project/project_config.h
Normal file
2049
project/project_config.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
project/psram.bin
Normal file
BIN
project/psram.bin
Normal file
Binary file not shown.
14
project/script.cfg
Normal file
14
project/script.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
//输入的源文件名
|
||||
app_file = APP.bin
|
||||
//生成输出的文件名
|
||||
output_file = app.bin
|
||||
//参数配置的文件
|
||||
config_file_name = config.cfg
|
||||
|
||||
|
||||
//以下配置一般不修改
|
||||
//对应宏的文件(如果是兼容,则不需要改)
|
||||
param_file_name = pin_param.h
|
||||
code_start = 0xc00
|
||||
code_offset = 0x230
|
||||
|
||||
372
project/sys_config.h
Normal file
372
project/sys_config.h
Normal file
@@ -0,0 +1,372 @@
|
||||
#ifndef __SDK_SYS_CONFIG_H__
|
||||
#define __SDK_SYS_CONFIG_H__
|
||||
#include "project_config.h"
|
||||
|
||||
#define PROJECT_TYPE PRO_TYPE_FPV
|
||||
#define SYS_CACHE_ENABLE 1
|
||||
#define SYSCFG_ENABLE 1
|
||||
|
||||
//#define OHOS //使用鸿蒙LiteOS,需要CDK排除csky目录: 右键Exclude
|
||||
#define CSKY_OS //使用 AliOS,需要CDK排除ohos目录: 右键Exclude
|
||||
|
||||
#define __ram __at_section(".ram.text")
|
||||
#define __psram_data __at_section(".psram.data")
|
||||
|
||||
#define SRAM_POOL_START (srampool_start)
|
||||
#define SRAM_POOL_SIZE (srampool_end - srampool_start)
|
||||
|
||||
#define PSRAM_POOL_START (psrampool_start)
|
||||
#define PSRAM_POOL_SIZE (psrampool_end - psrampool_start)
|
||||
|
||||
#define CPURPC_TASK_STACKSIZE 1024
|
||||
|
||||
#ifndef CONFIG_CORE_CPU_CLK
|
||||
#define CONFIG_CORE_CPU_CLK DEFAULT_SYS_CLK
|
||||
#endif
|
||||
|
||||
#ifndef CONFI_CORE_UARTDEV
|
||||
#define CONFI_CORE_UARTDEV UART0_BASE
|
||||
#endif
|
||||
|
||||
#ifndef CONFI_CORE_M2M_DMA
|
||||
#define CONFI_CORE_M2M_DMA M2M_DMA2_BASE
|
||||
#endif
|
||||
|
||||
#ifndef CONFI_CORE_DCACHE_MAINT_EN
|
||||
#define CONFI_CORE_DCACHE_MAINT_EN 1
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SRAM Layout :
|
||||
// --------------------------------------------------------------------------
|
||||
// |..core heap..|..core rxbuff..|..av heap ..|..sys heap..|
|
||||
// --------------------------------------------------------------------------
|
||||
#ifndef CONFIG_CORE_HEAP_START
|
||||
#define CONFIG_CORE_HEAP_START cpu1_mem_heap()
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_CORE_HEAP_SIZE
|
||||
#define CONFIG_CORE_HEAP_SIZE (40*1024)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef CONFIG_CORE_RXBUF_ADDR
|
||||
#define CONFIG_CORE_RXBUF_ADDR (cpu1_RXBUF_heap())
|
||||
#endif
|
||||
#ifndef CONFIG_CORE_RXBUF_SIZE
|
||||
#define CONFIG_CORE_RXBUF_SIZE (10*1024)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define SYS_HEAP_START (SRAM_POOL_START)
|
||||
#ifndef SYS_HEAP_SIZE
|
||||
#define SYS_HEAP_SIZE (SRAM_POOL_SIZE)
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// PSRAM Layout :
|
||||
// --------------------------------------------------------------------------
|
||||
// |..core skbpool..|.. psram avheap ..|.. psram heap ..| .... |
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef CONFIG_CORE_SKB_POOL_ADDR
|
||||
#define CONFIG_CORE_SKB_POOL_ADDR cpu1_skb_buf()//0x28000000//
|
||||
#endif
|
||||
#ifndef CONFIG_CORE_SKB_POOL_SIZE
|
||||
#define CONFIG_CORE_SKB_POOL_SIZE 200*1024//0x100000//
|
||||
#endif
|
||||
|
||||
|
||||
#define SYS_PSRAM_HEAP_START (PSRAM_POOL_START)
|
||||
#ifndef SYS_PSRAM_HEAP_SIZE
|
||||
#define SYS_PSRAM_HEAP_SIZE (PSRAM_POOL_SIZE)
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TXWSDK_POSIX
|
||||
#define TXWSDK_POSIX
|
||||
#endif
|
||||
|
||||
#ifndef OS_SYSTICK_HZ
|
||||
#define OS_SYSTICK_HZ (1000)
|
||||
#endif
|
||||
|
||||
#ifndef OS_IRQ_STACK_SIZE
|
||||
#define OS_IRQ_STACK_SIZE (1024)
|
||||
#endif
|
||||
|
||||
#ifndef OS_IDLE_TASK_STACK
|
||||
#define OS_IDLE_TASK_STACK (64*3)
|
||||
#endif
|
||||
|
||||
#ifndef OS_TIMER_TASK_STACK_SIZE
|
||||
#define OS_TIMER_TASK_STACK_SIZE (128) //=128*4
|
||||
#endif
|
||||
|
||||
#ifndef OS_TIMER_MSG_NUM
|
||||
#define OS_TIMER_MSG_NUM (30)
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_SYS_CLK
|
||||
#define DEFAULT_SYS_CLK 60000000UL
|
||||
#endif
|
||||
|
||||
#ifndef ATCMD_UARTDEV
|
||||
#define ATCMD_UARTDEV HG_UART0_DEVID
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_SSID_PREFIX
|
||||
#define WIFI_SSID_PREFIX "X2"
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_PASSWD_DEFAULT
|
||||
#define WIFI_PASSWD_DEFAULT "qichea701"
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_MODE_DEFAULT
|
||||
#define WIFI_MODE_DEFAULT WIFI_MODE_STA
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_HWMODE_DEFAULT
|
||||
#define WIFI_HWMODE_DEFAULT IEEE80211_HWMODE_11N
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_CHANNEL_DEFAULT
|
||||
#define WIFI_CHANNEL_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#ifndef BEACON_INTVAL_DEFAULT
|
||||
#define BEACON_INTVAL_DEFAULT 100 //单位:毫秒
|
||||
#endif
|
||||
|
||||
#ifndef DTIM_PERIOD_DEFAULT
|
||||
#define DTIM_PERIOD_DEFAULT 10 //单位:beacon个数
|
||||
#endif
|
||||
|
||||
#ifndef BSS_MAX_IDLE_DEFAULT
|
||||
#define BSS_MAX_IDLE_DEFAULT 300 //单位:秒
|
||||
#endif
|
||||
|
||||
#ifndef KEY_MGMT_DEFAULT
|
||||
#define KEY_MGMT_DEFAULT WPA_KEY_MGMT_PSK
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_BSSBW_DEFAULT
|
||||
#define WIFI_BSSBW_DEFAULT 20
|
||||
#endif
|
||||
|
||||
#ifndef NET_IP_ADDR_DEFAULT
|
||||
#define NET_IP_ADDR_DEFAULT 0x0101A8C0 //192.168.1.1
|
||||
#endif
|
||||
|
||||
#ifndef NET_MASK_DEFAULT
|
||||
#define NET_MASK_DEFAULT 0x00FFFFFF //255.255.255.0
|
||||
#endif
|
||||
|
||||
#ifndef NET_GW_IP_DEFAULT
|
||||
#define NET_GW_IP_DEFAULT 0x0101A8C0 //192.168.1.1
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_START_IP_DEFAULT
|
||||
#define DHCPD_START_IP_DEFAULT 0x6401A8C0 //192.168.1.100
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_END_IP_DEFAULT
|
||||
#define DHCPD_END_IP_DEFAULT 0xFE01A8C0 //192.168.1.254
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_LEASETIME_DEFAULT
|
||||
#define DHCPD_LEASETIME_DEFAULT 7200 //单位: 秒
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_DNS1_DEFAULT
|
||||
#define DHCPD_DNS1_DEFAULT 0x0101A8C0 //192.168.1.1
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_DNS2_DEFAULT
|
||||
#define DHCPD_DNS2_DEFAULT 0x0101A8C0 //192.168.1.1
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_ROUTER_DEFAULT
|
||||
#define DHCPD_ROUTER_DEFAULT 0x0101A8C0 //192.168.1.1
|
||||
#endif
|
||||
|
||||
#ifndef DHCPD_EN
|
||||
#define DHCPD_EN (1)
|
||||
#endif
|
||||
|
||||
#ifndef DHCPC_EN
|
||||
#define DHCPC_EN (1)
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_RTS_THRESHOLD
|
||||
#define WIFI_RTS_THRESHOLD -1
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_RTS_MAX_RETRY
|
||||
#define WIFI_RTS_MAX_RETRY 2
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_TX_MAX_RETRY
|
||||
#define WIFI_TX_MAX_RETRY 15
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_TX_SUPP_RATE
|
||||
#define WIFI_TX_SUPP_RATE 0x0FFFFF //TX速率支持,每1bit对应一种速率
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_MULICAST_RETRY
|
||||
#define WIFI_MULICAST_RETRY 0 //组播帧传输次数
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_ACS_CHAN_LISTS
|
||||
#define WIFI_ACS_CHAN_LISTS 0x03FF //要扫描的信道。每1bit对应1个信道(bit 0~11 -> chan 1~12)
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_ACS_SCAN_TIME
|
||||
#define WIFI_ACS_SCAN_TIME 150 //每个信道的扫描时间,单位ms
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_TX_DUTY_CYCLE
|
||||
#define WIFI_TX_DUTY_CYCLE 100 //tx发送占空比,单位是%,范围是0~100
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_SSID_FILTER_EN
|
||||
#define WIFI_SSID_FILTER_EN 0 //是否使能SSID过滤功能。使能后,只有隐藏SSID和指定SSID的beacon才会上传
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_PREVENT_PS_MODE_EN
|
||||
#define WIFI_PREVENT_PS_MODE_EN 0 //是否尽可能的阻止sta进入休眠
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_FEM_CHIP
|
||||
#define WIFI_FEM_CHIP LMAC_FEM_NONE //FEM芯片类型。LMAC_FEM_NONE以外的值会进行对应的FEM初始化
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_FREQ_OFFSET_TRACK_MODE
|
||||
#define WIFI_FREQ_OFFSET_TRACK_MODE LMAC_FREQ_OFFSET_TRACK_ALWAYS_ON //默认一直打开频偏跟踪功能
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_TEMPERATURE_COMPESATE_EN
|
||||
#define WIFI_TEMPERATURE_COMPESATE_EN 1 //是否使能温度补偿
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_PS_NO_FRM_LOSS_EN
|
||||
#define WIFI_PS_NO_FRM_LOSS_EN 0 //tx缓存的休眠帧是否不允许丢弃
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_TX_AGG_EN
|
||||
#define WIFI_TX_AGG_EN 0 //是否允许发送聚合。如果对时延要求不高的,可以打开
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_RX_AGG_EN
|
||||
#define WIFI_RX_AGG_EN 0 //是否允许接收聚合。CONFIG_CORE_RXBUF_SIZE小于18KB都不推荐使能
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_RF_PWR_LEVEL
|
||||
#define WIFI_RF_PWR_LEVEL 0
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_SINGLE_DEV
|
||||
#define WIFI_SINGLE_DEV 1
|
||||
#endif
|
||||
|
||||
#ifndef SYS_NETWORK_SUPPORT
|
||||
#define SYS_NETWORK_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_AP_SUPPORT
|
||||
#define WIFI_AP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_STA_SUPPORT
|
||||
#define WIFI_STA_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifndef SYS_APP_DHCPD
|
||||
#define SYS_APP_DHCPD 1
|
||||
#endif
|
||||
|
||||
#ifndef SYS_APP_SNTP
|
||||
#define SYS_APP_SNTP 0
|
||||
#endif
|
||||
|
||||
#ifndef SYS_APP_UHTTPD
|
||||
#define SYS_APP_UHTTPD 0
|
||||
#endif
|
||||
|
||||
#ifndef SYS_APP_BLENC
|
||||
#define SYS_APP_BLENC 0
|
||||
#endif
|
||||
|
||||
#ifndef SYS_IOT_ATCMD
|
||||
#define SYS_IOT_ATCMD 0
|
||||
#endif
|
||||
|
||||
#ifndef SYS_DISABLE_PRINT
|
||||
#define SYS_DISABLE_PRINT 0
|
||||
#endif
|
||||
|
||||
#ifndef ISP_SUPPORT_SENSOR_MAX_NUM
|
||||
#define ISP_SUPPORT_SENSOR_MAX_NUM 3
|
||||
#endif
|
||||
|
||||
#ifndef ISP_SENSOR_REG_MAX_LEN
|
||||
#define ISP_SENSOR_REG_MAX_LEN (100)
|
||||
#endif
|
||||
|
||||
#ifndef ISP_AE_CROP_ZONE_NUM
|
||||
#define ISP_AE_CROP_ZONE_NUM (5)
|
||||
#endif
|
||||
|
||||
#ifndef DUAL_EN
|
||||
#define DUAL_EN (0)
|
||||
#endif
|
||||
|
||||
#ifndef SD_MODE_TYPE
|
||||
#define SD_MODE_TYPE (2)
|
||||
#endif
|
||||
|
||||
#ifndef UBLE_UUID_128_SUPPORT
|
||||
#define UBLE_UUID_128_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifdef PSRAM_HEAP
|
||||
#define TCPIP_MBOX_SIZE 128
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 64
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 64
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 16
|
||||
|
||||
//#define MEM_LIBC_MALLOC 1
|
||||
//#define MEMP_MEM_MALLOC 1
|
||||
#define MEM_SIZE 80*1024
|
||||
#define MEMP_NUM_PBUF 40
|
||||
#define MEMP_NUM_NETCONN 16
|
||||
#define MEMP_NUM_NETBUF 64
|
||||
#define MEMP_NUM_UDP_PCB 8
|
||||
#define MEMP_NUM_TCP_PCB 16
|
||||
#define MEMP_NUM_TCP_SEG 320
|
||||
#define PBUF_POOL_SIZE 80
|
||||
|
||||
#define TCP_SND_BUF (40 * TCP_MSS)
|
||||
#define TCP_WND (40 * TCP_MSS)
|
||||
#define TCP_TMR_INTERVAL 50
|
||||
#endif
|
||||
|
||||
#ifndef VIDEO_YUV_RANGE_TYPE
|
||||
#define VIDEO_YUV_RANGE_TYPE (1)
|
||||
#endif
|
||||
|
||||
#define LWIP_DHCP_DOES_ACD_CHECK 0 //关闭lwip的acd模块功能
|
||||
#endif
|
||||
|
||||
197
project/syscfg.c
Normal file
197
project/syscfg.c
Normal file
@@ -0,0 +1,197 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "list.h"
|
||||
#include "dev.h"
|
||||
#include "devid.h"
|
||||
#include "osal/string.h"
|
||||
#include "osal/semaphore.h"
|
||||
#include "osal/mutex.h"
|
||||
#include "osal/irq.h"
|
||||
#include "osal/task.h"
|
||||
#include "osal/sleep.h"
|
||||
#include "osal/timer.h"
|
||||
#include "osal/work.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/uart.h"
|
||||
#include "lib/common/common.h"
|
||||
#include "lib/umac/ieee80211.h"
|
||||
#include "lib/syscfg/syscfg.h"
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
#define SYSCFG_WIFI_MODE(mode) ((mode) == WIFI_MODE_STA ? "sta" : ((mode) == WIFI_MODE_AP ? "ap" : "apsta"))
|
||||
|
||||
struct sys_config sys_cfgs = {
|
||||
.wifi_mode = WIFI_MODE_DEFAULT,
|
||||
.wifi_hwmode = WIFI_HWMODE_DEFAULT,
|
||||
.channel = WIFI_CHANNEL_DEFAULT,
|
||||
.beacon_int = BEACON_INTVAL_DEFAULT,
|
||||
.dtim_period = DTIM_PERIOD_DEFAULT,
|
||||
.bss_max_idle = BSS_MAX_IDLE_DEFAULT,
|
||||
.key_mgmt = KEY_MGMT_DEFAULT,
|
||||
.bss_bw = WIFI_BSSBW_DEFAULT,
|
||||
.ipaddr = NET_IP_ADDR_DEFAULT,
|
||||
.netmask = NET_MASK_DEFAULT,
|
||||
.gw_ip = NET_GW_IP_DEFAULT,
|
||||
.dhcpd_startip = DHCPD_START_IP_DEFAULT,
|
||||
.dhcpd_endip = DHCPD_END_IP_DEFAULT,
|
||||
.dhcpd_lease_time = DHCPD_LEASETIME_DEFAULT,
|
||||
.dhcpd_dns1 = DHCPD_DNS1_DEFAULT,
|
||||
.dhcpd_dns2 = DHCPD_DNS2_DEFAULT,
|
||||
.dhcpd_router = DHCPD_ROUTER_DEFAULT,
|
||||
.dhcpd_en = DHCPD_EN,
|
||||
.dhcpc_en = DHCPC_EN,
|
||||
.mipi_csi0_hs_zero_cnt = 0,
|
||||
.mipi_csi1_hs_zero_cnt = 0,
|
||||
};
|
||||
|
||||
extern void sys_dhcpd_start(void);
|
||||
|
||||
static void wificfg_custom_ap_wmm_param(uint8 ifidx)
|
||||
{
|
||||
#ifdef SYS_CUSTOM_APWMM
|
||||
const uint8 txq[][8] = { //使用自定义的wmm 参数
|
||||
{0x4F, 0x00, 0x02, 0x00, 0x09, 0x00, 0x01, 0x00,},
|
||||
{0x4F, 0x00, 0x02, 0x00, 0x09, 0x00, 0x01, 0x01,},
|
||||
{0x80, 0x00, 0x02, 0x00, 0x04, 0x00, 0x01, 0x02,},
|
||||
{0x41, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x03,},
|
||||
};
|
||||
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_AP && ifidx == WIFI_MODE_AP) {
|
||||
ieee80211_conf_set_wmm_param(WIFI_MODE_AP, 0xf0, (struct ieee80211_wmm_param *)&txq[0]);
|
||||
ieee80211_conf_set_wmm_param(WIFI_MODE_AP, 0xf1, (struct ieee80211_wmm_param *)&txq[1]);
|
||||
ieee80211_conf_set_wmm_param(WIFI_MODE_AP, 0xf2, (struct ieee80211_wmm_param *)&txq[2]);
|
||||
ieee80211_conf_set_wmm_param(WIFI_MODE_AP, 0xf3, (struct ieee80211_wmm_param *)&txq[3]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 wificfg_flush(uint8 ifidx)
|
||||
{
|
||||
wificfg_custom_ap_wmm_param(ifidx);
|
||||
|
||||
if (sys_cfgs.wifi_hwmode) {
|
||||
ieee80211_conf_set_hwmode(ifidx, sys_cfgs.wifi_hwmode);
|
||||
}
|
||||
|
||||
if (ifidx == WIFI_MODE_AP) {
|
||||
if (sys_cfgs.channel == 0 && sys_status.channel) {
|
||||
ieee80211_conf_set_channel(ifidx, sys_status.channel);
|
||||
} else {
|
||||
ieee80211_conf_set_channel(ifidx, sys_cfgs.channel);
|
||||
}
|
||||
}
|
||||
|
||||
ieee80211_conf_set_mac(ifidx, sys_cfgs.mac);
|
||||
ieee80211_conf_set_hwmode(ifidx, sys_cfgs.wifi_hwmode);
|
||||
ieee80211_conf_set_channel(ifidx, sys_status.channel);
|
||||
ieee80211_conf_set_beacon_int(ifidx, sys_cfgs.beacon_int);
|
||||
ieee80211_conf_set_dtim_int(ifidx, sys_cfgs.dtim_period);
|
||||
ieee80211_conf_set_bss_max_idle(ifidx, sys_cfgs.bss_max_idle);
|
||||
ieee80211_conf_set_aphide(ifidx, sys_cfgs.ap_hide);
|
||||
ieee80211_conf_set_bssbw(ifidx, sys_cfgs.bss_bw);
|
||||
|
||||
if (ifidx == WIFI_MODE_AP && sys_cfgs.wifi_mode == WIFI_MODE_APSTA && sys_cfgs.cfg_init) {
|
||||
//ieee80211_conf_set_ssid(ifidx, sys_cfgs.r_ssid);
|
||||
//ieee80211_conf_set_keymgmt(ifidx, sys_cfgs.r_key_mgmt);
|
||||
//ieee80211_conf_set_psk(ifidx, sys_cfgs.r_psk);
|
||||
//ieee80211_conf_set_passwd(ifidx, sys_cfgs.r_passwd);
|
||||
} else {
|
||||
ieee80211_conf_set_ssid(ifidx, sys_cfgs.ssid);
|
||||
ieee80211_conf_set_keymgmt(ifidx, sys_cfgs.key_mgmt);
|
||||
ieee80211_conf_set_psk(ifidx, sys_cfgs.psk);
|
||||
ieee80211_conf_set_passwd(ifidx, (char*)sys_cfgs.passwd);
|
||||
}
|
||||
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_APSTA) {
|
||||
//ieee80211_conf_set_relay_mode(WIFI_MODE_AP, sys_cfgs.relay_en, sys_cfgs.relay_level, sys_cfgs.relay_mcast);
|
||||
//ieee80211_conf_set_relay_mode(WIFI_MODE_STA, sys_cfgs.relay_en, sys_cfgs.relay_level, sys_cfgs.relay_mcast);
|
||||
} else {
|
||||
//ieee80211_conf_set_relay_mode(ifidx, 0, 0, 0);
|
||||
}
|
||||
|
||||
netdev_set_wifi_mode((struct netdev *)dev_get(HG_WIFI0_DEVID), sys_cfgs.wifi_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void netcfg_flush(void)
|
||||
{
|
||||
ip_addr_t ipaddr, netmask, gw;
|
||||
ipaddr.addr = sys_cfgs.ipaddr;
|
||||
netmask.addr = sys_cfgs.netmask;
|
||||
gw.addr = sys_cfgs.gw_ip;
|
||||
|
||||
lwip_netif_set_dhcp2("w0", sys_cfgs.dhcpc_en);
|
||||
lwip_netif_set_ip2("w0", &ipaddr, &netmask, &gw);
|
||||
|
||||
if (sys_cfgs.dhcpd_en) {
|
||||
sys_dhcpd_start();
|
||||
} else {
|
||||
dhcpd_stop();
|
||||
}
|
||||
}
|
||||
|
||||
void syscfg_flush(int32 reset)
|
||||
{
|
||||
if (reset) {
|
||||
ieee80211_iface_stop(WIFI_MODE_STA);
|
||||
ieee80211_iface_stop(WIFI_MODE_AP);
|
||||
}
|
||||
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_APSTA) {
|
||||
wificfg_flush(WIFI_MODE_AP);
|
||||
wificfg_flush(WIFI_MODE_STA);
|
||||
if (reset) {
|
||||
ieee80211_iface_start(WIFI_MODE_STA);
|
||||
ieee80211_iface_start(WIFI_MODE_AP);
|
||||
}
|
||||
} else {
|
||||
wificfg_flush(sys_cfgs.wifi_mode);
|
||||
if (reset) {
|
||||
ieee80211_iface_start(sys_cfgs.wifi_mode);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sys_cfgs.dhcpc_en) {
|
||||
sys_status.dhcpc_result.ipaddr = sys_cfgs.ipaddr;
|
||||
sys_status.dhcpc_result.netmask = sys_cfgs.netmask;
|
||||
sys_status.dhcpc_result.router = sys_cfgs.gw_ip;
|
||||
}
|
||||
}
|
||||
|
||||
int32 syscfg_save(void)
|
||||
{
|
||||
return syscfg_write("syscfg", &sys_cfgs, sizeof(sys_cfgs));
|
||||
}
|
||||
|
||||
void syscfg_default()
|
||||
{
|
||||
sysctrl_efuse_mac_addr_calc(sys_cfgs.mac);
|
||||
if (IS_ZERO_ADDR(sys_cfgs.mac)) {
|
||||
os_random_bytes(sys_cfgs.mac, 6);
|
||||
sys_cfgs.mac[0] &= 0xfe;
|
||||
os_printf(KERN_WARNING"use random mac "MACSTR"\r\n", MAC2STR(sys_cfgs.mac));
|
||||
}
|
||||
os_snprintf((char *)sys_cfgs.ssid, SSID_MAX_LEN, WIFI_SSID_PREFIX"%02X%02X%02X", sys_cfgs.mac[3], sys_cfgs.mac[4], sys_cfgs.mac[5]);
|
||||
os_strcpy(sys_cfgs.passwd, WIFI_PASSWD_DEFAULT);
|
||||
wpa_passphrase(sys_cfgs.ssid, (char*)sys_cfgs.passwd, sys_cfgs.psk);
|
||||
}
|
||||
|
||||
void syscfg_dump()
|
||||
{
|
||||
VERSION_SHOW();
|
||||
_os_printf("System Settings:\r\n");
|
||||
_os_printf(" mac:"MACSTR", dhcpc_en:%d, dhcpd_en:%d\r\n", MAC2STR(sys_cfgs.mac), sys_cfgs.dhcpc_en, sys_cfgs.dhcpd_en);
|
||||
_os_printf(" wifi:\r\n");
|
||||
_os_printf(" mode:%s, bw%d, channel:%d(%d)\r\n", SYSCFG_WIFI_MODE(sys_cfgs.wifi_mode), sys_cfgs.bss_bw, sys_cfgs.channel, sys_status.channel);
|
||||
_os_printf(" ssid:%s, passwd:%s, keymgmt:0x%x\r\n", sys_cfgs.ssid, sys_cfgs.passwd, sys_cfgs.key_mgmt);
|
||||
_os_printf(" bss_maxidle:%d, beacon_int:%d, dtim_period:%d\r\n", sys_cfgs.bss_max_idle, sys_cfgs.beacon_int, sys_cfgs.dtim_period);
|
||||
_os_printf(" network:\r\n");
|
||||
_os_printf(" ipaddr:"IPSTR", netmask:"IPSTR", gw:"IPSTR"\n", IP2STR_N(sys_cfgs.ipaddr), IP2STR_N(sys_cfgs.netmask), IP2STR_N(sys_cfgs.gw_ip));
|
||||
_os_printf(" dhcpserver: "IPSTR"-"IPSTR", leaseTime:%d\n", IP2STR_N(sys_cfgs.dhcpd_startip), IP2STR_N(sys_cfgs.dhcpd_endip), sys_cfgs.dhcpd_lease_time);
|
||||
}
|
||||
|
||||
79
project/syscfg.h
Normal file
79
project/syscfg.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef _PROJECT_SYSCFG_H_
|
||||
#define _PROJECT_SYSCFG_H_
|
||||
|
||||
enum WIFI_WORK_MODE {
|
||||
WIFI_MODE_NONE = 0,
|
||||
WIFI_MODE_STA,
|
||||
WIFI_MODE_AP,
|
||||
WIFI_MODE_APSTA,
|
||||
};
|
||||
|
||||
/* 系统状态信息 */
|
||||
struct system_status {
|
||||
uint32 dhcpc_done: 1,
|
||||
wifi_connected: 1,
|
||||
dbg_heap: 1,
|
||||
dbg_top: 2,
|
||||
dbg_lmac: 1,
|
||||
dbg_umac: 1,
|
||||
dbg_irq: 1,
|
||||
upgrading: 1,
|
||||
dbg_cache: 1,
|
||||
dbg_net: 1;
|
||||
int8 rssi;
|
||||
int8 evm;
|
||||
uint8 channel;
|
||||
uint8 wifi_mode;
|
||||
int8 pair_role;
|
||||
uint8 bssid[6];
|
||||
uint16 wifi_status_code;
|
||||
uint16 wifi_reason_code;
|
||||
struct {
|
||||
uint32 ipaddr, netmask, svrip, router, dns1, dns2, last_router;
|
||||
} dhcpc_result;
|
||||
};
|
||||
|
||||
/* 系统参数信息 */
|
||||
struct sys_config {
|
||||
/******* 参数区头部: 这部分区域不能修改 *****/
|
||||
uint16 magic_num, crc;
|
||||
uint16 size, rev1, rev2, rev3;
|
||||
/*******************************************/
|
||||
|
||||
uint8 wifi_mode, bss_bw, tx_mcs, channel;
|
||||
uint8 bssid[6], mac[6];
|
||||
uint8 ssid[SSID_MAX_LEN + 1];
|
||||
uint8 psk[32];
|
||||
uint8 passwd[PASSWD_MAX_LEN + 1];
|
||||
uint8 wifi_hwmode;
|
||||
uint16 bss_max_idle, beacon_int;
|
||||
uint16 ack_tmo, dtim_period;
|
||||
uint32 key_mgmt;
|
||||
|
||||
/*标识位*/
|
||||
uint32 dhcpc_en: 1,
|
||||
dhcpd_en: 1,
|
||||
use4addr: 1,
|
||||
cfg_init: 1,
|
||||
ap_hide: 1,
|
||||
xxxxxx: 27;
|
||||
|
||||
uint32 ipaddr, netmask, gw_ip;
|
||||
uint32 dhcpd_startip, dhcpd_endip, dhcpd_lease_time, dhcpd_dns1, dhcpd_dns2, dhcpd_router;
|
||||
|
||||
/* 只能在后面添加参数,保证参数区的兼容性 *****
|
||||
* 添加参数注意对齐,避免浪费Memory空间 ******/
|
||||
uint32 mipi_csi0_hs_zero_cnt : 16, mipi_csi1_hs_zero_cnt : 16;
|
||||
uint32 mipi_csi0_sensor_id : 8, mipi_csi1_sensor_id : 8, reserved : 16;
|
||||
};
|
||||
|
||||
extern struct sys_config sys_cfgs;
|
||||
extern struct system_status sys_status;
|
||||
|
||||
void syscfg_default(void);
|
||||
int32 wificfg_flush(uint8 ifidx);
|
||||
void syscfg_check(void);
|
||||
void syscfg_dump(void);
|
||||
void netcfg_flush(void);
|
||||
#endif
|
||||
|
||||
133
project/target_config.h
Normal file
133
project/target_config.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**@defgroup los_config System configuration items
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _TARGET_CONFIG_H
|
||||
#define _TARGET_CONFIG_H
|
||||
|
||||
#include "sys_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*=============================================================================
|
||||
System clock module configuration
|
||||
=============================================================================*/
|
||||
#define OS_SYS_CLOCK DEFAULT_SYS_CLK
|
||||
#define LOSCFG_BASE_CORE_TICK_PER_SECOND OS_SYSTICK_HZ
|
||||
#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
|
||||
#define LOSCFG_BASE_CORE_TICK_WTIMER 0
|
||||
#define LOSCFG_BASE_CORE_TICK_RESPONSE_MAX (OS_SYS_CLOCK / OS_SYSTICK_HZ)
|
||||
|
||||
/*=============================================================================
|
||||
Hardware interrupt module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_PLATFORM_HWI 1
|
||||
#define LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT 1
|
||||
#define LOSCFG_PLATFORM_HWI_LIMIT 106
|
||||
/*=============================================================================
|
||||
Task module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_BASE_CORE_TSK_LIMIT 32
|
||||
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x300U)
|
||||
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x800U)
|
||||
#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x200U)
|
||||
#define LOSCFG_BASE_CORE_TIMESLICE 1
|
||||
#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 5000
|
||||
/*=============================================================================
|
||||
Semaphore module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_BASE_IPC_SEM 1
|
||||
#define LOSCFG_BASE_IPC_SEM_LIMIT 128
|
||||
/*=============================================================================
|
||||
Mutex module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_BASE_IPC_MUX 1
|
||||
#define LOSCFG_BASE_IPC_MUX_LIMIT 128
|
||||
/*=============================================================================
|
||||
Queue module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_BASE_IPC_QUEUE 1
|
||||
#define LOSCFG_BASE_IPC_QUEUE_LIMIT 128
|
||||
/*=============================================================================
|
||||
Software timer module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_BASE_CORE_SWTMR 1
|
||||
#define LOSCFG_BASE_CORE_SWTMR_ALIGN 0
|
||||
#define LOSCFG_BASE_CORE_SWTMR_LIMIT 128
|
||||
/*=============================================================================
|
||||
Memory module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_MEM_MUL_POOL 0
|
||||
#define OS_SYS_MEM_NUM 20
|
||||
/*=============================================================================
|
||||
Exception module configuration
|
||||
=============================================================================*/
|
||||
#define LOSCFG_PLATFORM_EXC 0
|
||||
/* =============================================================================
|
||||
printf module configuration
|
||||
============================================================================= */
|
||||
#define LOSCFG_KERNEL_PRINTF 1
|
||||
|
||||
#define LOSCFG_BASE_CORE_SCHED_SLEEP 1
|
||||
|
||||
#define LOSCFG_KERNEL_PM 0
|
||||
|
||||
#define LOSCFG_BASE_CORE_TSK_MONITOR 1
|
||||
|
||||
#define LOSCFG_BASE_CORE_CPUP 1
|
||||
|
||||
|
||||
#define LOSCFG_PLATFORM_HWI_WITH_ARG 1
|
||||
|
||||
#define LOSCFG_SYS_EXTERNAL_HEAP 1
|
||||
#define LOSCFG_BASE_CORE_MEMPOOL 0
|
||||
|
||||
#define LOSCFG_SYS_HEAP_ADDR (void *)(SYS_HEAP_START) /*未生效: 使用了SDK的内存管理模块*/
|
||||
#define LOSCFG_SYS_HEAP_SIZE SYS_HEAP_SIZE /*OsTaskInitParamCheck会检查stack size 是否大于heap Size*/
|
||||
|
||||
extern unsigned int srampool_start;
|
||||
extern unsigned int srampool_end;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _TARGET_CONFIG_H */
|
||||
10219
project/txw82xApp.cdkproj
Normal file
10219
project/txw82xApp.cdkproj
Normal file
File diff suppressed because one or more lines are too long
11
project/txw82xApp.cdkws
Normal file
11
project/txw82xApp.cdkws
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CDK_Workspace Name="txw82xApp" Database="LanguageSever" DoubleClick="Yes">
|
||||
<DefaultPackPath>$(CDKWS)\__workspace_pack__</DefaultPackPath>
|
||||
<Project Name="txw82xApp" Path="txw82xApp.cdkproj" RootPath="" Active="Yes"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Environment/>
|
||||
<Project Name="txw82xApp" ConfigName="FLASH"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CDK_Workspace>
|
||||
6682
project/txw82xApp.mk
Normal file
6682
project/txw82xApp.mk
Normal file
File diff suppressed because one or more lines are too long
3
project/txw82xApp.modify.bat
Normal file
3
project/txw82xApp.modify.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
SET PATH=%Systemroot%\System32;%PATH%
|
||||
forfiles.exe -P "%1" -M %2 -C "cmd /c echo %1/%2 is modified at: @fdate @ftime" | findstr modified
|
||||
BIN
project/txw82xcore.bin
Normal file
BIN
project/txw82xcore.bin
Normal file
Binary file not shown.
9
project/utilities/aft_build.sh
Normal file
9
project/utilities/aft_build.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp -f ./Obj/txw4101.ihex project.hex
|
||||
cp -f ../../../../tools/makecode/BinScript.exe BinScript.exe
|
||||
cp -f ../../../../tools/makecode/crc.exe crc.exe
|
||||
cp -f ../../../../tools/makecode/makecode.exe makecode.exe
|
||||
|
||||
BinScript.exe BinScript.BinScript
|
||||
makecode.exe
|
||||
0
project/utilities/flashinit
Normal file
0
project/utilities/flashinit
Normal file
331
project/utilities/gcc_csky.ld
Normal file
331
project/utilities/gcc_csky.ld
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* @file gcc_csky.ld
|
||||
* @brief csky linker file
|
||||
* @version V1.0
|
||||
* @date 2025.4.12
|
||||
* SRAM0-0: 0x20000000 ~ 0x20003FFF 16KB
|
||||
* SRAM0-1: 0x20004000 ~ 0x2001FFFF 112KB
|
||||
* SRAM1: 0x20020000 ~ 0x2003FFFF 128KB
|
||||
* SRAM2-0: 0x20040000 ~ 0x20057FFF 96KB
|
||||
* SRAM2-1: 0x20058000 ~ 0x2005FFFF 32KB (DCAHCE)
|
||||
* SRAM2-2: 0x20060000 ~ 0x20067FFF 32KB (CPU1 I/D CACHE)
|
||||
* SRAM2-3: 0x20068000 ~ 0x2006BF00 16KB (末尾256byte为CoreSetting数据)
|
||||
* SRAM3: 0x20080000 ~ 0x2009FFFF 128KB (H264)
|
||||
******************************************************************************/
|
||||
MEMORY
|
||||
{
|
||||
ISRAM : ORIGIN = 0x04001000 , LENGTH = 0x2a000
|
||||
SRAM : ORIGIN = 0x20006b44 , LENGTH = 0x40000 /*起始地址为CoreCode BSS结束地址 */
|
||||
SRAM2 : ORIGIN = 0x20068000 , LENGTH = 0x3A00 /*末尾预留256byte做为CoreSetting数据*/
|
||||
FLASH : ORIGIN = 0x10000000 , LENGTH = 0x200000
|
||||
PSRAM : ORIGIN = 0x28000000 , LENGTH = 0x800000
|
||||
SRAM0 : ORIGIN = 0x20001100 , LENGTH = 0x2F00 /*SRAM0 16 - 4KB for sleep*/
|
||||
ALUSER-SRAM : ORIGIN = 0x2006BA00 , LENGTH = 0x400 /* 二次loader的固件参数区 ALUSER-SRAM 1KB */
|
||||
FW_INFO : ORIGIN = 0x2006BE00 , LENGTH = 0x100
|
||||
}
|
||||
|
||||
__heap_size = 0x40000;
|
||||
|
||||
PROVIDE (__ram_end = 0x20058000);
|
||||
PROVIDE (__heap_end = 0x20058000);
|
||||
PROVIDE (__sleep_data_start = 0x20000200);
|
||||
PROVIDE (__sleep_data_stop = 0x20001000);
|
||||
PROVIDE (__psram_heap_end = 0x29000000);
|
||||
PROVIDE (_data0_lma_start = 0);
|
||||
PROVIDE (__data0_start__ = 0);
|
||||
PROVIDE (__data0_end__ = 0);
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_RODATA", FLASH);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
REGION_ALIAS("REGION_INIT", SRAM);
|
||||
REGION_ALIAS("REGION_PSRAM_HEAP", PSRAM);
|
||||
REGION_ALIAS("REGION_NOLOAD_PSRAM", PSRAM);
|
||||
REGION_ALIAS("REGION_DATA2", SRAM2);
|
||||
REGION_ALIAS("REGION_OTA_VMA", SRAM);
|
||||
REGION_ALIAS("REGION_TEXT2", SRAM2);
|
||||
REGION_ALIAS("REGION_DSLEEP", SRAM0);
|
||||
REGION_ALIAS("REGION_ALUSER", ALUSER-SRAM);
|
||||
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
SECTIONS
|
||||
{
|
||||
.text : AT(ADDR(.text)) {
|
||||
. = ALIGN(0x4) ;
|
||||
__code_start = .;
|
||||
KEEP(*startup.o(.vectors))
|
||||
. = ALIGN(0x10) ;
|
||||
KEEP(*(SYS_PARAM)) /*如果预留参数区的Size 大于4K时 不能再放在此位置*/
|
||||
. = ALIGN(0x1000);
|
||||
. = . + 0x61fb4; /*预留CodeCode Size大小区间*/
|
||||
. = ALIGN(0x4);
|
||||
__stext = . ;
|
||||
*(.text)
|
||||
*(.text*)
|
||||
*(.text.*)
|
||||
*(INIT.TXT)
|
||||
*(INIT.TXT.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.gnu.linkonce.t*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.jcr)
|
||||
KEEP (*(.init*))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN (4) ;
|
||||
PROVIDE(__ctbp = .);
|
||||
*(.call_table_data)
|
||||
*(.call_table_text)
|
||||
. = ALIGN(4) ;
|
||||
__etext = . ;
|
||||
} > REGION_TEXT
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(0x4) ;
|
||||
__srodata = .;
|
||||
*(.rdata)
|
||||
*(.rdata*)
|
||||
*(.rdata1)
|
||||
*(.rdata.*)
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata*)
|
||||
*(.rodata.*)
|
||||
*(.rodata.str1.4)
|
||||
*(INIT.RO)
|
||||
*(INIT.RO.*)
|
||||
. = ALIGN(0x4) ;
|
||||
|
||||
__modver_start = .;
|
||||
KEEP(*(.modver))
|
||||
__modver_end = .;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
__CTOR_LIST__ = . ;
|
||||
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.ctors)))
|
||||
LONG(0)
|
||||
__CTOR_END__ = . ;
|
||||
__DTOR_LIST__ = . ;
|
||||
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.dtors)))
|
||||
LONG(0)
|
||||
__DTOR_END__ = . ;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
} > REGION_RODATA
|
||||
|
||||
.dsleep : {
|
||||
__data0_start__ = . ;
|
||||
__dsleep_start = .;
|
||||
*(.dsleep.*)
|
||||
. = ALIGN(0x4) ;
|
||||
__dsleep_end = .;
|
||||
__data0_end__ = . ;
|
||||
} > REGION_DSLEEP AT>REGION_RODATA
|
||||
_data0_lma_start = LOADADDR(.dsleep);
|
||||
_data0_lma_end = LOADADDR(.dsleep) + SIZEOF(.dsleep);
|
||||
|
||||
.data : {
|
||||
. = ALIGN(4) ;
|
||||
__sdata = . ;
|
||||
__data_start__ = . ;
|
||||
data_start = . ;
|
||||
|
||||
|
||||
*(INIT.DAT)
|
||||
*(INIT.DAT.*)
|
||||
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.gnu.linkonce.r*)
|
||||
*(.bobj)
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.data1)
|
||||
*(.gcc_except_table)
|
||||
*(.gcc_except_table*)
|
||||
__start_init_call = .;
|
||||
*(.initcall.init)
|
||||
__stop_init_call = .;
|
||||
__start_cmd = .;
|
||||
*(.bootloaddata.cmd)
|
||||
. = ALIGN(4) ;
|
||||
__stop_cmd = .;
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
*(__libc_atexit)
|
||||
*(__libc_subinit)
|
||||
*(__libc_subfreeres)
|
||||
*(.note.ABI-tag)
|
||||
*(.ram.text)
|
||||
. = ALIGN(0x4) ;
|
||||
__edata = .;
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT>REGION_RODATA
|
||||
_data_lma_start = LOADADDR(.data);
|
||||
_data_lma_end = LOADADDR(.data) + SIZEOF(.data);
|
||||
|
||||
.fw_info : {
|
||||
__fw_info_start = .;
|
||||
. += 160;
|
||||
__fw_info_end = .;
|
||||
} > FW_INFO
|
||||
|
||||
.no_init (NOLOAD) : {
|
||||
*(.irq_stack);
|
||||
*(.trap_stack);
|
||||
*(.no_init);
|
||||
} > REGION_BSS
|
||||
|
||||
.ota : {
|
||||
. = ALIGN(0x4) ;
|
||||
_ota_vma_start = . ;
|
||||
KEEP (*(.otacode))
|
||||
_ota_vma_end = . ;
|
||||
} > REGION_OTA_VMA AT > REGION_RODATA
|
||||
_ota_lma_start = LOADADDR(.ota);
|
||||
_ota_lma_end = LOADADDR(.ota) + SIZEOF(.ota);
|
||||
|
||||
|
||||
.iis : AT(LOADADDR(.ota) + SIZEOF(.ota)) {
|
||||
. = ALIGN(0x4) ;
|
||||
iis_start = .;
|
||||
KEEP (*(.iiscode))
|
||||
} > REGION_OTA_VMA
|
||||
_iis_start = LOADADDR(.iis);
|
||||
_iis_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
__code_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
|
||||
._al_user_sram (NOLOAD): {
|
||||
. = ALIGN(0x4) ;
|
||||
__al_user_sram_start = .;
|
||||
*(.al_user_data)
|
||||
__al_user_sram_current = .;
|
||||
} > REGION_ALUSER AT > REGION_BSS
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(0x4) ;
|
||||
__sbss = ALIGN(0x4) ;
|
||||
__bss_start__ = . ;
|
||||
*(.dynsbss)
|
||||
*(.sbss.ota)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4) ;
|
||||
__ebss = . ;
|
||||
__end = . ;
|
||||
end = . ;
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._user_heap : {
|
||||
. = ALIGN(0x4) ;
|
||||
__heap_start = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._psram_data (NOLOAD): {
|
||||
*(.psram.src)
|
||||
*(.psram.data)
|
||||
} > REGION_NOLOAD_PSRAM
|
||||
|
||||
.psram_heap : {
|
||||
. = ALIGN(4) ;
|
||||
__psram_heap_start = .;
|
||||
} > REGION_PSRAM_HEAP
|
||||
|
||||
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > REGION_BSS
|
||||
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } > REGION_BSS
|
||||
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
|
||||
.preinit_array :{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
}
|
||||
|
||||
.init_array :{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
}
|
||||
|
||||
.fini_array :{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
}
|
||||
|
||||
.junk 0 : { *(.rel*) *(.rela*) }
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
}
|
||||
|
||||
|
||||
/* ROM Functions */
|
||||
/* ASSERT(DEFINED(ROM_FUNC_ENABLE), "please disable ROM Functions in ld file") */
|
||||
/* ASSERT(ADDR(.text) < 0x20000068, "ROM Functions data area conflict!!!")*/
|
||||
|
||||
/* INPUT(romcode.ld) */
|
||||
memset = 0x00000568;
|
||||
memcpy = 0x00000608;
|
||||
memcmp = 0x00000688;
|
||||
331
project/utilities/gcc_csky.ld.i
Normal file
331
project/utilities/gcc_csky.ld.i
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* @file gcc_csky.ld
|
||||
* @brief csky linker file
|
||||
* @version V1.0
|
||||
* @date 2025.4.12
|
||||
* SRAM0-0: 0x20000000 ~ 0x20003FFF 16KB
|
||||
* SRAM0-1: 0x20004000 ~ 0x2001FFFF 112KB
|
||||
* SRAM1: 0x20020000 ~ 0x2003FFFF 128KB
|
||||
* SRAM2-0: 0x20040000 ~ 0x20057FFF 96KB
|
||||
* SRAM2-1: 0x20058000 ~ 0x2005FFFF 32KB (DCAHCE)
|
||||
* SRAM2-2: 0x20060000 ~ 0x20067FFF 32KB (CPU1 I/D CACHE)
|
||||
* SRAM2-3: 0x20068000 ~ 0x2006BF00 16KB (末尾256byte为CoreSetting数据)
|
||||
* SRAM3: 0x20080000 ~ 0x2009FFFF 128KB (H264)
|
||||
******************************************************************************/
|
||||
MEMORY
|
||||
{
|
||||
ISRAM : ORIGIN = 0x04001000 , LENGTH = 0x2a000
|
||||
SRAM : ORIGIN = COREBSS_END , LENGTH = 0x40000 /*起始地址为CoreCode BSS结束地址 */
|
||||
SRAM2 : ORIGIN = 0x20068000 , LENGTH = 0x3A00 /*末尾预留256byte做为CoreSetting数据*/
|
||||
FLASH : ORIGIN = 0x10000000 , LENGTH = 0x200000
|
||||
PSRAM : ORIGIN = 0x28000000 , LENGTH = 0x800000
|
||||
SRAM0 : ORIGIN = 0x20001100 , LENGTH = 0x2F00 /*SRAM0 16 - 4KB for sleep*/
|
||||
ALUSER-SRAM : ORIGIN = 0x2006BA00 , LENGTH = 0x400 /* 二次loader的固件参数区 ALUSER-SRAM 1KB */
|
||||
FW_INFO : ORIGIN = 0x2006BE00 , LENGTH = 0x100
|
||||
}
|
||||
|
||||
__heap_size = 0x40000;
|
||||
|
||||
PROVIDE (__ram_end = 0x20058000);
|
||||
PROVIDE (__heap_end = 0x20058000);
|
||||
PROVIDE (__sleep_data_start = 0x20000200);
|
||||
PROVIDE (__sleep_data_stop = 0x20001000);
|
||||
PROVIDE (__psram_heap_end = 0x29000000);
|
||||
PROVIDE (_data0_lma_start = 0);
|
||||
PROVIDE (__data0_start__ = 0);
|
||||
PROVIDE (__data0_end__ = 0);
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_RODATA", FLASH);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
REGION_ALIAS("REGION_INIT", SRAM);
|
||||
REGION_ALIAS("REGION_PSRAM_HEAP", PSRAM);
|
||||
REGION_ALIAS("REGION_NOLOAD_PSRAM", PSRAM);
|
||||
REGION_ALIAS("REGION_DATA2", SRAM2);
|
||||
REGION_ALIAS("REGION_OTA_VMA", SRAM);
|
||||
REGION_ALIAS("REGION_TEXT2", SRAM2);
|
||||
REGION_ALIAS("REGION_DSLEEP", SRAM0);
|
||||
REGION_ALIAS("REGION_ALUSER", ALUSER-SRAM);
|
||||
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
SECTIONS
|
||||
{
|
||||
.text : AT(ADDR(.text)) {
|
||||
. = ALIGN(0x4) ;
|
||||
__code_start = .;
|
||||
KEEP(*startup.o(.vectors))
|
||||
. = ALIGN(0x10) ;
|
||||
KEEP(*(SYS_PARAM)) /*如果预留参数区的Size 大于4K时 不能再放在此位置*/
|
||||
. = ALIGN(0x1000);
|
||||
. = . + CORECODE_SIZE; /*预留CodeCode Size大小区间*/
|
||||
. = ALIGN(0x4);
|
||||
__stext = . ;
|
||||
*(.text)
|
||||
*(.text*)
|
||||
*(.text.*)
|
||||
*(INIT.TXT)
|
||||
*(INIT.TXT.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.gnu.linkonce.t*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.jcr)
|
||||
KEEP (*(.init*))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN (4) ;
|
||||
PROVIDE(__ctbp = .);
|
||||
*(.call_table_data)
|
||||
*(.call_table_text)
|
||||
. = ALIGN(4) ;
|
||||
__etext = . ;
|
||||
} > REGION_TEXT
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(0x4) ;
|
||||
__srodata = .;
|
||||
*(.rdata)
|
||||
*(.rdata*)
|
||||
*(.rdata1)
|
||||
*(.rdata.*)
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata*)
|
||||
*(.rodata.*)
|
||||
*(.rodata.str1.4)
|
||||
*(INIT.RO)
|
||||
*(INIT.RO.*)
|
||||
. = ALIGN(0x4) ;
|
||||
|
||||
__modver_start = .;
|
||||
KEEP(*(.modver))
|
||||
__modver_end = .;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
__CTOR_LIST__ = . ;
|
||||
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.ctors)))
|
||||
LONG(0)
|
||||
__CTOR_END__ = . ;
|
||||
__DTOR_LIST__ = . ;
|
||||
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.dtors)))
|
||||
LONG(0)
|
||||
__DTOR_END__ = . ;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
} > REGION_RODATA
|
||||
|
||||
.dsleep : {
|
||||
__data0_start__ = . ;
|
||||
__dsleep_start = .;
|
||||
*(.dsleep.*)
|
||||
. = ALIGN(0x4) ;
|
||||
__dsleep_end = .;
|
||||
__data0_end__ = . ;
|
||||
} > REGION_DSLEEP AT>REGION_RODATA
|
||||
_data0_lma_start = LOADADDR(.dsleep);
|
||||
_data0_lma_end = LOADADDR(.dsleep) + SIZEOF(.dsleep);
|
||||
|
||||
.data : {
|
||||
. = ALIGN(4) ;
|
||||
__sdata = . ;
|
||||
__data_start__ = . ;
|
||||
data_start = . ;
|
||||
|
||||
|
||||
*(INIT.DAT)
|
||||
*(INIT.DAT.*)
|
||||
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.gnu.linkonce.r*)
|
||||
*(.bobj)
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.data1)
|
||||
*(.gcc_except_table)
|
||||
*(.gcc_except_table*)
|
||||
__start_init_call = .;
|
||||
*(.initcall.init)
|
||||
__stop_init_call = .;
|
||||
__start_cmd = .;
|
||||
*(.bootloaddata.cmd)
|
||||
. = ALIGN(4) ;
|
||||
__stop_cmd = .;
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
*(__libc_atexit)
|
||||
*(__libc_subinit)
|
||||
*(__libc_subfreeres)
|
||||
*(.note.ABI-tag)
|
||||
*(.ram.text)
|
||||
. = ALIGN(0x4) ;
|
||||
__edata = .;
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT>REGION_RODATA
|
||||
_data_lma_start = LOADADDR(.data);
|
||||
_data_lma_end = LOADADDR(.data) + SIZEOF(.data);
|
||||
|
||||
.fw_info : {
|
||||
__fw_info_start = .;
|
||||
. += 160;
|
||||
__fw_info_end = .;
|
||||
} > FW_INFO
|
||||
|
||||
.no_init (NOLOAD) : {
|
||||
*(.irq_stack);
|
||||
*(.trap_stack);
|
||||
*(.no_init);
|
||||
} > REGION_BSS
|
||||
|
||||
.ota : {
|
||||
. = ALIGN(0x4) ;
|
||||
_ota_vma_start = . ;
|
||||
KEEP (*(.otacode))
|
||||
_ota_vma_end = . ;
|
||||
} > REGION_OTA_VMA AT > REGION_RODATA
|
||||
_ota_lma_start = LOADADDR(.ota);
|
||||
_ota_lma_end = LOADADDR(.ota) + SIZEOF(.ota);
|
||||
|
||||
|
||||
.iis : AT(LOADADDR(.ota) + SIZEOF(.ota)) {
|
||||
. = ALIGN(0x4) ;
|
||||
iis_start = .;
|
||||
KEEP (*(.iiscode))
|
||||
} > REGION_OTA_VMA
|
||||
_iis_start = LOADADDR(.iis);
|
||||
_iis_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
__code_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
|
||||
._al_user_sram (NOLOAD): {
|
||||
. = ALIGN(0x4) ;
|
||||
__al_user_sram_start = .;
|
||||
*(.al_user_data)
|
||||
__al_user_sram_current = .;
|
||||
} > REGION_ALUSER AT > REGION_BSS
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(0x4) ;
|
||||
__sbss = ALIGN(0x4) ;
|
||||
__bss_start__ = . ;
|
||||
*(.dynsbss)
|
||||
*(.sbss.ota)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4) ;
|
||||
__ebss = . ;
|
||||
__end = . ;
|
||||
end = . ;
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._user_heap : {
|
||||
. = ALIGN(0x4) ;
|
||||
__heap_start = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._psram_data (NOLOAD): {
|
||||
*(.psram.src)
|
||||
*(.psram.data)
|
||||
} > REGION_NOLOAD_PSRAM
|
||||
|
||||
.psram_heap : {
|
||||
. = ALIGN(4) ;
|
||||
__psram_heap_start = .;
|
||||
} > REGION_PSRAM_HEAP
|
||||
|
||||
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > REGION_BSS
|
||||
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } > REGION_BSS
|
||||
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
|
||||
.preinit_array :{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
}
|
||||
|
||||
.init_array :{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
}
|
||||
|
||||
.fini_array :{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
}
|
||||
|
||||
.junk 0 : { *(.rel*) *(.rela*) }
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
}
|
||||
|
||||
|
||||
/* ROM Functions */
|
||||
/* ASSERT(DEFINED(ROM_FUNC_ENABLE), "please disable ROM Functions in ld file") */
|
||||
/* ASSERT(ADDR(.text) < 0x20000068, "ROM Functions data area conflict!!!")*/
|
||||
|
||||
/* INPUT(romcode.ld) */
|
||||
memset = 0x00000568;
|
||||
memcpy = 0x00000608;
|
||||
memcmp = 0x00000688;
|
||||
331
project/utilities/gcc_csky.ld.n
Normal file
331
project/utilities/gcc_csky.ld.n
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* @file gcc_csky.ld
|
||||
* @brief csky linker file
|
||||
* @version V1.0
|
||||
* @date 2025.4.12
|
||||
* SRAM0-0: 0x20000000 ~ 0x20003FFF 16KB
|
||||
* SRAM0-1: 0x20004000 ~ 0x2001FFFF 112KB
|
||||
* SRAM1: 0x20020000 ~ 0x2003FFFF 128KB
|
||||
* SRAM2-0: 0x20040000 ~ 0x20057FFF 96KB
|
||||
* SRAM2-1: 0x20058000 ~ 0x2005FFFF 32KB (DCAHCE)
|
||||
* SRAM2-2: 0x20060000 ~ 0x20067FFF 32KB (CPU1 I/D CACHE)
|
||||
* SRAM2-3: 0x20068000 ~ 0x2006BF00 16KB (末尾256byte为CoreSetting数据)
|
||||
* SRAM3: 0x20080000 ~ 0x2009FFFF 128KB (H264)
|
||||
******************************************************************************/
|
||||
MEMORY
|
||||
{
|
||||
ISRAM : ORIGIN = 0x04001000 , LENGTH = 0x2a000
|
||||
SRAM : ORIGIN = 0x20006b44 , LENGTH = 0x40000 /*起始地址为CoreCode BSS结束地址 */
|
||||
SRAM2 : ORIGIN = 0x20068000 , LENGTH = 0x3A00 /*末尾预留256byte做为CoreSetting数据*/
|
||||
FLASH : ORIGIN = 0x10000000 , LENGTH = 0x200000
|
||||
PSRAM : ORIGIN = 0x28000000 , LENGTH = 0x800000
|
||||
SRAM0 : ORIGIN = 0x20001100 , LENGTH = 0x2F00 /*SRAM0 16 - 4KB for sleep*/
|
||||
ALUSER-SRAM : ORIGIN = 0x2006BA00 , LENGTH = 0x400 /* 二次loader的固件参数区 ALUSER-SRAM 1KB */
|
||||
FW_INFO : ORIGIN = 0x2006BE00 , LENGTH = 0x100
|
||||
}
|
||||
|
||||
__heap_size = 0x40000;
|
||||
|
||||
PROVIDE (__ram_end = 0x20058000);
|
||||
PROVIDE (__heap_end = 0x20058000);
|
||||
PROVIDE (__sleep_data_start = 0x20000200);
|
||||
PROVIDE (__sleep_data_stop = 0x20001000);
|
||||
PROVIDE (__psram_heap_end = 0x29000000);
|
||||
PROVIDE (_data0_lma_start = 0);
|
||||
PROVIDE (__data0_start__ = 0);
|
||||
PROVIDE (__data0_end__ = 0);
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_RODATA", FLASH);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
REGION_ALIAS("REGION_INIT", SRAM);
|
||||
REGION_ALIAS("REGION_PSRAM_HEAP", PSRAM);
|
||||
REGION_ALIAS("REGION_NOLOAD_PSRAM", PSRAM);
|
||||
REGION_ALIAS("REGION_DATA2", SRAM2);
|
||||
REGION_ALIAS("REGION_OTA_VMA", SRAM);
|
||||
REGION_ALIAS("REGION_TEXT2", SRAM2);
|
||||
REGION_ALIAS("REGION_DSLEEP", SRAM0);
|
||||
REGION_ALIAS("REGION_ALUSER", ALUSER-SRAM);
|
||||
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
SECTIONS
|
||||
{
|
||||
.text : AT(ADDR(.text)) {
|
||||
. = ALIGN(0x4) ;
|
||||
__code_start = .;
|
||||
KEEP(*startup.o(.vectors))
|
||||
. = ALIGN(0x10) ;
|
||||
KEEP(*(SYS_PARAM)) /*如果预留参数区的Size 大于4K时 不能再放在此位置*/
|
||||
. = ALIGN(0x1000);
|
||||
. = . + 0x61fb4; /*预留CodeCode Size大小区间*/
|
||||
. = ALIGN(0x4);
|
||||
__stext = . ;
|
||||
*(.text)
|
||||
*(.text*)
|
||||
*(.text.*)
|
||||
*(INIT.TXT)
|
||||
*(INIT.TXT.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.gnu.linkonce.t*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.jcr)
|
||||
KEEP (*(.init*))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN (4) ;
|
||||
PROVIDE(__ctbp = .);
|
||||
*(.call_table_data)
|
||||
*(.call_table_text)
|
||||
. = ALIGN(4) ;
|
||||
__etext = . ;
|
||||
} > REGION_TEXT
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(0x4) ;
|
||||
__srodata = .;
|
||||
*(.rdata)
|
||||
*(.rdata*)
|
||||
*(.rdata1)
|
||||
*(.rdata.*)
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata*)
|
||||
*(.rodata.*)
|
||||
*(.rodata.str1.4)
|
||||
*(INIT.RO)
|
||||
*(INIT.RO.*)
|
||||
. = ALIGN(0x4) ;
|
||||
|
||||
__modver_start = .;
|
||||
KEEP(*(.modver))
|
||||
__modver_end = .;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
__CTOR_LIST__ = . ;
|
||||
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.ctors)))
|
||||
LONG(0)
|
||||
__CTOR_END__ = . ;
|
||||
__DTOR_LIST__ = . ;
|
||||
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
|
||||
KEEP(*(SORT(.dtors)))
|
||||
LONG(0)
|
||||
__DTOR_END__ = . ;
|
||||
|
||||
. = ALIGN(0x4) ;
|
||||
} > REGION_RODATA
|
||||
|
||||
.dsleep : {
|
||||
__data0_start__ = . ;
|
||||
__dsleep_start = .;
|
||||
*(.dsleep.*)
|
||||
. = ALIGN(0x4) ;
|
||||
__dsleep_end = .;
|
||||
__data0_end__ = . ;
|
||||
} > REGION_DSLEEP AT>REGION_RODATA
|
||||
_data0_lma_start = LOADADDR(.dsleep);
|
||||
_data0_lma_end = LOADADDR(.dsleep) + SIZEOF(.dsleep);
|
||||
|
||||
.data : {
|
||||
. = ALIGN(4) ;
|
||||
__sdata = . ;
|
||||
__data_start__ = . ;
|
||||
data_start = . ;
|
||||
|
||||
|
||||
*(INIT.DAT)
|
||||
*(INIT.DAT.*)
|
||||
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.gnu.linkonce.r*)
|
||||
*(.bobj)
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.data1)
|
||||
*(.gcc_except_table)
|
||||
*(.gcc_except_table*)
|
||||
__start_init_call = .;
|
||||
*(.initcall.init)
|
||||
__stop_init_call = .;
|
||||
__start_cmd = .;
|
||||
*(.bootloaddata.cmd)
|
||||
. = ALIGN(4) ;
|
||||
__stop_cmd = .;
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
*(__libc_atexit)
|
||||
*(__libc_subinit)
|
||||
*(__libc_subfreeres)
|
||||
*(.note.ABI-tag)
|
||||
*(.ram.text)
|
||||
. = ALIGN(0x4) ;
|
||||
__edata = .;
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT>REGION_RODATA
|
||||
_data_lma_start = LOADADDR(.data);
|
||||
_data_lma_end = LOADADDR(.data) + SIZEOF(.data);
|
||||
|
||||
.fw_info : {
|
||||
__fw_info_start = .;
|
||||
. += 160;
|
||||
__fw_info_end = .;
|
||||
} > FW_INFO
|
||||
|
||||
.no_init (NOLOAD) : {
|
||||
*(.irq_stack);
|
||||
*(.trap_stack);
|
||||
*(.no_init);
|
||||
} > REGION_BSS
|
||||
|
||||
.ota : {
|
||||
. = ALIGN(0x4) ;
|
||||
_ota_vma_start = . ;
|
||||
KEEP (*(.otacode))
|
||||
_ota_vma_end = . ;
|
||||
} > REGION_OTA_VMA AT > REGION_RODATA
|
||||
_ota_lma_start = LOADADDR(.ota);
|
||||
_ota_lma_end = LOADADDR(.ota) + SIZEOF(.ota);
|
||||
|
||||
|
||||
.iis : AT(LOADADDR(.ota) + SIZEOF(.ota)) {
|
||||
. = ALIGN(0x4) ;
|
||||
iis_start = .;
|
||||
KEEP (*(.iiscode))
|
||||
} > REGION_OTA_VMA
|
||||
_iis_start = LOADADDR(.iis);
|
||||
_iis_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
__code_end = LOADADDR(.iis) + SIZEOF(.iis);
|
||||
|
||||
._al_user_sram (NOLOAD): {
|
||||
. = ALIGN(0x4) ;
|
||||
__al_user_sram_start = .;
|
||||
*(.al_user_data)
|
||||
__al_user_sram_current = .;
|
||||
} > REGION_ALUSER AT > REGION_BSS
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(0x4) ;
|
||||
__sbss = ALIGN(0x4) ;
|
||||
__bss_start__ = . ;
|
||||
*(.dynsbss)
|
||||
*(.sbss.ota)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4) ;
|
||||
__ebss = . ;
|
||||
__end = . ;
|
||||
end = . ;
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._user_heap : {
|
||||
. = ALIGN(0x4) ;
|
||||
__heap_start = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._psram_data (NOLOAD): {
|
||||
*(.psram.src)
|
||||
*(.psram.data)
|
||||
} > REGION_NOLOAD_PSRAM
|
||||
|
||||
.psram_heap : {
|
||||
. = ALIGN(4) ;
|
||||
__psram_heap_start = .;
|
||||
} > REGION_PSRAM_HEAP
|
||||
|
||||
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > REGION_BSS
|
||||
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } > REGION_BSS
|
||||
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
|
||||
.preinit_array :{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
}
|
||||
|
||||
.init_array :{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
}
|
||||
|
||||
.fini_array :{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
}
|
||||
|
||||
.junk 0 : { *(.rel*) *(.rela*) }
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
}
|
||||
|
||||
|
||||
/* ROM Functions */
|
||||
/* ASSERT(DEFINED(ROM_FUNC_ENABLE), "please disable ROM Functions in ld file") */
|
||||
/* ASSERT(ADDR(.text) < 0x20000068, "ROM Functions data area conflict!!!")*/
|
||||
|
||||
/* INPUT(romcode.ld) */
|
||||
memset = 0x00000568;
|
||||
memcpy = 0x00000608;
|
||||
memcmp = 0x00000688;
|
||||
193
project/utilities/gcc_csky_qspiboot.ld
Normal file
193
project/utilities/gcc_csky_qspiboot.ld
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* @file gcc_csky.ld
|
||||
* @brief csky linker file
|
||||
* @version V1.0
|
||||
* @date 02. June 2017
|
||||
******************************************************************************/
|
||||
MEMORY
|
||||
{
|
||||
I-SRAM : ORIGIN = 0x0 , LENGTH = 0x80000 /* I-SRAM 128KB */
|
||||
D-SRAM : ORIGIN = 0x20000000 , LENGTH = 0x80000 /* D-SRAM 512KB */
|
||||
O-SRAM : ORIGIN = 0x50000000 , LENGTH = 0x800000 /* off-chip SRAM 8MB */
|
||||
FLASH : ORIGIN = 0x18000000 , LENGTH = 0x200000 /* MCP FLASH 2MB */
|
||||
SRAM : ORIGIN = 0x20002000 , LENGTH = 0x46000 /* on-chip SRAM 288KB */
|
||||
LMAC_BUF : ORIGIN = 0x20051000 , LENGTH = 18*1024 /* on-chip SRAM 18KB */
|
||||
}
|
||||
|
||||
__heap_size = 0x11000;
|
||||
|
||||
PROVIDE (__ram_end = 0x20048000);
|
||||
PROVIDE (__heap_end = 0x20048000);
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", FLASH);
|
||||
REGION_ALIAS("REGION_RODATA", FLASH);
|
||||
REGION_ALIAS("REGION_DATA", SRAM);
|
||||
REGION_ALIAS("REGION_BSS", SRAM);
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
SECTIONS
|
||||
{
|
||||
.text : AT(ADDR(.text)) {
|
||||
. = ALIGN(0x4) ;
|
||||
KEEP(*startup.o(.vectors))
|
||||
KEEP(*(SYS_PARAM))
|
||||
*(.dsleep_data)
|
||||
__stext = . ;
|
||||
*(.text)
|
||||
*(.text*)
|
||||
*(.text.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.gnu.linkonce.t*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.jcr)
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN (4) ;
|
||||
PROVIDE(__ctbp = .);
|
||||
*(.call_table_data)
|
||||
*(.call_table_text)
|
||||
. = ALIGN(0x10) ;
|
||||
__etext = . ;
|
||||
} > REGION_TEXT
|
||||
.rodata : {
|
||||
. = ALIGN(0x4) ;
|
||||
__srodata = .;
|
||||
*(.rdata)
|
||||
*(.rdata*)
|
||||
*(.rdata1)
|
||||
*(.rdata.*)
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata*)
|
||||
*(.rodata.*)
|
||||
*(.rodata.str1.4)
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
. = ALIGN(0x4) ;
|
||||
__erodata = .;
|
||||
} > REGION_RODATA
|
||||
|
||||
.data : AT(LOADADDR(.rodata) + SIZEOF(.rodata)){
|
||||
. = ALIGN(0x4) ;
|
||||
__sdata = . ;
|
||||
__data_start__ = . ;
|
||||
data_start = . ;
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
*(.gnu.linkonce.r*)
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.data1)
|
||||
*(.gcc_except_table)
|
||||
*(.gcc_except_table*)
|
||||
__start_init_call = .;
|
||||
*(.initcall.init)
|
||||
__stop_init_call = .;
|
||||
__start_cmd = .;
|
||||
*(.bootloaddata.cmd)
|
||||
. = ALIGN(4) ;
|
||||
__stop_cmd = .;
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
*(__libc_atexit)
|
||||
*(__libc_subinit)
|
||||
*(__libc_subfreeres)
|
||||
*(.note.ABI-tag)
|
||||
. = ALIGN(0x4) ;
|
||||
__edata = .;
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA
|
||||
|
||||
__dsleep_ro_start__ = LOADADDR(.rodata) + SIZEOF(.rodata) + SIZEOF(.data);
|
||||
.dsleep : AT(__dsleep_ro_start__) {
|
||||
__dsleep_code_start__ = .;
|
||||
KEEP(*(.dsleep_vector))
|
||||
*(.dsleep_txt)
|
||||
*(.lmac_dsleep_txt)
|
||||
*(.wphy_dsleep_txt)
|
||||
*(.rf_digicali_dsleep_txt)
|
||||
__dsleep_code_end__ = .;
|
||||
} > LMAC_BUF
|
||||
|
||||
.dsleep_buf (NOLOAD) : {
|
||||
*(.dsleep_stack)
|
||||
*(.lmac_dsleep_data)
|
||||
*(.wphy_dsleep_data)
|
||||
*(.rf_digicali_dsleep_data)
|
||||
} > LMAC_BUF
|
||||
|
||||
/* 当.dsleep的代码是放到sram,则在bss之前需要预留.dsleep加载代码的空间 */
|
||||
.fill_dsleep_code (NOLOAD) : {
|
||||
. = . + (((__dsleep_ro_start__ & 0x20000000) == 0x20000000) ? SIZEOF(.dsleep) : 0);
|
||||
} > REGION_DATA
|
||||
|
||||
.no_init (NOLOAD) : {
|
||||
*(.stack);
|
||||
*(.no_init);
|
||||
} > REGION_BSS
|
||||
.bss : {
|
||||
. = ALIGN(0x4) ;
|
||||
__sbss = ALIGN(0x4) ;
|
||||
__bss_start__ = . ;
|
||||
*(.dynsbss)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4) ;
|
||||
__ebss = . ;
|
||||
__end = . ;
|
||||
end = . ;
|
||||
__bss_end__ = .;
|
||||
} > REGION_BSS
|
||||
._user_heap : {
|
||||
. = ALIGN(0x4) ;
|
||||
__heap_start = .;
|
||||
} > REGION_BSS
|
||||
|
||||
._pdata_w 0x28800000 (NOLOAD): {
|
||||
*(.psram.src)
|
||||
}
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
}
|
||||
|
||||
|
||||
/* ROM Functions */
|
||||
/* ASSERT(DEFINED(ROM_FUNC_ENABLE), "please disable ROM Functions in ld file") */
|
||||
/* ASSERT(ADDR(.text) < 0x20000068, "ROM Functions data area conflict!!!")*/
|
||||
|
||||
/* INPUT(romcode.ld) */
|
||||
|
||||
46
project/utilities/gdb.init
Normal file
46
project/utilities/gdb.init
Normal file
@@ -0,0 +1,46 @@
|
||||
# ROM Writable : SYSCTRL->SYS_CON3[4]
|
||||
# set *(unsigned int *)0x40020010=0x08000010
|
||||
|
||||
# watchdog close : WDT->WDTKEY
|
||||
set *(unsigned int *)0x400C1004=0xdddd
|
||||
set *(unsigned int *)0x400C1014=0xdddd
|
||||
#//LP WDT
|
||||
set *(unsigned int*)0x400180b8=0xe8
|
||||
set *(unsigned int*)0x400180b4=0xdddd
|
||||
set *(unsigned int*)0x400180bc=0xC053781B
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020000=0x3fac87e4
|
||||
# stop cpu1
|
||||
#set *(unsigned int *)0x4002019c=0x0
|
||||
# sysclk = osc : SYSCTRL->CLK_CON0
|
||||
#set *(unsigned int *)0x40020044=0x00000001
|
||||
# ROM writeable : SYSCTRL->SYS_CON3 BIT(4)
|
||||
#set *(unsigned int *)0x40020010=0x00802138
|
||||
# ROM Writable : SYSCTRL->SYS_CON6
|
||||
#set *(unsigned int *)0x4002001c=0x01C0CCA4
|
||||
# CQSPI IO MAP : GPIOB->AFRL, default 0
|
||||
# CQSPI IO MAP : GPIOB->MODE
|
||||
#set *(unsigned int *)0x40020B00=0x02AA0000
|
||||
# QSPI clk : QSPI->CONFIG
|
||||
#set *(unsigned int *)0x40000000=0x00200081
|
||||
# SPIFLASH write enable : QSPI->FLASH_CMD_CTRL
|
||||
#set *(unsigned int *)0x40000090=0x06000001
|
||||
# QUAL MODE enable : QSPI->FLASH_CMD_WDATA_L && QSPI->FLASH_CMD_CTRL
|
||||
#set *(unsigned int *)0x400000A8=0x2
|
||||
#set *(unsigned int *)0x40000090=0x31008001
|
||||
|
||||
# QSPI DUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0801003B
|
||||
# QSPI QUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0802006B
|
||||
|
||||
# chip erase : QSPI->FLASH_CMD_CTRL
|
||||
#set *(unsigned int *)0x40000090=0xC7000001
|
||||
# delay 4000ms
|
||||
#shell sleep 7s
|
||||
#shell ping -c 3 -w 5 android.xx.xxx.com
|
||||
#shell ping -c 10 -i 5 www.google.com
|
||||
|
||||
#restore ../txw4302803/Obj/txw4302_core.ihex
|
||||
#restore ./Obj/txw4302_app.ihex
|
||||
|
||||
86
project/utilities/gdb_flash_24Mhz.init
Normal file
86
project/utilities/gdb_flash_24Mhz.init
Normal file
@@ -0,0 +1,86 @@
|
||||
#set breakpoint always-inserted on
|
||||
# watchdog close : WDT->WDTKEY
|
||||
set *(unsigned int *)0x400c1004=0xdddd
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020000=0x3fac87e4
|
||||
# sysclk = osc : SYSCTRL->CLK_CON0
|
||||
set *(unsigned int *)0x40020044=0x00000009
|
||||
set *(unsigned int *)0x40020048=0x00000000
|
||||
# ROM Writable : SYSCTRL->SYS_CON3[4]
|
||||
set *(unsigned int *)0x40020010=0x08000010
|
||||
#set *(unsigned int *)0x00000000=0x180000E8
|
||||
|
||||
# MONITOR disable : SYSMNT CTRL
|
||||
set *(unsigned int *)0x40021300=0x0
|
||||
set *(unsigned int *)0x40021308=0x1
|
||||
|
||||
# CQSPI IO MAP: GPIOB->PUPL/H
|
||||
set *(unsigned int *)0x40020B10=0x00111111
|
||||
set *(unsigned int *)0x40020B14=0x00000000
|
||||
# CQSPI IO MAP : GPIOB->MODE
|
||||
set *(unsigned int *)0x40020B00=0x00000000
|
||||
# CQSPI IO MAP : SYSCTRL->QSPI_MAP_CON
|
||||
set *(unsigned int *)0x40020184=0x00053A21
|
||||
|
||||
# VCC_FLASH POWER ON
|
||||
# pmu_reg_write((uint32)&PMU->PMUCON11, PMU->PMUCON11 & (~ BIT(17)));\
|
||||
# pmu_reg_write((uint32)&PMU->PMUCON0, PMU->PMUCON0 | BIT(23)); \
|
||||
set *(unsigned int *)0x400180B8=0x00000044
|
||||
set *(unsigned int *)0x400180B4=0x32c046a4
|
||||
set *(unsigned int *)0x400180BC=0xc053781b
|
||||
set *(unsigned int *)0x400180B8=0x00000010
|
||||
set *(unsigned int *)0x400180B4=0x20880400
|
||||
set *(unsigned int *)0x400180BC=0xc053781b
|
||||
# QSPI clk(96Mhz source) : QSPI->CONFIG
|
||||
#set *(unsigned int *)0x40000000=0x00F90081
|
||||
set *(unsigned int *)0x40000000=0x80883881
|
||||
# QSPI clk(96Mhz source) : QSPI->CONFIG
|
||||
#READ_DATA_CAPTURE
|
||||
set *(unsigned int *)0x40000010=0x00000003
|
||||
# QSPI DELAY: QSPI->DEV_DELAY
|
||||
set *(unsigned int *)0x4000000C=0x02020202
|
||||
# QSPI write protect low addr : QSPI->WRITE_PROT_L
|
||||
set *(unsigned int *)0x40000050=0x00000000
|
||||
# QSPI write protect high addr : QSPI->WRITE_PROT_H
|
||||
set *(unsigned int *)0x40000054=0x00020000
|
||||
# QSPI write protect enable : QSPI->WRITE_PROT_CTRL
|
||||
set *(unsigned int *)0x40000058=0x0
|
||||
|
||||
# FLASH reset
|
||||
set *(unsigned int *)0x40000090=0x66000001
|
||||
set *(unsigned int *)0x40000090=0x99000001
|
||||
|
||||
# SPIFLASH write enable : QSPI->FLASH_CMD_CTRL
|
||||
set *(unsigned int *)0x40000090=0x06000001
|
||||
# QUAL MODE enable : QSPI->FLASH_CMD_WDATA_L && QSPI->FLASH_CMD_CTRL
|
||||
set *(unsigned int *)0x400000A8=0x0200
|
||||
set *(unsigned int *)0x40000090=0x01009001
|
||||
|
||||
# QSPI DUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0801003B
|
||||
# QSPI QUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0802006B
|
||||
set *(unsigned int *)0x40000004=0x0802006B
|
||||
|
||||
#READ_DATA_CAPTURE_EXT
|
||||
|
||||
# QSPI poll disable
|
||||
#set *(unsigned int *)0x40000038=0x00014005
|
||||
# QSPI WEL disable
|
||||
#set *(unsigned int *)0x40000008=0x00000102
|
||||
|
||||
# scramble enable
|
||||
#set *(unsigned int *)0x40020188=0x80000000
|
||||
|
||||
# chip erase : QSPI->FLASH_CMD_CTRL
|
||||
#set *(unsigned int *)0x40000090=0xC7000001
|
||||
# delay 4000ms
|
||||
#shell sleep 7s
|
||||
#shell ping -c 3 -w 5 android.xx.xxx.com
|
||||
shell ping -c 10 -i 5 www.google.com
|
||||
|
||||
#softreset
|
||||
#set $chr=0xabcd0009
|
||||
set $pc=0x10040190
|
||||
|
||||
|
||||
234
project/utilities/gdb_psram_both.init
Normal file
234
project/utilities/gdb_psram_both.init
Normal file
@@ -0,0 +1,234 @@
|
||||
#set breakpoint always-inserted on
|
||||
# watchdog close : WDT->WDTKEY
|
||||
set *(unsigned int *)0x400C1004=0xdddd
|
||||
set *(unsigned int *)0x400C1014=0xdddd
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020000=0x3fac87e4
|
||||
#set *(unsigned int *)0x40020000=~0x0fac87e4
|
||||
|
||||
#/* msrom */
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020000=0x3fac87e4
|
||||
# ROM Writable : SYSCTRL->SYS_CON3[4]
|
||||
set *(unsigned int *)0x40020010=0x00000010
|
||||
|
||||
|
||||
set *(unsigned int *)0x4002019c=0x0
|
||||
# sysclk = osc : SYSCTRL->CLK_CON0
|
||||
set *(unsigned int *)0x40020044=0x0000000b
|
||||
set *(unsigned int *)0x40020048=0x00000000
|
||||
# ROM Writable : SYSCTRL->SYS_CON3[4]
|
||||
set *(unsigned int *)0x40020010=0x08000010
|
||||
#set *(unsigned int *)0x00000000=0x180000E8
|
||||
|
||||
|
||||
#rst pin cfg
|
||||
set *(unsigned int *)0x400e0000 = 0x40000000
|
||||
set *(unsigned int *)0x400e0024 = 0x00008000
|
||||
|
||||
#reset
|
||||
#SYSCTRL->CLK_CON4 &= ~BIT(20);
|
||||
#delay_ms(10);
|
||||
#SYSCTRL->CLK_CON4 |= BIT(20);
|
||||
#delay_ms(10);
|
||||
set *(unsigned int *)0x40020040= (*(unsigned int *)0x40020040 & 0xfffeffff)
|
||||
set *(unsigned int *)0x40020040= (*(unsigned int *)0x40020040 | 0x00010000)
|
||||
|
||||
#0xe3ff4a57 60MHZ 0xe2ff4a57 80MHZ
|
||||
set *(unsigned int *)0x40020054=0xe2ff4a57
|
||||
|
||||
#odd_even clk (8/16wire)
|
||||
#SYSCTRL->SYS_CON15 |= (BIT(14) | BIT(15));
|
||||
set *(unsigned int *)0x40020040= (*(unsigned int *)0x40020040 | 0x0000c000)
|
||||
|
||||
|
||||
#SET IO
|
||||
#restore ./utilities/ospi_io_cfg binary 0x400201A8
|
||||
#set *(unsigned int *)0x400201cc = 0
|
||||
set *(unsigned int *)0x400201a8 = 0x01871404
|
||||
set *(unsigned int *)0x400201ac = 0x16a4a0e6
|
||||
set *(unsigned int *)0x400201c4 = 0x2728c1ac
|
||||
set *(unsigned int *)0x400201c8 = 0x000bdab4
|
||||
set *(unsigned int *)0x400201cc = 0x00000000
|
||||
set *(unsigned int *)0x400201d0 = 0xffffffff
|
||||
set *(unsigned int *)0x400201d4 = 0xffffffff
|
||||
|
||||
#OSPI CFG
|
||||
restore ./utilities/ospi_cfg binary 0x40001000
|
||||
|
||||
set *(unsigned int *)0x400201d0 = 0xffffffff
|
||||
set *(unsigned int *)0x400201d4 = 0xffffffff
|
||||
|
||||
|
||||
#p_qspi->PHY_CONFIG = (p_qspi->PHY_CONFIG & ~(0x7FUL << 16)) | ((delay & 0x7FUL) << 16) | BIT(30);
|
||||
# rx0, tx
|
||||
set *(unsigned int*)0x400010b4 = (*(unsigned int*)0x400010b4 & (~0xffffff)) | (2) | (12 << 16)
|
||||
# rx1
|
||||
set *(unsigned int*)0x400010c4 = (*(unsigned int*)0x400010c4 & (~0xff)) | (2)
|
||||
#p_qspi->PHY_CONFIG = (p_qspi->PHY_CONFIG & ~(0x7FUL << 0)) | ((delay & 0x7FUL) << 0) | BIT(30);
|
||||
#p_qspi->NEW_ADD_CONFIG3 = (p_qspi->NEW_ADD_CONFIG3 & ~(0x7FUL << 0)) | ((delay & 0x7FUL) << 0);
|
||||
set *(unsigned int *)0x400010b4 = (*(unsigned int *)0x400010b4 & 0x7fffffff)
|
||||
set *(unsigned int *)0x400010b4 = (*(unsigned int *)0x400010b4 | 0x80000000)
|
||||
shell ping -c 10 -i 5 www.google.com
|
||||
#rwreg start
|
||||
#p_qspi->NEW_ADD_CONFIG2 = (p_qspi->NEW_ADD_CONFIG2 & ~(0x1UL << 22)) | ((0x1UL) << 22);
|
||||
set *(unsigned int *)0x400010d4 = 0x00d03f3f
|
||||
shell ping -c 10 -i 5 www.google.com
|
||||
|
||||
|
||||
#OSPI->DEV_WRINSTR_CONFIG = WR_OPC(wr_opc) | WEL_DISEN(0x1) | ADDR_TM(0x3) | DATA_TM(0x3) | WR_DUMMY(wr_dummy);
|
||||
set *(unsigned int *)0x40001008 = 0x00033160
|
||||
set *(unsigned int *)0x40001004 = 0x03033fe0
|
||||
set *(unsigned int *)0x4000100C = 0x02020202
|
||||
|
||||
#reset
|
||||
|
||||
|
||||
#dummy & various lc
|
||||
set *(unsigned short *)0x28001000 = 0x8f07
|
||||
|
||||
#OSPI->DEV_WRINSTR_CONFIG = WR_OPC(wr_opc) | WEL_DISEN(0x1) | ADDR_TM(0x3) | DATA_TM(0x3) | WR_DUMMY(wr_dummy);
|
||||
#OSPI->DEV_RDINSTR_CONFIG = WR_OPC(wr_opc) | WEL_DISEN(0x1) | ADDR_TM(0x3) | DATA_TM(0x3) | WR_DUMMY(wr_dummy);
|
||||
set *(unsigned int *)0x40001004 = 0x05033fa0
|
||||
set *(unsigned int *)0x40001008 = 0x05033120
|
||||
|
||||
#rwreg end
|
||||
#p_qspi->NEW_ADD_CONFIG2 = (p_qspi->NEW_ADD_CONFIG2 & ~(0x1UL << 22)) | ((0x0UL) << 22) ;
|
||||
set *(unsigned int *)0x400010d4 = 0x00903f3f
|
||||
|
||||
#reset
|
||||
#set *(unsigned int *)0x40020040= (*(unsigned int *)0x40020040 | 0x0000c000)
|
||||
#0xe3ff4a57 60MHZ 0xe2ff4a57 80MHZ
|
||||
set *(unsigned int *)0x40020054=0xe4ff4a57
|
||||
|
||||
|
||||
# load cpu1 psram code
|
||||
#restore ./../txw4302803/Obj/txw4302_core.ihex
|
||||
#restore ./../txw4302803/txw4302803.bin binary 0x28000000
|
||||
#restore ./../txw4302803/Obj/txw4302_core.elf
|
||||
#tb sys_main_loop
|
||||
#restore ./../txw4302803/Obj/txw4302_core.elf
|
||||
#tb sys_main_loop
|
||||
|
||||
|
||||
|
||||
|
||||
#set breakpoint always-inserted on
|
||||
# watchdog close : WDT->WDTKEY
|
||||
set *(unsigned int *)0x400c1004=0xdddd
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020000=0x3fac87e4
|
||||
# sysclk = osc : SYSCTRL->CLK_CON0
|
||||
set *(unsigned int *)0x40020044=0x00000009
|
||||
set *(unsigned int *)0x40020048=0x00000000
|
||||
# ROM Writable : SYSCTRL->SYS_CON3[4]
|
||||
set *(unsigned int *)0x40020010=0x08000010
|
||||
#set *(unsigned int *)0x00000000=0x180000E8
|
||||
|
||||
|
||||
|
||||
|
||||
# MONITOR disable : SYSMNT CTRL
|
||||
set *(unsigned int *)0x40021300=0x0
|
||||
set *(unsigned int *)0x40021308=0x1
|
||||
|
||||
|
||||
|
||||
|
||||
# CQSPI IO MAP: GPIOB->PUPL/H
|
||||
set *(unsigned int *)0x40020B10=0x00111111
|
||||
set *(unsigned int *)0x40020B14=0x00000000
|
||||
# CQSPI IO MAP : GPIOB->MODE
|
||||
set *(unsigned int *)0x40020B00=0x00000000
|
||||
# CQSPI IO MAP : SYSCTRL->QSPI_MAP_CON
|
||||
set *(unsigned int *)0x40020184=0x00053A21
|
||||
|
||||
|
||||
|
||||
|
||||
# VCC_FLASH POWER ON
|
||||
# pmu_reg_write((uint32)&PMU->PMUCON11, PMU->PMUCON11 & (~ BIT(17)));\
|
||||
# pmu_reg_write((uint32)&PMU->PMUCON0, PMU->PMUCON0 | BIT(23)); \
|
||||
set *(unsigned int *)0x400180B8=0x00000044
|
||||
set *(unsigned int *)0x400180B4=0x32c046a4
|
||||
set *(unsigned int *)0x400180BC=0xc053781b
|
||||
set *(unsigned int *)0x400180B8=0x00000010
|
||||
set *(unsigned int *)0x400180B4=0x20880400
|
||||
set *(unsigned int *)0x400180BC=0xc053781b
|
||||
# QSPI clk(96Mhz source) : QSPI->CONFIG
|
||||
#set *(unsigned int *)0x40000000=0x00F90081
|
||||
set *(unsigned int *)0x40000000=0x80883881
|
||||
# QSPI clk(96Mhz source) : QSPI->CONFIG
|
||||
#READ_DATA_CAPTURE
|
||||
set *(unsigned int *)0x40000010=0x00000003
|
||||
# QSPI DELAY: QSPI->DEV_DELAY
|
||||
set *(unsigned int *)0x4000000C=0x02020202
|
||||
# QSPI write protect low addr : QSPI->WRITE_PROT_L
|
||||
set *(unsigned int *)0x40000050=0x00000000
|
||||
# QSPI write protect high addr : QSPI->WRITE_PROT_H
|
||||
set *(unsigned int *)0x40000054=0x00020000
|
||||
# QSPI write protect enable : QSPI->WRITE_PROT_CTRL
|
||||
set *(unsigned int *)0x40000058=0x0
|
||||
|
||||
|
||||
|
||||
|
||||
# FLASH reset
|
||||
set *(unsigned int *)0x40000090=0x66000001
|
||||
set *(unsigned int *)0x40000090=0x99000001
|
||||
|
||||
|
||||
|
||||
|
||||
# SPIFLASH write enable : QSPI->FLASH_CMD_CTRL
|
||||
set *(unsigned int *)0x40000090=0x06000001
|
||||
# QUAL MODE enable : QSPI->FLASH_CMD_WDATA_L && QSPI->FLASH_CMD_CTRL
|
||||
set *(unsigned int *)0x400000A8=0x0200
|
||||
set *(unsigned int *)0x40000090=0x01009001
|
||||
|
||||
|
||||
|
||||
|
||||
# QSPI DUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0801003B
|
||||
# QSPI QUAL MODE : QSPI->DEV_RDINSTR_CONFIG
|
||||
#set *(unsigned int *)0x40000004=0x0802006B
|
||||
set *(unsigned int *)0x40000004=0x0802006B
|
||||
|
||||
|
||||
|
||||
|
||||
#READ_DATA_CAPTURE_EXT
|
||||
|
||||
|
||||
|
||||
|
||||
# QSPI poll disable
|
||||
#set *(unsigned int *)0x40000038=0x00014005
|
||||
# QSPI WEL disable
|
||||
#set *(unsigned int *)0x40000008=0x00000102
|
||||
|
||||
|
||||
|
||||
|
||||
# scramble enable
|
||||
#set *(unsigned int *)0x40020188=0x80000000
|
||||
|
||||
|
||||
|
||||
|
||||
# chip erase : QSPI->FLASH_CMD_CTRL
|
||||
#set *(unsigned int *)0x40000090=0xC7000001
|
||||
|
||||
|
||||
|
||||
|
||||
#softreset
|
||||
#set $chr=0xabcd0009
|
||||
set $pc=*(unsigned int *)0x10040000
|
||||
|
||||
|
||||
|
||||
|
||||
# sysctrl writable : SYSCTRL->SYS_KEY
|
||||
set *(unsigned int *)0x40020028=0x00300000
|
||||
BIN
project/utilities/ospi_80_80cfg
Normal file
BIN
project/utilities/ospi_80_80cfg
Normal file
Binary file not shown.
BIN
project/utilities/ospi_cfg
Normal file
BIN
project/utilities/ospi_cfg
Normal file
Binary file not shown.
BIN
project/utilities/ospi_io_cfg
Normal file
BIN
project/utilities/ospi_io_cfg
Normal file
Binary file not shown.
458
project/utilities/romcode.ld
Normal file
458
project/utilities/romcode.ld
Normal file
@@ -0,0 +1,458 @@
|
||||
ll_spi_init = 0x00007d6c;
|
||||
hgusb20_intr_dis = 0x00006bd4;
|
||||
ll_spi_rx = 0x00007f2c;
|
||||
strcpy = 0x00001820;
|
||||
ll_uart_txdma_kick = 0x00006a74;
|
||||
sdio_s_set_ds = 0x00003a14;
|
||||
hgusb20_clear_ep = 0x00006e70;
|
||||
sys_aes_init = 0x00007d10;
|
||||
fabs = 0x000001a8;
|
||||
disable_wphy_device_cont_tx = 0x0000618c;
|
||||
config_wphy_device_dpd_coef = 0x00006300;
|
||||
sys_aes_key_bitlen_sel = 0x00007cec;
|
||||
ll_simple_spi_init = 0x0000a674;
|
||||
hgusb20_irq_dma = 0x00007734;
|
||||
fw_upg_addr = 0x2005247c;
|
||||
crc16_modbus_calc = 0x00003018;
|
||||
close_wphy = 0x0000adb0;
|
||||
ll_iic_slave_rx = 0x0000828c;
|
||||
hgusb20_wifi_reset = 0x00007a8c;
|
||||
ll_crc_start = 0x00006afc;
|
||||
ll_m2m_memcpy = 0x000082fc;
|
||||
os_critical_close = 0x00001b2c;
|
||||
hgusb20_irq_set = 0x00007678;
|
||||
printf = 0x00001080;
|
||||
stdout = 0x20052420;
|
||||
ll_sdio_s_tx_kick = 0x000092f0;
|
||||
hgusb20_ep0_clrrx_pkt0 = 0x00006d30;
|
||||
uart_s_set_speed = 0x000042b4;
|
||||
get_wphy_device_avg_evm = 0x00006164;
|
||||
tbl_usb_language_id = 0x0000e06c;
|
||||
sdio_s_tx = 0x00003ab4;
|
||||
config_phy_tx_norm_mode = 0x0000ae6c;
|
||||
get_wphy_device_gfsk_tx_crc = 0x000063c4;
|
||||
ll_wdt_feed = 0x000064d4;
|
||||
ll_timer_ir_enable = 0x00007c64;
|
||||
ll_spi_buf_rx = 0x00007fd4;
|
||||
spiflash_boot = 0x00005eb8;
|
||||
md5_vector = 0x0000bc3c;
|
||||
ll_clock_syspll_config = 0x0000961c;
|
||||
ll_clock_hirc_enable = 0x00009370;
|
||||
fw_upg_blk_addr = 0x20052480;
|
||||
ll_uart_init = 0x00006860;
|
||||
tbl_usb_str_manufacturer = 0x0000e070;
|
||||
spi_cfg = 0x0000debc;
|
||||
strerror = 0x00002d48;
|
||||
config_phy_tx_sine_mode = 0x0000ae2c;
|
||||
ll_spi_config = 0x00007d88;
|
||||
hgwphy_bgn_attach = 0x0000b18c;
|
||||
qspi_flash_port_deinit = 0x00004df8;
|
||||
usb20 = 0x2004768c;
|
||||
ll_sys_clock_globle_set = 0x0000abfc;
|
||||
ll_m2m_memset = 0x00008320;
|
||||
hgusb20_ep0_clr_feature = 0x00006fdc;
|
||||
sdio_boot = 0x20052468;
|
||||
ll_tk_stop = 0x0000a664;
|
||||
hgusb20_dev_reset = 0x00006f1c;
|
||||
ll_gpio_iomap_output_config = 0x0000650c;
|
||||
get_wphy_device_rx_gain_para = 0x00006374;
|
||||
ll_sdio_s_irq_config = 0x0000925c;
|
||||
atol = 0x000014f4;
|
||||
ll_iic_master_tx = 0x00008190;
|
||||
ll_simple_uart_init = 0x0000a6f0;
|
||||
hgusb20_stall_ep = 0x00006df0;
|
||||
tbl_winusb_device_descriptor = 0x0000e1ac;
|
||||
ll_clock_set_sys_clk_src = 0x000093c4;
|
||||
ll_sys_clock_init = 0x0000abb8;
|
||||
hgusb20_ep0_get_status = 0x00006f64;
|
||||
config_dpd = 0x0000afb0;
|
||||
SHA1Update = 0x0000cbd8;
|
||||
ll_gmac_get_tx_frame_status = 0x00008cac;
|
||||
ll_qspi_controller_init = 0x00009224;
|
||||
sha256_init = 0x0000cee0;
|
||||
errno = 0x200524d0;
|
||||
open_wphy = 0x0000ace8;
|
||||
hgusb20_dev_init = 0x00006d88;
|
||||
ll_qspi_set_prefetch = 0x00009170;
|
||||
ll_gpio_pull_config = 0x00006680;
|
||||
tbl_winusb_compatible_id_feature_descriptor = 0x0000e184;
|
||||
get_wphy_avg_evm = 0x0000aea4;
|
||||
ll_spi_dma_start = 0x00007e7c;
|
||||
uart_s_rx = 0x0000431c;
|
||||
CORE_SEC_OPT = 0x0000932c;
|
||||
trig_calc_bk_noise = 0x0000b0d4;
|
||||
sha256_done = 0x0000cff0;
|
||||
spi_boot = 0x20052674;
|
||||
freq_offset_sign_ext = 0x0000b178;
|
||||
sys_aes_start = 0x00007d2c;
|
||||
SHA1Init = 0x0000cba8;
|
||||
ll_tk_ch_kick = 0x0000a658;
|
||||
ll_iic_master_rx = 0x000081c8;
|
||||
spi_s_tx = 0x00003e8c;
|
||||
enable_auto_sig_err_rst = 0x0000af9c;
|
||||
qspi_flash_poweroff = 0x00004ec8;
|
||||
fwinfo_check_fwinfo_hdr = 0x000044f8;
|
||||
hgusb20_irq_handler_set = 0x00007658;
|
||||
ll_iic_master_buf_tx = 0x00008218;
|
||||
ll_spi_dma_config = 0x00007e54;
|
||||
config_wphy_device_en_gfsk_wphy = 0x000063b0;
|
||||
memcpy = 0x00001908;
|
||||
hgusb20_ep0_set_feature = 0x00007020;
|
||||
sys_aes_get_pending = 0x00007cfc;
|
||||
atcmd_fwupg = 0x0000d8e0;
|
||||
ll_m2m_dma_init = 0x000082a4;
|
||||
fw_upg_prepare = 0x00004534;
|
||||
tbl_winusb20_wcidbos = 0x0000e160;
|
||||
spiflash_read = 0x00005ab0;
|
||||
ll_qspi_set_write_protect = 0x00009130;
|
||||
puts = 0x000010b8;
|
||||
hgusb20_ep0_set_configuration = 0x00007294;
|
||||
ll_tk_config = 0x0000a584;
|
||||
sys_aes_set_irq = 0x00007cb0;
|
||||
hgusb20_ep0_get_wcid_descriptor = 0x00007360;
|
||||
ll_gmac_start = 0x00008684;
|
||||
crc16_modbus_cfg = 0x0000d870;
|
||||
ll_iis_disable = 0x0000848c;
|
||||
hgusb20_ep0_func = 0x000074ec;
|
||||
ll_clock_test_clk_en = 0x00009350;
|
||||
ll_iic_irq_config = 0x000080c0;
|
||||
get_wphy_device_rx_gfsk_gain_para = 0x00006388;
|
||||
hgusb20_reset2device_mode = 0x00006b38;
|
||||
ll_gpio_analog_config = 0x000064ec;
|
||||
hgusb20_ep0_descriptor = 0x00007150;
|
||||
hgusb20_dev_rx = 0x000048a0;
|
||||
ll_suptmr_deinit = 0x00009ed4;
|
||||
strtoll = 0x00001518;
|
||||
ll_qspi_cmd_quad_enable = 0x00008e74;
|
||||
crc32_calc = 0x0000303c;
|
||||
ll_gmac_init = 0x00008504;
|
||||
qspi_flash_power_reset = 0x00004ef0;
|
||||
disable_wphy = 0x0000acb4;
|
||||
xmodem_receive = 0x00004ac0;
|
||||
strtoul = 0x00001198;
|
||||
ll_iic_master_buf_rx = 0x0000825c;
|
||||
config_wphy_device_cca_th = 0x00006224;
|
||||
adj_gain_value = 0x0000afc0;
|
||||
ll_gmac_send_frame = 0x00008a7c;
|
||||
ll_ir_timer_irq_config = 0x00007afc;
|
||||
hgusb20_switch_stable_device = 0x00006bc4;
|
||||
get_wphy_err_code = 0x0000aeb0;
|
||||
ll_led_timer_deinit = 0x00009da8;
|
||||
uart_s_tx = 0x000042ec;
|
||||
ll_iis_soft_rst = 0x00008494;
|
||||
isspace = 0x0000106c;
|
||||
boot = 0x200524d8;
|
||||
ll_crc_init = 0x00006a98;
|
||||
ll_spi_set_wire_mode = 0x00007e88;
|
||||
get_wphy_device_gfsk_rx_crc = 0x000063dc;
|
||||
ll_simple_spi_deinit = 0x0000a67c;
|
||||
ll_gmac_irq_config = 0x00008600;
|
||||
config_phy_tx_waveform_mode = 0x0000b158;
|
||||
ll_timer_deinit = 0x00007a98;
|
||||
sdio_slave_init = 0x00003d18;
|
||||
enable_wphy_device = 0x00006114;
|
||||
ll_crc_deinit = 0x00006ab4;
|
||||
usb_irq_ids = 0x200524a4;
|
||||
usb_test_mode_tbl = 0x0000df98;
|
||||
hgusb20_ep_set_txrdy = 0x00007998;
|
||||
strncasecmp = 0x00004c3c;
|
||||
ll_simple_uart_irq_config = 0x0000a708;
|
||||
sha256_vector = 0x0000d0e8;
|
||||
ll_clock_set_apb0_div = 0x000093fc;
|
||||
ll_timer_sync_start = 0x00007c7c;
|
||||
MD5Final = 0x0000bbc4;
|
||||
sdio_port_init = 0x00003b18;
|
||||
hgusb20_ep0_tx = 0x00006cb4;
|
||||
qspi_flash_deinit = 0x0000503c;
|
||||
config_wphy_device_gfsk_crc_init = 0x000063f4;
|
||||
ll_spi_deinit = 0x00007d7c;
|
||||
tbl_winusb20_wcid_descriptor_set = 0x0000e0bc;
|
||||
tbl_winusb_device_interface_guids = 0x0000e1c0;
|
||||
Te0 = 0x0000e8f8;
|
||||
ll_qspi_cmd_enter_qpi_mode = 0x00008eec;
|
||||
ll_ir_timer_config = 0x00007bd8;
|
||||
strtol = 0x00001298;
|
||||
crc32_cfg = 0x0000d88c;
|
||||
usb_test_packet = 0x0000dfa0;
|
||||
ll_spi_buf_tx = 0x00007f54;
|
||||
adj_gfsk_gain_value = 0x0000affc;
|
||||
ll_gmac_config = 0x00008554;
|
||||
uart_s_set_ds = 0x000042cc;
|
||||
config_cca_th = 0x0000af60;
|
||||
cfg_wphy_gfsk_ch = 0x0000b0c4;
|
||||
hgusb20_irq = 0x00007798;
|
||||
ll_uart_deinit = 0x00006874;
|
||||
spiflash_init = 0x000058a4;
|
||||
tbl_usb_str_serial_number = 0x0000e09c;
|
||||
cfg_wphy_gfsk_crc_init = 0x0000b0b4;
|
||||
get_wphy_device_tx_psdu_crc = 0x0000629c;
|
||||
strtod = 0x00001b6c;
|
||||
ll_suptmr_comm_config = 0x00009eec;
|
||||
spiflash_deinit = 0x000059b0;
|
||||
spi_s_rx_len_exp = 0x20052478;
|
||||
ll_gmac_setup_send_frame = 0x00008af8;
|
||||
ll_gpio_iomap_input_config = 0x0000655c;
|
||||
atof = 0x0000150c;
|
||||
ll_iic_dma_config = 0x00008154;
|
||||
disable_rx_agc = 0x0000af28;
|
||||
disable_auto_sig_err_rst = 0x0000af88;
|
||||
disable_gfsk_wphy = 0x0000b068;
|
||||
config_wphy_device_gfsk_ch = 0x00006408;
|
||||
sdio_s_rx = 0x00003ac4;
|
||||
ll_tk_sf_kick = 0x0000a638;
|
||||
strcat = 0x000018ec;
|
||||
ll_spi_irq_config = 0x00007dfc;
|
||||
hgusb20_init = 0x0000762c;
|
||||
sys_aes_set_mode = 0x00007cc4;
|
||||
adjust_wphy_device_gain_value = 0x00006328;
|
||||
tbl_usb_str_product = 0x0000e080;
|
||||
ll_tk_deinit = 0x0000a53c;
|
||||
sha256_process = 0x0000cf30;
|
||||
get_rx_freq_offset = 0x0000aed0;
|
||||
config_phy_tx_tri_mode = 0x0000ae4c;
|
||||
tbl_usb_config_all_descriptor_wifi = 0x0000e040;
|
||||
config_wphy_device_tx_tri_mode = 0x00006244;
|
||||
hgusb20_bot_reset = 0x00006ee0;
|
||||
sdio_rx_len_exp = 0x20052470;
|
||||
Td0 = 0x0000e3f8;
|
||||
ll_sdio_s_rx_kick = 0x00009320;
|
||||
ll_led_timer_init = 0x00009d9c;
|
||||
os_critical_enter = 0x00001b24;
|
||||
fw_upg_program = 0x00004578;
|
||||
ll_timer_ir_set_code_0 = 0x00007c74;
|
||||
sdio_s_set_speed = 0x00003aa8;
|
||||
ll_gpio_pin_lock_config = 0x00006810;
|
||||
ll_clock_exosc_enable = 0x00009398;
|
||||
uart_s_xfer_done = 0x20052488;
|
||||
soft_dereset_phy = 0x0000ac74;
|
||||
ll_timer_ir_disable = 0x00007c6c;
|
||||
sys_aes_set_block_num = 0x00007ca4;
|
||||
ll_uart_work_mode_change = 0x00006a84;
|
||||
memchr = 0x00001ae8;
|
||||
ll_qspi_cmd_device_reset = 0x00008fb8;
|
||||
stdin = 0x20052440;
|
||||
ll_spi_tx = 0x00007ef0;
|
||||
enable_rx_agc = 0x0000af3c;
|
||||
ll_spi_set_clock_mode = 0x00007ec4;
|
||||
delay_ms_systick = 0x0000aae8;
|
||||
qspi_flash_port_init = 0x00004d54;
|
||||
rand = 0x00001170;
|
||||
ll_uart_dma_config = 0x00006a34;
|
||||
ll_gmac_get_rx_frame_status = 0x00008cc4;
|
||||
enable_gfsk_wphy = 0x0000b03c;
|
||||
SysTickCnt = 0x200524bc;
|
||||
ll_gpio_iomap_inout_config = 0x000065fc;
|
||||
get_wphy_scrambler_init = 0x0000ae8c;
|
||||
enable_wphy_cont_tx = 0x0000acb8;
|
||||
ll_timer_config = 0x00007b3c;
|
||||
isupper = 0x00001b04;
|
||||
qspi_flash_init = 0x00004f20;
|
||||
ll_iic_dma_start = 0x00008184;
|
||||
ll_timer_irq_config = 0x00007a9c;
|
||||
ll_timer_start = 0x00007c54;
|
||||
ll_crc_stop = 0x00006b30;
|
||||
ll_led_config = 0x00009c24;
|
||||
hgusb20_wifi_init = 0x000079c4;
|
||||
ll_sdio_s_config = 0x00009264;
|
||||
sdio_interrupt_handle = 0x00003c54;
|
||||
ll_led_timer_irq_config = 0x00009e24;
|
||||
ll_qspi_set_clk = 0x000091a8;
|
||||
strcasecmp = 0x00004bf8;
|
||||
get_wphy_device_err_code = 0x000061b4;
|
||||
ll_iis_dma_config = 0x00008470;
|
||||
spi_base_pins = 0x0000de84;
|
||||
get_rx_gain_para = 0x0000afd8;
|
||||
hgusb20_wifi_ep_init = 0x000079c8;
|
||||
qspi_flash_poweron = 0x00004ea0;
|
||||
ll_gmac_mdio_read = 0x000088b4;
|
||||
ll_crc_config = 0x00006ab8;
|
||||
hgusb20_ep0_clrrx_contious = 0x00006d04;
|
||||
os_critical_exit = 0x00001b28;
|
||||
ll_iis_config = 0x0000835c;
|
||||
get_wphy_device_scrambler_init = 0x00006134;
|
||||
memcmp = 0x0000199c;
|
||||
hgusb20_ep0_get_descriptor = 0x0000719c;
|
||||
ll_qspi_cmd_release_power_down = 0x00009020;
|
||||
ll_gmac_mdio_write = 0x000086cc;
|
||||
adjust_wphy_device_gfsk_gain_value = 0x00006340;
|
||||
crc16_xmodem = 0x00004a90;
|
||||
isalpha = 0x00001b0c;
|
||||
ll_timer_init = 0x00007a94;
|
||||
disable_wphy_device = 0x00006124;
|
||||
crc8_calc = 0x00002ff4;
|
||||
config_wphy_device_tx_sine_mode = 0x00006234;
|
||||
ll_tk_init = 0x0000a520;
|
||||
delay_us = 0x0000aa3c;
|
||||
_ctype = 0x0000dd84;
|
||||
hgusb20_ep_rx_kick = 0x00007898;
|
||||
ll_gmac_deinit = 0x000085c8;
|
||||
disable_wphy_cont_tx = 0x0000acc8;
|
||||
enable_wphy_device_auto_sig_err_rst = 0x000062c4;
|
||||
ll_gmac_stop = 0x00008694;
|
||||
strtoull = 0x000013b8;
|
||||
disable_wphy_device_auto_sig_err_rst = 0x000062d8;
|
||||
rijndaelKeySetupEnc = 0x0000d17c;
|
||||
get_tx_psdu_crc16 = 0x0000acac;
|
||||
ll_iic_slave_tx = 0x00008298;
|
||||
config_wphy_rx_max_gain_state = 0x00006214;
|
||||
memset = 0x00001740;
|
||||
ll_suptmrx_config = 0x0000a02c;
|
||||
ll_m2m_dma_config = 0x000082e8;
|
||||
ll_m2m_dma_irq_config = 0x000082ec;
|
||||
ll_uart232_config = 0x000068fc;
|
||||
delay_ms = 0x0000aa68;
|
||||
hgusb20_ep0_request = 0x000074a8;
|
||||
ll_wdt_stop = 0x000064dc;
|
||||
close_wphy_device = 0x00006090;
|
||||
open_wphy_device = 0x00006080;
|
||||
uart_s_boot = 0x000045d8;
|
||||
srand = 0x0000118c;
|
||||
hgusb20_dev_tx = 0x0000487c;
|
||||
atcmd_bootl = 0x0000d8d8;
|
||||
cp_mode = 0x00002e60;
|
||||
get_wphy_device_rx_freq_offset = 0x0000635c;
|
||||
soft_reset_wphy_device = 0x00006264;
|
||||
config_wphy_device_dpd = 0x000062ec;
|
||||
soft_dereset_wphy_device = 0x00006274;
|
||||
ll_wdt_start = 0x000064c4;
|
||||
ll_wdt_config = 0x00006474;
|
||||
ll_suptmr_init = 0x00009e88;
|
||||
ll_uart_rxdma_kick = 0x00006a64;
|
||||
ll_clock_sys_clk_select = 0x0000942c;
|
||||
hgusb20_int_init_b = 0x00006d60;
|
||||
Td4s = 0x0000e7f8;
|
||||
hgusb20_ep0_class = 0x0000742c;
|
||||
get_wphy_device_tx_crc = 0x0000619c;
|
||||
sdio_s_func1_cis = 0x200475d0;
|
||||
ll_clock_test_clk_sel = 0x0000935c;
|
||||
hgusb20_ep0_set_address = 0x0000708c;
|
||||
spi_s_set_speed = 0x00003f00;
|
||||
ll_iis_init = 0x00008344;
|
||||
strcmp = 0x00001668;
|
||||
ll_iic_init = 0x00008040;
|
||||
config_wphy_device_low_pwr_th = 0x000062b4;
|
||||
ll_iic_deinit = 0x0000804c;
|
||||
ll_iis_irq_config = 0x00008448;
|
||||
ll_iis_deinit = 0x00008350;
|
||||
sys_clock_cfg = 0x200524a8;
|
||||
flash_memory_init = 0x000043f4;
|
||||
cfg_phy_tx_gain = 0x0000ada4;
|
||||
ll_gmac_allow_send_frame = 0x00008a68;
|
||||
ll_gpio_afio_config = 0x00006618;
|
||||
ll_m2m_dma_deinit = 0x000082dc;
|
||||
ll_gpio_ospeed_config = 0x00006828;
|
||||
MD5Init = 0x0000baf8;
|
||||
ll_wdt_deinit = 0x000064b4;
|
||||
os_critical_open = 0x00001b20;
|
||||
strtof = 0x000014e8;
|
||||
sys_aes_set_key = 0x00007c90;
|
||||
hgusb20_config_desc_prepare = 0x00006bec;
|
||||
dev_register = 0x0000641c;
|
||||
ll_led_init = 0x00009bfc;
|
||||
get_wphy_avg_power = 0x0000ae98;
|
||||
stderr = 0x20052400;
|
||||
ll_ir_timer_dma_config = 0x00007c24;
|
||||
ll_clock_usb_clk_en = 0x00009778;
|
||||
ll_timer_stop = 0x00007c5c;
|
||||
ll_qspi_cmd_busy_wait = 0x00008d90;
|
||||
hgusb20_ep_set_rxrdy = 0x00007994;
|
||||
ll_clock_is_exist = 0x00009494;
|
||||
enable_wphy = 0x0000b154;
|
||||
MD5Update = 0x0000bb20;
|
||||
spi_s_set_ds = 0x00003f0c;
|
||||
config_rx_max_gain_state = 0x0000af50;
|
||||
enable_wphy_device_cont_tx = 0x0000617c;
|
||||
fputc = 0x0000a810;
|
||||
config_wphy_device_tx_norm_mode = 0x00006254;
|
||||
tbl_usb_config_all_descriptor_gen = 0x0000e034;
|
||||
ll_simple_uart_config = 0x0000a74c;
|
||||
spi_rx_buf = 0x00005a60;
|
||||
get_rx_gfsk_gain_para = 0x0000b018;
|
||||
tbl_usb_device_descriptor = 0x0000e058;
|
||||
ll_tk_irq_config = 0x0000a540;
|
||||
get_wphy_device_agc_info = 0x000061cc;
|
||||
sysctrl_qspi_get_src_clk = 0x0000a794;
|
||||
hgsdio20_s_func1_cis = 0x0000e27c;
|
||||
isdigit = 0x00001afc;
|
||||
SHA1Final = 0x0000cc68;
|
||||
ll_tk_data = 0x0000a66c;
|
||||
qspi_flash_bootload_code = 0x000054a4;
|
||||
get_wphy_device_avg_power = 0x0000614c;
|
||||
ll_timer_ir_set_code_1 = 0x00007c78;
|
||||
aes_decrypt_encrypt = 0x00004ca4;
|
||||
ll_simple_spi_irq_config = 0x0000a684;
|
||||
spi_s_rx = 0x00003ec0;
|
||||
config_wphy_device_dis_gfsk_wphy = 0x0000639c;
|
||||
ll_spi_set_sample_delay = 0x00007ed4;
|
||||
sdio_s_dummy_buf = 0x2004759c;
|
||||
ll_gmac_receive_frame = 0x00008bb8;
|
||||
config_wphy_device_rx_gain_tab = 0x00006204;
|
||||
ll_led_timer_config = 0x00009db4;
|
||||
ll_qspi_cmd_write_enable = 0x00008e30;
|
||||
enable_wphy_device_rx_agc = 0x000061f4;
|
||||
ll_clock_usbpll_config = 0x00009674;
|
||||
SHA1Transform = 0x0000bc94;
|
||||
hgsdio20_s_speed_list = 0x0000e2b4;
|
||||
ll_uart_irq_config = 0x0000687c;
|
||||
sys_aes_set_key_src = 0x00007cd8;
|
||||
ll_clock_syspll_set = 0x000094e0;
|
||||
ll_simple_spi_config = 0x0000a69c;
|
||||
soft_reset_phy = 0x0000ac8c;
|
||||
ll_gmac_has_received_frame = 0x00008a30;
|
||||
get_wphy_gfsk_tx_crc = 0x0000b094;
|
||||
ll_wdt_init = 0x00006470;
|
||||
ll_qspi_cmd_exit_qpi_mode = 0x00008f64;
|
||||
ll_tk_scan_kick = 0x0000a64c;
|
||||
atoi = 0x00001500;
|
||||
ll_crc_wait_done_pending = 0x00006b20;
|
||||
hgusb20_dev_set_speed = 0x00004870;
|
||||
config_low_pwr_th = 0x0000b12c;
|
||||
ll_qspi_cmd_flash_64kb_erase = 0x00009064;
|
||||
ll_gmac_get_setup_frame_status = 0x00008c94;
|
||||
hgsdio20_s_func0_cis = 0x0000e268;
|
||||
config_wphy_device_tx_gain = 0x00006314;
|
||||
spiflash_bootloader = 0x00005c8c;
|
||||
ll_uart485_config = 0x000069c4;
|
||||
ll_tk_hw_kick = 0x0000a62c;
|
||||
crc8_itu_cfg = 0x0000d8a8;
|
||||
strlen = 0x000017e0;
|
||||
__cskyvprintfprintf = 0x0000109c;
|
||||
get_rx_psdu_crc16 = 0x0000aca4;
|
||||
hgusb20_init_globle = 0x00006b34;
|
||||
sdio_s_func0_cis = 0x200475bc;
|
||||
get_wphy_device_rx_psdu_crc = 0x00006284;
|
||||
get_wphy_device_info = 0x000060a0;
|
||||
sys_aes_clear_pending = 0x00007d04;
|
||||
hgusb20_dev_set_ds = 0x0000486c;
|
||||
rcons = 0x0000ecf8;
|
||||
ll_gmac_delay = 0x000084f0;
|
||||
abs = 0x00001290;
|
||||
strchr = 0x00001988;
|
||||
get_wphy_tx_crc = 0x0000acd8;
|
||||
fputs = 0x00001124;
|
||||
cfg_dpd_coef = 0x0000ad78;
|
||||
ll_qspi_cmd_issue = 0x00008cd4;
|
||||
spi_read_cfg_nor = 0x0000dedc;
|
||||
hgusb20_ep_tx_kick = 0x00007918;
|
||||
ll_crc_continue = 0x00006b08;
|
||||
ll_clock_set_sys_clk_div = 0x000093e4;
|
||||
get_wphy_gfsk_rx_crc = 0x0000b0a4;
|
||||
hgusb20_ep0_transfer = 0x000070cc;
|
||||
ll_iic_config = 0x00008058;
|
||||
ll_simple_uart_deinit = 0x0000a6fc;
|
||||
get_bk_noise = 0x0000b0e4;
|
||||
__jpeg_htable = 0x0000fc00;
|
||||
get_wphy_agc_info = 0x0000aec4;
|
||||
hgusb20_wifi_xfer_reset = 0x00007868;
|
||||
debug_select_interface = 0x0000a7e8;
|
||||
sha1_vector = 0x0000cd2c;
|
||||
ll_spi_get_wire_mode = 0x00007ee8;
|
||||
hgusb20_ep0_standard = 0x000072d4;
|
||||
disable_wphy_device_rx_agc = 0x000061e4;
|
||||
sys_reset = 0x0000aac8;
|
||||
ll_iis_enable = 0x00008480;
|
||||
ll_clock_set_apb1_div = 0x00009414;
|
||||
ll_led_deinit = 0x00009c10;
|
||||
qspi_flash_boot = 0x000055c8;
|
||||
config_rx_gain_tab = 0x0000b100;
|
||||
get_core_clock = 0x0000aafc;
|
||||
82
project/utilities/romcode_fpga.ld
Normal file
82
project/utilities/romcode_fpga.ld
Normal file
@@ -0,0 +1,82 @@
|
||||
strcat = 0x000018ec;
|
||||
strchr = 0x00001988;
|
||||
strcmp = 0x00001668;
|
||||
strcpy = 0x00001820;
|
||||
memset = 0x00001740;
|
||||
memcpy = 0x00001908;
|
||||
memcmp = 0x0000199c;
|
||||
memchr = 0x00001ae8;
|
||||
strcasecmp = 0x00004b4c;
|
||||
strncasecmp = 0x00004b90;
|
||||
printf = 0x00001080;
|
||||
puts = 0x000010b8;
|
||||
strerror = 0x00002d48;
|
||||
rand = 0x00001170;
|
||||
srand = 0x0000118c;
|
||||
abs = 0x00001290;
|
||||
fabs = 0x000001a8;
|
||||
atof = 0x0000150c;
|
||||
atoi = 0x00001500;
|
||||
atol = 0x000014f4;
|
||||
strtol = 0x00001298;
|
||||
strtoll = 0x00001518;
|
||||
strtoul = 0x00001198;
|
||||
strtoull = 0x000013b8;
|
||||
strtof = 0x000014e8;
|
||||
strtod = 0x00001b6c;
|
||||
isupper = 0x00001b04;
|
||||
isspace = 0x0000106c;
|
||||
isdigit = 0x00001afc;
|
||||
isalpha = 0x00001b0c;
|
||||
|
||||
SHA1Init = 0x0000ca60;
|
||||
SHA1Transform = 0x0000bb4c;
|
||||
SHA1Update = 0x0000ca90;
|
||||
sha1_vector = 0x0000cbe4;
|
||||
SHA1Final = 0x0000cb20;
|
||||
sha256_init = 0x0000cd98;
|
||||
sha256_done = 0x0000cea8;
|
||||
sha256_vector = 0x0000cfa0;
|
||||
sha256_process = 0x0000cde8;
|
||||
|
||||
MD5Init = 0x0000b9b0;
|
||||
MD5Update = 0x0000b9d8;
|
||||
md5_vector = 0x0000baf4;
|
||||
MD5Final = 0x0000ba7c;
|
||||
/**/
|
||||
hgusb20_intr_dis = 0x00006b50;
|
||||
hgusb20_int_init_b = 0x00006cdc;
|
||||
hgusb20_clear_ep = 0x00006dec;
|
||||
hgusb20_ep0_clrrx_pkt0 = 0x00006cac;
|
||||
hgusb20_ep0_clr_feature = 0x00006f58;
|
||||
hgusb20_stall_ep = 0x00006d6c;
|
||||
hgusb20_ep0_get_status = 0x00006ee0;
|
||||
hgusb20_ep0_set_feature = 0x00006f9c;
|
||||
hgusb20_ep0_set_configuration = 0x00007210;
|
||||
hgusb20_ep0_get_wcid_descriptor = 0x000072dc;
|
||||
hgusb20_reset2device_mode = 0x00006ab4;
|
||||
hgusb20_switch_stable_device = 0x00006b40;
|
||||
hgusb20_ep_set_txrdy = 0x00007914;
|
||||
hgusb20_ep0_tx = 0x00006c30;
|
||||
hgusb20_ep_rx_kick = 0x00007814;
|
||||
hgusb20_ep0_class = 0x000073a8;
|
||||
hgusb20_ep0_set_address = 0x00007008;
|
||||
hgusb20_ep_set_rxrdy = 0x00007910;
|
||||
hgusb20_ep_tx_kick = 0x00007894;
|
||||
hgusb20_ep0_transfer = 0x00007048;
|
||||
hgusb20_ep0_descriptor = 0x000070cc;
|
||||
tbl_usb_language_id = 0x0000df1c;
|
||||
tbl_usb_str_manufacturer = 0x0000df20;
|
||||
tbl_winusb_device_descriptor = 0x0000e05c;
|
||||
tbl_winusb_compatible_id_feature_descriptor = 0x0000e034;
|
||||
tbl_winusb20_wcidbos = 0x0000e010;
|
||||
usb_test_packet = 0x0000de50;
|
||||
usb_test_mode_tbl = 0x0000de48;
|
||||
tbl_winusb20_wcid_descriptor_set = 0x0000df6c;
|
||||
tbl_winusb_device_interface_guids = 0x0000e070;
|
||||
tbl_usb_str_serial_number = 0x0000df4c;
|
||||
tbl_usb_str_product = 0x0000df30;
|
||||
tbl_usb_config_all_descriptor_wifi = 0x0000def0;
|
||||
tbl_usb_config_all_descriptor_gen = 0x0000dee4;
|
||||
tbl_usb_device_descriptor = 0x0000df08;
|
||||
|
||||
455
project/utilities/romcode_fpga_org.ld
Normal file
455
project/utilities/romcode_fpga_org.ld
Normal file
@@ -0,0 +1,455 @@
|
||||
ll_spi_init = 0x00007ce8;
|
||||
|
||||
ll_spi_rx = 0x00007ea8;
|
||||
|
||||
ll_uart_txdma_kick = 0x000069f0;
|
||||
sdio_s_set_ds = 0x000038c8;
|
||||
|
||||
sys_aes_init = 0x00007c8c;
|
||||
|
||||
disable_wphy_device_cont_tx = 0x00006108;
|
||||
config_wphy_device_dpd_coef = 0x0000627c;
|
||||
sys_aes_key_bitlen_sel = 0x00007c68;
|
||||
ll_simple_spi_init = 0x0000a5e4;
|
||||
hgusb20_irq_dma = 0x000076b0;
|
||||
fw_upg_addr = 0x2005247c;
|
||||
crc16_modbus_calc = 0x00002ecc;
|
||||
close_wphy = 0x0000ac68;
|
||||
ll_iic_slave_rx = 0x00008208;
|
||||
hgusb20_wifi_reset = 0x00007a08;
|
||||
ll_crc_start = 0x00006a78;
|
||||
ll_m2m_memcpy = 0x00008278;
|
||||
os_critical_close = 0x00001b2c;
|
||||
hgusb20_irq_set = 0x000075f4;
|
||||
|
||||
ll_sdio_s_tx_kick = 0x00009264;
|
||||
|
||||
uart_s_set_speed = 0x00004208;
|
||||
get_wphy_device_avg_evm = 0x000060e0;
|
||||
|
||||
sdio_s_tx = 0x00003968;
|
||||
config_phy_tx_norm_mode = 0x0000ad24;
|
||||
get_wphy_device_gfsk_tx_crc = 0x00006340;
|
||||
ll_wdt_feed = 0x00006450;
|
||||
ll_timer_ir_enable = 0x00007be0;
|
||||
ll_spi_buf_rx = 0x00007f50;
|
||||
spiflash_boot = 0x00005e34;
|
||||
|
||||
ll_clock_syspll_config = 0x0000958c;
|
||||
ll_clock_hirc_enable = 0x000092e4;
|
||||
fw_upg_blk_addr = 0x20052480;
|
||||
ll_uart_init = 0x000067dc;
|
||||
|
||||
spi_cfg = 0x0000dd6c;
|
||||
|
||||
config_phy_tx_sine_mode = 0x0000ace4;
|
||||
ll_spi_config = 0x00007d04;
|
||||
hgwphy_bgn_attach = 0x0000b044;
|
||||
qspi_flash_port_deinit = 0x00004d4c;
|
||||
usb20 = 0x2004768c;
|
||||
ll_sys_clock_globle_set = 0x0000aab4;
|
||||
ll_m2m_memset = 0x0000829c;
|
||||
|
||||
sdio_boot = 0x20052468;
|
||||
ll_tk_stop = 0x0000a5d4;
|
||||
hgusb20_dev_reset = 0x00006e98;
|
||||
ll_gpio_iomap_output_config = 0x00006488;
|
||||
get_wphy_device_rx_gain_para = 0x000062f0;
|
||||
ll_sdio_s_irq_config = 0x000091d0;
|
||||
|
||||
ll_iic_master_tx = 0x0000810c;
|
||||
ll_simple_uart_init = 0x0000a660;
|
||||
|
||||
|
||||
ll_clock_set_sys_clk_src = 0x00009338;
|
||||
ll_sys_clock_init = 0x0000aa70;
|
||||
|
||||
config_dpd = 0x0000ae68;
|
||||
|
||||
ll_gmac_get_tx_frame_status = 0x00008c28;
|
||||
ll_qspi_controller_init = 0x00009198;
|
||||
|
||||
errno = 0x200524d0;
|
||||
open_wphy = 0x0000aba0;
|
||||
hgusb20_dev_init = 0x00006d04;
|
||||
ll_qspi_set_prefetch = 0x000090ec;
|
||||
ll_gpio_pull_config = 0x000065fc;
|
||||
|
||||
get_wphy_avg_evm = 0x0000ad5c;
|
||||
ll_spi_dma_start = 0x00007df8;
|
||||
uart_s_rx = 0x00004270;
|
||||
CORE_SEC_OPT = 0x000092a0;
|
||||
trig_calc_bk_noise = 0x0000af8c;
|
||||
|
||||
spi_boot = 0x20052674;
|
||||
freq_offset_sign_ext = 0x0000b030;
|
||||
sys_aes_start = 0x00007ca8;
|
||||
|
||||
ll_tk_ch_kick = 0x0000a5c8;
|
||||
ll_iic_master_rx = 0x00008144;
|
||||
spi_s_tx = 0x00003dd0;
|
||||
enable_auto_sig_err_rst = 0x0000ae54;
|
||||
qspi_flash_poweroff = 0x00004e1c;
|
||||
fwinfo_check_fwinfo_hdr = 0x0000444c;
|
||||
hgusb20_irq_handler_set = 0x000075d4;
|
||||
ll_iic_master_buf_tx = 0x00008194;
|
||||
ll_spi_dma_config = 0x00007dd0;
|
||||
config_wphy_device_en_gfsk_wphy = 0x0000632c;
|
||||
|
||||
|
||||
sys_aes_get_pending = 0x00007c78;
|
||||
atcmd_fwupg = 0x0000d790;
|
||||
ll_m2m_dma_init = 0x00008220;
|
||||
fw_upg_prepare = 0x00004488;
|
||||
|
||||
spiflash_read = 0x00005a2c;
|
||||
ll_qspi_set_write_protect = 0x000090ac;
|
||||
|
||||
|
||||
ll_tk_config = 0x0000a4f4;
|
||||
sys_aes_set_irq = 0x00007c2c;
|
||||
|
||||
ll_gmac_start = 0x00008600;
|
||||
crc16_modbus_cfg = 0x0000d720;
|
||||
ll_iis_disable = 0x00008408;
|
||||
hgusb20_ep0_func = 0x00007468;
|
||||
ll_clock_test_clk_en = 0x000092c4;
|
||||
ll_iic_irq_config = 0x0000803c;
|
||||
get_wphy_device_rx_gfsk_gain_para = 0x00006304;
|
||||
|
||||
ll_gpio_analog_config = 0x00006468;
|
||||
|
||||
hgusb20_dev_rx = 0x000047f4;
|
||||
ll_suptmr_deinit = 0x00009e44;
|
||||
|
||||
ll_qspi_cmd_quad_enable = 0x00008df0;
|
||||
crc32_calc = 0x00002ef0;
|
||||
ll_gmac_init = 0x00008480;
|
||||
qspi_flash_power_reset = 0x00004e44;
|
||||
disable_wphy = 0x0000ab6c;
|
||||
xmodem_receive = 0x00004a14;
|
||||
|
||||
ll_iic_master_buf_rx = 0x000081d8;
|
||||
config_wphy_device_cca_th = 0x000061a0;
|
||||
adj_gain_value = 0x0000ae78;
|
||||
ll_gmac_send_frame = 0x000089f8;
|
||||
ll_ir_timer_irq_config = 0x00007a78;
|
||||
|
||||
get_wphy_err_code = 0x0000ad68;
|
||||
ll_led_timer_deinit = 0x00009d18;
|
||||
uart_s_tx = 0x00004240;
|
||||
ll_iis_soft_rst = 0x00008410;
|
||||
stdout = 0x20052420;
|
||||
boot = 0x200524d8;
|
||||
ll_crc_init = 0x00006a14;
|
||||
ll_spi_set_wire_mode = 0x00007e04;
|
||||
get_wphy_device_gfsk_rx_crc = 0x00006358;
|
||||
ll_simple_spi_deinit = 0x0000a5ec;
|
||||
ll_gmac_irq_config = 0x0000857c;
|
||||
config_phy_tx_waveform_mode = 0x0000b010;
|
||||
ll_timer_deinit = 0x00007a14;
|
||||
sdio_slave_init = 0x00003c5c;
|
||||
enable_wphy_device = 0x00006090;
|
||||
ll_crc_deinit = 0x00006a30;
|
||||
usb_irq_ids = 0x200524a4;
|
||||
|
||||
|
||||
|
||||
ll_simple_uart_irq_config = 0x0000a678;
|
||||
|
||||
ll_clock_set_apb0_div = 0x00009370;
|
||||
ll_timer_sync_start = 0x00007bf8;
|
||||
|
||||
sdio_port_init = 0x000039cc;
|
||||
|
||||
qspi_flash_deinit = 0x00004f90;
|
||||
config_wphy_device_gfsk_crc_init = 0x00006370;
|
||||
ll_spi_deinit = 0x00007cf8;
|
||||
|
||||
Te0 = 0x0000e7a8;
|
||||
ll_qspi_cmd_enter_qpi_mode = 0x00008e68;
|
||||
ll_ir_timer_config = 0x00007b54;
|
||||
|
||||
crc32_cfg = 0x0000d73c;
|
||||
|
||||
ll_spi_buf_tx = 0x00007ed0;
|
||||
adj_gfsk_gain_value = 0x0000aeb4;
|
||||
ll_gmac_config = 0x000084d0;
|
||||
uart_s_set_ds = 0x00004220;
|
||||
config_cca_th = 0x0000ae18;
|
||||
cfg_wphy_gfsk_ch = 0x0000af7c;
|
||||
hgusb20_irq = 0x00007714;
|
||||
ll_uart_deinit = 0x000067f0;
|
||||
spiflash_init = 0x00005820;
|
||||
|
||||
cfg_wphy_gfsk_crc_init = 0x0000af6c;
|
||||
get_wphy_device_tx_psdu_crc = 0x00006218;
|
||||
|
||||
ll_suptmr_comm_config = 0x00009e5c;
|
||||
spiflash_deinit = 0x0000592c;
|
||||
spi_s_rx_len_exp = 0x20052478;
|
||||
ll_gmac_setup_send_frame = 0x00008a74;
|
||||
ll_gpio_iomap_input_config = 0x000064d8;
|
||||
|
||||
ll_iic_dma_config = 0x000080d0;
|
||||
disable_rx_agc = 0x0000ade0;
|
||||
disable_auto_sig_err_rst = 0x0000ae40;
|
||||
disable_gfsk_wphy = 0x0000af20;
|
||||
config_wphy_device_gfsk_ch = 0x00006384;
|
||||
sdio_s_rx = 0x00003978;
|
||||
ll_tk_sf_kick = 0x0000a5a8;
|
||||
|
||||
ll_spi_irq_config = 0x00007d78;
|
||||
hgusb20_init = 0x000075a8;
|
||||
sys_aes_set_mode = 0x00007c40;
|
||||
adjust_wphy_device_gain_value = 0x000062a4;
|
||||
|
||||
ll_tk_deinit = 0x0000a4ac;
|
||||
|
||||
get_rx_freq_offset = 0x0000ad88;
|
||||
config_phy_tx_tri_mode = 0x0000ad04;
|
||||
|
||||
config_wphy_device_tx_tri_mode = 0x000061c0;
|
||||
hgusb20_bot_reset = 0x00006e5c;
|
||||
sdio_rx_len_exp = 0x20052470;
|
||||
Td0 = 0x0000e2a8;
|
||||
ll_sdio_s_rx_kick = 0x00009294;
|
||||
ll_led_timer_init = 0x00009d0c;
|
||||
os_critical_enter = 0x00001b24;
|
||||
fw_upg_program = 0x000044cc;
|
||||
ll_timer_ir_set_code_0 = 0x00007bf0;
|
||||
sdio_s_set_speed = 0x0000395c;
|
||||
ll_gpio_pin_lock_config = 0x0000678c;
|
||||
ll_clock_exosc_enable = 0x0000930c;
|
||||
uart_s_xfer_done = 0x20052488;
|
||||
soft_dereset_phy = 0x0000ab2c;
|
||||
ll_timer_ir_disable = 0x00007be8;
|
||||
sys_aes_set_block_num = 0x00007c20;
|
||||
ll_uart_work_mode_change = 0x00006a00;
|
||||
|
||||
ll_qspi_cmd_device_reset = 0x00008f34;
|
||||
stdin = 0x20052440;
|
||||
ll_spi_tx = 0x00007e6c;
|
||||
enable_rx_agc = 0x0000adf4;
|
||||
ll_spi_set_clock_mode = 0x00007e40;
|
||||
delay_ms_systick = 0x0000a9a8;
|
||||
qspi_flash_port_init = 0x00004ca8;
|
||||
|
||||
ll_uart_dma_config = 0x000069b0;
|
||||
ll_gmac_get_rx_frame_status = 0x00008c40;
|
||||
enable_gfsk_wphy = 0x0000aef4;
|
||||
SysTickCnt = 0x200524bc;
|
||||
ll_gpio_iomap_inout_config = 0x00006578;
|
||||
get_wphy_scrambler_init = 0x0000ad44;
|
||||
enable_wphy_cont_tx = 0x0000ab70;
|
||||
ll_timer_config = 0x00007ab8;
|
||||
|
||||
qspi_flash_init = 0x00004e74;
|
||||
ll_iic_dma_start = 0x00008100;
|
||||
ll_timer_irq_config = 0x00007a18;
|
||||
ll_timer_start = 0x00007bd0;
|
||||
ll_crc_stop = 0x00006aac;
|
||||
ll_led_config = 0x00009b94;
|
||||
hgusb20_wifi_init = 0x00007940;
|
||||
ll_sdio_s_config = 0x000091d8;
|
||||
sdio_interrupt_handle = 0x00003b98;
|
||||
ll_led_timer_irq_config = 0x00009d94;
|
||||
ll_qspi_set_clk = 0x00009124;
|
||||
|
||||
get_wphy_device_err_code = 0x00006130;
|
||||
ll_iis_dma_config = 0x000083ec;
|
||||
spi_base_pins = 0x0000dd34;
|
||||
get_rx_gain_para = 0x0000ae90;
|
||||
hgusb20_wifi_ep_init = 0x00007944;
|
||||
qspi_flash_poweron = 0x00004df4;
|
||||
ll_gmac_mdio_read = 0x00008830;
|
||||
ll_crc_config = 0x00006a34;
|
||||
hgusb20_ep0_clrrx_contious = 0x00006c80;
|
||||
os_critical_exit = 0x00001b28;
|
||||
ll_iis_config = 0x000082d8;
|
||||
get_wphy_device_scrambler_init = 0x000060b0;
|
||||
|
||||
hgusb20_ep0_get_descriptor = 0x00007118;
|
||||
ll_qspi_cmd_release_power_down = 0x00008f9c;
|
||||
ll_gmac_mdio_write = 0x00008648;
|
||||
adjust_wphy_device_gfsk_gain_value = 0x000062bc;
|
||||
crc16_xmodem = 0x000049e4;
|
||||
|
||||
ll_timer_init = 0x00007a10;
|
||||
disable_wphy_device = 0x000060a0;
|
||||
crc8_calc = 0x00002ea8;
|
||||
config_wphy_device_tx_sine_mode = 0x000061b0;
|
||||
ll_tk_init = 0x0000a490;
|
||||
delay_us = 0x0000a92c;
|
||||
_ctype = 0x0000dc34;
|
||||
|
||||
ll_gmac_deinit = 0x00008544;
|
||||
disable_wphy_cont_tx = 0x0000ab80;
|
||||
enable_wphy_device_auto_sig_err_rst = 0x00006240;
|
||||
ll_gmac_stop = 0x00008610;
|
||||
|
||||
disable_wphy_device_auto_sig_err_rst = 0x00006254;
|
||||
rijndaelKeySetupEnc = 0x0000d034;
|
||||
get_tx_psdu_crc16 = 0x0000ab64;
|
||||
ll_iic_slave_tx = 0x00008214;
|
||||
config_wphy_rx_max_gain_state = 0x00006190;
|
||||
|
||||
ll_suptmrx_config = 0x00009f9c;
|
||||
ll_m2m_dma_config = 0x00008264;
|
||||
ll_m2m_dma_irq_config = 0x00008268;
|
||||
ll_uart232_config = 0x00006878;
|
||||
delay_ms = 0x0000a94c;
|
||||
hgusb20_ep0_request = 0x00007424;
|
||||
ll_wdt_stop = 0x00006458;
|
||||
close_wphy_device = 0x0000600c;
|
||||
open_wphy_device = 0x00005ffc;
|
||||
uart_s_boot = 0x0000452c;
|
||||
|
||||
hgusb20_dev_tx = 0x000047d0;
|
||||
atcmd_bootl = 0x0000d788;
|
||||
cp_mode = 0x00002e70;
|
||||
get_wphy_device_rx_freq_offset = 0x000062d8;
|
||||
soft_reset_wphy_device = 0x000061e0;
|
||||
config_wphy_device_dpd = 0x00006268;
|
||||
soft_dereset_wphy_device = 0x000061f0;
|
||||
ll_wdt_start = 0x00006440;
|
||||
ll_wdt_config = 0x000063f0;
|
||||
ll_suptmr_init = 0x00009df8;
|
||||
ll_uart_rxdma_kick = 0x000069e0;
|
||||
ll_clock_sys_clk_select = 0x000093a0;
|
||||
|
||||
Td4s = 0x0000e6a8;
|
||||
|
||||
get_wphy_device_tx_crc = 0x00006118;
|
||||
sdio_s_func1_cis = 0x200475d0;
|
||||
ll_clock_test_clk_sel = 0x000092d0;
|
||||
|
||||
spi_s_set_speed = 0x00003e44;
|
||||
ll_iis_init = 0x000082c0;
|
||||
|
||||
ll_iic_init = 0x00007fbc;
|
||||
config_wphy_device_low_pwr_th = 0x00006230;
|
||||
ll_iic_deinit = 0x00007fc8;
|
||||
ll_iis_irq_config = 0x000083c4;
|
||||
ll_iis_deinit = 0x000082cc;
|
||||
sys_clock_cfg = 0x200524a8;
|
||||
flash_memory_init = 0x00004348;
|
||||
cfg_phy_tx_gain = 0x0000ac5c;
|
||||
ll_gmac_allow_send_frame = 0x000089e4;
|
||||
ll_gpio_afio_config = 0x00006594;
|
||||
ll_m2m_dma_deinit = 0x00008258;
|
||||
ll_gpio_ospeed_config = 0x000067a4;
|
||||
|
||||
ll_wdt_deinit = 0x00006430;
|
||||
os_critical_open = 0x00001b20;
|
||||
|
||||
sys_aes_set_key = 0x00007c0c;
|
||||
hgusb20_config_desc_prepare = 0x00006b68;
|
||||
dev_register = 0x00006398;
|
||||
ll_led_init = 0x00009b6c;
|
||||
get_wphy_avg_power = 0x0000ad50;
|
||||
stderr = 0x20052400;
|
||||
ll_ir_timer_dma_config = 0x00007ba0;
|
||||
ll_clock_usb_clk_en = 0x000096e8;
|
||||
ll_timer_stop = 0x00007bd8;
|
||||
ll_qspi_cmd_busy_wait = 0x00008d0c;
|
||||
|
||||
ll_clock_is_exist = 0x00009408;
|
||||
enable_wphy = 0x0000b00c;
|
||||
|
||||
spi_s_set_ds = 0x00003e50;
|
||||
config_rx_max_gain_state = 0x0000ae08;
|
||||
enable_wphy_device_cont_tx = 0x000060f8;
|
||||
fputc = 0x0000a72c;
|
||||
config_wphy_device_tx_norm_mode = 0x000061d0;
|
||||
|
||||
ll_simple_uart_config = 0x0000a6bc;
|
||||
spi_rx_buf = 0x000059dc;
|
||||
get_rx_gfsk_gain_para = 0x0000aed0;
|
||||
|
||||
ll_tk_irq_config = 0x0000a4b0;
|
||||
get_wphy_device_agc_info = 0x00006148;
|
||||
hgsdio20_s_func1_cis = 0x0000e12c;
|
||||
|
||||
|
||||
ll_tk_data = 0x0000a5dc;
|
||||
qspi_flash_bootload_code = 0x000053f8;
|
||||
get_wphy_device_avg_power = 0x000060c8;
|
||||
ll_timer_ir_set_code_1 = 0x00007bf4;
|
||||
aes_decrypt_encrypt = 0x00004bf8;
|
||||
ll_simple_spi_irq_config = 0x0000a5f4;
|
||||
spi_s_rx = 0x00003e04;
|
||||
config_wphy_device_dis_gfsk_wphy = 0x00006318;
|
||||
ll_spi_set_sample_delay = 0x00007e50;
|
||||
sdio_s_dummy_buf = 0x2004759c;
|
||||
ll_gmac_receive_frame = 0x00008b34;
|
||||
config_wphy_device_rx_gain_tab = 0x00006180;
|
||||
ll_led_timer_config = 0x00009d24;
|
||||
ll_qspi_cmd_write_enable = 0x00008dac;
|
||||
enable_wphy_device_rx_agc = 0x00006170;
|
||||
ll_clock_usbpll_config = 0x000095e4;
|
||||
|
||||
hgsdio20_s_speed_list = 0x0000e164;
|
||||
ll_uart_irq_config = 0x000067f8;
|
||||
sys_aes_set_key_src = 0x00007c54;
|
||||
ll_clock_syspll_set = 0x00009450;
|
||||
ll_simple_spi_config = 0x0000a60c;
|
||||
soft_reset_phy = 0x0000ab44;
|
||||
ll_gmac_has_received_frame = 0x000089ac;
|
||||
get_wphy_gfsk_tx_crc = 0x0000af4c;
|
||||
ll_wdt_init = 0x000063ec;
|
||||
ll_qspi_cmd_exit_qpi_mode = 0x00008ee0;
|
||||
ll_tk_scan_kick = 0x0000a5bc;
|
||||
|
||||
ll_crc_wait_done_pending = 0x00006a9c;
|
||||
hgusb20_dev_set_speed = 0x000047c4;
|
||||
config_low_pwr_th = 0x0000afe4;
|
||||
ll_qspi_cmd_flash_64kb_erase = 0x00008fe0;
|
||||
ll_gmac_get_setup_frame_status = 0x00008c10;
|
||||
hgsdio20_s_func0_cis = 0x0000e118;
|
||||
config_wphy_device_tx_gain = 0x00006290;
|
||||
spiflash_bootloader = 0x00005c08;
|
||||
ll_uart485_config = 0x00006940;
|
||||
ll_tk_hw_kick = 0x0000a59c;
|
||||
crc8_itu_cfg = 0x0000d758;
|
||||
strlen = 0x000017e0;
|
||||
__cskyvprintfprintf = 0x0000109c;
|
||||
get_rx_psdu_crc16 = 0x0000ab5c;
|
||||
hgusb20_init_globle = 0x00006ab0;
|
||||
sdio_s_func0_cis = 0x200475bc;
|
||||
get_wphy_device_rx_psdu_crc = 0x00006200;
|
||||
get_wphy_device_info = 0x0000601c;
|
||||
sys_aes_clear_pending = 0x00007c80;
|
||||
hgusb20_dev_set_ds = 0x000047c0;
|
||||
rcons = 0x0000eba8;
|
||||
ll_gmac_delay = 0x0000846c;
|
||||
|
||||
|
||||
get_wphy_tx_crc = 0x0000ab90;
|
||||
fputs = 0x00001124;
|
||||
cfg_dpd_coef = 0x0000ac30;
|
||||
ll_qspi_cmd_issue = 0x00008c50;
|
||||
spi_read_cfg_nor = 0x0000dd8c;
|
||||
|
||||
ll_crc_continue = 0x00006a84;
|
||||
ll_clock_set_sys_clk_div = 0x00009358;
|
||||
get_wphy_gfsk_rx_crc = 0x0000af5c;
|
||||
|
||||
ll_iic_config = 0x00007fd4;
|
||||
ll_simple_uart_deinit = 0x0000a66c;
|
||||
get_bk_noise = 0x0000af9c;
|
||||
__jpeg_htable = 0x0000fc00;
|
||||
get_wphy_agc_info = 0x0000ad7c;
|
||||
hgusb20_wifi_xfer_reset = 0x000077e4;
|
||||
debug_select_interface = 0x0000a704;
|
||||
|
||||
ll_spi_get_wire_mode = 0x00007e64;
|
||||
hgusb20_ep0_standard = 0x00007250;
|
||||
disable_wphy_device_rx_agc = 0x00006160;
|
||||
sys_reset = 0x0000a988;
|
||||
ll_iis_enable = 0x000083fc;
|
||||
ll_clock_set_apb1_div = 0x00009388;
|
||||
ll_led_deinit = 0x00009b80;
|
||||
qspi_flash_boot = 0x0000551c;
|
||||
config_rx_gain_tab = 0x0000afb8;
|
||||
get_core_clock = 0x0000a9bc;
|
||||
458
project/utilities/romcode_org.ld
Normal file
458
project/utilities/romcode_org.ld
Normal file
@@ -0,0 +1,458 @@
|
||||
ll_spi_init = 0x00007d6c;
|
||||
hgusb20_intr_dis = 0x00006bd4;
|
||||
ll_spi_rx = 0x00007f2c;
|
||||
strcpy = 0x00001820;
|
||||
ll_uart_txdma_kick = 0x00006a74;
|
||||
sdio_s_set_ds = 0x00003a14;
|
||||
hgusb20_clear_ep = 0x00006e70;
|
||||
sys_aes_init = 0x00007d10;
|
||||
fabs = 0x000001a8;
|
||||
disable_wphy_device_cont_tx = 0x0000618c;
|
||||
config_wphy_device_dpd_coef = 0x00006300;
|
||||
sys_aes_key_bitlen_sel = 0x00007cec;
|
||||
ll_simple_spi_init = 0x0000a674;
|
||||
hgusb20_irq_dma = 0x00007734;
|
||||
fw_upg_addr = 0x2005247c;
|
||||
crc16_modbus_calc = 0x00003018;
|
||||
close_wphy = 0x0000adb0;
|
||||
ll_iic_slave_rx = 0x0000828c;
|
||||
hgusb20_wifi_reset = 0x00007a8c;
|
||||
ll_crc_start = 0x00006afc;
|
||||
ll_m2m_memcpy = 0x000082fc;
|
||||
os_critical_close = 0x00001b2c;
|
||||
hgusb20_irq_set = 0x00007678;
|
||||
printf = 0x00001080;
|
||||
stdout = 0x20052420;
|
||||
ll_sdio_s_tx_kick = 0x000092f0;
|
||||
hgusb20_ep0_clrrx_pkt0 = 0x00006d30;
|
||||
uart_s_set_speed = 0x000042b4;
|
||||
get_wphy_device_avg_evm = 0x00006164;
|
||||
tbl_usb_language_id = 0x0000e06c;
|
||||
sdio_s_tx = 0x00003ab4;
|
||||
config_phy_tx_norm_mode = 0x0000ae6c;
|
||||
get_wphy_device_gfsk_tx_crc = 0x000063c4;
|
||||
ll_wdt_feed = 0x000064d4;
|
||||
ll_timer_ir_enable = 0x00007c64;
|
||||
ll_spi_buf_rx = 0x00007fd4;
|
||||
spiflash_boot = 0x00005eb8;
|
||||
md5_vector = 0x0000bc3c;
|
||||
ll_clock_syspll_config = 0x0000961c;
|
||||
ll_clock_hirc_enable = 0x00009370;
|
||||
fw_upg_blk_addr = 0x20052480;
|
||||
ll_uart_init = 0x00006860;
|
||||
tbl_usb_str_manufacturer = 0x0000e070;
|
||||
spi_cfg = 0x0000debc;
|
||||
strerror = 0x00002d48;
|
||||
config_phy_tx_sine_mode = 0x0000ae2c;
|
||||
ll_spi_config = 0x00007d88;
|
||||
hgwphy_bgn_attach = 0x0000b18c;
|
||||
qspi_flash_port_deinit = 0x00004df8;
|
||||
usb20 = 0x2004768c;
|
||||
ll_sys_clock_globle_set = 0x0000abfc;
|
||||
ll_m2m_memset = 0x00008320;
|
||||
hgusb20_ep0_clr_feature = 0x00006fdc;
|
||||
sdio_boot = 0x20052468;
|
||||
ll_tk_stop = 0x0000a664;
|
||||
hgusb20_dev_reset = 0x00006f1c;
|
||||
ll_gpio_iomap_output_config = 0x0000650c;
|
||||
get_wphy_device_rx_gain_para = 0x00006374;
|
||||
ll_sdio_s_irq_config = 0x0000925c;
|
||||
atol = 0x000014f4;
|
||||
ll_iic_master_tx = 0x00008190;
|
||||
ll_simple_uart_init = 0x0000a6f0;
|
||||
hgusb20_stall_ep = 0x00006df0;
|
||||
tbl_winusb_device_descriptor = 0x0000e1ac;
|
||||
ll_clock_set_sys_clk_src = 0x000093c4;
|
||||
ll_sys_clock_init = 0x0000abb8;
|
||||
hgusb20_ep0_get_status = 0x00006f64;
|
||||
config_dpd = 0x0000afb0;
|
||||
SHA1Update = 0x0000cbd8;
|
||||
ll_gmac_get_tx_frame_status = 0x00008cac;
|
||||
ll_qspi_controller_init = 0x00009224;
|
||||
sha256_init = 0x0000cee0;
|
||||
errno = 0x200524d0;
|
||||
open_wphy = 0x0000ace8;
|
||||
hgusb20_dev_init = 0x00006d88;
|
||||
ll_qspi_set_prefetch = 0x00009170;
|
||||
ll_gpio_pull_config = 0x00006680;
|
||||
tbl_winusb_compatible_id_feature_descriptor = 0x0000e184;
|
||||
get_wphy_avg_evm = 0x0000aea4;
|
||||
ll_spi_dma_start = 0x00007e7c;
|
||||
uart_s_rx = 0x0000431c;
|
||||
CORE_SEC_OPT = 0x0000932c;
|
||||
trig_calc_bk_noise = 0x0000b0d4;
|
||||
sha256_done = 0x0000cff0;
|
||||
spi_boot = 0x20052674;
|
||||
freq_offset_sign_ext = 0x0000b178;
|
||||
sys_aes_start = 0x00007d2c;
|
||||
SHA1Init = 0x0000cba8;
|
||||
ll_tk_ch_kick = 0x0000a658;
|
||||
ll_iic_master_rx = 0x000081c8;
|
||||
spi_s_tx = 0x00003e8c;
|
||||
enable_auto_sig_err_rst = 0x0000af9c;
|
||||
qspi_flash_poweroff = 0x00004ec8;
|
||||
fwinfo_check_fwinfo_hdr = 0x000044f8;
|
||||
hgusb20_irq_handler_set = 0x00007658;
|
||||
ll_iic_master_buf_tx = 0x00008218;
|
||||
ll_spi_dma_config = 0x00007e54;
|
||||
config_wphy_device_en_gfsk_wphy = 0x000063b0;
|
||||
memcpy = 0x00001908;
|
||||
hgusb20_ep0_set_feature = 0x00007020;
|
||||
sys_aes_get_pending = 0x00007cfc;
|
||||
atcmd_fwupg = 0x0000d8e0;
|
||||
ll_m2m_dma_init = 0x000082a4;
|
||||
fw_upg_prepare = 0x00004534;
|
||||
tbl_winusb20_wcidbos = 0x0000e160;
|
||||
spiflash_read = 0x00005ab0;
|
||||
ll_qspi_set_write_protect = 0x00009130;
|
||||
puts = 0x000010b8;
|
||||
hgusb20_ep0_set_configuration = 0x00007294;
|
||||
ll_tk_config = 0x0000a584;
|
||||
sys_aes_set_irq = 0x00007cb0;
|
||||
hgusb20_ep0_get_wcid_descriptor = 0x00007360;
|
||||
ll_gmac_start = 0x00008684;
|
||||
crc16_modbus_cfg = 0x0000d870;
|
||||
ll_iis_disable = 0x0000848c;
|
||||
hgusb20_ep0_func = 0x000074ec;
|
||||
ll_clock_test_clk_en = 0x00009350;
|
||||
ll_iic_irq_config = 0x000080c0;
|
||||
get_wphy_device_rx_gfsk_gain_para = 0x00006388;
|
||||
hgusb20_reset2device_mode = 0x00006b38;
|
||||
ll_gpio_analog_config = 0x000064ec;
|
||||
hgusb20_ep0_descriptor = 0x00007150;
|
||||
hgusb20_dev_rx = 0x000048a0;
|
||||
ll_suptmr_deinit = 0x00009ed4;
|
||||
strtoll = 0x00001518;
|
||||
ll_qspi_cmd_quad_enable = 0x00008e74;
|
||||
crc32_calc = 0x0000303c;
|
||||
ll_gmac_init = 0x00008504;
|
||||
qspi_flash_power_reset = 0x00004ef0;
|
||||
disable_wphy = 0x0000acb4;
|
||||
xmodem_receive = 0x00004ac0;
|
||||
strtoul = 0x00001198;
|
||||
ll_iic_master_buf_rx = 0x0000825c;
|
||||
config_wphy_device_cca_th = 0x00006224;
|
||||
adj_gain_value = 0x0000afc0;
|
||||
ll_gmac_send_frame = 0x00008a7c;
|
||||
ll_ir_timer_irq_config = 0x00007afc;
|
||||
hgusb20_switch_stable_device = 0x00006bc4;
|
||||
get_wphy_err_code = 0x0000aeb0;
|
||||
ll_led_timer_deinit = 0x00009da8;
|
||||
uart_s_tx = 0x000042ec;
|
||||
ll_iis_soft_rst = 0x00008494;
|
||||
isspace = 0x0000106c;
|
||||
boot = 0x200524d8;
|
||||
ll_crc_init = 0x00006a98;
|
||||
ll_spi_set_wire_mode = 0x00007e88;
|
||||
get_wphy_device_gfsk_rx_crc = 0x000063dc;
|
||||
ll_simple_spi_deinit = 0x0000a67c;
|
||||
ll_gmac_irq_config = 0x00008600;
|
||||
config_phy_tx_waveform_mode = 0x0000b158;
|
||||
ll_timer_deinit = 0x00007a98;
|
||||
sdio_slave_init = 0x00003d18;
|
||||
enable_wphy_device = 0x00006114;
|
||||
ll_crc_deinit = 0x00006ab4;
|
||||
usb_irq_ids = 0x200524a4;
|
||||
usb_test_mode_tbl = 0x0000df98;
|
||||
hgusb20_ep_set_txrdy = 0x00007998;
|
||||
strncasecmp = 0x00004c3c;
|
||||
ll_simple_uart_irq_config = 0x0000a708;
|
||||
sha256_vector = 0x0000d0e8;
|
||||
ll_clock_set_apb0_div = 0x000093fc;
|
||||
ll_timer_sync_start = 0x00007c7c;
|
||||
MD5Final = 0x0000bbc4;
|
||||
sdio_port_init = 0x00003b18;
|
||||
hgusb20_ep0_tx = 0x00006cb4;
|
||||
qspi_flash_deinit = 0x0000503c;
|
||||
config_wphy_device_gfsk_crc_init = 0x000063f4;
|
||||
ll_spi_deinit = 0x00007d7c;
|
||||
tbl_winusb20_wcid_descriptor_set = 0x0000e0bc;
|
||||
tbl_winusb_device_interface_guids = 0x0000e1c0;
|
||||
Te0 = 0x0000e8f8;
|
||||
ll_qspi_cmd_enter_qpi_mode = 0x00008eec;
|
||||
ll_ir_timer_config = 0x00007bd8;
|
||||
strtol = 0x00001298;
|
||||
crc32_cfg = 0x0000d88c;
|
||||
usb_test_packet = 0x0000dfa0;
|
||||
ll_spi_buf_tx = 0x00007f54;
|
||||
adj_gfsk_gain_value = 0x0000affc;
|
||||
ll_gmac_config = 0x00008554;
|
||||
uart_s_set_ds = 0x000042cc;
|
||||
config_cca_th = 0x0000af60;
|
||||
cfg_wphy_gfsk_ch = 0x0000b0c4;
|
||||
hgusb20_irq = 0x00007798;
|
||||
ll_uart_deinit = 0x00006874;
|
||||
spiflash_init = 0x000058a4;
|
||||
tbl_usb_str_serial_number = 0x0000e09c;
|
||||
cfg_wphy_gfsk_crc_init = 0x0000b0b4;
|
||||
get_wphy_device_tx_psdu_crc = 0x0000629c;
|
||||
strtod = 0x00001b6c;
|
||||
ll_suptmr_comm_config = 0x00009eec;
|
||||
spiflash_deinit = 0x000059b0;
|
||||
spi_s_rx_len_exp = 0x20052478;
|
||||
ll_gmac_setup_send_frame = 0x00008af8;
|
||||
ll_gpio_iomap_input_config = 0x0000655c;
|
||||
atof = 0x0000150c;
|
||||
ll_iic_dma_config = 0x00008154;
|
||||
disable_rx_agc = 0x0000af28;
|
||||
disable_auto_sig_err_rst = 0x0000af88;
|
||||
disable_gfsk_wphy = 0x0000b068;
|
||||
config_wphy_device_gfsk_ch = 0x00006408;
|
||||
sdio_s_rx = 0x00003ac4;
|
||||
ll_tk_sf_kick = 0x0000a638;
|
||||
strcat = 0x000018ec;
|
||||
ll_spi_irq_config = 0x00007dfc;
|
||||
hgusb20_init = 0x0000762c;
|
||||
sys_aes_set_mode = 0x00007cc4;
|
||||
adjust_wphy_device_gain_value = 0x00006328;
|
||||
tbl_usb_str_product = 0x0000e080;
|
||||
ll_tk_deinit = 0x0000a53c;
|
||||
sha256_process = 0x0000cf30;
|
||||
get_rx_freq_offset = 0x0000aed0;
|
||||
config_phy_tx_tri_mode = 0x0000ae4c;
|
||||
tbl_usb_config_all_descriptor_wifi = 0x0000e040;
|
||||
config_wphy_device_tx_tri_mode = 0x00006244;
|
||||
hgusb20_bot_reset = 0x00006ee0;
|
||||
sdio_rx_len_exp = 0x20052470;
|
||||
Td0 = 0x0000e3f8;
|
||||
ll_sdio_s_rx_kick = 0x00009320;
|
||||
ll_led_timer_init = 0x00009d9c;
|
||||
os_critical_enter = 0x00001b24;
|
||||
fw_upg_program = 0x00004578;
|
||||
ll_timer_ir_set_code_0 = 0x00007c74;
|
||||
sdio_s_set_speed = 0x00003aa8;
|
||||
ll_gpio_pin_lock_config = 0x00006810;
|
||||
ll_clock_exosc_enable = 0x00009398;
|
||||
uart_s_xfer_done = 0x20052488;
|
||||
soft_dereset_phy = 0x0000ac74;
|
||||
ll_timer_ir_disable = 0x00007c6c;
|
||||
sys_aes_set_block_num = 0x00007ca4;
|
||||
ll_uart_work_mode_change = 0x00006a84;
|
||||
memchr = 0x00001ae8;
|
||||
ll_qspi_cmd_device_reset = 0x00008fb8;
|
||||
stdin = 0x20052440;
|
||||
ll_spi_tx = 0x00007ef0;
|
||||
enable_rx_agc = 0x0000af3c;
|
||||
ll_spi_set_clock_mode = 0x00007ec4;
|
||||
delay_ms_systick = 0x0000aae8;
|
||||
qspi_flash_port_init = 0x00004d54;
|
||||
rand = 0x00001170;
|
||||
ll_uart_dma_config = 0x00006a34;
|
||||
ll_gmac_get_rx_frame_status = 0x00008cc4;
|
||||
enable_gfsk_wphy = 0x0000b03c;
|
||||
SysTickCnt = 0x200524bc;
|
||||
ll_gpio_iomap_inout_config = 0x000065fc;
|
||||
get_wphy_scrambler_init = 0x0000ae8c;
|
||||
enable_wphy_cont_tx = 0x0000acb8;
|
||||
ll_timer_config = 0x00007b3c;
|
||||
isupper = 0x00001b04;
|
||||
qspi_flash_init = 0x00004f20;
|
||||
ll_iic_dma_start = 0x00008184;
|
||||
ll_timer_irq_config = 0x00007a9c;
|
||||
ll_timer_start = 0x00007c54;
|
||||
ll_crc_stop = 0x00006b30;
|
||||
ll_led_config = 0x00009c24;
|
||||
hgusb20_wifi_init = 0x000079c4;
|
||||
ll_sdio_s_config = 0x00009264;
|
||||
sdio_interrupt_handle = 0x00003c54;
|
||||
ll_led_timer_irq_config = 0x00009e24;
|
||||
ll_qspi_set_clk = 0x000091a8;
|
||||
strcasecmp = 0x00004bf8;
|
||||
get_wphy_device_err_code = 0x000061b4;
|
||||
ll_iis_dma_config = 0x00008470;
|
||||
spi_base_pins = 0x0000de84;
|
||||
get_rx_gain_para = 0x0000afd8;
|
||||
hgusb20_wifi_ep_init = 0x000079c8;
|
||||
qspi_flash_poweron = 0x00004ea0;
|
||||
ll_gmac_mdio_read = 0x000088b4;
|
||||
ll_crc_config = 0x00006ab8;
|
||||
hgusb20_ep0_clrrx_contious = 0x00006d04;
|
||||
os_critical_exit = 0x00001b28;
|
||||
ll_iis_config = 0x0000835c;
|
||||
get_wphy_device_scrambler_init = 0x00006134;
|
||||
memcmp = 0x0000199c;
|
||||
hgusb20_ep0_get_descriptor = 0x0000719c;
|
||||
ll_qspi_cmd_release_power_down = 0x00009020;
|
||||
ll_gmac_mdio_write = 0x000086cc;
|
||||
adjust_wphy_device_gfsk_gain_value = 0x00006340;
|
||||
crc16_xmodem = 0x00004a90;
|
||||
isalpha = 0x00001b0c;
|
||||
ll_timer_init = 0x00007a94;
|
||||
disable_wphy_device = 0x00006124;
|
||||
crc8_calc = 0x00002ff4;
|
||||
config_wphy_device_tx_sine_mode = 0x00006234;
|
||||
ll_tk_init = 0x0000a520;
|
||||
delay_us = 0x0000aa3c;
|
||||
_ctype = 0x0000dd84;
|
||||
hgusb20_ep_rx_kick = 0x00007898;
|
||||
ll_gmac_deinit = 0x000085c8;
|
||||
disable_wphy_cont_tx = 0x0000acc8;
|
||||
enable_wphy_device_auto_sig_err_rst = 0x000062c4;
|
||||
ll_gmac_stop = 0x00008694;
|
||||
strtoull = 0x000013b8;
|
||||
disable_wphy_device_auto_sig_err_rst = 0x000062d8;
|
||||
rijndaelKeySetupEnc = 0x0000d17c;
|
||||
get_tx_psdu_crc16 = 0x0000acac;
|
||||
ll_iic_slave_tx = 0x00008298;
|
||||
config_wphy_rx_max_gain_state = 0x00006214;
|
||||
memset = 0x00001740;
|
||||
ll_suptmrx_config = 0x0000a02c;
|
||||
ll_m2m_dma_config = 0x000082e8;
|
||||
ll_m2m_dma_irq_config = 0x000082ec;
|
||||
ll_uart232_config = 0x000068fc;
|
||||
delay_ms = 0x0000aa68;
|
||||
hgusb20_ep0_request = 0x000074a8;
|
||||
ll_wdt_stop = 0x000064dc;
|
||||
close_wphy_device = 0x00006090;
|
||||
open_wphy_device = 0x00006080;
|
||||
uart_s_boot = 0x000045d8;
|
||||
srand = 0x0000118c;
|
||||
hgusb20_dev_tx = 0x0000487c;
|
||||
atcmd_bootl = 0x0000d8d8;
|
||||
cp_mode = 0x00002e60;
|
||||
get_wphy_device_rx_freq_offset = 0x0000635c;
|
||||
soft_reset_wphy_device = 0x00006264;
|
||||
config_wphy_device_dpd = 0x000062ec;
|
||||
soft_dereset_wphy_device = 0x00006274;
|
||||
ll_wdt_start = 0x000064c4;
|
||||
ll_wdt_config = 0x00006474;
|
||||
ll_suptmr_init = 0x00009e88;
|
||||
ll_uart_rxdma_kick = 0x00006a64;
|
||||
ll_clock_sys_clk_select = 0x0000942c;
|
||||
hgusb20_int_init_b = 0x00006d60;
|
||||
Td4s = 0x0000e7f8;
|
||||
hgusb20_ep0_class = 0x0000742c;
|
||||
get_wphy_device_tx_crc = 0x0000619c;
|
||||
sdio_s_func1_cis = 0x200475d0;
|
||||
ll_clock_test_clk_sel = 0x0000935c;
|
||||
hgusb20_ep0_set_address = 0x0000708c;
|
||||
spi_s_set_speed = 0x00003f00;
|
||||
ll_iis_init = 0x00008344;
|
||||
strcmp = 0x00001668;
|
||||
ll_iic_init = 0x00008040;
|
||||
config_wphy_device_low_pwr_th = 0x000062b4;
|
||||
ll_iic_deinit = 0x0000804c;
|
||||
ll_iis_irq_config = 0x00008448;
|
||||
ll_iis_deinit = 0x00008350;
|
||||
sys_clock_cfg = 0x200524a8;
|
||||
flash_memory_init = 0x000043f4;
|
||||
cfg_phy_tx_gain = 0x0000ada4;
|
||||
ll_gmac_allow_send_frame = 0x00008a68;
|
||||
ll_gpio_afio_config = 0x00006618;
|
||||
ll_m2m_dma_deinit = 0x000082dc;
|
||||
ll_gpio_ospeed_config = 0x00006828;
|
||||
MD5Init = 0x0000baf8;
|
||||
ll_wdt_deinit = 0x000064b4;
|
||||
os_critical_open = 0x00001b20;
|
||||
strtof = 0x000014e8;
|
||||
sys_aes_set_key = 0x00007c90;
|
||||
hgusb20_config_desc_prepare = 0x00006bec;
|
||||
dev_register = 0x0000641c;
|
||||
ll_led_init = 0x00009bfc;
|
||||
get_wphy_avg_power = 0x0000ae98;
|
||||
stderr = 0x20052400;
|
||||
ll_ir_timer_dma_config = 0x00007c24;
|
||||
ll_clock_usb_clk_en = 0x00009778;
|
||||
ll_timer_stop = 0x00007c5c;
|
||||
ll_qspi_cmd_busy_wait = 0x00008d90;
|
||||
hgusb20_ep_set_rxrdy = 0x00007994;
|
||||
ll_clock_is_exist = 0x00009494;
|
||||
enable_wphy = 0x0000b154;
|
||||
MD5Update = 0x0000bb20;
|
||||
spi_s_set_ds = 0x00003f0c;
|
||||
config_rx_max_gain_state = 0x0000af50;
|
||||
enable_wphy_device_cont_tx = 0x0000617c;
|
||||
fputc = 0x0000a810;
|
||||
config_wphy_device_tx_norm_mode = 0x00006254;
|
||||
tbl_usb_config_all_descriptor_gen = 0x0000e034;
|
||||
ll_simple_uart_config = 0x0000a74c;
|
||||
spi_rx_buf = 0x00005a60;
|
||||
get_rx_gfsk_gain_para = 0x0000b018;
|
||||
tbl_usb_device_descriptor = 0x0000e058;
|
||||
ll_tk_irq_config = 0x0000a540;
|
||||
get_wphy_device_agc_info = 0x000061cc;
|
||||
sysctrl_qspi_get_src_clk = 0x0000a794;
|
||||
hgsdio20_s_func1_cis = 0x0000e27c;
|
||||
isdigit = 0x00001afc;
|
||||
SHA1Final = 0x0000cc68;
|
||||
ll_tk_data = 0x0000a66c;
|
||||
qspi_flash_bootload_code = 0x000054a4;
|
||||
get_wphy_device_avg_power = 0x0000614c;
|
||||
ll_timer_ir_set_code_1 = 0x00007c78;
|
||||
aes_decrypt_encrypt = 0x00004ca4;
|
||||
ll_simple_spi_irq_config = 0x0000a684;
|
||||
spi_s_rx = 0x00003ec0;
|
||||
config_wphy_device_dis_gfsk_wphy = 0x0000639c;
|
||||
ll_spi_set_sample_delay = 0x00007ed4;
|
||||
sdio_s_dummy_buf = 0x2004759c;
|
||||
ll_gmac_receive_frame = 0x00008bb8;
|
||||
config_wphy_device_rx_gain_tab = 0x00006204;
|
||||
ll_led_timer_config = 0x00009db4;
|
||||
ll_qspi_cmd_write_enable = 0x00008e30;
|
||||
enable_wphy_device_rx_agc = 0x000061f4;
|
||||
ll_clock_usbpll_config = 0x00009674;
|
||||
SHA1Transform = 0x0000bc94;
|
||||
hgsdio20_s_speed_list = 0x0000e2b4;
|
||||
ll_uart_irq_config = 0x0000687c;
|
||||
sys_aes_set_key_src = 0x00007cd8;
|
||||
ll_clock_syspll_set = 0x000094e0;
|
||||
ll_simple_spi_config = 0x0000a69c;
|
||||
soft_reset_phy = 0x0000ac8c;
|
||||
ll_gmac_has_received_frame = 0x00008a30;
|
||||
get_wphy_gfsk_tx_crc = 0x0000b094;
|
||||
ll_wdt_init = 0x00006470;
|
||||
ll_qspi_cmd_exit_qpi_mode = 0x00008f64;
|
||||
ll_tk_scan_kick = 0x0000a64c;
|
||||
atoi = 0x00001500;
|
||||
ll_crc_wait_done_pending = 0x00006b20;
|
||||
hgusb20_dev_set_speed = 0x00004870;
|
||||
config_low_pwr_th = 0x0000b12c;
|
||||
ll_qspi_cmd_flash_64kb_erase = 0x00009064;
|
||||
ll_gmac_get_setup_frame_status = 0x00008c94;
|
||||
hgsdio20_s_func0_cis = 0x0000e268;
|
||||
config_wphy_device_tx_gain = 0x00006314;
|
||||
spiflash_bootloader = 0x00005c8c;
|
||||
ll_uart485_config = 0x000069c4;
|
||||
ll_tk_hw_kick = 0x0000a62c;
|
||||
crc8_itu_cfg = 0x0000d8a8;
|
||||
strlen = 0x000017e0;
|
||||
__cskyvprintfprintf = 0x0000109c;
|
||||
get_rx_psdu_crc16 = 0x0000aca4;
|
||||
hgusb20_init_globle = 0x00006b34;
|
||||
sdio_s_func0_cis = 0x200475bc;
|
||||
get_wphy_device_rx_psdu_crc = 0x00006284;
|
||||
get_wphy_device_info = 0x000060a0;
|
||||
sys_aes_clear_pending = 0x00007d04;
|
||||
hgusb20_dev_set_ds = 0x0000486c;
|
||||
rcons = 0x0000ecf8;
|
||||
ll_gmac_delay = 0x000084f0;
|
||||
abs = 0x00001290;
|
||||
strchr = 0x00001988;
|
||||
get_wphy_tx_crc = 0x0000acd8;
|
||||
fputs = 0x00001124;
|
||||
cfg_dpd_coef = 0x0000ad78;
|
||||
ll_qspi_cmd_issue = 0x00008cd4;
|
||||
spi_read_cfg_nor = 0x0000dedc;
|
||||
hgusb20_ep_tx_kick = 0x00007918;
|
||||
ll_crc_continue = 0x00006b08;
|
||||
ll_clock_set_sys_clk_div = 0x000093e4;
|
||||
get_wphy_gfsk_rx_crc = 0x0000b0a4;
|
||||
hgusb20_ep0_transfer = 0x000070cc;
|
||||
ll_iic_config = 0x00008058;
|
||||
ll_simple_uart_deinit = 0x0000a6fc;
|
||||
get_bk_noise = 0x0000b0e4;
|
||||
__jpeg_htable = 0x0000fc00;
|
||||
get_wphy_agc_info = 0x0000aec4;
|
||||
hgusb20_wifi_xfer_reset = 0x00007868;
|
||||
debug_select_interface = 0x0000a7e8;
|
||||
sha1_vector = 0x0000cd2c;
|
||||
ll_spi_get_wire_mode = 0x00007ee8;
|
||||
hgusb20_ep0_standard = 0x000072d4;
|
||||
disable_wphy_device_rx_agc = 0x000061e4;
|
||||
sys_reset = 0x0000aac8;
|
||||
ll_iis_enable = 0x00008480;
|
||||
ll_clock_set_apb1_div = 0x00009414;
|
||||
ll_led_deinit = 0x00009c10;
|
||||
qspi_flash_boot = 0x000055c8;
|
||||
config_rx_gain_tab = 0x0000b100;
|
||||
get_core_clock = 0x0000aafc;
|
||||
BIN
project/utilities/sched_cfg
Normal file
BIN
project/utilities/sched_cfg
Normal file
Binary file not shown.
171
project/wifi.c
Normal file
171
project/wifi.c
Normal file
@@ -0,0 +1,171 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "hal/adc.h"
|
||||
#include "lib/rpc/cpurpc.h"
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/umac/ieee80211.h"
|
||||
#include "lib/lmac/lmac.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
__init static void sys_wifi_start_acs(void)
|
||||
{
|
||||
void *ops = NULL; //另外一个CPU处理
|
||||
struct lmac_acs_ctl acs_ctl;
|
||||
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_AP) {
|
||||
if (sys_cfgs.channel == 0) {
|
||||
acs_ctl.enable = 1;
|
||||
acs_ctl.scan_ms = WIFI_ACS_SCAN_TIME;;
|
||||
acs_ctl.chn_bitmap = WIFI_ACS_CHAN_LISTS;
|
||||
lmac_start_async_acs(ops, &acs_ctl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__init static void sys_wifi_parameter_init(void)
|
||||
{
|
||||
void *ops = NULL; //另外一个CPU处理
|
||||
lmac_set_rf_pwr_level(ops, WIFI_RF_PWR_LEVEL);
|
||||
#if WIFI_FEM_CHIP != LMAC_FEM_NONE
|
||||
lmac_fem_pin_func(1);
|
||||
lmac_set_fem(ops, WIFI_FEM_CHIP); //初始化FEM之后,不能进行RF档位选择!
|
||||
#endif
|
||||
lmac_set_rts(ops, WIFI_RTS_THRESHOLD);
|
||||
lmac_set_retry_cnt(ops, WIFI_TX_MAX_RETRY, WIFI_RTS_MAX_RETRY);
|
||||
lmac_set_supp_rate(ops, WIFI_TX_SUPP_RATE);
|
||||
lmac_set_mcast_dup_txcnt(ops, WIFI_MULICAST_RETRY);
|
||||
lmac_set_tx_duty_cycle(ops, WIFI_TX_DUTY_CYCLE);
|
||||
#if WIFI_SSID_FILTER_EN
|
||||
lmac_set_ssid_filter(ops, sys_cfgs.ssid, strlen(sys_cfgs.ssid));
|
||||
#endif
|
||||
#if WIFI_PREVENT_PS_MODE_EN
|
||||
lmac_set_prevent_ps_mode(ops, WIFI_PREVENT_PS_MODE_EN);
|
||||
#endif
|
||||
lmac_set_ps_no_frm_loss(ops, WIFI_PS_NO_FRM_LOSS_EN);
|
||||
|
||||
#ifdef RATE_CONTROL_SELECT
|
||||
lmac_rate_ctrl_type(ops, RATE_CONTROL_SELECT);
|
||||
#endif
|
||||
#if !WIFI_METER_TEST_EN
|
||||
uint8 gain_table[] = {
|
||||
125, 125, 100, 100, 80, 80, 56, 56, // NON HT OFDM
|
||||
125, 100, 100, 80, 80, 56, 56, 56, // HT
|
||||
80, 80, 80, 80, // DSSS
|
||||
};
|
||||
lmac_set_tx_modulation_gain(ops, gain_table, sizeof(gain_table));
|
||||
lmac_set_temperature_compesate_en(ops, WIFI_TEMPERATURE_COMPESATE_EN);
|
||||
#endif
|
||||
lmac_set_freq_offset_track_mode(ops, WIFI_FREQ_OFFSET_TRACK_MODE);
|
||||
|
||||
#if WIFI_HIGH_PRIORITY_TX_MODE_EN
|
||||
struct lmac_txq_param txq_max;
|
||||
struct lmac_txq_param txq_min;
|
||||
|
||||
txq_max.aifs = 0xFF; //不限制aifs
|
||||
txq_max.txop = 0xFFFF; //不限制txop
|
||||
txq_max.cw_min = 3; //cwmin最大值。如果觉得冲突太厉害,可以改大
|
||||
txq_max.cw_max = 511; //cwmax最大值。如果觉得冲突太厉害,可以改大
|
||||
lmac_set_edca_max(ops, &txq_max);
|
||||
lmac_set_tx_edca_slot_time(ops, 6); //6us是其他客户推荐的值
|
||||
lmac_set_nav_max(ops, 10*1000); //NAV最大限制为10ms
|
||||
|
||||
txq_min.aifs = 0;
|
||||
txq_min.txop = 100; //txop最小值限制为100
|
||||
txq_min.cw_min = 0;
|
||||
txq_min.cw_max = 0;
|
||||
lmac_set_edca_min(ops, &txq_min);
|
||||
#endif
|
||||
|
||||
#if WIFI_TX_AGG_EN == 0
|
||||
lmac_set_aggcnt(ops, 0);
|
||||
#endif
|
||||
#if WIFI_RX_AGG_EN == 0
|
||||
lmac_set_rx_aggcnt(ops, 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SLEEP
|
||||
void *bgn_dsleep_init(void *ops);
|
||||
bgn_dsleep_init(ops);
|
||||
#endif
|
||||
}
|
||||
|
||||
__init void sys_wifi_test_mode_init(void)
|
||||
{
|
||||
uint8 default_gain_table[] = { //gain默认值
|
||||
56, 56, 56, 56, 56, 56, 56, 56, //OFDM
|
||||
56, 56, 56, 56, 56, 56, 56, 56, //HT
|
||||
56, 56, 56, 56, //DSSS
|
||||
};
|
||||
|
||||
lmac_set_mac_addr(NULL, 0, sys_cfgs.mac);
|
||||
lmac_set_tx_modulation_gain(NULL, default_gain_table, sizeof(default_gain_table));
|
||||
#if WIFI_FEM_CHIP != LMAC_FEM_NONE
|
||||
lmac_fem_pin_func(1);
|
||||
lmac_set_fem(NULL, WIFI_FEM_CHIP); //初始化FEM之后,不能进行RF档位选择!
|
||||
#endif
|
||||
}
|
||||
|
||||
__init static void sys_wifi_ap_init(void)
|
||||
{
|
||||
ieee80211_iface_create_ap(WIFI_MODE_AP, IEEE80211_BAND_2GHZ);
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_AP) {
|
||||
wificfg_flush(WIFI_MODE_AP);
|
||||
ieee80211_conf_set_psdata_cnt(WIFI_MODE_AP, 100);
|
||||
ieee80211_iface_start(WIFI_MODE_AP);
|
||||
}
|
||||
}
|
||||
|
||||
__init static void sys_wifi_sta_init(void)
|
||||
{
|
||||
ieee80211_iface_create_sta(WIFI_MODE_STA, IEEE80211_BAND_2GHZ);
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_STA) {
|
||||
wificfg_flush(WIFI_MODE_STA);
|
||||
ieee80211_iface_start(WIFI_MODE_STA);
|
||||
}
|
||||
}
|
||||
|
||||
/* p2p功能需要使用 AP/STA 功能,p2p默认复用了AP/STA接口。
|
||||
如果需要同时使用AP/STA功能和p2p功能,则需要为 p2p 创建专用的ap/sta接口,WIFI_WORK_MODE为p2p添加定义
|
||||
*/
|
||||
__init static void sys_wifi_p2p_init(void)
|
||||
{
|
||||
#if WIFI_P2P_SUPPORT
|
||||
ieee80211_iface_create_ap(WIFI_MODE_AP, IEEE80211_BAND_2GHZ);
|
||||
//wificfg_flush(WIFI_MODE_AP);
|
||||
ieee80211_conf_set_mac(WIFI_MODE_AP, sys_cfgs.mac);
|
||||
ieee80211_iface_create_sta(WIFI_MODE_STA, IEEE80211_BAND_2GHZ);
|
||||
ieee80211_conf_stabr_table(WIFI_MODE_STA, 128, 10 * 60);
|
||||
//wificfg_flush(WIFI_MODE_STA);
|
||||
ieee80211_conf_set_mac(WIFI_MODE_STA, sys_cfgs.mac);
|
||||
ieee80211_iface_create_p2pdev(WIFI_MODE_P2P, IEEE80211_BAND_2GHZ, WIFI_MODE_AP, WIFI_MODE_STA);
|
||||
//wificfg_flush(WIFI_MODE_P2P);
|
||||
ieee80211_conf_set_mac(WIFI_MODE_P2P, sys_cfgs.mac);
|
||||
ieee80211_conf_set_ssid(WIFI_MODE_P2P, sys_cfgs.ssid);
|
||||
ieee80211_conf_set_keymgmt(WIFI_MODE_P2P, sys_cfgs.key_mgmt);
|
||||
ieee80211_conf_set_psk(WIFI_MODE_P2P, sys_cfgs.psk);
|
||||
ieee80211_iface_start(WIFI_MODE_P2P);
|
||||
#endif
|
||||
}
|
||||
|
||||
__init void sys_wifi_init(void)
|
||||
{
|
||||
sys_wifi_parameter_init();
|
||||
|
||||
ieee80211_deliver_init(16, 60);
|
||||
|
||||
#if WIFI_AP_SUPPORT
|
||||
sys_wifi_ap_init();
|
||||
#endif
|
||||
|
||||
#if WIFI_STA_SUPPORT
|
||||
sys_wifi_sta_init();
|
||||
#endif
|
||||
|
||||
#if WIFI_P2P_SUPPORT
|
||||
sys_wifi_p2p_init();
|
||||
#endif
|
||||
|
||||
sys_wifi_start_acs();
|
||||
}
|
||||
|
||||
116
project/wifi_pair.c
Normal file
116
project/wifi_pair.c
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "sys_config.h"
|
||||
#include "basic_include.h"
|
||||
#include "lib/rpc/cpurpc.h"
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
#include "lib/common/atcmd.h"
|
||||
#include "lib/umac/ieee80211.h"
|
||||
#include "lwip/etharp.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
/* WiFi配对 */
|
||||
#if SYS_WIFI_PAIR
|
||||
struct wifi_pair_status {
|
||||
uint8 pair_sucess;
|
||||
uint8 pair_mac[6];
|
||||
uint8 aid;
|
||||
uint8 ngo_ap;
|
||||
} wifi_pair;
|
||||
|
||||
#define WIFI_PAIR_MAGIC (0x1234)
|
||||
|
||||
void sys_wifi_pair_init()
|
||||
{
|
||||
ieee80211_pair_enable(WIFI_MODE_AP, WIFI_PAIR_MAGIC);
|
||||
ieee80211_pair_enable(WIFI_MODE_STA, WIFI_PAIR_MAGIC);
|
||||
}
|
||||
|
||||
|
||||
/* 参数:
|
||||
magic == 0 --- 停止配对
|
||||
magic == 1 --- 启动配对
|
||||
magic > 1 --- 启动配对,并修改magic (初始值为WIFI_PAIR_MAGIC)
|
||||
*/
|
||||
void sys_wifi_pair_start(uint8 ifidx, uint16 magic)
|
||||
{
|
||||
etharp_cleanup_netif(netif_find("w0")); //是否需要清空ARP?
|
||||
ieee80211_pairing(ifidx, magic);
|
||||
}
|
||||
|
||||
void sys_event_hdl_wifi_pair(uint32 event_id, uint32 data, uint32 priv)
|
||||
{
|
||||
switch (event_id) {
|
||||
case SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_PAIR_DONE):
|
||||
//配对成功,保存参数
|
||||
if (wifi_pair.pair_sucess) {
|
||||
ieee80211_conf_get_ssid(sys_cfgs.wifi_mode, sys_cfgs.ssid);
|
||||
ieee80211_conf_get_psk(sys_cfgs.wifi_mode, sys_cfgs.psk);
|
||||
sys_cfgs.key_mgmt = ieee80211_conf_get_keymgmt(sys_cfgs.wifi_mode);
|
||||
|
||||
if ((int32)data == 1 && sys_cfgs.wifi_mode == WIFI_MODE_STA) {
|
||||
os_printf(KERN_NOTICE"wifi pair done, NGO role AP!\r\n");
|
||||
sys_cfgs.wifi_mode = WIFI_MODE_AP;
|
||||
ieee80211_iface_stop(WIFI_MODE_STA); //stop STA
|
||||
wificfg_flush(WIFI_MODE_AP);
|
||||
ieee80211_iface_start(WIFI_MODE_AP); //switch to AP
|
||||
sys_cfgs.dhcpd_en = 1;
|
||||
sys_cfgs.dhcpc_en = 0;
|
||||
netcfg_flush();
|
||||
}
|
||||
|
||||
if ((int32)data == -1 && sys_cfgs.wifi_mode == WIFI_MODE_AP) {
|
||||
os_printf(KERN_NOTICE"wifi pair done, NGO role STA!\r\n");
|
||||
sys_cfgs.wifi_mode = WIFI_MODE_STA;
|
||||
ieee80211_iface_stop(WIFI_MODE_AP); //stop AP
|
||||
wificfg_flush(WIFI_MODE_STA);
|
||||
ieee80211_iface_start(WIFI_MODE_STA); //switch to STA.
|
||||
sys_cfgs.dhcpd_en = 0;
|
||||
sys_cfgs.dhcpc_en = 1;
|
||||
netcfg_flush();
|
||||
}
|
||||
|
||||
if (sys_cfgs.wifi_mode == WIFI_MODE_STA || data) {
|
||||
syscfg_save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32 sys_wifi_event_hdl_wifi_pair(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2)
|
||||
{
|
||||
int32 ret = 0;
|
||||
switch (evt) {
|
||||
case IEEE80211_EVENT_PAIR_START:
|
||||
wifi_pair.ngo_ap = 0;
|
||||
wifi_pair.pair_sucess = 0;
|
||||
os_memset(wifi_pair.pair_mac, 0, 6);
|
||||
os_printf(KERN_NOTICE"Pair Start\r\n");
|
||||
break;
|
||||
case IEEE80211_EVENT_PAIR_SUCCESS:
|
||||
wifi_pair.pair_sucess = 1;
|
||||
os_memcpy(wifi_pair.pair_mac, param1, 6); //对方的MAC地址
|
||||
os_printf(KERN_NOTICE"pair success with "MACSTR", AID:%d\r\n", MAC2STR(wifi_pair.pair_mac), param2);
|
||||
if(!wifi_pair.ngo_ap){ //STA端自动停止配对
|
||||
ieee80211_pairing(ifidx, 0); //自动停止配对
|
||||
}
|
||||
break;
|
||||
case IEEE80211_EVENT_PAIR_DONE:
|
||||
os_printf(KERN_NOTICE"pair DONE, ngo=%d\r\n", param2);
|
||||
sys_event_new(SYS_EVENT(SYS_EVENT_WIFI, SYSEVT_WIFI_PAIR_DONE), param2);
|
||||
break;
|
||||
case IEEE80211_EVENT_REQ_PAIR_AID: //只有AP才会产生此事件
|
||||
wifi_pair.ngo_ap = 1;
|
||||
ret = (wifi_pair.aid++) + 1;
|
||||
break;
|
||||
case IEEE80211_EVENT_PAIR_NGO:
|
||||
//配对角色协商事件,在此事件可以控制角色协商结果:详细信息请阅读"TXSDK_WiFi开发指南,4.1.30"
|
||||
// ret = 1; //协商结果:本机AP
|
||||
// ret = -1; //协商结果:本机做STA
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
233
project/wifi_pairled.c
Normal file
233
project/wifi_pairled.c
Normal file
@@ -0,0 +1,233 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "list.h"
|
||||
#include "dev.h"
|
||||
#include "devid.h"
|
||||
#include "osal/string.h"
|
||||
#include "osal/semaphore.h"
|
||||
#include "osal/mutex.h"
|
||||
#include "osal/irq.h"
|
||||
#include "osal/work.h"
|
||||
#include "osal/sleep.h"
|
||||
#include "osal/timer.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/uart.h"
|
||||
#include "lib/common/common.h"
|
||||
#include "lib/common/sysevt.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/syscfg/syscfg.h"
|
||||
#include "lib/lmac/lmac.h"
|
||||
#include "lib/skb/skbpool.h"
|
||||
#include "lib/atcmd/libatcmd.h"
|
||||
#include "lib/bus/xmodem/xmodem.h"
|
||||
#include "lib/net/skmonitor/skmonitor.h"
|
||||
#include "lib/net/dhcpd/dhcpd.h"
|
||||
#include "lib/umac/ieee80211.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#include "syscfg.h"
|
||||
|
||||
/* WiFi配对LED控制 */
|
||||
#if SYS_WIFI_PAIR_LED
|
||||
static struct os_work ledctrl_wk;
|
||||
static struct os_work pairkey_wk;
|
||||
|
||||
struct {
|
||||
uint8 init: 1, last_val: 1, def_val: 1;
|
||||
} sys_pairctrl;
|
||||
|
||||
struct {
|
||||
uint8 conn: 1, rssi1: 1, rssi2: 1, rssi3: 1, val: 1, init: 1, res: 1, pair: 1;
|
||||
uint8 wk_delay;
|
||||
} sys_ledctrl;
|
||||
|
||||
static int32 sys_pairkey_val(void)
|
||||
{
|
||||
int32 i, v;
|
||||
int32 v0 = 0, v1 = 0;
|
||||
|
||||
for (i = 0; i < 50; i++) {
|
||||
v = gpio_get_val(WIFI_PAIRKEY_IO);
|
||||
if (v) {
|
||||
v1++;
|
||||
} else {
|
||||
v0++;
|
||||
}
|
||||
}
|
||||
return (v1 > v0 ? 1 : 0);
|
||||
}
|
||||
|
||||
static int32 sys_pairled_work(struct os_work *work)
|
||||
{
|
||||
//init parameters
|
||||
if ((sys_ledctrl.init) == 0) {
|
||||
sys_ledctrl.init = 1;
|
||||
sys_ledctrl.wk_delay = 100;
|
||||
sys_ledctrl.val = 1;
|
||||
sys_ledctrl.pair = 0;
|
||||
gpio_set_dir(WIFI_RSSI_IO1, GPIO_DIR_OUTPUT);
|
||||
gpio_set_dir(WIFI_RSSI_IO2, GPIO_DIR_OUTPUT);
|
||||
gpio_set_dir(WIFI_RSSI_IO3, GPIO_DIR_OUTPUT);
|
||||
gpio_set_val(WIFI_RSSI_IO1, 0);
|
||||
gpio_set_val(WIFI_RSSI_IO2, 0);
|
||||
gpio_set_val(WIFI_RSSI_IO3, 0);
|
||||
}
|
||||
|
||||
if (!sys_ledctrl.pair) {
|
||||
//rssi led show, after connect and stop pair
|
||||
if (sys_ledctrl.conn) {
|
||||
gpio_set_val(WIFI_RSSI_IO1, sys_ledctrl.rssi1);
|
||||
gpio_set_val(WIFI_RSSI_IO2, sys_ledctrl.rssi2);
|
||||
gpio_set_val(WIFI_RSSI_IO3, sys_ledctrl.rssi3);
|
||||
} else {
|
||||
gpio_set_val(WIFI_RSSI_IO1, 0);
|
||||
gpio_set_val(WIFI_RSSI_IO2, 0);
|
||||
gpio_set_val(WIFI_RSSI_IO3, 0);
|
||||
}
|
||||
} else {
|
||||
//pair state
|
||||
gpio_set_val(WIFI_RSSI_IO1, 0);
|
||||
if (sys_ledctrl.val) {
|
||||
gpio_set_val(WIFI_RSSI_IO2, 1);
|
||||
gpio_set_val(WIFI_RSSI_IO3, 0);
|
||||
} else {
|
||||
gpio_set_val(WIFI_RSSI_IO2, 0);
|
||||
gpio_set_val(WIFI_RSSI_IO3, 1);
|
||||
}
|
||||
sys_ledctrl.val = !sys_ledctrl.val;
|
||||
}
|
||||
|
||||
os_run_work_delay(&ledctrl_wk, sys_ledctrl.wk_delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32 sys_pairkey_work(struct os_work *work)
|
||||
{
|
||||
int32 new_val;
|
||||
|
||||
if (!sys_pairctrl.init) {
|
||||
sys_pairctrl.init = 1;
|
||||
gpio_set_dir(WIFI_PAIRKEY_IO, GPIO_DIR_INPUT);
|
||||
gpio_set_mode(WIFI_PAIRKEY_IO, GPIO_PULL_UP, GPIO_PULL_LEVEL_4_7K);
|
||||
new_val = sys_pairkey_val();
|
||||
sys_pairctrl.def_val = new_val;
|
||||
sys_pairctrl.last_val = new_val;
|
||||
} else {
|
||||
new_val = sys_pairkey_val();
|
||||
if (new_val != sys_pairctrl.last_val) {
|
||||
if (new_val == sys_pairctrl.def_val) {
|
||||
ieee80211_pairing(sys_cfgs.wifi_mode, 0);
|
||||
} else {
|
||||
ieee80211_pairing(sys_cfgs.wifi_mode, 1);
|
||||
}
|
||||
sys_pairctrl.last_val = new_val;
|
||||
}
|
||||
}
|
||||
os_run_work_delay(&pairkey_wk, 100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 sys_wifi_event_hdl_pairled(uint8 ifidx, uint16 evt, uint32 param1, uint32 param2)
|
||||
{
|
||||
int32 ret = 0;
|
||||
switch (evt) {
|
||||
case IEEE80211_EVENT_CONNECTED:
|
||||
if (!sys_ledctrl.pair) {
|
||||
sys_ledctrl.conn = 1;
|
||||
sys_ledctrl.rssi1 = 1;
|
||||
sys_ledctrl.rssi2 = 1;
|
||||
sys_ledctrl.rssi3 = 1;
|
||||
}
|
||||
break;
|
||||
case IEEE80211_EVENT_DISCONNECTED:
|
||||
if (ifidx == WIFI_MODE_STA && !sys_ledctrl.pair) {
|
||||
sys_ledctrl.conn = 0;
|
||||
sys_ledctrl.rssi1 = 0;
|
||||
sys_ledctrl.rssi2 = 0;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
}
|
||||
break;
|
||||
case IEEE80211_EVENT_RSSI:
|
||||
if (ifidx == WIFI_MODE_STA && !sys_ledctrl.pair) {
|
||||
if ((int8)param1 > -48 && sys_ledctrl.conn) {
|
||||
sys_ledctrl.rssi1 = 1;
|
||||
sys_ledctrl.rssi2 = 1;
|
||||
sys_ledctrl.rssi3 = 1;
|
||||
} else if ((int8)param1 > -60 && sys_ledctrl.conn) {
|
||||
sys_ledctrl.rssi1 = 1;
|
||||
sys_ledctrl.rssi2 = 1;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
} else {
|
||||
sys_ledctrl.rssi1 = 0;
|
||||
sys_ledctrl.rssi2 = 0;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IEEE80211_EVENT_INTERFACE_DISABLE:
|
||||
sys_ledctrl.conn = 0;
|
||||
sys_ledctrl.rssi1 = 0;
|
||||
sys_ledctrl.rssi2 = 0;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
break;
|
||||
case IEEE80211_EVENT_INTERFACE_ENABLE:
|
||||
//rssi leds show all if mode is AP
|
||||
if (ifidx == WIFI_MODE_AP) {
|
||||
sys_ledctrl.conn = 1;
|
||||
sys_ledctrl.rssi1 = 1;
|
||||
sys_ledctrl.rssi2 = 1;
|
||||
sys_ledctrl.rssi3 = 1;
|
||||
}
|
||||
break;
|
||||
//rate of led overturn determined "sys_ledctrl.wk_delay" changes slowly,
|
||||
case IEEE80211_EVENT_PAIR_START:
|
||||
sys_ledctrl.pair = 1;
|
||||
sys_ledctrl.conn = 0;
|
||||
sys_ledctrl.rssi1 = 0;
|
||||
sys_ledctrl.rssi2 = 0;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
sys_ledctrl.wk_delay = 255;
|
||||
break;
|
||||
//wait for connect done, even though in pairkey lock state.
|
||||
//rate of led overturn determined "sys_ledctrl.wk_delay" changes fastly,
|
||||
case IEEE80211_EVENT_PAIR_SUCCESS:
|
||||
sys_ledctrl.wk_delay = 80;
|
||||
break;
|
||||
//wait for pairkey unlock
|
||||
case IEEE80211_EVENT_PAIR_DONE:
|
||||
if (ifidx == WIFI_MODE_AP) {
|
||||
sys_ledctrl.conn = 1;
|
||||
sys_ledctrl.rssi1 = 1;
|
||||
sys_ledctrl.rssi2 = 1;
|
||||
sys_ledctrl.rssi3 = 1;
|
||||
} else {
|
||||
sys_ledctrl.conn = 0;
|
||||
sys_ledctrl.rssi1 = 0;
|
||||
sys_ledctrl.rssi2 = 0;
|
||||
sys_ledctrl.rssi3 = 0;
|
||||
}
|
||||
|
||||
sys_ledctrl.pair = 0;
|
||||
sys_ledctrl.wk_delay = 100;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sys_wifi_pair_led_init(void)
|
||||
{
|
||||
OS_WORK_INIT(&ledctrl_wk, sys_pairled_work, 20);
|
||||
OS_WORK_INIT(&pairkey_wk, sys_pairkey_work, 0);
|
||||
os_run_work_delay(&ledctrl_wk, 100);
|
||||
os_run_work_delay(&pairkey_wk, 100);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user