#include "os/os.h"
#include "lwip/netif.h"
+#define TICKS_PHY_AUTONEG 4000
+
/* this MAC address is used when user put NULL on the right place when calling postInit function */
#define RPP_MAC_ADDR {0x12,0x34,0x56,0x78,0x9a,0xbc}
#if STATIC_IP_ADDRESS
* @param waitTicksForPHYAneg maximum amount of ticks it will wait for autonegotiation
*
* @return SUCCESS if init successful.
+ * FAILURE if module was already initialized
* NETIF_ADD_ERR if lwip netif was not succesfully initialized or on low hw init error.
* DHCP_MEM_ERR if DHCP unsuccesfull.
* DHCP_BIND_TIMEOUT
*/
err_t rpp_eth_stringToIP(ip_addr_t * ip, uint8_t * ipstr);
+/**
+ * Converts given null terminated string containing number to number in
+ * range <1-65535>
+ *
+ * @param string to be converted
+ * @return 0 on error
+ * port number otherwise
+ */
+uint16_t rpp_eth_portStrToInt(uint8_t *string);
+
/**
* Returns struct describing network interface
*
return SUCCESS;
}
+/* returns number in range 0-65535 where 0 is error */
+uint16_t rpp_eth_portStrToInt(uint8_t *string)
+{
+ uint8_t index;
+ uint16_t portNO = 0;
+ for(index = 0;string[index] != '\0';index++)
+ {
+ if(string[index] < '0' || string[index] > '9')
+ {
+ portNO = 0;
+ break;
+ }
+ portNO = portNO * 10 + string[index] - '0';
+ }
+ return portNO;
+}
+
struct netif *rpp_eth_get_netif(uint32_t instNum)
{
return &hdkNetIF[instNum];
if(rpp_eth_phylinkstat(hdkif->inst_num))
{
- rpp_debug_printf((const char *)"cable connected\r\n");
+ rpp_debug_printf((const char *)"cable connected ... setting IP params\r\n");
#if STATIC_IP_ADDRESS
netif_set_up(netif);
#elif LWIP_DHCP /* STATIC_IP_ADDRESS-LWIP_DHCP */
netif->name[1] = IFNAME1;
- hdkif->waitTicksForPHYAneg = 4000;
+ hdkif->waitTicksForPHYAneg = TICKS_PHY_AUTONEG;
/*
* Initialize the snmp variables and counters inside the struct netif.
}
last_rxbd->next = NULL;
-#ifdef DEBUG
- rpp_debug_printf((const char *) "last_rxbd: 0x%x\r\n",last_rxbd);
-#endif
rxch->active_tail = last_rxbd;
num_bd = (((uint32_t)rxch->active_tail - (uint32_t)rxch->active_head) / sizeof(struct emac_rx_bd) + 1);
-#ifdef DEBUG
- rpp_debug_printf((const char *) "num of filled bds: %d\r\nnum of pbufs: %d\r\n", num_bd, pbuf_cnt);
-#endif
/* for flow control - there could be set an interrupt when we reach preset amount of receive descriptors remaining - see RXBUFFERFLOWEN */