/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ /* os shim includes */ #include "os_types.h" #include "os_task.h" #include "os_utils.h" /* common includes */ #include "iot_io.h" #include "iot_bitops.h" #include "iot_pkt.h" #include "iot_ipc.h" #include "iot_plc_lib.h" #include "iot_dbglog_api.h" #include "iot_config.h" /* driver includes */ #include "iot_clock.h" #include "iot_uart.h" #include "iot_led.h" /* cli includes */ #include "iot_cli.h" #include "iot_uart_h.h" /* debug includes*/ #include "dbg_io.h" #include "iot_gpio_api.h" #include "apb_glb_reg.h" #include "hw_reg_api.h" #include "gpio_mtx_reg.h" #include "pin_rf.h" #include "gpio_mtx.h" #include "iot_share_task.h" static const iot_pkt_config_t test_pkt_config = { { { 256, 50, PKT_OWNER_ALL, }, { 600, 50, PKT_OWNER_ALL, }, { 1100, 15, PKT_OWNER_ALL, }, { 2200, 6, PKT_OWNER_ALL, }, { 0, 0, PKT_OWNER_NONE, }, { 0, 0, PKT_OWNER_NONE, }, { 0, 0, PKT_OWNER_NONE, }, { 0, 0, PKT_OWNER_NONE, }, } }; void mdelay(uint32_t m) { volatile int i= 0; for(int j = 0 ; j < m; j++){ for(i = 0; i < 1000000; i++); } } #include "iot_pkt.h" #include "dwc_eth.h" t_dwc_ctrl *g_emac_ctrl = NULL; #define EMAC_TEST_UNIT 0 char arp_str[] = {0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x11,0x22,0x33, 0x44,0x55, 0x08,0x06,0x00,0x01,0x08,0x00,0x06,0x04, 0x00,0x01, 0x00,0x11,0x22,0x33,0x44,0x55, 0xc0,0xa8, 0x04,0xa3, 0x00,0x00,0x00,0x00,0x00,0x00, 0xc0,0xa8, 0x04,0x01, 0x00,0x00,0x00,0x00}; char dst_ip[] = {192, 168, 4, 163}; char src_ip[] = {192, 168, 4, 28}; os_task_h test_init_handle; extern int platform_init(); void signal_dump(int sig) { int data; if(sig < 57) { data = *(volatile int*)(0x44020000 + 0x4*sig); iot_printf("\r\nSIGN#%02d(CORE#%02d, DEFT#%02d) <- GPIO#%03d.", sig, (data&0x1000)?1:0, (data&0x300)>>8, data&0xFF); } else { iot_printf("\r\nSIGN#%02d INVALID!"); } } void gpio_dump(int g) { int data, data2, addr; if(g < 47) { if(g < 29){ addr = 0x44007000 + 0x24 + (g << 2); } else if(g < 37 ){ addr = 0x44007000 + 0x4 + ((g-29)<<2); } else if(g < 43){ addr = 0x44007000 + 0xa8 + ((g-37)<<2); } else if( g < 47){ addr =0x44007000 + 0x98 + ((g-43)<< 2); } data = *(volatile int*)addr; data2 = *(volatile int*)(0x44020400 + 0x4*g); iot_printf("\r\nGPIO#%02d(FUNC#%02d, PULL#%c%c) <- SIGN#%03d.", g, (data&0x30)>>4, (data&0x80)?'U':'-', (data&0x40)?'D':'-', data2&0xFF); } else { iot_printf("\r\nGPIO#%02d INVALID!"); } } void eth_gpio_dump(void) { int g; for(g = 8; g < 15; g++) { gpio_dump(g); } gpio_dump(18); gpio_dump(19); signal_dump(43); } extern void dwc_gpio_bind(int unit); void eth_test_send_ping(void) { iot_pkt_ls lst; uint8_t * data, p_mac[6]; lst.pkt = iot_pkt_alloc(52, 0); lst.next = NULL; os_mem_cpy(lst.pkt->head, arp_str, sizeof(arp_str)); iot_pkt_set_data(lst.pkt, lst.pkt->head); iot_pkt_set_tail(lst.pkt, lst.pkt->data + sizeof(arp_str)); data = lst.pkt->data; dwc_mac_addr_get(g_emac_ctrl, p_mac); data[6] = p_mac[0]; data[7] = p_mac[1]; data[8] = p_mac[2]; data[9] = p_mac[3]; data[10] = p_mac[4]; data[11] = p_mac[5]; data[22] = p_mac[0]; data[23] = p_mac[1]; data[24] = p_mac[2]; data[25] = p_mac[3]; data[26] = p_mac[4]; data[27] = p_mac[5]; data[28] = src_ip[0]; data[29] = src_ip[1]; data[30] = src_ip[2]; data[31] = src_ip[3]; data[38] = dst_ip[0]; data[39] = dst_ip[1]; data[40] = dst_ip[2]; data[41] = dst_ip[3]; dwc_eth_send_frame(g_emac_ctrl, &lst); return; } void eth_test_rcv(t_dwc_ctrl* p_ctrl, uint8_t * data, uint32_t len) { int i; iot_printf("\r\nEth rcv (port=%d, pack_len=%d),packet dump :\r\n", p_ctrl->unit, len); for(i=0; i