add set mac, cmsis-dap load sdram, ...

This commit is contained in:
pvvx 2017-12-28 18:43:58 +03:00
parent 0830a1244a
commit b381813514
27 changed files with 255 additions and 88 deletions

View file

@ -129,6 +129,8 @@ void ina219_init(void)
// (!) Установки драйвера I2C заданы в структуре ina219drv
// rtl_printf("INA219 control reg = 0x%04x\n", p->config);
// _i2c_setup(&p->i2c, INA219_I2C_PIN_SDA , INA219_I2C_PIN_SCL, DRV_I2C_FS_MODE); // == DRV_I2C_OK?
// HAL_GPIO_PullCtrl((u32)PC_4, (u32)PullUp);
// HAL_GPIO_PullCtrl((u32)PC_5, (u32)PullUp);
_i2c_init(&p->i2c);
// _i2c_set_speed(&p->i2c, INA219_I2C_BUS_CLK);
rtl_printf("I2C%d mode = %d, drvStatus = %d\n", p->i2c.idx, p->i2c.mode, p->i2c.status);

View file

@ -47,8 +47,8 @@ INA219DRV ina219drv = {
// Если шаг заполнения 1 ms -> буфер на 0.71 сек
// Оптимизация под TCP: (TCP_MSS*2 - 80)/4 = (1460*2 - 80)/4 = 710
.i2c.status = DRV_I2C_OFF,
.i2c.idx = 1, // I2C1
.i2c.io_sel = S0, // PC_4, PC_5
.i2c.idx = 1, // =1: I2C1
.i2c.io_sel = S0, // =S0: PC_4, PC_5
.i2c.mode = DRV_I2C_FS_MODE // DRV_I2C_FS_MODE
};
/*
@ -270,6 +270,8 @@ void ina219_init(void)
};
// (!) Установки драйвера I2C заданы в структуре ina219drv
// _i2c_setup(&p->i2c, INA219_I2C_PIN_SDA , INA219_I2C_PIN_SCL, DRV_I2C_FS_MODE); // == DRV_I2C_OK?
GPIO_PullCtrl_8195a((u32)PC_4, DIN_PULL_HIGH); // HAL_GPIO_PullCtrl((u32)PC_4, (u32)PullUp);
GPIO_PullCtrl_8195a((u32)PC_5, DIN_PULL_HIGH); // HAL_GPIO_PullCtrl((u32)PC_5, (u32)PullUp);
_i2c_init(&p->i2c);
// _i2c_set_speed(&p->i2c, INA219_I2C_BUS_CLK);
rtl_printf("I2C%d mode = %d, drvStatus = %d\n", p->i2c.idx, p->i2c.mode, p->i2c.status);

View file

@ -74,7 +74,6 @@ void user_init_thrd(void) {
if(!syscfg.cfg.b.debug_print_enable) print_off = 1;
/* Initilaize the console stack */
console_init();
/* Web Disk Init */

View file

@ -533,14 +533,14 @@ extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
else ifcmp("auth") tcp_put((wifi_ap_cfg.security) ? '1' : '0');
else ifcmp("hssid") tcp_put((wifi_ap_cfg.ssid_hidden & 1) + '0');
else ifcmp("bint") tcp_puts("%u", wifi_ap_cfg.beacon_interval);
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_AP_NETIF_NUM].hwaddr));
else ifcmp("mac") tcp_put_mac(xnetif[WLAN_AP_NETIF_NUM].hwaddr); //s(MACSTR, MAC2STR(xnetif[WLAN_AP_NETIF_NUM].hwaddr));
else ifcmp("hostname") tcp_strcpy(lwip_host_name[1]);
else ifcmp("dhcp") tcp_puts("%u", wifi_ap_dhcp.mode);
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.ip));
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.gw));
else ifcmp("msk") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.mask));
else ifcmp("cip") tcp_puts(IPSTR, IP2STR(&xnetif[WLAN_ST_NETIF_NUM].ip_addr.addr));
// else ifcmp("mac") strtomac(pvar, wifi_ap_cfg.macaddr);
else ifcmp("mac") tcp_put_mac(xnetif[WLAN_AP_NETIF_NUM].hwaddr);
// else ifcmp("sip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.start_ip));
// else ifcmp("eip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.end_ip));
#if DEBUGSOO > 2
@ -565,8 +565,8 @@ extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
wifi_st_cfg.password[IW_PASSPHRASE_MAX_SIZE] = '\0';
tcp_strcpy(wifi_st_cfg.password);
}
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_ST_NETIF_NUM].hwaddr));
else ifcmp("bssid") tcp_puts(MACSTR, MAC2STR(wifi_st_cfg.bssid));
else ifcmp("mac") tcp_put_mac(xnetif[WLAN_ST_NETIF_NUM].hwaddr); // (MACSTR, MAC2STR(xnetif[WLAN_ST_NETIF_NUM].hwaddr));
else ifcmp("bssid") tcp_put_mac(wifi_st_cfg.bssid); // (MACSTR, MAC2STR(wifi_st_cfg.bssid));
else ifcmp("sbss") tcp_puts("%u", wifi_st_cfg.flg);
else ifcmp("sleep") tcp_puts("%d", wifi_st_cfg.sleep);
else ifcmp("dtim") tcp_puts("%u", wifi_st_cfg.dtim);

View file

@ -263,7 +263,19 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
else ifcmp("ip") wifi_ap_dhcp.ip = ipaddr_addr(pvar);
else ifcmp("gw") wifi_ap_dhcp.gw = ipaddr_addr(pvar);
else ifcmp("msk") wifi_ap_dhcp.mask = ipaddr_addr(pvar);
// else ifcmp("mac") strtomac(pvar, wifi_ap_cfg.macaddr);
else ifcmp("mac") {
if(wifi_mode & RTW_MODE_AP) {
uint8 new_mac[6];
if (strtomac(pvar, new_mac)) {
uint16 xs = 0;
for(int i = 0; i < 6; i++) xs += new_mac[i];
if (xs != 0 && xs != 0xff*6 && memcmp(xnetif[WLAN_AP_NETIF_NUM].hwaddr, new_mac, 6)) {
if(wifi_mode == RTW_MODE_STA_AP) new_mac[5]--; // если AP+ST, то последняя цифра mac - 1
wifi_set_mac_address(new_mac);
}
}
}
}
// else ifcmp("sip") wifi_ap_dhcp.start_ip = ipaddr_addr(pvar);
// else ifcmp("eip") wifi_ap_dhcp.end_ip = ipaddr_addr(pvar);
#if DEBUGSOO > 2
@ -321,7 +333,19 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
else ifcmp("ip") wifi_st_dhcp.ip = ipaddr_addr(pvar);
else ifcmp("gw") wifi_st_dhcp.gw = ipaddr_addr(pvar);
else ifcmp("msk") wifi_st_dhcp.mask = ipaddr_addr(pvar);
// else ifcmp("mac") strtomac(pvar, wifi_st_cfg.mac);
else ifcmp("mac") {
if(wifi_mode & RTW_MODE_STA) {
uint8 new_mac[6];
if (strtomac(pvar, new_mac)) {
uint16 xs = 0;
for(int i = 0; i < 6; i++) xs += new_mac[i];
if (xs != 0 && xs != 0xff*6 && memcmp(xnetif[WLAN_ST_NETIF_NUM].hwaddr, new_mac, 6)) {
// if(wifi_mode == RTW_MODE_STA_AP) new_mac[5]--; // если AP+ST, то последняя цифра mac - 1
wifi_set_mac_address(new_mac);
}
}
}
}
// else ifcmp("sbss") wifi_st_cfg.bssidx = val;
#if DEBUGSOO > 5
else os_printf(" - none!\n");

View file

@ -375,18 +375,27 @@ uint32 ICACHE_FLASH_ATTR str_array_b(uint8 *s, uint8 *buf, uint32 max_buf)
/******************************************************************************
* FunctionName : strtmac
*******************************************************************************/
void ICACHE_FLASH_ATTR strtomac(uint8 *s, uint8 *macaddr)
int ICACHE_FLASH_ATTR strtomac(uint8 *s, uint8 *macaddr)
{
uint8 pbuf[4];
s = cmpcpystr(pbuf, s, 0, ':', 3);
*macaddr++ = hextoul(pbuf);
int i = 4;
while(i--) {
s = cmpcpystr(pbuf, s, ':', ':', 3);
*macaddr++ = hextoul(pbuf);
uint8 * ptrm = macaddr;
int slen = strlen(s);
uint8 * ptr = s;
if(slen == (6*2 + 5) || slen == (6*2)) {
uint8 pbuf[4];
pbuf[2] = 0;
slen = 6;
while(slen--) {
pbuf[0] = ptr[0];
pbuf[1] = ptr[1];
*ptrm++ = (uint8)hextoul(pbuf);
if(ptr[2] != ':') ptr +=2;
else ptr +=3;
}
return 1;
} else {
rtl_memset(macaddr, 0xff, 6);
return 0;
}
s = cmpcpystr(pbuf, s, ':', ' ', 3);
*macaddr++ = hextoul(pbuf);
}
/******************************************************************************
* FunctionName : urldecode