2ef1d95cf5b52936b651e95a370f0485bb60d998
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

1) #include "cyc_cnt.h"
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

2) #include "eth.h"
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

3) #include "lcd.h"
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

4) #include "leds.h"
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

5) #include "uart.h"
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

6) #include "switches.h"
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

7) 
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

8) //#define CFG_SIMULATION
9) 
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

10) #define CFG_ETH_RX
11) #define CFG_ETH_TX
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

12) #define CFG_UART
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

13) #ifdef CFG_SIMULATION
14) # define CFG_UART_CHK
15) #else
16) # define CFG_DELAY
17) # define CFG_LCD
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

18) # define CFG_SWITCHES
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

19) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

20) 
Stefan Schuermans implemented loading of data...

Stefan Schuermans authored 12 years ago

21) const int myconst = 0x12345678;
22) 
23) int myvar = 0x11223344;
24) 
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

25) volatile int data[100];
26) 
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

27) #ifdef CFG_ETH_TX
28)   static const unsigned char example_packet[] = {
29)     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* destination MAC */
30)     0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* source MAC */
31)     0x08, 0x00, /* ethertype: IP */
32)     0x45, 0x00, 0x00, 0x36, /* IP header: ..., len */
33)     0x12, 0x34, 0x00, 0x00, /* IP header: ..., not fragmented */
34)     0x40, 0x11, 0x00, 0x00, /* IP header: ..., UDP, ... */
35)     0x7F, 0x00, 0x00, 0x01, /* source IP */
36)     0xFF, 0xFF, 0xFF, 0xFF, /* destination IP */
37)     0x00, 0x01, 0x00, 0x01, /* UDP: source port, destination port */
38)     0x00, 0x22, 0x00, 0x00, /* UDP: len, ... */
39)     'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
40)     'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
41)   };
42) #endif
43) 
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

44) void switches(void)
45) {
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

46) #ifdef CFG_LCD
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

47) #ifdef CFG_SWITCHES
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

48)   lcd_chr(1, 0, switches_get_state(sw_0) ? '0' : ' ');
49)   lcd_chr(1, 1, switches_get_state(sw_1) ? '1' : ' ');
50)   lcd_chr(1, 2, switches_get_state(sw_2) ? '2' : ' ');
51)   lcd_chr(1, 3, switches_get_state(sw_3) ? '3' : ' ');
52)   lcd_chr(1, 4, switches_get_state(sw_east) ? 'E' : ' ');
53)   lcd_chr(1, 5, switches_get_state(sw_north) ? 'N' : ' ');
54)   lcd_chr(1, 6, switches_get_state(sw_south) ? 'S' : ' ');
55)   lcd_chr(1, 7, switches_get_state(sw_west) ? 'W' : ' ');
56)   lcd_chr(1, 8, switches_get_state(sw_center) ? 'C' : ' ');
57)   lcd_chr(1, 9, switches_get_state(sw_rot_a) ? 'a' : ' ');
58)   lcd_chr(1, 10, switches_get_state(sw_rot_b) ? 'b' : ' ');
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

59) #endif
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

60) #endif
Stefan Schuermans implemented displaying rota...

Stefan Schuermans authored 12 years ago

61) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

62) #ifdef CFG_LCD
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

63) #ifdef CFG_SWITCHES
Stefan Schuermans implemented displaying rota...

Stefan Schuermans authored 12 years ago

64)   unsigned int cnt = switches_get_rot_cnt();
65)   lcd_chr(1, 12, '0' + (cnt >> 9 & 0x7));
66)   lcd_chr(1, 13, '0' + (cnt >> 6 & 0x7));
67)   lcd_chr(1, 14, '0' + (cnt >> 3 & 0x7));
68)   lcd_chr(1, 15, '0' + (cnt & 0x7));
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

69) #endif
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

70) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

71) }
72) 
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

73) void delay(void)
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

74) {
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

75)   unsigned int i;
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

76) #ifdef CFG_ETH_RX
77)   void *vptr;
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

78)   unsigned char *ptr;
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

79)   unsigned int sz;
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

80) #endif
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

81) 
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

82)   for (i = 0; i < 10; ++i) {
83)     switches();
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

84) #ifdef CFG_ETH_RX
85)     while (eth_rx(&vptr, &sz)) {
86)       ptr = vptr;
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

87) #ifdef CFG_UART
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

88)       for ( ; sz > 0; ptr++, sz--)
89)         uart_tx(*ptr);
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

90) #endif
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

91)     }
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

92) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

93) #ifdef CFG_DELAY
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

94)     cyc_cnt_delay_ms(20);
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

95) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

96)   }
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

97) }
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

98) 
99) int main()
100) {
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

101)   unsigned int i;
Stefan Schuermans add UART error check to FW

Stefan Schuermans authored 12 years ago

102)   unsigned short chr;
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

103)   unsigned char leds;
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

104) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

105)   leds_set_state(0x01);
106) 
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

107)   for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
108)     data[i] = i;
109) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

110)   leds_set_state(0x02);
111) 
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

112) #ifdef CFG_ETH_RX
Stefan Schuermans made MAC configurable in et...

Stefan Schuermans authored 12 years ago

113)   eth_mac_init();
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

114)   eth_rx_init();
115) #endif
116) 
117)   leds_set_state(0x04);
118) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

119) #ifdef CFG_LCD
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

120)   lcd_init();
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

121)   lcd_str(0, "MIPS I system");
122)   lcd_str(1, "");
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

123) #endif
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

124) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

125)   leds_set_state(0x08);
126) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

127) #ifdef CFG_UART
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

128)   uart_cfg_scale(62); /* 115200 */
129)   uart_cfg_bits(8);
130)   uart_cfg_stop(1);
131)   uart_tx('M');
132)   uart_tx('I');
133)   uart_tx('P');
134)   uart_tx('S');
135)   uart_tx(' ');
136)   uart_tx('I');
137)   uart_tx('\r');
138)   uart_tx('\n');
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

139) #ifdef CFG_UART_CHK
140)   if (uart_rx() != 'M') while(1);
141)   if (uart_rx() != 'I') while(1);
142)   if (uart_rx() != 'P') while(1);
143)   if (uart_rx() != 'S') while(1);
144)   if (uart_rx() != ' ') while(1);
145)   if (uart_rx() != 'I') while(1);
146)   if (uart_rx() != '\r') while(1);
147)   if (uart_rx() != '\n') while(1);
148) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

149) #endif
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

150) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

151)   leds_set_state(0x10);
152) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

153)   leds = 0x11;
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

154)   while (1) {
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

155) #ifdef CFG_UART
Stefan Schuermans add UART error check to FW

Stefan Schuermans authored 12 years ago

156)     if (uart_can_rx()) {
157)       chr = uart_rx();
158)       if (uart_is_err(chr))
159)         leds = 0;
160)       else
161)         leds = chr;
162)     }
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

163) #endif
164)     leds_set_state(leds);
165)     leds = leds << 1 | leds >> 7;
166)     delay();
Stefan Schuermans send ethernet packet on cen...

Stefan Schuermans authored 12 years ago

167) #ifdef CFG_ETH_TX
168) #ifdef CFG_SWITCHES
169)     if (switches_get_state(sw_center))
170) #endif
171)       eth_tx(example_packet, sizeof(example_packet));
172) #endif
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

173)   }
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

174)