41147d391f30f2357048efbf73b98abcf5fdfed8
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 RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

11) #ifdef CFG_SIMULATION
12) # define CFG_UART_CHK
13) #else
14) # define CFG_DELAY
15) # define CFG_ETH
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 fra...

Stefan Schuermans authored 12 years ago

54)   unsigned int w;
Stefan Schuermans shortcut to switch between...

Stefan Schuermans authored 12 years ago

55) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

58) #ifdef CFG_ETH
59)   while (eth_can_rx()) {
Stefan Schuermans implemented ethernet RX fra...

Stefan Schuermans authored 12 years ago

60)     w = eth_rx();
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

62)   uart_tx(w);
63)   uart_tx(w >> 8);
64)   uart_tx(w >> 16);
65)   uart_tx(w >> 24);
Stefan Schuermans begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

66) #endif
67)   }
68) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

69) #ifdef CFG_DELAY
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

71) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

73) }
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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 RX part of UART...

Stefan Schuermans authored 12 years ago

84) #ifdef CFG_LCD
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

85)   lcd_init();
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

88) #endif
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

91)   uart_cfg_scale(62); /* 115200 */
92)   uart_cfg_bits(8);
93)   uart_cfg_stop(1);
94)   uart_tx('M');
95)   uart_tx('I');
96)   uart_tx('P');
97)   uart_tx('S');
98)   uart_tx(' ');
99)   uart_tx('I');
100)   uart_tx('\r');
101)   uart_tx('\n');
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

102) #ifdef CFG_UART_CHK
103)   if (uart_rx() != 'M') while(1);
104)   if (uart_rx() != 'I') while(1);
105)   if (uart_rx() != 'P') while(1);
106)   if (uart_rx() != 'S') while(1);
107)   if (uart_rx() != ' ') while(1);
108)   if (uart_rx() != 'I') while(1);
109)   if (uart_rx() != '\r') while(1);
110)   if (uart_rx() != '\n') while(1);
111) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

113) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

117)     if (uart_can_rx()) {
118)       chr = uart_rx();
119)       if (uart_is_err(chr))
120)         leds = 0;
121)       else
122)         leds = chr;
123)     }
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

124) #endif
125)     leds_set_state(leds);
126)     leds = leds << 1 | leds >> 7;
127)     delay();
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

129)