now it is working

This commit is contained in:
Wolfgang Hottgenroth 2020-11-09 19:47:39 +01:00
parent d286756310
commit f433f3a28b

View File

@ -14,13 +14,17 @@
wiz_NetInfo netInfo = {
.mac = { 0xa0, 0x57, 0x62, 0x01, 0x02, 0x03 },
.ip = { 172, 16, 3, 210 },
.sn = { 255, 255, 255, 255 },
.gw = { 172, 16, 3, 1 },
.dns = { 172, 16, 3, 1 },
.dhcp = NETINFO_DHCP
};
#define DHCP_BUFFER_SIZE 2048
static uint8_t dhcpBuffer[DHCP_BUFFER_SIZE];
const uint8_t DHCP_SOCK = 6;
const uint8_t DHCP_SOCK = 0;
void wiz_cs_select(void) {
@ -76,14 +80,17 @@ static void wizDHCPHandler(void *handle) {
if (lastStablePhyLink != phyLink) {
coloredMsg(LOG_RED, "wizdh, ctlwizchip returns %d, phy link changed to %d", res, phyLink);
lastStablePhyLink = phyLink;
}
if (phyLink == PHY_LINK_ON) {
wiz_PhyConf wpc;
wizphy_getphyconf(&wpc);
coloredMsg(LOG_RED, "wizdh, wpc: b:%02x, m:%02x, s:%02x, d:%02x",
wpc.by, wpc.mode, wpc.speed, wpc.duplex);
} else if (phyLink == PHY_LINK_ON) {
if (! dhcpInitialized) {
memset(dhcpBuffer, 0, DHCP_BUFFER_SIZE);
reg_dhcp_cbfunc(wizDHCPAssign, wizDHCPUpdate, NULL);
DHCP_init(DHCP_SOCK, dhcpBuffer);
coloredMsg(LOG_RED, "wizI, DHCP initialized");
coloredMsg(LOG_RED, "wizdh, DHCP initialized");
dhcpInitialized = true;
}
@ -102,7 +109,7 @@ int wizInit() {
wizReset(true);
activeDelay(2);
wizReset(false);
activeDelay(2);
activeDelay(50);
coloredMsg(LOG_RED, "wizI, registering callbacks");
reg_wizchip_cs_cbfunc(wiz_cs_select, wiz_cs_deselect);
@ -114,9 +121,22 @@ int wizInit() {
coloredMsg(LOG_RED, "wizI, initializing Ethernet module");
int8_t res = wizchip_init(NULL, NULL);
uint8_t bufSizes[] = { 2, 2, 2, 2, 2, 2, 2, 2 };
int8_t res = wizchip_init(bufSizes, bufSizes);
coloredMsg(LOG_RED, "wizI, module driver returned %d", res);
wizphy_reset();
activeDelay(5);
coloredMsg(LOG_RED, "wizI, reset phy");
wiz_PhyConf wpc;
wpc.mode = PHY_MODE_MANUAL;
wpc.speed = PHY_MODE_MANUAL;
wpc.duplex = PHY_DUPLEX_FULL;
wizphy_setphyconf(&wpc);
activeDelay(5);
coloredMsg(LOG_RED, "wizI, phy config set");
wizchip_setnetinfo(&netInfo);
coloredMsg(LOG_RED, "wizI, netinfo set to Ethernet module");
@ -125,8 +145,8 @@ int wizInit() {
coloredMsg(LOG_RED, "wizI, CW_GET_ID: %d %02x %02x %02x %02x %02x %02x", res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
//schAdd(wizDHCPHandler, NULL, 0, 100);
//coloredMsg(LOG_RED, "wizI, DHCP handler scheduled");
schAdd(wizDHCPHandler, NULL, 0, 1000);
coloredMsg(LOG_RED, "wizI, DHCP handler scheduled");
return 0;
}