mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
add WDT, new console, ...
This commit is contained in:
parent
e851661fa4
commit
de57c04fb4
21 changed files with 3158 additions and 2639 deletions
332
project/src/driver/console_api.c
Normal file
332
project/src/driver/console_api.c
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue