Commit 1fc9fea9 authored by li hongming's avatar li hongming

Add tcpip module present signal.

parent 76a3863c
...@@ -7,16 +7,30 @@ ...@@ -7,16 +7,30 @@
#include "hw/tcpip-config.h" #include "hw/tcpip-config.h"
#include "tcpip_config.h" #include "tcpip_config.h"
enum tcpip_status tcpip_status = TCPIP_OK; extern uint8_t tcpip_status = TCPIP_NULL;
uint8_t tcpip_present()
{
if ((*(uint16_t *)(BASE_TCPIP_CFG+TCPIP_STATUS_HIGH))> 0)
{
tcpip_status = TCPIP_PRS;
return 1;
} else
return 0;
}
void tcpip_init(void) void tcpip_init(void)
{ {
uint8_t tcpip_mac_addr[6]; uint8_t tcpip_mac_addr[6];
uint8_t tmp_ip_addr[4]; uint8_t tmp_ip_addr[4];
uint32_t tmp_mac_addr=0;
if (!tcpip_present())
{
pp_printf("No TCPIP module is found!\n");
return;
}
get_mac_addr(tcpip_mac_addr); get_mac_addr(tcpip_mac_addr);
pp_printf("mac is %x:%x\n",tcpip_mac_addr[0],tcpip_mac_addr[1]);
memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_HIGH16 + 2), (uint8_t *)tcpip_mac_addr, 2); memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_HIGH16 + 2), (uint8_t *)tcpip_mac_addr, 2);
memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_LOW32), (uint8_t *)tcpip_mac_addr+2, 4); memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_LOW32), (uint8_t *)tcpip_mac_addr+2, 4);
...@@ -104,7 +118,7 @@ void tcpip_rx_tcp_port(uint16_t port) ...@@ -104,7 +118,7 @@ void tcpip_rx_tcp_port(uint16_t port)
*rtp = (uint32_t)port; *rtp = (uint32_t)port;
} }
void tcpip_poll() uint8_t tcpip_poll()
{ {
uint8_t * ip; uint8_t * ip;
static uint16_t arp_count = 0; static uint16_t arp_count = 0;
...@@ -126,7 +140,7 @@ void tcpip_poll() ...@@ -126,7 +140,7 @@ void tcpip_poll()
DEFINE_WRC_TASK(tcpip) = { DEFINE_WRC_TASK(tcpip) = {
.name = "tcpip", .name = "tcpip",
.enable = &link_status, .enable = &tcpip_status,
.init = tcpip_init, .init = tcpip_init,
.job = tcpip_poll, .job = tcpip_poll,
}; };
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#ifndef TCPIP_CONFIG #ifndef TCPIP_CONFIG
#define TCPIP_CONFIG #define TCPIP_CONFIG
#define ERROR_STATUS_HIGH 0 #define TCPIP_STATUS_HIGH 0
#define ERROR_STATUS_LOW 4 #define TCPIP_STATUS_LOW 4
#define SDB_ADDRESS_HIGH 8 #define SDB_ADDRESS_HIGH 8
#define SDB_ADDRSES_LOW 12 #define SDB_ADDRSES_LOW 12
......
...@@ -14,10 +14,10 @@ void tcpip_get_hisIP(uint8_t *ip); ...@@ -14,10 +14,10 @@ void tcpip_get_hisIP(uint8_t *ip);
void tcpip_set_hisMAC(uint8_t mac_addr[]); void tcpip_set_hisMAC(uint8_t mac_addr[]);
void tcpip_rx_tcp_port(uint16_t port); void tcpip_rx_tcp_port(uint16_t port);
enum tcpip_status { #define TCPIP_NULL 0
TCPIP_ARP, #define TCPIP_PRS 1
TCPIP_OK, #define TCPIP_ARP 2
}; #define TCPIP_OK 3
extern enum tcpip_status tcpip_status; uint8_t tcpip_status;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment