1 |
585 |
jeremybenn |
/******************************************************************************
|
2 |
|
|
* DISCLAIMER
|
3 |
|
|
* Please refer to http://www.renesas.com/disclaimer
|
4 |
|
|
******************************************************************************
|
5 |
|
|
Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.
|
6 |
|
|
*******************************************************************************
|
7 |
|
|
* File Name : hwEthernet.h
|
8 |
|
|
* Version : 1.00
|
9 |
|
|
* Description : Ethernet module device driver
|
10 |
|
|
******************************************************************************
|
11 |
|
|
* History : DD.MM.YYYY Version Description
|
12 |
|
|
* : 06.10.2009 1.00 First Release
|
13 |
|
|
******************************************************************************/
|
14 |
|
|
|
15 |
|
|
#ifndef HWETHERNET_H_INCLUDED
|
16 |
|
|
#define HWETHERNET_H_INCLUDED
|
17 |
|
|
|
18 |
|
|
/******************************************************************************
|
19 |
|
|
Includes <System Includes> , "Project Includes"
|
20 |
|
|
******************************************************************************/
|
21 |
|
|
|
22 |
|
|
#include "typedefine.h"
|
23 |
|
|
|
24 |
|
|
/******************************************************************************
|
25 |
|
|
Typedef definitions
|
26 |
|
|
******************************************************************************/
|
27 |
|
|
typedef struct Discript
|
28 |
|
|
{
|
29 |
|
|
uint32_t status;
|
30 |
|
|
ushort16_t bufsize;
|
31 |
|
|
ushort16_t size;
|
32 |
|
|
char8_t *buf_p;
|
33 |
|
|
struct Discript *next;
|
34 |
|
|
} ethfifo;
|
35 |
|
|
|
36 |
|
|
/******************************************************************************
|
37 |
|
|
Macro definitions
|
38 |
|
|
******************************************************************************/
|
39 |
|
|
#define BUFSIZE 256
|
40 |
|
|
#define ENTRY 8
|
41 |
|
|
|
42 |
|
|
#define ACT 0x80000000
|
43 |
|
|
#define DL 0x40000000
|
44 |
|
|
#define FP1 0x20000000
|
45 |
|
|
#define FP0 0x10000000
|
46 |
|
|
#define FE 0x08000000
|
47 |
|
|
|
48 |
|
|
#define RFOVER 0x00000200
|
49 |
|
|
#define RMAF 0x00000080
|
50 |
|
|
#define RRF 0x00000010
|
51 |
|
|
#define RTLF 0x00000008
|
52 |
|
|
#define RTSF 0x00000004
|
53 |
|
|
#define PRE 0x00000002
|
54 |
|
|
#define CERF 0x00000001
|
55 |
|
|
|
56 |
|
|
#define ITF 0x00000010
|
57 |
|
|
#define CND 0x00000008
|
58 |
|
|
#define DLC 0x00000004
|
59 |
|
|
#define CD 0x00000002
|
60 |
|
|
#define TRO 0x00000001
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* Renesas Ethernet API return defines
|
64 |
|
|
**/
|
65 |
|
|
#define R_ETHER_OK 0
|
66 |
|
|
#define R_ETHER_ERROR -1
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/******************************************************************************
|
70 |
|
|
Variable Externs
|
71 |
|
|
******************************************************************************/
|
72 |
|
|
|
73 |
|
|
/******************************************************************************
|
74 |
|
|
Functions Prototypes
|
75 |
|
|
******************************************************************************/
|
76 |
|
|
/**
|
77 |
|
|
* Renesas Ethernet API prototypes
|
78 |
|
|
**/
|
79 |
|
|
|
80 |
|
|
#ifdef __cplusplus
|
81 |
|
|
extern "C" {
|
82 |
|
|
#endif
|
83 |
|
|
|
84 |
|
|
extern int32_t R_Ether_Open(uint32_t ch, uint8_t mac_addr[]);
|
85 |
|
|
extern int32_t R_Ether_Close(uint32_t ch);
|
86 |
|
|
extern int32_t R_Ether_Write(uint32_t ch, void *buf, uint32_t len);
|
87 |
|
|
extern int32_t R_Ether_Read(uint32_t ch, void *buf);
|
88 |
|
|
|
89 |
|
|
/* Added for the FreeRTOS demo project. */
|
90 |
|
|
unsigned long ulEMACRead( void );
|
91 |
|
|
void vEMACWrite( void );
|
92 |
|
|
void vInitEmac( void );
|
93 |
|
|
long lEMACWaitForLink( void );
|
94 |
|
|
|
95 |
|
|
/* Extension of the API functions added to allow PnP link */
|
96 |
|
|
|
97 |
|
|
/* R_Ether_OpenEx opens irrispective of link status */
|
98 |
|
|
extern int32_t R_Ether_OpenEx(uint32_t ch, uint8_t mac_addr[]);
|
99 |
|
|
/* Enables/disables operation for the current link */
|
100 |
|
|
extern int32_t R_Ether_EnableEx(uint32_t ch, int iEnable);
|
101 |
|
|
|
102 |
|
|
#ifdef __cplusplus
|
103 |
|
|
}
|
104 |
|
|
#endif
|
105 |
|
|
|
106 |
|
|
/****************************************************/
|
107 |
|
|
/* Ethernet statistic collection data */
|
108 |
|
|
struct enet_stats
|
109 |
|
|
{
|
110 |
|
|
uint32_t rx_packets; /* total packets received */
|
111 |
|
|
uint32_t tx_packets; /* total packets transmitted */
|
112 |
|
|
uint32_t rx_errors; /* bad packets received */
|
113 |
|
|
uint32_t tx_errors; /* packet transmit problems */
|
114 |
|
|
uint32_t rx_dropped; /* no space in buffers */
|
115 |
|
|
uint32_t tx_dropped; /* no space available */
|
116 |
|
|
uint32_t multicast; /* multicast packets received */
|
117 |
|
|
uint32_t collisions;
|
118 |
|
|
|
119 |
|
|
/* detailed rx_errors: */
|
120 |
|
|
uint32_t rx_length_errors;
|
121 |
|
|
uint32_t rx_over_errors; /* receiver ring buffer overflow */
|
122 |
|
|
uint32_t rx_crc_errors; /* recved pkt with crc error */
|
123 |
|
|
uint32_t rx_frame_errors; /* recv'd frame alignment error */
|
124 |
|
|
uint32_t rx_fifo_errors; /* recv'r fifo overrun */
|
125 |
|
|
uint32_t rx_missed_errors; /* receiver missed packet */
|
126 |
|
|
|
127 |
|
|
/* detailed tx_errors */
|
128 |
|
|
uint32_t tx_aborted_errors;
|
129 |
|
|
uint32_t tx_carrier_errors;
|
130 |
|
|
uint32_t tx_fifo_errors;
|
131 |
|
|
uint32_t tx_heartbeat_errors;
|
132 |
|
|
uint32_t tx_window_errors;
|
133 |
|
|
};
|
134 |
|
|
|
135 |
|
|
struct ei_device
|
136 |
|
|
{
|
137 |
|
|
const char8_t *name;
|
138 |
|
|
uchar8_t open;
|
139 |
|
|
uchar8_t Tx_act;
|
140 |
|
|
uchar8_t Rx_act;
|
141 |
|
|
uchar8_t txing; /* Transmit Active */
|
142 |
|
|
uchar8_t irqlock; /* EDMAC's interrupt disabled when '1'. */
|
143 |
|
|
uchar8_t dmaing; /* EDMAC Active */
|
144 |
|
|
ethfifo *rxcurrent; /* current receive discriptor */
|
145 |
|
|
ethfifo *txcurrent; /* current transmit discriptor */
|
146 |
|
|
uchar8_t save_irq; /* Original dev->irq value. */
|
147 |
|
|
struct enet_stats stat;
|
148 |
|
|
uchar8_t mac_addr[6];
|
149 |
|
|
};
|
150 |
|
|
|
151 |
|
|
#endif /* HWETHERNET_H_INCLUDED */
|
152 |
|
|
|