This commit is contained in:
pvvx 2017-12-28 18:44:55 +03:00
parent 8c8b03208e
commit 8e26e8ec8d
24 changed files with 2592 additions and 2483 deletions

View file

@ -415,6 +415,7 @@ void log_service(void *param)
#if CONFIG_INIC_EN
inic_cmd_ioctl = 0;
#endif
extern int tcm_heap_freeSpace(void);
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\n\r[MEM] After do cmd, available heap %d+%d\n\r", xPortGetFreeHeapSize(), tcm_heap_freeSpace());
_AT_DBG_MSG(AT_FLAG_COMMON, AT_DBG_ALWAYS, "\r\n\n# "); //"#" is needed for mp tool
#if CONFIG_EXAMPLE_UART_ATCMD
@ -493,5 +494,5 @@ void at_log_init(void)
{
log_service_add_table(at_log_items, sizeof(at_log_items)/sizeof(at_log_items[0]));
}
log_module_init(at_log_init);
//log_module_init(at_log_init);
#endif

View file

@ -634,12 +634,39 @@ int wifi_is_ready_to_transceive(rtw_interface_t interface) {
}
return RTW_ERROR;
}
//----------------------------------------------------------------------------//
int wifi_set_mac_address(char * mac) {
char buf[13 + 17 + 1];
rtw_memset(buf, 0, sizeof(buf));
snprintf(buf, 13 + 17, "write_mac %s", mac);
int mactostr(char * s, unsigned char *mac, bool fmt)
{
char *ptrb = s;
unsigned char *ptrm = mac;
int i = 6;
while(i--) {
unsigned char x = ptrm[0] >> 4;
if (x <= 9) ptrb[0] = x + '0';
else ptrb[0] = x - 10 + 'a';
ptrb++;
x = ptrm[0] & 0x0f;
if (x <= 9) ptrb[0] = x + '0';
else ptrb[0] = x - 10 + 'a';
ptrb++;
ptrm++;
if(fmt && i) {
ptrb[0] = ':';
ptrb++;
}
};
*ptrb = '\0';
if (fmt) return 12+5;
return 12;
}
//----------------------------------------------------------------------------//
int wifi_set_mac_address(char * new_mac) {
// char buf[13 + 17 + 1];
char buf[10 + 12 + 1];
memcpy(buf,"write_mac ", 10);
// snprintf(buf, 13 + 17, "write_mac %s", mac);
//BAG NotWork! rtl_sprintf(buf, "write_mac %02x%02x%02x%02x%02x%02x", new_mac[0], new_mac[1], new_mac[2], new_mac[3], new_mac[4], new_mac[5]);
mactostr(&buf[10], new_mac, false);
return wext_private_command(WLAN0_NAME, buf, SHOW_PRIVATE_OUT);
}
@ -656,6 +683,7 @@ int wifi_get_mac_address(char * mac) {
return ret;
}
//----------------------------------------------------------------------------//
int wifi_enable_powersave(void) {
return wext_enable_powersave(WLAN0_NAME, 1, 1);

View file

@ -703,6 +703,8 @@ int wifi_disable_packet_filter(unsigned char filter_id);
int wifi_remove_packet_filter(unsigned char filter_id);
#endif
int mactostr(char * s, unsigned char *mac, bool fmt);
#ifdef __cplusplus
}
#endif

View file

@ -280,8 +280,9 @@ int SC_send_simple_config_ack(u8 round)
#endif
}
}
#if LEAVE_ACK_EARLY
leave_ack:
#endif
close(ack_socket);
#endif
@ -296,7 +297,6 @@ leave_ack:
static int SC_check_and_show_connection_info(void)
{
rtw_wifi_setting_t setting;
int ret = -1;
#if CONFIG_LWIP_LAYER
@ -308,6 +308,7 @@ static int SC_check_and_show_connection_info(void)
#endif
#if CONFIG_EXAMPLE_UART_ATCMD == 0
rtw_wifi_setting_t setting;
wifi_get_setting(WLAN0_NAME, &setting);
wifi_show_setting(WLAN0_NAME, &setting);
#endif
@ -614,7 +615,7 @@ int SC_connect_to_candidate_AP (rtw_network_info_t *wifi){
}
/* call wifi scan to scan */
if(scan_cnt = (wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf)) < 0){
if((scan_cnt = (wifi_scan(RTW_SCAN_TYPE_ACTIVE, RTW_BSS_TYPE_ANY, &scan_buf))) < 0){
printf("ERROR: wifi scan failed\n");
ret = RTW_ERROR;
}else{
@ -696,7 +697,7 @@ enum sc_result SC_connect_to_AP(void)
goto wifi_connect_fail;
}
rtw_join_status = 0;//clear simple config status
ret = wifi_connect(g_bssid,
ret = wifi_connect(g_bssid,
1,
(char*)wifi.ssid.val,
wifi.security_type,
@ -704,7 +705,7 @@ enum sc_result SC_connect_to_AP(void)
wifi.key_id,
NULL);
if (ret == RTW_SUCCESS)
if (ret == 0)
goto wifi_connect_success;
if (retry == max_retry) {
@ -718,7 +719,7 @@ enum sc_result SC_connect_to_AP(void)
#if 1
/* when optimization fail: if connect with bssid fail because of we have connect to the wrong AP */
ret = SC_connect_to_candidate_AP(&wifi);
if (RTW_SUCCESS == ret) {
if (ret == 0) {
goto wifi_connect_success;
} else {
ret = SC_JOIN_BSS_FAIL;
@ -769,15 +770,15 @@ extern void rtk_sc_deinit(void);
void init_simple_config_lib_config(struct simple_config_lib_config* config)
{
config->free = rtw_mfree;
config->malloc = rtw_malloc;
config->free = (simple_config_free_fn) rtw_mfree;
config->malloc = (simple_config_malloc_fn) rtw_malloc;
config->memcmp = memcmp;
config->memcpy = memcpy;
config->memset = memset;
config->memset = (simple_config_memset_fn) memset;
config->printf = printf;
config->strcpy = strcpy;
config->strlen = strlen;
config->zmalloc = rtw_zmalloc;
config->zmalloc = (simple_config_zmalloc_fn) rtw_zmalloc;
#if CONFIG_LWIP_LAYER
config->_ntohl = lwip_ntohl;
#else

View file

@ -280,14 +280,14 @@ int uartadapter_uart_open(ua_socket_t *ua_socket, ua_uart_set_str *puartpara)
serial_rx_fifo_level(&ua_socket->uart.uart_sobj, FifoLvHalf);
//---------------------------- add Flow
#define rxflow UA_UART_RTS_PIN
#define txflow UA_UART_CTS_PIN
// #define rxflow UA_UART_RTS_PIN
// #define txflow UA_UART_CTS_PIN
if(puartpara->FlowControl){
pin_mode(txflow, PullDown); // init CTS in low
serial_set_flow_control(&ua_socket->uart.uart_sobj, FlowControlRTSCTS, rxflow, txflow);
serial_set_flow_control(&ua_socket->uart.uart_sobj, FlowControlRTSCTS);//, rxflow, txflow);
}
else
serial_set_flow_control(&ua_socket->uart.uart_sobj, FlowControlNone, rxflow, txflow);
serial_set_flow_control(&ua_socket->uart.uart_sobj, FlowControlNone);//, rxflow, txflow);
//---------------------------- add Flow
/*uart irq handle*/

View file

@ -269,10 +269,9 @@ int reset_uart_atcmd_setting(){
return 0;
}
#if ATCMD_RX_GPIO_WAKEUP
#ifdef UART_AT_RX_WAKE // UART_RX
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
#include "gpio_irq_api.h"
#define UART_AT_RX_WAKE UART_RX
void gpio_uart_at_rx_irq_callback (uint32_t id, gpio_irq_event event)
{
/* PMU_LOGUART_DEVICE is also handled in log service.
@ -289,7 +288,6 @@ void uart_at_rx_wakeup()
gpio_irq_enable(&gpio_rx_wake);
}
#endif
#endif
void uart_atcmd_reinit(UART_LOG_CONF* uartconf){
serial_baud(&at_cmd_sobj,uartconf->BaudRate);
@ -297,14 +295,12 @@ void uart_atcmd_reinit(UART_LOG_CONF* uartconf){
// set flow control, only support RTS and CTS concurrent mode
// rxflow and tx flow is fixed by hardware
#define rxflow UART_RTS
#define txflow UART_CTS
if(uartconf->FlowControl){
pin_mode(txflow, PullDown); //init CTS in low
serial_set_flow_control(&at_cmd_sobj, FlowControlRTSCTS, rxflow, txflow);
serial_set_flow_control(&at_cmd_sobj, FlowControlRTSCTS); // , rxflow, txflow);
}
else
serial_set_flow_control(&at_cmd_sobj, FlowControlNone, rxflow, txflow);
serial_set_flow_control(&at_cmd_sobj, FlowControlNone); // , rxflow, txflow);
}
void uart_at_send_string(char *str)
@ -532,10 +528,10 @@ void uart_atcmd_main(void)
#define txflow UART_CTS
if(uartconf.FlowControl){
pin_mode(txflow, PullDown); //init CTS in low
serial_set_flow_control(&at_cmd_sobj, FlowControlRTSCTS, rxflow, txflow);
serial_set_flow_control(&at_cmd_sobj, FlowControlRTSCTS); //, rxflow, txflow);
}
else
serial_set_flow_control(&at_cmd_sobj, FlowControlNone, rxflow, txflow);
serial_set_flow_control(&at_cmd_sobj, FlowControlNone); //, rxflow, txflow);
/*uart_at_lock_init();*/
@ -550,7 +546,7 @@ void uart_atcmd_main(void)
serial_irq_handler(&at_cmd_sobj, uart_irq, (uint32_t)&at_cmd_sobj);
serial_irq_set(&at_cmd_sobj, RxIrq, 1);
#if ATCMD_RX_GPIO_WAKEUP
#ifdef UART_AT_RX_WAKE
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
uart_at_rx_wakeup();
#endif

View file

@ -12,20 +12,48 @@
#include "semphr.h"
/*UART Pinmux*/
#define CONFIG_AMEBA1 1
#if CONFIG_AMEBA1
#define UART_TX PA_4
#define UART_RX PA_0
#define UART_RTS PA_2
#define UART_CTS PA_1
#else
#define UART_TX PA_23
#define UART_RX PA_18
#define UART_RTS PA_22
#define UART_CTS PA_19
#if defined(RTL8710AF) && defined(RTL8711AM)
#if 1
// RTL8711AM + RTL8710AF + RTL8195AM
#define UART_TX PE_0
#define UART_RX PE_3
#define UART_AT_RX_WAKE PE_3
#define UART_RTS PE_1
#define UART_CTS PE_2
#elif 0
// RTL8711AM + RTL8710AF
#define UART_TX PC_3
#define UART_RX PC_0 // no Interrupt!
//#define UART_AT_RX_WAKE PE_3
#define UART_RTS PC_2
#define UART_CTS PC_1
#elif 0
// RTL8711AM - RAK473
#define UART_TX PA_7
#define UART_RX PA_6 // no Interrupt!
//#define UART_RX_INT PE_3
#define UART_RTS PA_3
#define UART_CTS PA_5
#endif
#elif defined(RTL8710AF)
// RTL8710AF
#define UART_TX PA_4
#define UART_RX PA_0
#define UART_AT_RX_WAKE PA_0
#define UART_RTS PA_2
#define UART_CTS PA_1
#elif defined(RTL8711AM)
// RTL8711AM - RAK473
#define UART_TX PA_7
#define UART_RX PA_6 // no Interrupt!
//#define UART_AT_RX_WAKE PE_3
#define UART_RTS PA_3
#define UART_CTS PA_5
#endif
#define ATCMD_RX_GPIO_WAKEUP 0
#define KEY_NL 0xa // '\n'
#define KEY_ENTER 0xd // '\r'
#define KEY_BS 0x8

View file

@ -67,7 +67,7 @@ void serial_break_clear(serial_t *obj);
void serial_pinout_tx(PinName tx);
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
void serial_set_flow_control(serial_t *obj, FlowControl type); // , PinName rxflow, PinName txflow);
#ifdef __cplusplus
}

View file

@ -47,6 +47,7 @@ int flash_set_extend_addr (flash_t * obj, uint32_t data);
int flash_get_extend_addr (flash_t * obj);
unsigned int flash_get_size (flash_t *obj);
int flash_otp_read (flash_t *obj, uint32_t address, uint32_t Length, uint8_t * data);
unsigned int flash_read_id (flash_t *obj);
#ifdef __cplusplus
}

View file

@ -589,6 +589,27 @@ unsigned int flash_get_size(flash_t *obj) {
return flashchip_size;
}
unsigned int flash_read_id(flash_t *obj)
{
flash_turnon();
/* Disable SPI_FLASH User Mode */
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
/* Set Ctrlr1; 1 byte data frames */
HAL_SPI_WRITE32(REG_SPIC_CTRLR1, BIT_NDF(3));
/* Send flash RX command and read the data */
SpicRxCmdRefinedRtl8195A(FLASH_CMD_RDID, obj->SpicInitPara);
unsigned int ret = HAL_SPI_READ32(REG_SPIC_DR0);
/* Disable SPI_FLASH User Mode */
HAL_SPI_WRITE32(REG_SPIC_SSIENR, 0);
SpicDisableRtl8195A();
return ret;
}
/*
* Read Flash OTP data
*/
@ -604,6 +625,7 @@ int flash_otp_read(flash_t *obj, uint32_t address, uint32_t Length,
switch (flashobj.SpicInitPara.flashtype) {
case FLASH_MXIC_4IO:
case FLASH_MXIC: // Only 512 bits
case FLASH_OTHERS:
#if CONFIG_DEBUG_LOG > 4
DBG_SPIF_INFO("MXIC: Only 512 bits!\n");
#endif
@ -629,9 +651,10 @@ int flash_otp_read(flash_t *obj, uint32_t address, uint32_t Length,
ret = 0;
break;
default:
DBG_8195A("Flash type?");
DBG_8195A("Flash type [%06x]?\n", flash_read_id(&flashobj));
ret = 0;
}
SpicDisableRtl8195A();
return ret;
}

View file

@ -438,7 +438,7 @@ void serial_recv_comp_handler(serial_t *obj, void *handler, uint32_t id)
pHalRuartAdapter->RxCompCbPara = (void*)id;
}
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
void serial_set_flow_control(serial_t *obj, FlowControl type) // , PinName rxflow, PinName txflow)
{
PHAL_RUART_ADAPTER pHalRuartAdapter;