FITkit
Fakulta informačních technologií

enc28j60_spi_tx.h

Zobrazit dokumentaci tohoto souboru.
00001 /*******************************************************************************
00002    enc28j60_spi_tx.h: Knihovna funkcí pro práci s odesílacím bufferem
00003    Copyright (C) 2010 Brno University of Technology,
00004                       Faculty of Information Technology
00005    Author(s): Martin Musil <xmusil34 AT fit.vutbr.cz>
00006 
00007    LICENSE TERMS
00008 
00009    Redistribution and use in source and binary forms, with or without
00010    modification, are permitted provided that the following conditions
00011    are met:
00012    1. Redistributions of source code must retain the above copyright
00013       notice, this list of conditions and the following disclaimer.
00014    2. Redistributions in binary form must reproduce the above copyright
00015       notice, this list of conditions and the following disclaimer in
00016       the documentation and/or other materials provided with the
00017       distribution.
00018    3. All advertising materials mentioning features or use of this software
00019       or firmware must display the following acknowledgement:
00020 
00021         This product includes software developed by the University of
00022         Technology, Faculty of Information Technology, Brno and its
00023         contributors.
00024 
00025    4. Neither the name of the Company nor the names of its contributors
00026       may be used to endorse or promote products derived from this
00027       software without specific prior written permission.
00028 
00029    This software or firmware is provided ``as is'', and any express or implied
00030    warranties, including, but not limited to, the implied warranties of
00031    merchantability and fitness for a particular purpose are disclaimed.
00032    In no event shall the company or contributors be liable for any
00033    direct, indirect, incidental, special, exemplary, or consequential
00034    damages (including, but not limited to, procurement of substitute
00035    goods or services; loss of use, data, or profits; or business
00036    interruption) however caused and on any theory of liability, whether
00037    in contract, strict liability, or tort (including negligence or
00038    otherwise) arising in any way out of the use of this software, even
00039    if advised of the possibility of such damage.
00040 
00041    $Id$
00042 
00043 *******************************************************************************/ 
00044 
00050 #ifndef _ENC28J60_SPI_TX_
00051 #define _ENC28J60_SPI_TX_
00052 
00053 
00054 //protokoly
00055 #define TCP_PROTO   1   
00056 #define UDP_PROTO   2   
00057 #define ICMP_PROTO      3       
00058 #define ARP_PROTO       4       
00059 
00060 
00064 
00065 #define TCP_PROTO_HEADER_ONLY 5
00066 
00067 //konstanty pro identifikaci hlavicek
00068 
00069 #define CTRL            10      
00070 #define ETH_HEADER      11      
00071 #define IP_HEADER       12      
00072 #define ICMP_HEADER     13      
00073 #define TCP_HEADER      14      
00074 #define UDP_HEADER      15      
00075 
00076 
00077 
00078 
00079 
00080 //délky hlaviček
00081 
00082 #define CTRL_LEN                1       
00083 #define TCP_HEADER_LEN  20      
00084 #define UDP_HEADER_LEN  8       
00085 #define ETH_HEADER_LEN  14      
00086 #define IP_HEADER_LEN   20      
00087 #define ICMP_HEADER_LEN 8       
00088 
00089 
00090 /*
00091 #define TX1ST   0                       //zacatek UDP paketu
00092 #define TX1ND   1514            //konec mista pro UDP paket, vynechana mezera 7B pro status vektor 
00093 #define TX2ST   1522            //zacatek pomocneho bufferu, pro ARP (a ICMP) dotazy
00094 #define TX2ND   1596            //konec mista pro ARP paket, vynechana mezera 7B pro status vektor
00095 #define TX3ST   1604            //zacatek TCP paketu
00096 #define TX3ND   3118            //konec mista pro TCP paket
00097 */
00098 
00099 /*
00100 zmena, dodany radic mel obcasne problemy s inicializaci jednoho registru, ERXWRPT,
00101 je pouze pro cteni a inicializuje se automaticky podle hodnoty ERXST, ale obcas
00102 se v nem hodnota ERXST neobjevila, byla tam 0, proto jsem ukazatele zamenil,
00103 aby byla hodnota ERXST a potazmo ERXWRPT 0 a tak i pri teto chybe pracoval radic spravne
00104 */
00105 
00106 #define TX4ST   4974    
00107 #define TX4ND   5018    
00108 #define TX1ST   5026    
00109 #define TX1ND   6540    
00110 #define TX3ST   6548    
00111 #define TX3ND   8062    
00112 #define TX2ST   8070    
00113 #define TX2ND   8184    
00114 
00115 
00116 #define TIMEOUT 1000    
00117 
00118 //konstanty pro identifikaci aktualniho bufferu
00119 #define TX1     32      
00120 #define TX2     64      
00121 #define TX3     128     
00122 #define TX4     192     
00123 
00124 
00136 char tx_init(unsigned char transport_protocol);
00137 
00138 
00144 void tx_rewind();
00145 
00154 void tx_seek(unsigned char header);
00155 
00165 inline void tx_close();
00166 
00177 void tx_save(unsigned char buffer);
00178 
00185 void tx_load(unsigned char buffer);
00186 
00191 unsigned char tx_act();
00192 
00205 unsigned char tx_putc(char c);
00206 
00215 unsigned int tx_write(void* ptr, unsigned int length);
00216 
00224 #define tx_write_str(str) tx_write(str,enc_strlen(str))
00225 
00232 unsigned int tx_skip(unsigned int length);
00233 
00240 unsigned int tx_fill(unsigned char value, unsigned int length);
00241 
00251 char tx_send();
00252 
00261 inline unsigned int tx_left();
00262 
00271 inline unsigned int tx_data_len();
00272 
00277 unsigned int tx_checksum();
00278 
00283 inline void tx_unlock(unsigned char buffer);
00284 
00289 #endif /*_ENC28J60_SPI_TX_*/