OpenCores
URL https://opencores.org/ocsvn/1g_ethernet_dpi/1g_ethernet_dpi/trunk

Subversion Repositories 1g_ethernet_dpi

[/] [1g_ethernet_dpi/] [tags/] [v0.0/] [sw/] [dev/] [test_main/] [src/] [main/] [test_main.c] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 kuzmi4
/*
2
 * simple test application
3
 *
4
 * UART baud rate == 115200
5
 *
6
 */
7
 
8
#include <stdio.h>
9
#ifndef MSIM
10
 #include "platform.h"
11
#else
12
 #include "xil_printf.h"
13
#endif // MSIM
14
 
15
 
16
#include "xparameters.h" // XPAR_TMEMAC_0_BASEADDR, XPAR_AXIDMA_0_DEVICE_ID, XPAR_BRAM_0_BASEADDR
17
#include "tri_mode_emac.h" // tmemac_cfg_t
18
 
19
#include "xil_lib.h" // xil_malloc, xil_free
20
 
21
#include "net.h" // net_init, net_input
22
#include "arp.h"
23
#include "ip.h"
24
 
25
// CFG:
26
//  eth pkt
27
#define ETH_MIN_PKT_LEN 64
28
#define ETH_MAX_PKT_LEN 1024
29
//  tri_mode_emac
30
tmemac_cfg_t tmemac_cfg;
31
 
32
// lightweight version of stdio-GETCHAR / !!!no HDR-file for inbyte.c!!!
33
char inbyte(void);
34
 
35
// MAIN
36
int main(void)
37
{
38
    // dec vars
39
    int result;
40
 
41
    // init
42
#ifndef MSIM
43
    init_platform();
44
#else
45
    ublaze_initial(); ublaze_wait(100);
46
#endif // MSIM
47
 
48
    // msg2usr
49
    xil_printf("Hello from MICROB\n\r");
50
    // w8
51
#ifndef MSIM
52
    inbyte();// w8 4 user
53
#endif // MSIM
54
 
55
    // prep cfg / MAC: {locally administered address}!!!
56
    tmemac_cfg.base     = XPAR_TMEMAC_0_BASEADDR;
57
    tmemac_cfg.mac_high = _MAC_ADDR_HIGH(0x02, 0x05);               //       02-05
58
    tmemac_cfg.mac_low  = _MAC_ADDR_LOW( 0x69, 0x03, 0x04, 0x05);   // 69-03-04-05
59
    tmemac_cfg.ip_addr  = _IP_ADDR(192,168,43,5);                   // !!!RFC6890: Priv-16 / RFC1918
60
 
61
    // net init
62
    result = net_init(  &tmemac_cfg,
63
                        (XPAR_BRAM_0_BASEADDR + 0),
64
                        (XPAR_BRAM_0_BASEADDR + ETH_MAX_PKT_LEN));
65
    if (result) {
66
        xil_printf("ERR: net_init: %x\n\r", result);
67
        xil_printf("MICROB: exit\n\r");
68
        return -1;
69
    }
70
 
71
    // rx-buff-malloc
72
    char *buff = (char *)xil_malloc(ETH_MAX_PKT_LEN);
73
    if (!buff){
74
        xil_printf("ERR: xil_malloc\n\r");
75
        xil_printf("MICROB: exit\n\r");
76
        return -1;
77
    }
78
 
79
    // proc-loop
80
    while (1) {
81
        // proc
82
        result = net_input(buff);
83
        // check err
84
        if (result < 0) {
85
            xil_printf("ERR: net_input: %x\n\r", result);
86
            break;
87
        }
88
        // check rxd
89
        if (result) {
90
            // ARP
91
            eth_arp(buff);
92
            // IP-ICMP
93
            eth_ip(buff);
94
        }
95
    }
96
    // if we are here -> clean+msg2usr
97
    xil_free(buff);
98
    xil_printf("MICROB: exit\n\r");
99
 
100
    // Final
101
#ifndef MSIM
102
    cleanup_platform();
103
#else
104
    //ublaze_final();
105
#endif // MSIM
106
    return 0;
107
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.