add WDT, new console, ...

This commit is contained in:
pvvx 2017-02-28 10:39:37 +03:00
parent e851661fa4
commit de57c04fb4
21 changed files with 3158 additions and 2639 deletions

View file

@ -2753,6 +2753,9 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
{
mtCOVERAGE_TEST_MARKER();
}
#ifdef CONFIG_WDG_ON_IDLE
WDGRefresh();
#endif
}
#endif /* configUSE_TICKLESS_IDLE */
}
@ -3641,7 +3644,7 @@ TCB_t *pxTCB;
/* What percentage of the total run time has the task used?
This will always be rounded down to the nearest integer.
ulTotalRunTimeDiv100 has already been divided by 100. */
#if 0
#if 1
ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime;
#else
ulStatsAsPercentage = (100*pxTaskStatusArray[ x ].ulDelataRunTimeCounterOfPeroid) / ulDeltaTotalRunTime;
@ -3651,25 +3654,30 @@ TCB_t *pxTCB;
else
ulDeltaRunTimeCounter = portCONFIGURE_STATS_PEROID_VALUE*ulStatsAsPercentage/100;
#endif
int cnt = sprintf( pcWriteBuffer, "%s", pxTaskStatusArray[ x ].pcTaskName);
pcWriteBuffer += cnt;
while(cnt < configMAX_TASK_NAME_LEN) {
cnt++;
*pcWriteBuffer++ = ' ';
}
if( ulStatsAsPercentage > 0UL )
{
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
#if 0
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
#if 1
sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
#else
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\n", pxTaskStatusArray[ x ].pcTaskName, ulDeltaRunTimeCounter, ulStatsAsPercentage );
sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\n", ulDeltaRunTimeCounter, ulStatsAsPercentage );
#endif
}
#else
{
/* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */
#if 0
sprintf( pcWriteBuffer, "%s\t\t%u\t\t%u%%\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
#if 1
sprintf( pcWriteBuffer, "\t%lu\t\t%u%%\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
#else
sprintf( pcWriteBuffer, "%s\t\t%u\t\t%u%%\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) ulDeltaRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
sprintf( pcWriteBuffer, "\t%u\t\t%u%%\n", ( unsigned int ) ulDeltaRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
#endif
}
#endif
@ -3680,20 +3688,20 @@ TCB_t *pxTCB;
consumed less than 1% of the total run time. */
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{
#if 0
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
#if 1
sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\n", pxTaskStatusArray[ x ].ulRunTimeCounter );
#else
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\n", pxTaskStatusArray[ x ].pcTaskName, ulDeltaRunTimeCounter );
sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\n", ulDeltaRunTimeCounter );
#endif
}
#else
{
/* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */
#if 0
sprintf( pcWriteBuffer, "%s\t\t%u\t\t<1%%\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );
#if 1
sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );
#else
sprintf( pcWriteBuffer, "%s\t\t%u\t\t<1%%\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) ulDeltaRunTimeCounter );
sprintf( pcWriteBuffer, "\t%u\t\t<1%%\n", ( unsigned int ) ulDeltaRunTimeCounter );
#endif
}
#endif

View file

@ -89,6 +89,32 @@ prvDiagSPrintf(
IN const char *fmt, ...
);
#if CONFIG_DEBUG_LOG > 3
#define debug_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define info_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#elif CONFIG_DEBUG_LOG > 2
#define debug_printf(fmt, ...)
#define info_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#elif CONFIG_DEBUG_LOG > 1
#define debug_printf(fmt, ...)
#define info_printf(fmt, ...)
#define warning_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#elif CONFIG_DEBUG_LOG > 0
#define debug_printf(fmt, ...)
#define info_printf(fmt, ...)
#define warning_printf(fmt, ...)
#define error_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
#else
#define debug_printf(fmt, ...)
#define info_printf(fmt, ...)
#define warning_printf(fmt, ...)
#define error_printf(fmt, ...)
#endif
#define _DbgDump DiagPrintf

View file

@ -624,6 +624,7 @@ SECTIONS
rom_wps_rcons = 0x35d88;
rom_wps_Td4s = 0x35d94;
rom_wps_Td0 = 0x35e94;
str_rom_hex_addr = 0x442D6;
__rom_b_cut_end__ = 0x4467c;
__rom_c_cut_text_start__ = 0x4467c;
HalInitPlatformLogUartV02 = 0x4467d;

View file

@ -150,8 +150,14 @@ SECTIONS
LONG(__sdram_heap_end__ - __sdram_heap_start__)
LONG(0)
LONG(0)
UartLogRamCmdTable = .;
KEEP(*(SORT(.mon.tab*)))
UartLogRamCmdTable_end = .;
LONG(0)
} > BD_RAM
PROVIDE(UartLogRamCmdTableSize = UartLogRamCmdTable_end - UartLogRamCmdTable);
.ram.data :
{
__data_start__ = .;

View file

@ -230,7 +230,7 @@ RtlConsolInitRam(
pUartLogCtl->TaskRdy = 0;
#ifdef PLATFORM_FREERTOS
#define LOGUART_STACK_SIZE 200 //USE_MIN_STACK_SIZE modify from 512 to 128
#if CONFIG_USE_TCM_HEAP
#if 0 //CONFIG_USE_TCM_HEAP
{
int ret = 0;
void *stack_addr = tcm_heap_malloc(LOGUART_STACK_SIZE*sizeof(int));
@ -249,13 +249,13 @@ RtlConsolInitRam(
NULL);
if (pdTRUE != ret)
{
DiagPrintf("Create Log UART Task Err!!\n");
DiagPrintf("Create Log UART Task Err!\n");
}
}
#else
if (pdTRUE != xTaskCreate( RtlConsolTaskRam, (const signed char * const)"log_uart", LOGUART_STACK_SIZE, NULL, tskIDLE_PRIORITY + 5 + PRIORITIE_OFFSET, NULL))
{
DiagPrintf("Create Log UART Task Err!!\n");
DiagPrintf("Create Log UART Task Err!\n");
}
#endif
@ -312,6 +312,10 @@ RtlConsolTaskRam(
{
#if SUPPORT_LOG_SERVICE
log_service_init();
#else
#ifdef CONFIG_AT_USR
at_user_init();
#endif
#endif
//4 Set this for UartLog check cmd history
#ifdef CONFIG_KERNEL

View file

@ -29,17 +29,16 @@
#define UART_LOG_CMD_BUFLEN 127
#define MAX_ARGV 10
extern COMMAND_TABLE UartLogRomCmdTable[6]; // in ROM (hal_diag.h)
typedef u32 (*ECHOFUNC)(IN u8*,...); //UART LOG echo-function type.
typedef struct _UART_LOG_BUF_ {
u8 BufCount; //record the input cmd char number.
u8 BufCount; //record the input cmd char number.
u8 UARTLogBuf[UART_LOG_CMD_BUFLEN]; //record the input command.
} UART_LOG_BUF, *PUART_LOG_BUF;
typedef struct _UART_LOG_CTL_ {
u8 NewIdx; //+0x00
u8 SeeIdx; //+0x01
@ -49,19 +48,17 @@ typedef struct _UART_LOG_CTL_ {
u8 ExecuteEsc; //+0x05
u8 BootRdy; //+0x06
u8 Resvd; //+0x07
PUART_LOG_BUF pTmpLogBuf;
VOID *pfINPUT;
PCOMMAND_TABLE pCmdTbl;
u32 CmdTblSz;
PUART_LOG_BUF pTmpLogBuf; //+0x08 = UartLogBuf
VOID *pfINPUT; //+0x0C = DiagPrintf
PCOMMAND_TABLE pCmdTbl; //+0x10
u32 CmdTblSz; //+0x14
#ifdef CONFIG_UART_LOG_HISTORY
u32 CRSTS;
#endif
#ifdef CONFIG_UART_LOG_HISTORY
u8 (*pHistoryBuf)[UART_LOG_CMD_BUFLEN];
u32 CRSTS; //+0x18
u8 (*pHistoryBuf)[UART_LOG_CMD_BUFLEN]; //+0x1C UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN]
#endif
#ifdef CONFIG_KERNEL
u32 TaskRdy;
_Sema Sema;
u32 TaskRdy; //+0x20
_Sema Sema; //+0x24
#else
// Since ROM code will reference this typedef, so keep the typedef same size
u32 TaskRdy;
@ -128,6 +125,8 @@ Strtoul(
IN u32 base
);
_LONG_CALL_ extern VOID UartLogIrqHandle(VOID * Data); // in ROM
void console_init(void);
extern _LONG_CALL_ROM_ int GetArgc(const u8 *string);

View file

@ -203,6 +203,8 @@
#define MON_RAM_BSS_SECTION \
SECTION(".mon.ram.bss")
#define MON_RAM_TAB_SECTION \
SECTION(".mon.tab.rodata")
//3 SDIO Section
#define SECTION_SDIO_RAM

View file

@ -39,7 +39,7 @@ void test_sha1(void)
if ( rtl_memcmpb((void*)digest, (void*)&sha1_test_digest[i][0], 20) == 0 )
DiagPrintf("SHA1 test result is correct, ret=%d\r\n", ret);
else
DiagPrintf("SHA test result is WRONG!!, ret=%d\r\n", ret);
DiagPrintf("SHA test result is WRONG!, ret=%d\r\n", ret);
}
}
//static const u8 plaintext[] = "The quick brown fox jumps over the lazy dog";
@ -144,7 +144,7 @@ void test_md5(void)
if ( rtl_memcmpb(digest, md5_digest, 16) == 0 ) {
DiagPrintf("MD5 test result is correct, ret=%d\r\n", ret);
} else {
DiagPrintf("MD5 test result is WRONG!!, ret=%d\r\n", ret);
DiagPrintf("MD5 test result is WRONG!, ret=%d\r\n", ret);
}
for( i = 0; i < 16; i++ )

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,7 @@
#define CONFIG_WDG 1
#undef CONFIG_WDG_NON
#define CONFIG_WDG_NORMAL 1
#define CONFIG_WDG_ON_IDLE 1 // add pvvx: wdt on -> main.c + tasks.c
#define CONFIG_GDMA_EN 1
#define CONFIG_GDMA_NORMAL 1
#undef CONFIG_GDMA_TEST

View file

@ -13,7 +13,7 @@
/**
* For AT cmd Log service configurations
*/
#define SUPPORT_LOG_SERVICE 1
#define SUPPORT_LOG_SERVICE 0
#if SUPPORT_LOG_SERVICE
#define LOG_SERVICE_BUFLEN 100 //can't larger than UART_LOG_CMD_BUFLEN(127)
#define CONFIG_LOG_HISTORY 0

View file

@ -79,7 +79,7 @@ typedef struct _USR_server_setings
} mp3_server_setings;
extern mp3_server_setings mp3_serv;
extern void at_USR_init(void);
extern void start_init(void);
#endif // CONFIG_AT_USR

View file

@ -0,0 +1,332 @@
/*
* console_api.c
*
* Created on: 24/02/17
* Author: pvvx
*/
//======================================================
#define LOGUART_STACK_SIZE 400 // USE_MIN_STACK_SIZE modify from 512 to 128
#define CONSOLE_PRIORITY 1
//======================================================
#include "rtl8195a.h"
#include "rtl_bios_data.h"
#include "osdep_api.h"
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
#include "freertos_pmu.h"
#else
#error "Define configUSE_WAKELOCK_PMU = 1 & configUSE_WAKELOCK_PMU = 1!"
#endif
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
#else
#error "Define CONFIG_KERNEL & TASK_SCHEDULER_DISABLED = 0!"
#endif
#ifndef CONFIG_UART_LOG_HISTORY
#error "Define CONFIG_UART_LOG_HISTORY!"
#endif
//======================================================
// #define USE_ROM_CONSOLE
//======================================================
_LONG_CALL_ extern u8 UartLogCmdChk(
IN u8 RevData, IN UART_LOG_CTL *prvUartLogCtl,
IN u8 EchoFlag);
_LONG_CALL_ extern void ArrayInitialize(
IN u8 *pArrayToInit,
IN u8 ArrayLen,
IN u8 InitValue);
_LONG_CALL_ extern void UartLogHistoryCmd(
IN u8 RevData, IN UART_LOG_CTL *prvUartLogCtl,
IN u8 EchoFlag);
_LONG_CALL_ extern void UartLogCmdExecute(IN PUART_LOG_CTL pUartLogCtlExe);
//======================================================
extern PCOMMAND_TABLE UartLogRamCmdTable[];
extern UartLogRamCmdTableSize;
//======================================================
//<Function>: UartLogIrqHandleRam
//<Usage >: To deal with Uart-Log RX IRQ
//<Argus >: void
//<Return >: void
//<Notes >: NA
//======================================================
// overload original UartLogIrqHandle
MON_RAM_TEXT_SECTION
void UartLogIrqHandleRam(void * Data) {
uint32 IrqEn = DiagGetIsrEnReg(); // HAL_UART_READ32(UART_INTERRUPT_EN_REG_OFF)
DiagSetIsrEnReg(0); // HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, 0)
uint8 UartReceiveData = DiagGetChar(_FALSE); // if(flg) while(!(HAL_UART_READ32(UART_LINE_STATUS_REG_OFF)&1)); return HAL_UART_READ32(UART_REV_BUF_OFF);
if (UartReceiveData == 0) {
goto exit;
}
PUART_LOG_CTL p = pUartLogCtl;
//KB_ESC chk is for cmd history, it's a special case here.
if (UartReceiveData == KB_ASCII_ESC) {
// Esc detection is only valid in the first stage of boot sequence (few seconds)
if (p->ExecuteEsc != _TRUE) {
p->ExecuteEsc = _TRUE;
p->EscSTS = 0;
} else {
//4 the input commands are valid only when the task is ready to execute commands
if (p->BootRdy == 1 || p->TaskRdy == 1) {
if (p->EscSTS == 0) {
p->EscSTS = 1;
}
} else {
p->EscSTS = 0;
}
}
} else if (p->EscSTS == 1) {
if (UartReceiveData != KB_ASCII_LBRKT) { // '['
p->EscSTS = 0;
} else {
p->EscSTS = 2;
}
} else {
if (p->EscSTS == 2) {
p->EscSTS = 0;
if (UartReceiveData == 'A' || UartReceiveData == 'B') {
// if(UartReceiveData == ...) set pUartLogCtl->SeeIdx ...
// prvStrCpy(pUartLogCtl->pTmpLogBuf->UARTLogBuf, pUartLogCtl->pHistoryBuf[pUartLogCtl->SeeIdx]);
// pUartLogCtl->pTmpLogBuf->BufCount = prvStrLen(pUartLogCtl->pTmpLogBuf->UARTLogBuf);
// if(EchoFlag) pUartLogCtl->pfINPUT(pUartLogCtl->pTmpLogBuf->UARTLogBuf);
UartLogHistoryCmd(UartReceiveData, (UART_LOG_CTL *) pUartLogCtl,
1);
}
} else {
if (UartLogCmdChk(UartReceiveData, (UART_LOG_CTL *) pUartLogCtl, 1)
== 2) {
// check UartLog buffer to prevent from incorrect access
if (p->pTmpLogBuf != NULL) {
p->ExecuteCmd = _TRUE;
if (p->TaskRdy) {
RtlUpSemaFromISR((_Sema *) &pUartLogCtl->Sema);
}
} else {
ArrayInitialize((u8 *) pUartLogCtl->pTmpLogBuf->UARTLogBuf,
UART_LOG_CMD_BUFLEN, '\0');
}
}
}
}
exit:
DiagSetIsrEnReg(IrqEn); // HAL_UART_WRITE32(UART_INTERRUPT_EN_REG_OFF, IrqEn)
}
//======================================================
//<Function>: GetArgvRam
//<Usage >: парсигн аргументов строки
//<Argus >: pstr - указатель на строку
//<Return >: кол-во аргументов
//<Notes >: 2 формата:
// 1) cmd=arg1,arg2,...
// 2) cmd arg1 arg2
// arg может быть обрамлен '"' или '\''
// для передачи ' ' или ','.
// Начальные пробелы cmd или arg удаляются.
//======================================================
int GetArgvRam(IN u8 *pstr) {
int arvc = 0;
u8** argv = ArgvArray;
u8* p = pstr;
u8 t, n = ' ';
int m = 0;
while(*p != 0
&& *p != '\r'
&& *p != '\n'
&& arvc < MAX_ARGV
&& p < &pstr[UART_LOG_CMD_BUFLEN-1]) {
switch(m) {
case 0: // wait cmd
if(*p == ' ') {
// *p = 0;
break;
}
*argv++ = p;
arvc++;
m++;
break;
case 1: // test end cmd, type format parm
if(*p == ' ') { // format cmd arg1 arg2 ...
m++;
*p = 0;
} else if(*p == '=') { // "at" format cmd=arg1,arg2,...
n = ',';
m++;
*p = 0;
}
break;
case 2: // wait start arg
if(*p == ' ') {
*p = 0;
break;
}
if(*p == '"' || *p == '\'') {
t = *p;
m = 4;
*p = 0;
break;
}
*argv++ = p;
arvc++;
m++;
case 3: // end arg
if(*p == n) { // ' ' or ','
m = 2;
*p = 0;
}
break;
case 4:
*argv++ = p;
arvc++;
m++;
case 5:
if(*p == t) { // '\'' or '"'
m = 3;
*p = 0;
}
break;
}
p++;
}
return arvc;
}
//======================================================
//<Function>: RtlConsolTaskRam
//<Usage >: overload original RtlConsolTaskRam
//<Argus >: Data - указатель PUART_LOG_CTL
//<Return >: none
//<Notes >:
//======================================================
MON_RAM_TEXT_SECTION void RtlConsolTaskRam(void *Data) {
PUART_LOG_CTL p = pUartLogCtl;
#ifdef USE_ROM_CONSOLE // show Help
p->pTmpLogBuf->UARTLogBuf[0] = '?';
p->pTmpLogBuf->BufCount = 1;
p->ExecuteCmd = _TRUE;
#endif
do {
p->TaskRdy = _TRUE;
RtlDownSema(&p->Sema);
if (p->ExecuteCmd) {
// UartLogCmdExecute(pUartLogCtl);
int argc = GetArgvRam(p->pTmpLogBuf->UARTLogBuf);
if(argc) {
StrUpr(ArgvArray[0]);
PCOMMAND_TABLE pcmd = p->pCmdTbl;
int flg = 1;
#ifdef USE_ROM_CONSOLE
for(int i = 0; i < p->CmdTblSz; i++) {
#else
while(pcmd->cmd) {
#endif
if(prvStrCmp(ArgvArray[0], pcmd->cmd) == 0) {
flg = 0;
if(pcmd->ArgvCnt < argc) {
#ifdef USE_ROM_CONSOLE
pcmd->func(argc-1, &ArgvArray[1]);
#else
pcmd->func(argc, &ArgvArray);
#endif
} else {
#ifdef USE_ROM_CONSOLE
DiagPrintf(pcmd->msg);
#else
DiagPrintf("%s%s\n", pcmd->cmd, pcmd->msg);
#endif
}
}
pcmd++;
}
if(flg) DiagPrintf("cmd: %s - nothing!\n", ArgvArray[0]);
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
release_wakelock(WAKELOCK_LOGUART);
#endif
}
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
else acquire_wakelock(WAKELOCK_LOGUART);
#endif
p->pTmpLogBuf->BufCount = 0;
p->pTmpLogBuf->UARTLogBuf[0] = 0;
HalSerialPutcRtl8195a('\r');
HalSerialPutcRtl8195a('>');
p->ExecuteCmd = _FALSE;
}
} while (1);
}
//======================================================
//<Function>: console_init
//<Usage >: Initialize rtl console
//<Argus >: none
//<Return >: none
//<Notes >: delete rtl_concole.h from project
//======================================================
MON_RAM_TEXT_SECTION void console_init(void) {
IRQ_HANDLE UartIrqHandle;
// Register Log Uart Callback function
UartIrqHandle.Data = 0; // (u32)&UartAdapter;
UartIrqHandle.IrqNum = UART_LOG_IRQ;
UartIrqHandle.IrqFun = (IRQ_FUN) UartLogIrqHandleRam;
UartIrqHandle.Priority = 0; // ??
// Register Isr handle
InterruptUnRegister(&UartIrqHandle);
#ifdef USE_ROM_CONSOLE // use ROM Consol init & printf "<RTL8195A>"
RtlConsolInit(RAM_STAGE, (u32) 6, (void*) UartLogRomCmdTable);
#else
UartLogBuf.BufCount = 0;
ArrayInitialize(&UartLogBuf.UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
pUartLogCtl = &UartLogCtl;
pUartLogCtl->NewIdx = 0;
pUartLogCtl->SeeIdx = 0;
pUartLogCtl->EscSTS = 0;
pUartLogCtl->BootRdy = 0;
pUartLogCtl->pTmpLogBuf = &UartLogBuf;
pUartLogCtl->CRSTS = 0;
pUartLogCtl->pHistoryBuf = UartLogHistoryBuf;
pUartLogCtl->pfINPUT = (void*) &DiagPrintf;
pUartLogCtl->pCmdTbl = (PCOMMAND_TABLE) UartLogRamCmdTable;
pUartLogCtl->CmdTblSz = UartLogRamCmdTableSize/16; //6; // GetRomCmdNum()
pUartLogCtl->TaskRdy = 0;
#endif
pUartLogCtl->RevdNo = UART_LOG_HISTORY_LEN;
// Create a Semaphone
RtlInitSema(&pUartLogCtl->Sema, 1);
// executing boot sequence
pUartLogCtl->ExecuteCmd = _FALSE;
pUartLogCtl->ExecuteEsc = _TRUE; //don't check Esc anymore
InterruptRegister(&UartIrqHandle);
if (pdTRUE
!= xTaskCreate(RtlConsolTaskRam,
(const signed char * const )"loguart", LOGUART_STACK_SIZE,
NULL, tskIDLE_PRIORITY + CONSOLE_PRIORITY + PRIORITIE_OFFSET, NULL)) {
DiagPrintf("Create Log UART Task Err!!\n");
}
}
#ifndef USE_ROM_CONSOLE
//======================================================
//<Function>: console_help
//<Usage >: Initialize rtl console
//<Argus >: argc - кол-во аргуметов, argv - список аргументов
//<Return >: none
//<Notes >:
//======================================================
_WEAK void console_help(int argc, char *argv[]) { // Help
DiagPrintf("CONSOLE COMMAND SET:\n");
DiagPrintf("==============================\n");
PCOMMAND_TABLE pcmdtab = UartLogRamCmdTable;
while(pcmdtab->cmd) {
#ifdef USE_ROM_CONSOLE
DiagPrintf(pcmdtab->msg);
#else
DiagPrintf("%s%s\n", pcmdtab->cmd, pcmdtab->msg);
#endif
pcmdtab++;
}
DiagPrintf("==============================\n");
}
// (!) размещается в специальном сегменте '.mon.tab*' (см. *.ld файл)
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands[] = {
{"?", 0, console_help, ": This Help"} // Help
// {"HELP", 0, console_help, ": Help"} // Help
};
#endif

View file

@ -16,21 +16,14 @@
#include "user/atcmd_user.h"
#include "user/playerconfig.h"
#include "sleep_ex_api.h"
#include "lwip/tcp_impl.h"
rtw_mode_t wifi_mode = RTW_MODE_STA;
mp3_server_setings mp3_serv = {0,{0}}; //{ PLAY_PORT, { PLAY_SERVER }};
#define DEBUG_AT_USER_LEVEL 1
/******************************************************************************/
/*
#define _AT_WLAN_SET_SSID_ "ATW0"
#define _AT_WLAN_SET_PASSPHRASE_ "ATW1"
#define _AT_WLAN_SET_KEY_ID_ "ATW2"
#define _AT_WLAN_JOIN_NET_ "ATWC"
#define _AT_WLAN_SET_MP3_URL_ "ATWS"
*/
//extern struct netif xnetif[NET_IF_NUM];
/* fastconnect use wifi AT command. Not init_wifi_struct when log service disabled
* static initialize all values for using fastconnect when log service disabled
*/
@ -48,6 +41,9 @@ static unsigned char password[65] = {0};
_WEAK void connect_start(void)
{
#ifdef CONFIG_DEBUG_LOG
printf("Time at start %d ms.\n", xTaskGetTickCount());
#endif
}
_WEAK void connect_close(void)
@ -70,65 +66,7 @@ static void init_wifi_struct(void)
ap.channel = 1;
}
void fATW0(void *arg){
if(!arg){
printf("ATW0: Usage: ATW0=SSID\n");
goto exit;
}
#if DEBUG_AT_USER_LEVEL > 1
printf("ATW0: %s\n", (char*)arg);
#endif
strcpy((char *)wifi.ssid.val, (char*)arg);
wifi.ssid.len = strlen((char*)arg);
exit:
return;
}
void fATW1(void *arg){
#if DEBUG_AT_USER_LEVEL > 1
printf("ATW1: %s\n", (char*)arg);
#endif
strcpy((char *)password, (char*)arg);
wifi.password = password;
wifi.password_len = strlen((char*)arg);
return;
}
void fATW2(void *arg){
#if DEBUG_AT_USER_LEVEL > 1
printf("ATW2: %s\n", (char*)arg);
#endif
if((strlen((const char *)arg) != 1 ) || (*(char*)arg <'0' ||*(char*)arg >'3')) {
printf("ATW2: Wrong WEP key id. Must be one of 0,1,2, or 3.\n");
return;
}
wifi.key_id = atoi((const char *)(arg));
return;
}
// Test
void fATST(void *arg){
// AT_PRINTK("[ATS#]: _AT_SYSTEM_TEST_");
DBG_8195A("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
dump_mem_block_list();
u32 saved = ConfigDebugInfo;
DBG_INFO_MSG_ON(_DBG_TCM_HEAP_); // On Debug TCM MEM
tcm_heap_dump();
ConfigDebugInfo = saved;
printf("\n");
#if (configGENERATE_RUN_TIME_STATS == 1)
char *cBuffer = pvPortMalloc(512);
if(cBuffer != NULL) {
vTaskGetRunTimeStats((char *)cBuffer);
printf("%s", cBuffer);
}
vPortFree(cBuffer);
#endif
}
int mp3_cfg_read(void)
static int mp3_cfg_read(void)
{
bzero(&mp3_serv, sizeof(mp3_serv));
if(flash_read_cfg(mp3_serv, 0x5000, sizeof(mp3_serv.port) + 2) >= sizeof(mp3_serv.port) + 2) {
@ -138,35 +76,37 @@ int mp3_cfg_read(void)
return mp3_serv.port;
}
void start_init(void)
{
init_wifi_struct();
mp3_cfg_read();
}
// MP3 Set server, Close connect
void fATWS(void *arg){
int argc = 0;
char *argv[MAX_ARGC] = {0};
if(arg) {
argc = parse_param(arg, argv);
// MP3 Set server, Close/Open connect
void fATWS(int argc, char *argv[]){
if (argc == 2) {
StrUpr(argv[1]);
if(argv[1][0] == '?') {
printf("ATWS: %s,%d\n", mp3_serv.url, mp3_serv.port);
return;
}
else if(strcmp(argv[1], "open") == 0) {
else if(argv[1][0] == 'O') { // strcmp(argv[1], "open") == 0
printf("ATWS: open %s:%d\n", mp3_serv.url, mp3_serv.port);
connect_close();
return;
}
else if(strcmp(argv[1], "close") == 0) {
else if(argv[1][0] == 'C') { // strcmp(argv[1], "close") == 0
printf("ATWS: close\n");
connect_close();
return;
}
else if(strcmp(argv[1], "read") == 0) {
else if(argv[1][0] == 'R') { // strcmp(argv[1], "read") == 0
mp3_cfg_read();
connect_start();
return;
}
else if(strcmp(argv[1], "save") == 0) {
printf("ATWS: %s,%d\n", mp3_serv.url, mp3_serv.port);
else if(argv[1][0] == 'S') { // strcmp(argv[1], "save") == 0
printf("%s: %s,%d\n", argv[0], mp3_serv.url, mp3_serv.port);
if(flash_write_cfg(&mp3_serv, 0x5000, strlen(mp3_serv.port) + strlen(mp3_serv.url)))
printf("ATWS: saved\n", mp3_serv.url, mp3_serv.port);
return;
@ -175,29 +115,64 @@ void fATWS(void *arg){
else if (argc >= 3 ) {
strcpy((char *)mp3_serv.url, (char*)argv[1]);
mp3_serv.port = atoi((char*)argv[2]);
printf("ATWS: %s,%d\r\n", mp3_serv.url, mp3_serv.port);
printf("%s: %s,%d\r\n", argv[0], mp3_serv.url, mp3_serv.port);
connect_start();
return;
}
}
printf("ATWS: Usage: ATWS=URL,PORT or ATWS=close, ATWS=read, ATWS=save\n");
}
// Mem info
void fATST(void){
extern u8 __HeapLimit, __StackTop;
extern struct Heap g_tcm_heap;
printf("\nCLK CPU\t\t%d Hz\nRAM heap\t%d bytes\nTCM heap\t%d bytes\n",
HalGetCpuClk(), xPortGetFreeHeapSize(), tcm_heap_freeSpace());
dump_mem_block_list();
u32 saved = ConfigDebugInfo;
DBG_INFO_MSG_ON(_DBG_TCM_HEAP_); // On Debug TCM MEM
tcm_heap_dump();
ConfigDebugInfo = saved;
printf("\n");
#if (configGENERATE_RUN_TIME_STATS == 1)
char *cBuffer = pvPortMalloc(512);
if(cBuffer != NULL) {
vTaskGetRunTimeStats((char *)cBuffer);
printf("%s", cBuffer);
}
vPortFree(cBuffer);
#endif
}
void fATWC(void *arg){
void fATWC(int argc, char *argv[]){
int mode, ret;
unsigned long tick1 = xTaskGetTickCount();
unsigned long tick2, tick3;
char empty_bssid[6] = {0}, assoc_by_bssid = 0;
connect_close();
#if DEBUG_AT_USER_LEVEL > 1
printf("ATWC: Connect to AP...\n");
#endif
if(argc > 1) {
if(argv[1][0] == '?') {
printf("Not released!\n");
return;
}
strcpy((char *)wifi.ssid.val, argv[1]);
wifi.ssid.len = strlen((char*)wifi.ssid.val);
}
if(argc > 2) {
strcpy((char *)password, argv[2]);
wifi.password = password;
wifi.password_len = strlen(password);
}
if(argc > 3) {
if((strlen(argv[3][0]) != 1 ) || (argv[3][0] <'0' || argv[3][0] >'3')) {
printf("%s: Wrong WEP key id. Must be one of 0,1,2, or 3.\n", argv[0]);
return;
}
wifi.key_id = atoi(argv[1]);
}
if(memcmp (wifi.bssid.octet, empty_bssid, 6))
assoc_by_bssid = 1;
else if(wifi.ssid.val[0] == 0){
printf("ATWC: Error: SSID can't be empty\n");
printf("%s: Error: SSID can't be empty\n", argv[0]);
ret = RTW_BADARG;
goto EXIT;
}
@ -212,12 +187,13 @@ void fATWC(void *arg){
else{
wifi.security_type = RTW_SECURITY_OPEN;
}
connect_close();
//Check if in AP mode
wext_get_mode(WLAN0_NAME, &mode);
if(mode == IW_MODE_MASTER) {
dhcps_deinit();
wifi_off();
vTaskDelay(20);
vTaskDelay(wifi_test_timeout_step_ms/portTICK_RATE_MS);
if (wifi_on(RTW_MODE_STA) < 0){
printf("ERROR: Wifi on failed!\n");
ret = RTW_ERROR;
@ -225,6 +201,8 @@ void fATWC(void *arg){
}
}
///wifi_set_channel(1);
if(assoc_by_bssid){
printf("Joining BSS by BSSID "MAC_FMT" ...\n", MAC_ARG(wifi.bssid.octet));
ret = wifi_connect_bssid(wifi.bssid.octet, (char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password,
@ -240,27 +218,24 @@ void fATWC(void *arg){
goto EXIT;
}
tick2 = xTaskGetTickCount();
printf("Connected after %dms\n", (tick2-tick1));
printf("Connected after %d ms\n", (tick2-tick1));
/* Start DHCPClient */
LwIP_DHCP(0, DHCP_START);
tick3 = xTaskGetTickCount();
printf("Got IP after %dms\n", (tick3-tick1));
printf("\n\r");
printf("Got IP after %d ms\n\n", (tick3-tick1));
connect_start();
EXIT:
init_wifi_struct( );
}
void fATWD(void *arg){
int timeout = 20;
// WIFI Disconnect
void fATWD(int argc, char *argv[]){
int timeout = wifi_test_timeout_ms/wifi_test_timeout_step_ms;;
char essid[33];
int ret = RTW_SUCCESS;
connect_close();
#if DEBUG_AT_USER_LEVEL > 1
printf("ATWD: Disconnect...\n");
#endif
printf("Dissociating AP ...\n");
printf("Deassociating AP ...\n");
if(wext_get_ssid(WLAN0_NAME, (unsigned char *) essid) < 0) {
printf("WIFI disconnected\n");
goto exit;
@ -283,7 +258,7 @@ void fATWD(void *arg){
break;
}
vTaskDelay(1 * configTICK_RATE_HZ);
vTaskDelay(wifi_test_timeout_step_ms/portTICK_RATE_MS);
timeout --;
}
printf("\n\r");
@ -292,89 +267,250 @@ exit:
return;
}
// Dump register
void fATSD(void *arg)
/*-------------------------------------------------------------------------------------
Копирует данные из области align(4) (flash, registers, ...) в область align(1) (ram)
--------------------------------------------------------------------------------------*/
extern void copy_align4_to_align1(unsigned char * pd, void * ps, unsigned int len);
/*
static void copy_align4_to_align1(unsigned char * pd, void * ps, unsigned int len)
{
int argc = 0;
char *argv[MAX_ARGC] = {0};
union {
unsigned char uc[4];
unsigned int ud;
}tmp;
unsigned int *p = (unsigned int *)((unsigned int)ps & (~3));
unsigned int xlen = (unsigned int)ps & 3;
// unsigned int size = len;
#if DEBUG_AT_USER_LEVEL > 1
printf("ATSD: dump registers\n");
#endif
if(!arg){
printf("ATSD: Usage: ATSD=REGISTER");
return;
if(xlen) {
tmp.ud = *p++;
while (len) {
len--;
*pd++ = tmp.uc[xlen++];
if(xlen & 4) break;
}
}
argc = parse_param(arg, argv);
if(argc == 2 || argc == 3)
CmdDumpWord(argc-1, (unsigned char**)(argv+1));
xlen = len >> 2;
while(xlen) {
tmp.ud = *p++;
*pd++ = tmp.uc[0];
*pd++ = tmp.uc[1];
*pd++ = tmp.uc[2];
*pd++ = tmp.uc[3];
xlen--;
}
if(len & 3) {
tmp.ud = *p;
pd[0] = tmp.uc[0];
if(len & 2) {
pd[1] = tmp.uc[1];
if(len & 1) {
pd[2] = tmp.uc[2];
}
}
}
// return size;
}
*/
int print_hex_dump(uint8_t *buf, int len, unsigned char k) {
uint32_t ss[2];
ss[0] = 0x78323025; // "%02x"
ss[1] = k; // ","...'\0'
uint8_t * ptr = buf;
int result = 0;
while (len--) {
if (len == 0)
ss[1] = 0;
result += printf((uint8_t *) &ss, *ptr++);
}
return result;
}
void fATSW(void *arg)
extern char str_rom_hex_addr[]; // in *.ld "[Addr] .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F\n"
// Dump byte register
void fATSB(int argc, char *argv[])
{
int argc = 0;
char *argv[MAX_ARGC] = {0};
#if DEBUG_AT_USER_LEVEL > 1
printf("ATSW: write register\n");
#endif
if(!arg){
printf("ATSW: Usage: ATSW=REGISTER,DATA");
return;
uint8 buf[17];
int size = 0;
int addr = Strtoul(argv[1],0,16);
if (argc > 2)
size = Strtoul(argv[2],0,10);
if (size <= 0 || size > 16384)
size = 1;
u32 symbs_line = sizeof(buf)-1;
printf(str_rom_hex_addr);
while (size) {
if (symbs_line > size) symbs_line = size;
printf("%08X ", addr);
copy_align4_to_align1(buf, addr, symbs_line);
print_hex_dump(buf, symbs_line, ' ');
int i;
for(i = 0 ; i < symbs_line ; i++) {
if(buf[i] < 0x20 || buf[i] > 0x7E) {
buf[i] = '.';
}
}
buf[symbs_line] = 0;
i = (sizeof(buf)-1) - symbs_line;
while(i--) printf(" ");
printf(" %s\r\n", buf);
addr += symbs_line;
size -= symbs_line;
}
argc = parse_param(arg, argv);
if(argc == 2 || argc == 3)
CmdWriteWord(argc-1, (unsigned char**)(argv+1));
}
///// MP3 Set Mode
// MP3 Off
void fATOF(void *arg)
// Dump dword register
void fATSD(int argc, char *argv[])
{
CmdDumpWord(argc-1, (unsigned char**)(argv+1));
}
void fATSW(int argc, char *argv[])
{
CmdWriteWord(argc-1, (unsigned char**)(argv+1));
}
// Close connections
void fATOF(int argc, char *argv[])
{
#if DEBUG_AT_USER_LEVEL > 1
printf("ATOF: MP3 off...\n");
#endif
connect_close();
}
void print_wlan_help(void *arg){
printf("WLAN AT COMMAND SET:\n");
printf("==============================\n");
printf(" Set MP3 server\n");
printf("\t# ATWS=URL,PORT\n");
printf("\tSample:\tATWS=icecast.omroep.nl/3fm-sb-mp3,80\n");
printf("\t\tATWS=meuk.spritesserver.nl/Ii.Romanzeandante.mp3,80\n");
printf("\t\tATWS=?, ATWS=close, ATWS=save, ATWS=read\n");
printf(" Connect to an AES AP\n");
printf("\t# ATW0=SSID\n");
printf("\t# ATW1=PASSPHRASE\n");
printf("\t# ATWC\n");
printf(" DisConnect AP\n");
printf("\t# ATWD\n");
// Open connections
void fATON(int argc, char *argv[])
{
connect_start();
}
log_item_t at_user_items[ ] = {
{"ATW0", fATW0,},
{"ATW1", fATW1,},
{"ATW2", fATW2,},
{"ATWC", fATWC,},
{"ATST", fATST,},
{"ATSD", fATSD,}, // Dump register
{"ATSW", fATSW,}, // Set register
{"ATWD", fATWD,}, //
{"ATWS", fATWS,}, // MP3 Set server, Close connect
{"ATOF", fATOF,}, // MP3 Set Mode
/* Get one byte from the 4-byte address */
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
/* These are cast to u16_t, with the intent that they are often arguments
* to printf using the U16_F format from cc.h. */
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
ip4_addr2_16(ipaddr), \
ip4_addr3_16(ipaddr), \
ip4_addr4_16(ipaddr)
#define IPSTR "%d.%d.%d.%d"
extern const char * const tcp_state_str[];
/*
static const char * const tcp_state_str[] = {
"CLOSED",
"LISTEN",
"SYN_SENT",
"SYN_RCVD",
"ESTABLISHED",
"FIN_WAIT_1",
"FIN_WAIT_2",
"CLOSE_WAIT",
"CLOSING",
"LAST_ACK",
"TIME_WAIT"
};
*/
/******************************************************************************
* FunctionName : debug
* Parameters :
* Returns :
*******************************************************************************/
void print_udp_pcb(void)
{
struct udp_pcb *pcb;
bool prt_none = true;
rtl_printf("UDP pcbs:\n");
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
rtl_printf("flg:%02x\t" IPSTR ":%d\t" IPSTR ":%d\trecv:%p\n", pcb->flags, IP2STR(&pcb->local_ip), pcb->local_port, IP2STR(&pcb->remote_ip), pcb->remote_port, pcb->recv );
prt_none = false;
}
if(prt_none) rtl_printf("none\n");
}
/******************************************************************************
* FunctionName : debug
* Parameters :
* Returns :
*******************************************************************************/
void print_tcp_pcb(void)
{
struct tcp_pcb *pcb;
rtl_printf("Active PCB states:\n");
bool prt_none = true;
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p\t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
prt_none = false;
}
if(prt_none) rtl_printf("none\n");
rtl_printf("Listen PCB states:\n");
prt_none = true;
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p\t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
prt_none = false;
}
if(prt_none) rtl_printf("none\n");
rtl_printf("TIME-WAIT PCB states:\n");
prt_none = true;
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
rtl_printf("Port %d|%d\tflg:%02x\ttmr:%p\t%s\n", pcb->local_port, pcb->remote_port, pcb->flags, pcb->tmr, tcp_state_str[pcb->state]);
prt_none = false;
}
if(prt_none) rtl_printf("none\n");
}
/******************************************************************************
* FunctionName : debug
* Parameters :
* Returns :
*******************************************************************************/
//------------------------------------------------------------------------------
void fATLW(int argc, char *argv[]) // Info Lwip
{
print_udp_pcb();
print_tcp_pcb();
}
void fATDS(int argc, char *argv[]) // Deep sleep
{
uint32 sleep_ms = 10000;
if(argc > 2) sleep_ms = atoi(argv[1]);
#if 0
// turn off log uart
sys_log_uart_off();
// initialize wakeup pin at PB_1
gpio_t gpio_wake;
gpio_init(&gpio_wake, PB_1);
gpio_dir(&gpio_wake, PIN_INPUT);
gpio_mode(&gpio_wake, PullDown);
// enter deep sleep
deepsleep_ex(DSLEEP_WAKEUP_BY_GPIO | DSLEEP_WAKEUP_BY_TIMER, 10000); */
// standby_wakeup_event_add(STANDBY_WAKEUP_BY_STIMER, 10000, 0);
// deepstandby_ex();
// sleep_ex(SLEEP_WAKEUP_BY_STIMER, 8000); // sleep_ex can't be put in irq handler
// release_wakelock(WAKELOCK_OS);
#else
deepsleep_ex(DSLEEP_WAKEUP_BY_TIMER, sleep_ms);
#endif
}
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands1[] = {
{"ATPN", 1, fATWC, "=<SSID>[,<PASSPHRASE>[,WEPKEY]]: WIFI Connect to AP"},
{"ATWS", 1, fATWS, "=<URL,PORT>: MP3 Connect to URL\nATWS=<c>[lose]: Close MP3\nATWS=<r>[ead]: Read MP3 URL\nATWS=<s>[ave]: Save MP3 URL\nATWS=<?>: URL Info"},
{"ATWD", 0, fATWD, ": WIFI Disconnect"},
{"ATST", 0, fATST, ": Memory info"},
{"ATLW", 0, fATLW, ": Lwip Info"},
{"ATSB", 1, fATSB, "=<ADDRES(hex)>[,COUNT(dec)]: Dump byte register"},
{"ATSD", 1, fATSD, "=<ADDRES(hex)>[,COUNT(dec)]: Dump dword register"},
{"ATSW", 2, fATSW, "=<ADDRES(hex)>,<DATA(hex)>: Set register"},
{"ATDS", 0, fATDS, "=[TIME(ms)]: Deep sleep"},
{"ATON", 0, fATON, ": Open connections"},
{"ATOF", 0, fATOF, ": Close connections"}
};
void at_user_init(void)
{
init_wifi_struct();
mp3_cfg_read();
log_service_add_table(at_user_items, sizeof(at_user_items)/sizeof(at_user_items[0]));
}
log_module_init(at_user_init);
#endif //#ifdef CONFIG_AT_USR

View file

@ -471,7 +471,7 @@ void connect_start(void) {
tskreader_enable = 1;
if (xTaskCreate(tskreader, "tskreader", 300, NULL, PRIO_READER, NULL) != pdPASS) {
#if DEBUG_MAIN_LEVEL > 0
DBG_8195A("\n\r%s xTaskCreate(tskreader) failed", __FUNCTION__);
DBG_8195A("\n%s xTaskCreate(tskreader) failed!\n", __FUNCTION__);
#endif
tskreader_enable = 0;
}
@ -483,17 +483,16 @@ void connect_start(void) {
#endif
}
/**
* @brief Main program.
* @param None
* @retval None
*/
void main(void) {
void main(void)
{
#if DEBUG_MAIN_LEVEL > 3
ConfigDebugErr = -1;
ConfigDebugInfo = -1; //~_DBG_SPI_FLASH_;
ConfigDebugInfo = ~(_DBG_SPI_FLASH_);//|_DBG_TCM_HEAP_);
ConfigDebugWarn = -1;
CfgSysDebugErr = -1;
CfgSysDebugInfo = -1;
@ -503,10 +502,10 @@ void main(void) {
#if CPU_CLOCK_SEL_DIV5_3
// 6 - 200000000 Hz, 7 - 10000000 Hz, 8 - 50000000 Hz, 9 - 25000000 Hz, 10 - 12500000 Hz, 11 - 4000000 Hz
HalCpuClkConfig(CPU_CLOCK_SEL_VALUE);
*((int *)0x40000074) |= (1<<17); // REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) |= (1<<17); // REG_SYS_SYSPLL_CTRL1 |= BIT_SYS_SYSPLL_DIV5_3
#else
// 0 - 166666666 Hz, 1 - 83333333 Hz, 2 - 41666666 Hz, 3 - 20833333 Hz, 4 - 10416666 Hz, 5 - 4000000 Hz
*((int *)0x40000074) &= ~(1<<17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
*((int *)(SYSTEM_CTRL_BASE+REG_SYS_SYSPLL_CTRL1)) &= ~(1<<17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
HalCpuClkConfig(CPU_CLOCK_SEL_VALUE);
#endif
HAL_LOG_UART_ADAPTER pUartAdapter;
@ -515,17 +514,24 @@ void main(void) {
SystemCoreClockUpdate();
En32KCalibration();
}
#if defined(CONFIG_CRYPTO_STARTUP) && (CONFIG_CRYPTO_STARTUP)
if ( rtl_cryptoEngine_init() != 0 ) {
DBG_8195A("crypto engine init failed\r\n");
#ifdef CONFIG_WDG_ON_IDLE
HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & 0x1FFFFF);
WDGInitial(5000); // 5 s
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 > 0
vPortFree(pvPortMalloc(4)); // Init RAM heap
fATST(NULL); // RAM/TCM/Heaps info
fATST(); // RAM/TCM/Heaps info
#endif
start_init(); // in atcmd_user.c
/* pre-processor of application example */
pre_example_entry();
@ -537,7 +543,7 @@ void main(void) {
console_init();
/* Execute application example */
example_entry();
// example_entry();
/*Enable Schedule, Start Kernel*/
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED

View file

@ -89,13 +89,13 @@ SRC_C += sdk/component/soc/realtek/8195a/misc/rtl_std_lib/lib_rtlstd/rtl_math_ra
SRC_C += sdk/component/soc/realtek/8195a/cmsis/device/system_8195a.c
#console
SRC_C += sdk/component/common/api/at_cmd/atcmd_ethernet.c
SRC_C += sdk/component/common/api/at_cmd/atcmd_lwip.c
SRC_C += sdk/component/common/api/at_cmd/atcmd_sys.c
SRC_C += sdk/component/common/api/at_cmd/atcmd_wifi.c
SRC_C += sdk/component/common/api/at_cmd/log_service.c
#SRC_C += sdk/component/common/api/at_cmd/atcmd_ethernet.c
#SRC_C += sdk/component/common/api/at_cmd/atcmd_lwip.c
#SRC_C += sdk/component/common/api/at_cmd/atcmd_sys.c
#SRC_C += sdk/component/common/api/at_cmd/atcmd_wifi.c
#SRC_C += sdk/component/common/api/at_cmd/log_service.c
SRC_C += sdk/component/soc/realtek/8195a/misc/driver/low_level_io.c
SRC_C += sdk/component/soc/realtek/8195a/misc/driver/rtl_consol.c
#SRC_C += sdk/component/soc/realtek/8195a/misc/driver/rtl_consol.c
#network - api
SRC_C += sdk/component/common/api/wifi/rtw_wpa_supplicant/wpa_supplicant/wifi_eap_config.c
@ -187,7 +187,7 @@ SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/analogin_api.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/dma_api.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/efuse_api.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/ethernet_api.c
SRC_C += sdk/component/common/drivers/ethernet_mii/ethernet_mii.c
#SRC_C += sdk/component/common/drivers/ethernet_mii/ethernet_mii.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/flash_api.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/gpio_api.c
SRC_C += sdk/component/common/mbed/targets/hal/rtl8195a/gpio_irq_api.c
@ -401,6 +401,8 @@ ADD_SRC_C += project/src/mad/stream.c
#driver
ADD_SRC_C += project/src/driver/i2s_freertos.c
#ADD_SRC_C += project/src/driver/wifi_api.c
ADD_SRC_C += project/src/driver/console_api.c
#include
INCLUDES += project/inc/mad