URL
https://opencores.org/ocsvn/plasma/plasma/trunk
Subversion Repositories plasma
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 421 to Rev 422
- ↔ Reverse comparison
Rev 421 → Rev 422
/plasma/trunk/kernel/uart.c
486,7 → 486,7
{ |
mask &= 0xff; |
MemoryWrite(GPIO0_CLEAR, mask); //clear |
MemoryWrite(GPIO0_OUT, value & mask); //set LEDs |
MemoryWrite(GPIO0_SET, value & mask); //set LEDs |
} |
|
|
/plasma/trunk/kernel/ethernet.c
25,8 → 25,6
#define COUNT_EMPTY 16 //Count to decide there isn't data |
#define INDEX_MASK 0xffff //Size of receive buffer |
|
//void dump(const unsigned char *data, int length); |
|
static unsigned char gDestMac[]={0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
static unsigned int CrcTable[256]; |
static unsigned char reflect[256]; |
163,8 → 161,6
if(MemoryRead(IRQ_STATUS) & IRQ_ETHERNET_TRANSMIT) |
break; |
} |
//if(i > 100) |
// printf("wait=%d ", i); |
|
Led(2, 2); |
while(length < 60 || (length & 3) != 0) |
212,7 → 208,6
|
for(;;) |
{ |
OS_ThreadSleep(1); //give TCP/IP stack CPU time |
OS_InterruptMaskSet(IRQ_ETHERNET_RECEIVE); //enable interrupt |
OS_SemaphorePend(SemEthernet, 50); //wait for interrupt |
|
308,11 → 303,50
} |
|
|
//Use the Ethernet MDIO bus to configure the Ethernet PHY |
static int EthernetConfigure(int index, int value) |
{ |
unsigned int data; |
int i, bit, rc=0; |
|
//Format of SMI data: 0101 A4:A0 R4:R0 00 D15:D0 |
if(value <= 0xffff) |
data = 0x5f800000; //write |
else |
data = 0x6f800000; //read |
data |= index << 18 | value; |
|
MemoryWrite(GPIO0_SET, ETHERNET_MDIO | ETHERNET_MDIO_WE | ETHERNET_MDC); |
for(i = 0; i < 34; ++i) |
{ |
MemoryWrite(GPIO0_SET, ETHERNET_MDC); //clock high |
SpinWait(10); |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDC); //clock low |
SpinWait(10); |
} |
for(i = 31; i >= 0; --i) |
{ |
bit = (data >> i) & 1; |
if(bit) |
MemoryWrite(GPIO0_SET, ETHERNET_MDIO); |
else |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDIO); |
SpinWait(10); |
MemoryWrite(GPIO0_SET, ETHERNET_MDC); //clock high |
SpinWait(10); |
rc = rc << 1 | ((MemoryRead(GPIOA_IN) >> 13) & 1); |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDC); //clock low |
SpinWait(10); |
if(value > 0xffff && i == 17) |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDIO_WE); |
} |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDIO | ETHERNET_MDIO_WE | ETHERNET_MDC); |
return (rc >> 1) & 0xffff; |
} |
|
|
void EthernetInit(unsigned char MacAddress[6]) |
{ |
//Format of SMI data: 0101 A4:A0 R4:R0 00 D15:D0 |
unsigned long data=0x5f800100; //SMI R0 = 10Mbps full duplex |
//unsigned long data=0x5f800000; //SMI R0 = 10Mbps half duplex |
int i, value; |
volatile unsigned char *buf = (unsigned char*)ETHERNET_RECEIVE; |
|
326,29 → 360,18
} |
} |
|
//Configure Ethernet PHY for 10Mbps full duplex via SMI interface |
MemoryWrite(GPIO0_OUT, ETHERNET_MDIO | ETHERNET_MDIO_WE | ETHERENT_MDC); |
for(i = 0; i < 34; ++i) |
{ |
MemoryWrite(GPIO0_OUT, ETHERENT_MDC); //clock high |
SpinWait(10); |
MemoryWrite(GPIO0_CLEAR, ETHERENT_MDC); //clock low |
SpinWait(10); |
} |
for(i = 31; i >= 0; --i) |
{ |
value = (data >> i) & 1; |
if(value) |
MemoryWrite(GPIO0_OUT, ETHERNET_MDIO); |
else |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDIO); |
MemoryWrite(GPIO0_OUT, ETHERENT_MDC); //clock high |
SpinWait(10); |
MemoryWrite(GPIO0_CLEAR, ETHERENT_MDC); //clock low |
SpinWait(10); |
} |
MemoryWrite(GPIO0_CLEAR, ETHERNET_MDIO_WE | ETHERNET_ENABLE); |
EthernetConfigure(4, 0x0061); //advertise 10Base-T full duplex |
EthernetConfigure(0, 0x1300); //start auto negotiation |
#if 0 |
OS_ThreadSleep(100); |
printf("reg4=0x%x (0x61)\n", EthernetConfigure(4, 0x10000)); |
printf("reg0=0x%x (0x1100)\n", EthernetConfigure(0, 0x10000)); |
printf("reg1=status=0x%x (0x7809)\n", EthernetConfigure(1, 0x10000)); |
printf("reg5=partner=0x%x (0x01e1)\n", EthernetConfigure(5, 0x10000)); |
#endif |
|
MemoryWrite(GPIO0_CLEAR, ETHERNET_ENABLE); |
|
//Clear receive buffer |
for(i = 0; i <= INDEX_MASK; ++i) |
buf[i] = BYTE_EMPTY; |
364,5 → 387,5
OS_InterruptRegister(IRQ_ETHERNET_RECEIVE, EthernetIsr); |
|
//Start receive DMA |
MemoryWrite(GPIO0_OUT, ETHERNET_ENABLE); |
MemoryWrite(GPIO0_SET, ETHERNET_ENABLE); |
} |
/plasma/trunk/kernel/tcpip.h
19,7 → 19,7
#define RETRANSMIT_TIME 110 |
#define SOCKET_TIMEOUT 10 |
#define SEND_WINDOW 7000 |
#define RECEIVE_WINDOW (536*2) |
#define RECEIVE_WINDOW (536*10) |
|
typedef enum IPMode_e { |
IP_MODE_UDP, |
/plasma/trunk/kernel/netutil.c
1137,8 → 1137,9
static void ConsoleUptime(IPSocket *socket, char *argv[]) |
{ |
unsigned int ticks; |
int days, hours, minutes, seconds; |
unsigned int days, hours, minutes, seconds; |
(void)argv; |
|
//ticks per sec = 25E6/2^18 = 95.36743 -> 10.48576 ms/tick |
ticks = OS_ThreadTime(); // 1/(1-95.3674/95) = -259 |
seconds = (ticks - ticks / 259) / 95; |
/plasma/trunk/kernel/rtos.c
1381,7 → 1381,7
(void)programEnd; //Pointer to end of used memory |
(void)argv; |
|
UartPrintfCritical("Starting RTOS\n"); |
UartPrintfCritical("Starting RTOS " __DATE__ " " __TIME__ "\n"); |
MemoryWrite(IRQ_MASK, 0); |
#ifdef WIN32 |
OS_Init((uint32*)HeapSpace, sizeof(HeapSpace)); //For PC simulation |