c559f2fe8b700ba22f5ae8a98e5d7bba818f209a
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 begin of ethernet RX implem...

Stefan Schuermans authored 12 years ago

54)   unsigned char chr;
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()) {
60)     chr = eth_rx();
61) #ifdef CFG_UART
62)   uart_tx(chr);
63) #endif
64)   }
65) #endif
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

66) #ifdef CFG_DELAY
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

68) #endif
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

70) }
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

77) 
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

78)   for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
79)     data[i] = i;
80) 
Stefan Schuermans implemented RX part of UART...

Stefan Schuermans authored 12 years ago

81) #ifdef CFG_LCD
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

82)   lcd_init();
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

85) #endif
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

121) #endif
122)     leds_set_state(leds);
123)     leds = leds << 1 | leds >> 7;
124)     delay();
Stefan Schuermans slower LED animation for ex...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

126)