OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [Atmel/] [at91lib/] [peripherals/] [emac/] [emac.h] - Blame information for rev 608

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/* ----------------------------------------------------------------------------
2
 *         ATMEL Microcontroller Software Support
3
 * ----------------------------------------------------------------------------
4
 * Copyright (c) 2008, Atmel Corporation
5
 *
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * - Redistributions of source code must retain the above copyright notice,
12
 * this list of conditions and the disclaimer below.
13
 *
14
 * Atmel's name may not be used to endorse or promote products derived from
15
 * this software without specific prior written permission.
16
 *
17
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * ----------------------------------------------------------------------------
28
 */
29
 
30
// peripherals/emac/emac.h
31
 
32
#ifndef EMAC_H
33
#define EMAC_H
34
 
35
//-----------------------------------------------------------------------------
36
/// \dir
37
/// !Purpose
38
///
39
///     Definition of methods and structures for using EMAC
40
///     
41
/// !Usage
42
///
43
/// -# Initialize EMAC with EMAC_Init.
44
/// -# Setup EMAC with EMAC_SetupTx, EMAC_SetupRx, EMAC_SetupMacAddress
45
///    and EMAC_SetupStack. 
46
/// -# Drive the EMAC status machine by EMAC_Task.
47
/// -# EMAC_GetStatus give EMAC status machine current status 
48
/// -# Send a packet to network with EMAC_SendPacket.
49
/// -# Get a packet from network with EMAC_GetPacket.
50
///
51
//-----------------------------------------------------------------------------
52
 
53
 
54
//-----------------------------------------------------------------------------
55
//         Headers
56
//-----------------------------------------------------------------------------
57
 
58
//-----------------------------------------------------------------------------
59
//         Definitions
60
//-----------------------------------------------------------------------------
61
/// Number of buffer for RX, be carreful: MUST be 2^n
62
#define RX_BUFFERS  16
63
/// Number of buffer for TX, be carreful: MUST be 2^n
64
#define TX_BUFFERS   8
65
 
66
/// Buffer Size
67
#define EMAC_RX_UNITSIZE            128     /// Fixed size for RX buffer
68
#define EMAC_TX_UNITSIZE            1518    /// Size for ETH frame length
69
 
70
// The MAC can support frame lengths up to 1536 bytes.
71
#define EMAC_FRAME_LENTGH_MAX       1536
72
 
73
 
74
//-----------------------------------------------------------------------------
75
//         Types
76
//-----------------------------------------------------------------------------
77
 
78
//-----------------------------------------------------------------------------
79
/// Describes the statistics of the EMAC.
80
//-----------------------------------------------------------------------------
81
typedef struct _EmacStats {
82
 
83
    // TX errors
84
    unsigned int tx_packets;    /// Total Number of packets sent
85
    unsigned int tx_comp;       /// Packet complete
86
    unsigned int tx_errors;     /// TX errors ( Retry Limit Exceed )
87
    unsigned int collisions;    /// Collision
88
    unsigned int tx_exausts;    /// Buffer exhausted
89
    unsigned int tx_underruns;  /// Under Run, not able to read from memory
90
    // RX errors
91
    unsigned int rx_packets;    /// Total Number of packets RX
92
    unsigned int rx_eof;        /// No EOF error
93
    unsigned int rx_ovrs;       /// Over Run, not able to store to memory
94
    unsigned int rx_bnas;       /// Buffer is not available
95
 
96
} EmacStats, *PEmacStats;
97
 
98
//-----------------------------------------------------------------------------
99
//         PHY Exported functions
100
//-----------------------------------------------------------------------------
101
extern unsigned char EMAC_SetMdcClock( unsigned int mck );
102
 
103
extern void EMAC_EnableMdio( void );
104
 
105
extern void EMAC_DisableMdio( void );
106
 
107
extern void EMAC_EnableMII( void );
108
 
109
extern void EMAC_EnableRMII( void );
110
 
111
extern unsigned char EMAC_ReadPhy(unsigned char PhyAddress,
112
                                  unsigned char Address,
113
                                  unsigned int *pValue,
114
                                  unsigned int retry);
115
 
116
extern unsigned char EMAC_WritePhy(unsigned char PhyAddress,
117
                                   unsigned char Address,
118
                                   unsigned int Value,
119
                                   unsigned int retry);
120
 
121
extern void EMAC_SetLinkSpeed(unsigned char speed,
122
                              unsigned char fullduplex);
123
 
124
//-----------------------------------------------------------------------------
125
//         EMAC Exported functions
126
//-----------------------------------------------------------------------------
127
/// Callback used by send function
128
typedef void (*EMAC_TxCallback)(unsigned int status);
129
typedef void (*EMAC_RxCallback)(unsigned int status);
130
typedef void (*EMAC_WakeupCallback)(void);
131
 
132
extern void EMAC_Init( unsigned char id, const unsigned char *pMacAddress,
133
                unsigned char enableCAF, unsigned char enableNBC );
134
#define EMAC_CAF_DISABLE  0
135
#define EMAC_CAF_ENABLE   1
136
#define EMAC_NBC_DISABLE  0
137
#define EMAC_NBC_ENABLE   1
138
 
139
extern void EMAC_Handler(void);
140
 
141
extern unsigned char EMAC_Send(void *pBuffer,
142
                               unsigned int size,
143
                               EMAC_TxCallback fEMAC_TxCallback);
144
/// Return for EMAC_Send function
145
#define EMAC_TX_OK                     0
146
#define EMAC_TX_BUFFER_BUSY            1
147
#define EMAC_TX_INVALID_PACKET         2
148
 
149
 
150
extern unsigned char EMAC_Poll(unsigned char *pFrame,
151
                               unsigned int frameSize,
152
                               unsigned int *pRcvSize);
153
/// Return for EMAC_Poll function
154
#define EMAC_RX_OK                   0
155
#define EMAC_RX_NO_DATA              1
156
#define EMAC_RX_FRAME_SIZE_TOO_SMALL 2
157
 
158
extern void EMAC_GetStatistics(EmacStats *pStats, unsigned char reset);
159
 
160
#endif // #ifndef EMAC_H
161
 

powered by: WebSVN 2.1.0

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