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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_AT91SAM3U256_IAR/] [AT91Lib/] [peripherals/] [emac/] [emac.h] - Blame information for rev 603

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 580 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 with MAC address.
44
/// -# Then the caller application need to initialize the PHY driver before further calling EMAC
45
///      driver.
46
/// -# Get a packet from network
47
///      -# Interrupt mode: EMAC_Set_RxCb to register a function to process the frame packet
48
///      -# Polling mode: EMAC_Poll for a data packet from network 
49
/// -# Send a packet to network with EMAC_Send.
50
///
51
/// Please refer to the list of functions in the #Overview# tab of this unit
52
/// for more detailed information.
53
//-----------------------------------------------------------------------------
54
 
55
 
56
//-----------------------------------------------------------------------------
57
//         Headers
58
//-----------------------------------------------------------------------------
59
 
60
//-----------------------------------------------------------------------------
61
//         Definitions
62
//-----------------------------------------------------------------------------
63
/// Number of buffer for RX, be carreful: MUST be 2^n
64
#define RX_BUFFERS  16
65
/// Number of buffer for TX, be carreful: MUST be 2^n
66
#define TX_BUFFERS   8
67
 
68
/// Buffer Size
69
#define EMAC_RX_UNITSIZE            128     /// Fixed size for RX buffer
70
#define EMAC_TX_UNITSIZE            1518    /// Size for ETH frame length
71
 
72
// The MAC can support frame lengths up to 1536 bytes.
73
#define EMAC_FRAME_LENTGH_MAX       1536
74
 
75
 
76
//-----------------------------------------------------------------------------
77
//         Types
78
//-----------------------------------------------------------------------------
79
 
80
//-----------------------------------------------------------------------------
81
/// Describes the statistics of the EMAC.
82
//-----------------------------------------------------------------------------
83
typedef struct _EmacStats {
84
 
85
    // TX errors
86
    unsigned int tx_packets;    /// Total Number of packets sent
87
    unsigned int tx_comp;       /// Packet complete
88
    unsigned int tx_errors;     /// TX errors ( Retry Limit Exceed )
89
    unsigned int collisions;    /// Collision
90
    unsigned int tx_exausts;    /// Buffer exhausted
91
    unsigned int tx_underruns;  /// Under Run, not able to read from memory
92
    // RX errors
93
    unsigned int rx_packets;    /// Total Number of packets RX
94
    unsigned int rx_eof;        /// No EOF error
95
    unsigned int rx_ovrs;       /// Over Run, not able to store to memory
96
    unsigned int rx_bnas;       /// Buffer is not available
97
 
98
} EmacStats, *PEmacStats;
99
 
100
//-----------------------------------------------------------------------------
101
//         PHY Exported functions
102
//-----------------------------------------------------------------------------
103
extern unsigned char EMAC_SetMdcClock( unsigned int mck );
104
 
105
extern void EMAC_EnableMdio( void );
106
 
107
extern void EMAC_DisableMdio( void );
108
 
109
extern void EMAC_EnableMII( void );
110
 
111
extern void EMAC_EnableRMII( void );
112
 
113
extern unsigned char EMAC_ReadPhy(unsigned char PhyAddress,
114
                                  unsigned char Address,
115
                                  unsigned int *pValue,
116
                                  unsigned int retry);
117
 
118
extern unsigned char EMAC_WritePhy(unsigned char PhyAddress,
119
                                   unsigned char Address,
120
                                   unsigned int Value,
121
                                   unsigned int retry);
122
 
123
extern void EMAC_SetLinkSpeed(unsigned char speed,
124
                              unsigned char fullduplex);
125
 
126
//-----------------------------------------------------------------------------
127
//         EMAC Exported functions
128
//-----------------------------------------------------------------------------
129
/// Callback used by send function
130
typedef void (*EMAC_TxCallback)(unsigned int status);
131
typedef void (*EMAC_RxCallback)(unsigned int status);
132
typedef void (*EMAC_WakeupCallback)(void);
133
 
134
extern void EMAC_Init( unsigned char id, const unsigned char *pMacAddress,
135
                unsigned char enableCAF, unsigned char enableNBC );
136
#define EMAC_CAF_DISABLE  0
137
#define EMAC_CAF_ENABLE   1
138
#define EMAC_NBC_DISABLE  0
139
#define EMAC_NBC_ENABLE   1
140
 
141
extern void EMAC_Handler(void);
142
 
143
extern unsigned char EMAC_Send(void *pBuffer,
144
                               unsigned int size,
145
                               EMAC_TxCallback fEMAC_TxCallback);
146
/// Return for EMAC_Send function
147
#define EMAC_TX_OK                     0
148
#define EMAC_TX_BUFFER_BUSY            1
149
#define EMAC_TX_INVALID_PACKET         2
150
 
151
 
152
extern unsigned char EMAC_Poll(unsigned char *pFrame,
153
                               unsigned int frameSize,
154
                               unsigned int *pRcvSize);
155
/// Return for EMAC_Poll function
156
#define EMAC_RX_OK                   0
157
#define EMAC_RX_NO_DATA              1
158
#define EMAC_RX_FRAME_SIZE_TOO_SMALL 2
159
 
160
extern void EMAC_GetStatistics(EmacStats *pStats, unsigned char reset);
161
 
162
#endif // #ifndef EMAC_H
163
 

powered by: WebSVN 2.1.0

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