first commit

This commit is contained in:
pvvx 2017-04-22 16:54:00 +03:00
commit fa343db334
154 changed files with 18186 additions and 0 deletions

97
project/src/user/main.c Normal file
View file

@ -0,0 +1,97 @@
/*
*
*/
#include "platform_autoconf.h"
#include "autoconf.h"
#include "FreeRTOS.h"
#include "task.h"
#include "diag.h"
#include "hal_crypto.h"
#include "hal_log_uart.h"
#include "hal_misc.h"
#include "diag.h"
//#include "wdt_api.h"
//#include <osdep_service.h>
#include "hal_platform.h"
#include "rtl8195a_sys_on.h"
#ifdef CONFIG_WDG_ON_IDLE
#include "hal_peri_on.h"
#include "rtl8195a_peri_on.h"
#endif
/* ---------------------------------------------------
* Customized Signature (Image Name)
* ---------------------------------------------------*/
#include "section_config.h"
SECTION(".custom.validate.rodata")
const unsigned char cus_sig[32] = "WEB Sample";
#ifdef CONFIG_DEBUG_LOG
#define DEBUG_MAIN_LEVEL CONFIG_DEBUG_LOG
#else
#define DEBUG_MAIN_LEVEL 0
#endif
#ifndef CONFIG_INIT_NET
#define CONFIG_INIT_NET 1
#endif
#ifndef CONFIG_INTERACTIVE_MODE
#define CONFIG_INTERACTIVE_MODE 1
#endif
extern void user_init_thrd(void);
/* RAM/TCM/Heaps info */
void ShowMemInfo(void)
{
DiagPrintf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
}
/* main */
void main(void)
{
#if DEBUG_MAIN_LEVEL > 3
ConfigDebugErr = -1;
ConfigDebugInfo = ~(_DBG_SPI_FLASH_);//|_DBG_TCM_HEAP_);
ConfigDebugWarn = -1;
CfgSysDebugErr = -1;
CfgSysDebugInfo = -1;
CfgSysDebugWarn = -1;
#endif
#ifdef CONFIG_WDG_ON_IDLE
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF);
#if CONFIG_DEBUG_LOG > 3
WDGInitial(CONFIG_WDG_ON_IDLE * 3000); // 30 s
#else
WDGInitial(CONFIG_WDG_ON_IDLE * 1000); // 10 s
#endif
WDGStart();
#endif
#if (defined(CONFIG_CRYPTO_STARTUP) && (CONFIG_CRYPTO_STARTUP))
if(rtl_cryptoEngine_init() != 0 ) {
DBG_8195A("Crypto engine init failed!\n");
}
#endif
#if DEBUG_MAIN_LEVEL > 1
vPortFree(pvPortMalloc(4)); // Init RAM heap
ShowMemInfo(); // RAM/TCM/Heaps info
#endif
/* wlan & user_start intialization */
xTaskCreate(user_init_thrd, "user_init", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
/*Enable Schedule, Start Kernel*/
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
#ifdef PLATFORM_FREERTOS
vTaskStartScheduler();
#endif
#else
RtlConsolTaskRom(NULL);
#endif
}

View file

@ -0,0 +1,77 @@
/*
* user_start.c
*
* Created on: 26/03/2017
* Author: pvvx
*/
#include "user_config.h"
#include "platform_autoconf.h"
#include "autoconf.h"
#include "FreeRTOS.h"
#include "task.h"
#include "diag.h"
#include "netbios/netbios.h"
#include "user/sys_cfg.h"
#include "web/web_srv.h"
#include "webfs/webfs.h"
struct SystemCfg syscfg = {
.cfg.w = SYS_CFG_DEBUG_ENA | SYS_CFG_NETBIOS_ENA,
#if defined(USE_WEB)
.web_port = USE_WEB,
#else
.web_port = 0,
#endif
.web_twrec = 5,
.web_twcls = 5
};
void connect_start(void)
{
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
}
void connect_close(void)
{
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
}
void user_start(void)
{
info_printf("\%s: Time at start %d ms.\n", __func__, xTaskGetTickCount());
}
void sys_write_cfg(void)
{
flash_write_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg));
}
void user_init_thrd(void) {
flash_read_cfg(&syscfg, FEEP_ID_SYS_CFG, sizeof(syscfg));
if(!syscfg.cfg.b.debug_print_enable) print_off = 1;
/* Initilaize the console stack */
console_init();
/* Web Disk Init */
WEBFSInit();
/* Load cfg, init WiFi + LwIP init, WiFi start if wifi_cfg.mode != RTW_MODE_NONE */
wifi_init();
if(syscfg.cfg.b.netbios_ena) netbios_init();
// webstuff_init(); // httpd_init();
webserver_init(syscfg.web_port);
// xTaskCreate(x_init_thrd, "wifi_init", 1024, NULL, tskIDLE_PRIORITY + 1 + PRIORITIE_OFFSET, NULL);
/* Kill init thread after all init tasks done */
vTaskDelete(NULL);
}