f2b3968b8c542262b9d8431b8555303f83086441
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
18) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

19) 
Stefan Schuermans implemented loading of data...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

24) volatile int data[100];
25) 
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

26) void switches(void)
27) {
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

28) #ifdef CFG_LCD
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

29)   lcd_chr(1, 0, switches_get_state(sw_0) ? '0' : ' ');
30)   lcd_chr(1, 1, switches_get_state(sw_1) ? '1' : ' ');
31)   lcd_chr(1, 2, switches_get_state(sw_2) ? '2' : ' ');
32)   lcd_chr(1, 3, switches_get_state(sw_3) ? '3' : ' ');
33)   lcd_chr(1, 4, switches_get_state(sw_east) ? 'E' : ' ');
34)   lcd_chr(1, 5, switches_get_state(sw_north) ? 'N' : ' ');
35)   lcd_chr(1, 6, switches_get_state(sw_south) ? 'S' : ' ');
36)   lcd_chr(1, 7, switches_get_state(sw_west) ? 'W' : ' ');
37)   lcd_chr(1, 8, switches_get_state(sw_center) ? 'C' : ' ');
38)   lcd_chr(1, 9, switches_get_state(sw_rot_a) ? 'a' : ' ');
39)   lcd_chr(1, 10, switches_get_state(sw_rot_b) ? 'b' : ' ');
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

42) #ifdef CFG_LCD
Stefan Schuermans implemented displaying rota...

Stefan Schuermans authored 12 years ago

43)   unsigned int cnt = switches_get_rot_cnt();
44)   lcd_chr(1, 12, '0' + (cnt >> 9 & 0x7));
45)   lcd_chr(1, 13, '0' + (cnt >> 6 & 0x7));
46)   lcd_chr(1, 14, '0' + (cnt >> 3 & 0x7));
47)   lcd_chr(1, 15, '0' + (cnt & 0x7));
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

48) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

49) }
50) 
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

52) {
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

54) #ifdef CFG_ETH_RX
55)   void *vptr;
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

59) #ifdef CFG_ETH_TX
60)   static const unsigned char example_packet[] = {
61)     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* destination MAC */
62)     0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* source MAC */
63)     0x08, 0x00, /* ethertype: IP */
64)     0x45, 0x00, 0x00, 0x36, /* IP header: ..., len */
65)     0x12, 0x34, 0x00, 0x00, /* IP header: ..., not fragmented */
66)     0x40, 0x11, 0x00, 0x00, /* IP header: ..., UDP, ... */
67)     0x7F, 0x00, 0x00, 0x01, /* source IP */
68)     0xFF, 0xFF, 0xFF, 0xFF, /* destination IP */
69)     0x00, 0x01, 0x00, 0x01, /* UDP: source port, destination port */
70)     0x00, 0x22, 0x00, 0x00, /* UDP: len, ... */
71)     'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
72)     'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
73)   };
74) #endif
75) 
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

78) #ifdef CFG_ETH_RX
79)     while (eth_rx(&vptr, &sz)) {
80)       ptr = vptr;
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

87) #ifdef CFG_DELAY
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

89) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

90)   }
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

91) #ifdef CFG_ETH_TX
92)   eth_tx(example_packet, sizeof(example_packet));
93) #endif
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

94) }
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

95) 
96) int main()
97) {
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

101) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

102)   leds_set_state(0x01);
103) 
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

104)   for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
105)     data[i] = i;
106) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

107)   leds_set_state(0x02);
108) 
Stefan Schuermans implemented ethernet TX fir...

Stefan Schuermans authored 12 years ago

109) #ifdef CFG_ETH_RX
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

110)   eth_rx_init();
111) #endif
112) 
113)   leds_set_state(0x04);
114) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

115) #ifdef CFG_LCD
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

116)   lcd_init();
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

119) #endif
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

120) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

121)   leds_set_state(0x08);
122) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

146) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

147)   leds_set_state(0x10);
148) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

152)     if (uart_can_rx()) {
153)       chr = uart_rx();
154)       if (uart_is_err(chr))
155)         leds = 0;
156)       else
157)         leds = chr;
158)     }
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

159) #endif
160)     leds_set_state(leds);
161)     leds = leds << 1 | leds >> 7;
162)     delay();
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

164)