mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2026-07-06 11:25:39 +00:00
add set mac, cmsis-dap load sdram, ...
This commit is contained in:
parent
0830a1244a
commit
b381813514
27 changed files with 255 additions and 88 deletions
|
|
@ -1269,20 +1269,21 @@ void fATFO(void *arg) {
|
|||
rdsize = size;
|
||||
else
|
||||
rdsize = 8 * symbs_line;
|
||||
flash_otp_read(&flashobj, addr, rdsize, flash_data);
|
||||
uint8_t *ptr = flash_data;
|
||||
while (ptr < flash_data + rdsize) {
|
||||
if (symbs_line > size)
|
||||
symbs_line = size;
|
||||
printf("%08X ", addr);
|
||||
print_hex_dump(ptr, symbs_line, ' ');
|
||||
printf("\r\n");
|
||||
addr += symbs_line;
|
||||
ptr += symbs_line;
|
||||
size -= symbs_line;
|
||||
if (size == 0)
|
||||
break;
|
||||
}
|
||||
if (flash_otp_read(&flashobj, addr, rdsize, flash_data)) {
|
||||
uint8_t *ptr = flash_data;
|
||||
while (ptr < flash_data + rdsize) {
|
||||
if (symbs_line > size)
|
||||
symbs_line = size;
|
||||
printf("%08X ", addr);
|
||||
print_hex_dump(ptr, symbs_line, ' ');
|
||||
printf("\r\n");
|
||||
addr += symbs_line;
|
||||
ptr += symbs_line;
|
||||
size -= symbs_line;
|
||||
if (size == 0)
|
||||
break;
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
free(flash_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -635,10 +635,38 @@ int wifi_is_ready_to_transceive(rtw_interface_t interface) {
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ int wext_set_mac_address(const char *ifname, char * mac)
|
|||
{
|
||||
char buf[13+17+1];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, 13+17, "write_mac %s", mac);
|
||||
snprintf(buf, 13+17, "write_mac %02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return wext_private_command(ifname, buf, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#include "main.h"
|
||||
#include "wifi_user_set.h"
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
#undef debug_printf
|
||||
#define debug_printf(fmt, ...) rtl_printf(fmt, ##__VA_ARGS__)
|
||||
#undef info_printf
|
||||
|
|
@ -558,7 +558,7 @@ LOCAL int _wifi_on(rtw_mode_t mode) {
|
|||
wext_set_adaptivity(wifi_cfg.adaptivity & 3);
|
||||
|
||||
debug_printf("Wlan0 init...\n");
|
||||
|
||||
// rltk_wlan_deinit_fastly();
|
||||
ret = rltk_wlan_init(WLAN0_IDX, mode); // rtw_mode_t
|
||||
|
||||
debug_printf("netif_set_up 0...\n");
|
||||
|
|
|
|||
|
|
@ -284,10 +284,10 @@ int uartadapter_uart_open(ua_socket_t *ua_socket, ua_uart_set_str *puartpara)
|
|||
#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*/
|
||||
|
|
|
|||
|
|
@ -287,9 +287,9 @@ int reset_uart_atcmd_setting(){
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UART_AT_RX_WAKE
|
||||
#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)
|
||||
{
|
||||
/* WAKELOCK_LOGUART is also handled in log service.
|
||||
|
|
@ -301,16 +301,12 @@ void gpio_uart_at_rx_irq_callback (uint32_t id, gpio_irq_event event)
|
|||
void uart_at_rx_wakeup()
|
||||
{
|
||||
gpio_irq_t gpio_rx_wake;
|
||||
#ifdef RTL8711AM
|
||||
#if (UART_AT_RX_WAKE!=PA_0)||(UART_AT_RX_WAKE!=PE_3)
|
||||
#error "Set pin rx_wakeup!"
|
||||
#endif
|
||||
#endif
|
||||
gpio_irq_init(&gpio_rx_wake, UART_AT_RX_WAKE, gpio_uart_at_rx_irq_callback, 0);
|
||||
gpio_irq_set(&gpio_rx_wake, IRQ_FALL, 1); // Falling Edge Trigger
|
||||
gpio_irq_enable(&gpio_rx_wake);
|
||||
}
|
||||
#endif
|
||||
#endif // UART_AT_RX_WAKE
|
||||
|
||||
void uart_atcmd_reinit(UART_LOG_CONF* uartconf){
|
||||
serial_baud(&at_cmd_sobj,uartconf->BaudRate);
|
||||
|
|
@ -318,14 +314,15 @@ 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
|
||||
// unsigned rxflow = UART_RTS;
|
||||
unsigned 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)
|
||||
|
|
@ -535,21 +532,25 @@ void uart_atcmd_main(void)
|
|||
{
|
||||
UART_LOG_CONF uartconf;
|
||||
|
||||
unsigned rx = UART_RX;
|
||||
unsigned tx = UART_TX;
|
||||
unsigned rxflow = UART_RTS;
|
||||
unsigned txflow = UART_CTS;
|
||||
|
||||
read_uart_atcmd_setting_from_system_data(&uartconf);
|
||||
serial_init(&at_cmd_sobj, UART_TX, UART_RX);
|
||||
serial_init(&at_cmd_sobj, tx, rx);
|
||||
printf("tx: %02x, rx: %02x\n", tx, rx);
|
||||
serial_baud(&at_cmd_sobj,uartconf.BaudRate);
|
||||
serial_format(&at_cmd_sobj, uartconf.DataBits, (SerialParity)uartconf.Parity, uartconf.StopBits);
|
||||
serial_rx_fifo_level(&at_cmd_sobj, FifoLvHalf);
|
||||
// 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);
|
||||
|
||||
/*uart_at_lock_init();*/
|
||||
|
||||
|
|
@ -564,9 +565,11 @@ 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);
|
||||
|
||||
#ifdef UART_AT_RX_WAKE
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
uart_at_rx_wakeup();
|
||||
#endif
|
||||
#endif // UART_AT_RX_WAKE
|
||||
}
|
||||
|
||||
static void uart_atcmd_thread(void *param)
|
||||
|
|
|
|||
|
|
@ -13,33 +13,45 @@
|
|||
#include "osdep_api.h"
|
||||
|
||||
|
||||
#if defined(RTL8710AF)
|
||||
// RTL8710AF
|
||||
#define UART_TX PA_4 // PC_3
|
||||
#define UART_RX PA_0 // PC_0
|
||||
#define UART_RTS PA_2 // PC_2
|
||||
#define UART_CTS PA_1 // PC_1
|
||||
|
||||
#elif 0 // defined(RTL8711AM)
|
||||
// RTL8711AM
|
||||
#define UART_TX PA_7
|
||||
#define UART_RX PA_6 // no Interrupt!
|
||||
#define UART_RTS PA_3
|
||||
#define UART_CTS PA_5
|
||||
|
||||
#elif 0 // else
|
||||
#if defined(RTL8710AF) && defined(RTL8711AM)
|
||||
#if 0
|
||||
// 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 1
|
||||
// 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 + RTL8710AF
|
||||
#define UART_TX PE_0
|
||||
#define UART_RX PE_3
|
||||
#define UART_RTS PE_1
|
||||
#define UART_CTS PE_2
|
||||
// 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
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ 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);
|
||||
// rxflow and tx flow is fixed by hardware
|
||||
void serial_set_flow_control(serial_t *obj, FlowControl type);// PinName rxflow, PinName txflow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -587,6 +587,26 @@ 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
|
||||
*/
|
||||
|
|
@ -619,17 +639,25 @@ int flash_otp_read(flash_t *obj, uint32_t address, uint32_t Length,
|
|||
flashobj.SpicInitPara.Mode.BitMode);
|
||||
SpicTxCmdWithDataRtl8195A(FLASH_CMD_WRDI, 0, 0, flashobj.SpicInitPara); // exit secured OTP
|
||||
break;
|
||||
// case FLASH_OTHERS: // ?
|
||||
case FLASH_MICRON: // (4Bh) READ OTP ARRAY
|
||||
#if CONFIG_DEBUG_LOG > 4
|
||||
DBG_SPIF_INFO("MICRON: @TODO !\n");
|
||||
#endif
|
||||
// FLASH_CMD_ROTPA
|
||||
ret = 0;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
DBG_8195A("Flash type?");
|
||||
DBG_8195A("Flash type %d [%06x]?\n", flashobj.SpicInitPara.flashtype, flash_read_id(&flashobj));
|
||||
/* Read Flash status reg */
|
||||
/*
|
||||
SpicRxCmdRefinedRtl8195A(0x05, flashobj.SpicInitPara);
|
||||
u16 st = HAL_SPI_READ32(REG_SPIC_DR0);
|
||||
SpicRxCmdRefinedRtl8195A(0x35, flashobj.SpicInitPara);
|
||||
st = (st & 0xFF) | (HAL_SPI_READ32(REG_SPIC_DR0) << 8);
|
||||
DBG_8195A("Flash status: 0x%04x\n", st);
|
||||
*/
|
||||
ret = 0;
|
||||
}
|
||||
SpicDisableRtl8195A();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -436,7 +436,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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue