Go to the documentation of this file.00001
00002
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 #include <cfg/memory.h>
00045 #include <cfg/arch/avr.h>
00046
00047 #include <arch/avr.h>
00048
00049 #if defined(RTL_EESK_BIT) && defined(__GNUC__) && defined(NUTXMEM_SIZE)
00050
00051
00052
00053
00054
00055 #ifndef RTL_BASE_ADDR
00056 #define RTL_BASE_ADDR 0x8300
00057 #endif
00058 #define NIC_CR _MMIO_BYTE(RTL_BASE_ADDR)
00059 #define NIC_EE _MMIO_BYTE(RTL_BASE_ADDR + 1)
00060
00061 #if (RTL_EEMU_AVRPORT == AVRPORTB)
00062 #define RTL_EEMU_PORT PORTB
00063 #define RTL_EEMU_DDR DDRB
00064
00065 #elif (RTL_EEMU_AVRPORT == AVRPORTD)
00066 #define RTL_EEMU_PORT PORTD
00067 #define RTL_EEMU_DDR DDRD
00068
00069 #elif (RTL_EEMU_AVRPORT == AVRPORTE)
00070 #define RTL_EEMU_PORT PORTE
00071 #define RTL_EEMU_DDR DDRE
00072
00073 #elif (RTL_EEMU_AVRPORT == AVRPORTF)
00074 #define RTL_EEMU_PORT PORTF
00075 #define RTL_EEMU_DDR DDRF
00076
00077 #else
00078 #define RTL_EE_MEMBUS
00079 #define RTL_EEMU_PORT PORTC
00080 #define RTL_EEMU_DDR DDRC
00081
00082 #endif
00083
00084 #if (RTL_EEDO_AVRPORT == AVRPORTB)
00085 #define RTL_EEDO_PORT PORTB
00086 #define RTL_EEDO_DDR DDRB
00087
00088 #elif (RTL_EEDO_AVRPORT == AVRPORTD)
00089 #define RTL_EEDO_PORT PORTD
00090 #define RTL_EEDO_DDR DDRD
00091
00092 #elif (RTL_EEDO_AVRPORT == AVRPORTE)
00093 #define RTL_EEDO_PORT PORTE
00094 #define RTL_EEDO_DDR DDRE
00095
00096 #elif (RTL_EEDO_AVRPORT == AVRPORTF)
00097 #define RTL_EEDO_PORT PORTF
00098 #define RTL_EEDO_DDR DDRF
00099
00100 #else
00101 #define RTL_EE_MEMBUS
00102 #define RTL_EEDO_PORT PORTC
00103 #define RTL_EEDO_DDR DDRC
00104
00105 #endif
00106
00107 #if (RTL_EESK_AVRPORT == AVRPORTB)
00108 #define RTL_EESK_PIN PINB
00109 #define RTL_EESK_DDR DDRB
00110
00111 #elif (RTL_EESK_AVRPORT == AVRPORTD)
00112 #define RTL_EESK_PIN PIND
00113 #define RTL_EESK_DDR DDRD
00114
00115 #elif (RTL_EESK_AVRPORT == AVRPORTE)
00116 #define RTL_EESK_PIN PINE
00117 #define RTL_EESK_DDR DDRE
00118
00119 #elif (RTL_EESK_AVRPORT == AVRPORTF)
00120 #define RTL_EESK_PIN PINF
00121 #define RTL_EESK_DDR DDRF
00122
00123 #else
00124 #define RTL_EE_MEMBUS
00125 #define RTL_EESK_PIN PINC
00126 #define RTL_EESK_DDR DDRC
00127
00128 #endif
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 static void FakeNicEeprom(void) __attribute__ ((naked, section(".init1"), used));
00143 void FakeNicEeprom(void)
00144 {
00145
00146
00147
00148
00149 #ifdef RTL_EEMU_BIT
00150 sbi(RTL_EEMU_PORT, RTL_EEMU_BIT);
00151 sbi(RTL_EEMU_DDR, RTL_EEMU_BIT);
00152 #endif
00153 sbi(RTL_EEDO_PORT, RTL_EEDO_BIT);
00154 sbi(RTL_EEDO_DDR, RTL_EEDO_BIT);
00155
00156
00157 NIC_CR = 0xE1;
00158 NIC_EE = 0x40;
00159
00160
00161 #ifdef RTL_EE_MEMBUS
00162 cbi(MCUCR, SRE);
00163 #endif
00164
00165
00166
00167
00168
00169
00170 __asm__ __volatile__("\n"
00171 "EmuLoop: " "\n"
00172 " ldi r24, 0 " "\n"
00173 " ldi r25, 0 " "\n"
00174 " sbis %0, %1 " "\n"
00175 " rjmp EmuClkClr " "\n"
00176 "EmuClkSet: " "\n"
00177 " adiw r24, 1 " "\n"
00178 " breq EmuDone " "\n"
00179 " sbis %0, %1 " "\n"
00180 " rjmp EmuLoop " "\n"
00181 " rjmp EmuClkSet " "\n"
00182 "EmuClkClr: " "\n"
00183 " adiw r24, 1 " "\n"
00184 " breq EmuDone " "\n"
00185 " sbic %0, %1 " "\n"
00186 " rjmp EmuLoop " "\n"
00187 " rjmp EmuClkClr " "\n"
00188 "EmuDone: \n\t"
00189 :
00190 :"I"(_SFR_IO_ADDR(RTL_EESK_PIN)),
00191 "I"(RTL_EESK_BIT)
00192 :"r24", "r25");
00193
00194
00195 #ifdef RTL_EE_MEMBUS
00196 sbi(MCUCR, SRE);
00197 #endif
00198
00199
00200 #ifdef RTL_EEMU_BIT
00201 cbi(RTL_EEMU_PORT, RTL_EEMU_BIT);
00202 cbi(RTL_EEMU_DDR, RTL_EEMU_BIT);
00203 #endif
00204 cbi(RTL_EEDO_PORT, RTL_EEDO_BIT);
00205 cbi(RTL_EEDO_DDR, RTL_EEDO_BIT);
00206 }
00207
00208 #endif
00209
00213 void NutBoardInit(void)
00214 {
00215 }
00216