This commit is contained in:
pvvx 2017-05-14 05:55:03 +03:00
parent 3147c97e3f
commit 437e8beb33
8 changed files with 102 additions and 49 deletions

View file

@ -8,6 +8,21 @@
#ifndef _INCLUDE_WEB_UTILS_H_
#define _INCLUDE_WEB_UTILS_H_
typedef enum {
SEG_ID_ROM = 0,
SEG_ID_SRAM,
SEG_ID_TCM,
SEG_ID_FLASH,
SEG_ID_SDRAM,
SEG_ID_SOC,
SEG_ID_CPU,
SEG_ID_ERR,
SEG_ID_MAX
} SEG_ID;
extern const uint32 tab_seg_def[];
SEG_ID get_seg_id(uint32 addr, int32 size);
int rom_atoi(const char *s);
void copy_align4(void *ptrd, void *ptrs, uint32 len);
uint32 hextoul(uint8 *s);

View file

@ -44,16 +44,11 @@ LOCAL void fATPWM(int argc, char *argv[]) {
};
}
LOCAL void fATWLED(int argc, char *argv[]) {
HalPinCtrlRtl8195A(WL_LED, 2, 1);
HalPinCtrlRtl8195A(EGTIM, ahextoul(argv[1]), 1);
}
//------------------------------------------------------------------------------
// atpwm=34,1048575,524287
// atpwm=34,122,61 (8.187kHz)
// atsw 40000368 85001002 (8.187kHz)
// atsd 40000360 6
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_adc[] = {
{ "ATWLED", 0, fATWLED, ": WLED Test" },
MON_RAM_TAB_SECTION COMMAND_TABLE console_commands_pwm[] = {
{ "ATPWM", 3, fATPWM, "=<pin>,<period>,<pulse>: PWM Test" }
};

View file

@ -53,6 +53,10 @@
#define mMIN(a, b) ((a<b)?a:b)
#define ifcmp(a) if(rom_xstrcmp(cstr, a))
#define OpenFlash() { device_mutex_lock(RT_DEV_LOCK_FLASH); flash_turnon(); }
#define CloseFlash() { SpicDisableRtl8195A(); device_mutex_unlock(RT_DEV_LOCK_FLASH); }
extern struct netif xnetif[NET_IF_NUM]; /* network interface structure */
@ -230,16 +234,22 @@ void ICACHE_FLASH_ATTR web_hexdump(TCP_SERV_CONN *ts_conn)
int i;
web_conn->udata_stop &= 0xfffffff0;
while(web_conn->msgbuflen + (9+3*16+17+2) <= web_conn->msgbufsize) {
if((uint32)addr < 0x9A000000) {
// if((uint32)addr < 0x9A000000) {
if((uint32)addr >= 0x98000000 && (uint32)addr < 0x9A000000) {
OpenFlash();
}
tcp_puts("%08x", addr);
for(i=0 ; i < 4 ; i++) data.dw[i] = *addr++;
web_conn->udata_start = (uint32)addr;
if(ts_conn->flag.user_option1) {
if(ts_conn->flag.user_option1) { // dword or byte ?
for(i=0 ; i < 4 ; i++) tcp_puts(" %08x", data.dw[i]);
}
else {
for(i=0 ; i < 16 ; i++) tcp_puts(" %02x", data.b[i]);
}
if((uint32)addr >= 0x98000000 && (uint32)addr < 0x9A000000) {
CloseFlash();
}
tcp_put(' '); tcp_put(' ');
for(i=0 ; i < 16 ; i++) tcp_put((data.b[i] >=' ' && data.b[i] != 0x7F)? data.b[i] : '.');
tcp_puts("\r\n");
@ -248,13 +258,12 @@ void ICACHE_FLASH_ATTR web_hexdump(TCP_SERV_CONN *ts_conn)
if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
return;
}
}
else {
tcp_puts("%p = Bad address!\r\n", addr);
ClrSCB(SCB_RETRYCB);
if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
return;
};
// } else {
// tcp_puts("%p = Bad address!\r\n", addr);
// ClrSCB(SCB_RETRYCB);
// if(!CheckSCB(SCB_WEBSOC)) SetSCB(SCB_FCLOSE | SCB_DISCONNECT); // connection close
// return;
// };
}
// repeat in the next call ...
SetSCB(SCB_RETRYCB);
@ -283,18 +292,18 @@ void ICACHE_FLASH_ATTR web_get_flash(TCP_SERV_CONN *ts_conn)
#if DEBUGSOO > 2
os_printf("%08x..%08x ",web_conn->udata_start, web_conn->udata_start + len );
#endif
// device_mutex_lock(RT_DEV_LOCK_FLASH);
device_mutex_lock(RT_DEV_LOCK_FLASH);
if(spi_flash_read(web_conn->udata_start, web_conn->msgbuf, len)) {
web_conn->udata_start += len;
web_conn->msgbuflen += len;
if(web_conn->udata_start < web_conn->udata_stop) {
SetNextFunSCB(web_get_flash);
// device_mutex_unlock(RT_DEV_LOCK_FLASH);
device_mutex_unlock(RT_DEV_LOCK_FLASH);
SetSCB(SCB_RETRYCB);
return;
};
};
// device_mutex_unlock(RT_DEV_LOCK_FLASH);
device_mutex_unlock(RT_DEV_LOCK_FLASH);
ClrSCB(SCB_RETRYCB);
// SetSCB(SCB_FCLOSE | SCB_DISCONNECT);
return;
@ -320,7 +329,13 @@ void ICACHE_FLASH_ATTR web_get_ram(TCP_SERV_CONN *ts_conn)
}
// Get/put as many bytes as possible
uint32 len = mMIN(web_conn->msgbufsize - web_conn->msgbuflen, web_conn->udata_stop - web_conn->udata_start);
if((uint32)web_conn->udata_start >= 0x98000000 && (uint32)web_conn->udata_start < 0x9A000000) {
OpenFlash();
}
copy_align4(web_conn->msgbuf, (void *)(web_conn->udata_start), len);
if((uint32)web_conn->udata_start >= 0x98000000 && (uint32)web_conn->udata_start < 0x9A000000) {
CloseFlash();
}
web_conn->msgbuflen += len;
web_conn->udata_start += len;
#if DEBUGSOO > 2

View file

@ -95,6 +95,46 @@ int ICACHE_FLASH_ATTR rom_atoi(const char *s)
n = 10*n - (*s++ - '0');
return neg ? n : -n;
}
/******************************************************************************
* get_seg_id()
*******************************************************************************/
const char * const txt_tab_seg[] = {
"ROM" // 0
"SRAM", // 1
"TCM", // 2
"FLASH", // 3 // -> flash On
"SDRAM", // 4 // -> Test ChipID or HAL_PERI_ON_WRITE32(REG_SOC_FUNC_EN, HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) | BIT(21)); // Flag SDRAM Off
"SOC", // 5 // protected !
"CPU", // 6 // protected !
"UNK", // 7
};
const uint32 tab_seg_def[] = {
0x00000000, 0x00050000,
0x10000000, 0x10070000,
0x1fff0000, 0x20000000,
0x98000000, 0xA0000000,
0x30000000, 0x30200000,
0x40000000, 0x40800000,
0xE0000000, 0xE0010000,
0x00000000, 0xFFFFFFFF
};
SEG_ID get_seg_id(uint32 addr, int32 size) {
SEG_ID ret = SEG_ID_ERR;
uint32 * ptr = &tab_seg_def;
if (size > 0) {
do {
ret++;
if (addr >= ptr[0] && addr + size <= ptr[1]) {
return ret;
};
ptr += 2;
} while (ret < SEG_ID_MAX);
};
return 0;
}
/******************************************************************************
* copy_align4
* копирует данные из области кеширования flash и т.д.