00001 #ifndef _SYS_DEVICE_H_
00002 #define _SYS_DEVICE_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include <sys/types.h>
00065
00075
00076
00077
00078
00079
00080 #ifndef __EMULATION__
00081 #define WAIT5 5
00082 #define WAIT50 50
00083 #define WAIT100 100
00084 #define WAIT250 250
00085 #define WAIT500 500
00086 #else
00087 #define WAIT5 1
00088 #define WAIT50 5
00089 #define WAIT100 10
00090 #define WAIT250 25
00091 #define WAIT500 50
00092 #endif
00093
00094
00095
00096
00097 #define IFTYP_RAM 0
00098 #define IFTYP_ROM 1
00099 #define IFTYP_STREAM 2
00100 #define IFTYP_NET 3
00105 typedef struct _NUTDEVICE NUTDEVICE;
00106
00111 struct _NUTDEVICE {
00112 NUTDEVICE *dev_next;
00113 u_char dev_name[9];
00114 u_char dev_type;
00121 u_short dev_base;
00126 u_char dev_irq;
00131 void *dev_icb;
00137 void *dev_dcb;
00140 int (*dev_init)(NUTDEVICE *);
00145 int (*dev_ioctl)(NUTDEVICE *, int, void *);
00149 };
00157
00158 #define UART_SETSPEED 0x0101
00159 #define UART_GETSPEED 0x0102
00160 #define UART_SETDATABITS 0x0103
00161 #define UART_GETDATABITS 0x0104
00162 #define UART_SETPARITY 0x0105
00163 #define UART_GETPARITY 0x0106
00164 #define UART_SETSTOPBITS 0x0107
00165 #define UART_GETSTOPBITS 0x0108
00166 #define UART_SETSTATUS 0x0109
00167 #define UART_GETSTATUS 0x010a
00168 #define UART_SETREADTIMEOUT 0x010b
00169 #define UART_GETREADTIMEOUT 0x010c
00170 #define UART_SETWRITETIMEOUT 0x010d
00171 #define UART_GETWRITETIMEOUT 0x010e
00173 #define DIO_SETSTATUS 0x0209
00174 #define DIO_GETSTATUS 0x020a
00175 #define DIO_WAITSTATUS 0x020b
00178
00179
00183 #define UART_FRAMINGERROR 0x00000001
00184 #define UART_OVERRUNERROR 0x00000002
00185 #define UART_RXBUFFEREMPTY 0x00000004
00186 #define UART_TXBUFFEREMPTY 0x00000008
00188
00189 extern NUTDEVICE *nutDeviceList;
00190
00191 extern int NutRegisterDevice(NUTDEVICE *dev, u_short base, u_char irq);
00192 extern NUTDEVICE *NutDeviceLookup(CONST char *name);
00193 extern NUTDEVICE *NutDeviceOpen(CONST char *name);
00194 extern int NutDeviceClose(NUTDEVICE *dev);
00195 extern int NutDeviceRead(NUTDEVICE *dev, void *data, int size);
00196 extern int NutDeviceReadTran(NUTDEVICE *dev, void *data, int size);
00197 extern int NutDeviceGetLine(NUTDEVICE *dev, void *data, int size);
00198 extern int NutDeviceWrite(NUTDEVICE *dev, CONST void *data, int len);
00199 extern int NutDeviceWriteTran(NUTDEVICE *dev, CONST void *data);
00200 extern int NutDeviceWrite_P(NUTDEVICE *dev, PGM_P data, int len);
00201 extern int NutDeviceIOCtl(NUTDEVICE *dev, int req, void *conf);
00202
00203 #ifdef __GNUC__
00204 #ifdef __AVR_ATmega128__
00205 #define UDR UDR0
00206 #define UBRR UBRR0L
00207 #define USR UCSR0A
00208 #define UCR UCSR0B
00209 #define EICR EICRB
00210 #endif
00211 #endif
00212
00213 #endif