c906a48b0ededd4b309f78a0e70d657e561dad0a
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 RX bus...

Stefan Schuermans authored 12 years ago

10) #define CFG_ETH
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

12) #ifdef CFG_SIMULATION
13) # define CFG_UART_CHK
14) #else
15) # define CFG_DELAY
16) # define CFG_LCD
17) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

18) 
Stefan Schuermans implemented loading of data...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

27) #ifdef CFG_LCD
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

47) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

48) }
49) 
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

51) {
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

52)   unsigned int i;
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

53) #ifdef CFG_ETH
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

54)   unsigned int sz;
55)   unsigned char *ptr;
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

56) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

57)   for (i = 0; i < 10; ++i) {
58)     switches();
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

59) #ifdef CFG_ETH
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

60)   while (eth_rx(&ptr, &sz)) {
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

61) #ifdef CFG_UART
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

64) #endif
65)   }
66) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

67) #ifdef CFG_DELAY
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

69) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

71) }
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

72) 
73) int main()
74) {
Stefan Schuermans added "LEDs" I/O peripheral...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

78) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

79)   leds_set_state(0x01);
80) 
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

81)   for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
82)     data[i] = i;
83) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

84)   leds_set_state(0x02);
85) 
86) #ifdef CFG_ETH
87)   eth_rx_init();
88) #endif
89) 
90)   leds_set_state(0x04);
91) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

92) #ifdef CFG_LCD
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

93)   lcd_init();
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

96) #endif
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

97) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

98)   leds_set_state(0x08);
99) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

101)   uart_cfg_scale(62); /* 115200 */
102)   uart_cfg_bits(8);
103)   uart_cfg_stop(1);
104)   uart_tx('M');
105)   uart_tx('I');
106)   uart_tx('P');
107)   uart_tx('S');
108)   uart_tx(' ');
109)   uart_tx('I');
110)   uart_tx('\r');
111)   uart_tx('\n');
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

112) #ifdef CFG_UART_CHK
113)   if (uart_rx() != 'M') while(1);
114)   if (uart_rx() != 'I') while(1);
115)   if (uart_rx() != 'P') while(1);
116)   if (uart_rx() != 'S') while(1);
117)   if (uart_rx() != ' ') while(1);
118)   if (uart_rx() != 'I') while(1);
119)   if (uart_rx() != '\r') while(1);
120)   if (uart_rx() != '\n') while(1);
121) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

123) 
Stefan Schuermans implemented ethernet RX bus...

Stefan Schuermans authored 12 years ago

124)   leds_set_state(0x10);
125) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

129)     if (uart_can_rx()) {
130)       chr = uart_rx();
131)       if (uart_is_err(chr))
132)         leds = 0;
133)       else
134)         leds = chr;
135)     }
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

136) #endif
137)     leds_set_state(leds);
138)     leds = leds << 1 | leds >> 7;
139)     delay();
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

141)