Explorar o código

Added network init for dhcp lease

jancoow %!s(int64=9) %!d(string=hai) anos
pai
achega
df83763f86
Modificáronse 3 ficheiros con 39 adicións e 0 borrados
  1. 3 0
      main.c
  2. 26 0
      make.sh
  3. 10 0
      network.h

+ 3 - 0
main.c

@@ -41,6 +41,7 @@
 #include "watchdog.h"
 #include "flash.h"
 #include "spidrv.h"
+#include "network.h"
 
 #include <time.h>
 #include "rtc.h"
@@ -236,6 +237,7 @@ int main(void)
 
     CardInit();
 
+    NetworkInit();
 	/*
 	 * Kroeske: sources in rtc.c en rtc.h
 	 */
@@ -252,6 +254,7 @@ int main(void)
     }
 
 
+
     RcInit();
     
 	KbInit();

+ 26 - 0
make.sh

@@ -0,0 +1,26 @@
+//
+// Created by janco on 25-2-16.
+//
+#include <dev/board.h>
+#include <sys/timer.h>
+#include <sys/confnet.h>
+
+#include <dev/nicrtl.h>
+
+#include <stdio.h>
+#include <io.h>
+#include <arpa/inet.h>
+#include <pro/dhcp.h>
+#include "network.h"
+
+void NetworkInit() {
+    /* Register de internet controller. */
+    if (NutRegisterDevice(&DEV_ETHER, 0, 0)) {
+        printf("Registering  failed.");
+    }/* Netwerk configureren op dhcp */
+    else if (NutDhcpIfConfig(DEV_ETHER_NAME, NULL, 0)) {
+        /* Done. */
+    }else {
+        printf("Now try 'ping %s' on your PC.\n", inet_ntoa(confnet.cdn_ip_addr));
+    }
+}

+ 10 - 0
network.h

@@ -0,0 +1,10 @@
+//
+// Created by janco on 25-2-16.
+//
+
+#ifndef _Network_H
+#define _Network_H
+
+extern void NetworkInit(void);
+
+#endif /* _Network_H */