BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
cc0f06d
Branches
Tags
master
mips_sys
fw
main.c
implementation of ethernet and ARP (not completely working yet, hangs on received ARP request)
Stefan Schuermans
commited
cc0f06d
at 2012-03-17 01:03:19
main.c
Blame
History
Raw
#include "arp.h" #include "cyc_cnt.h" #include "eth.h" #include "lcd.h" #include "leds.h" #include "uart.h" #include "switches.h" unsigned char leds_val = 0x88; void switches(void) { lcd_chr(1, 0, switches_get_state(sw_0) ? '0' : ' '); lcd_chr(1, 1, switches_get_state(sw_1) ? '1' : ' '); lcd_chr(1, 2, switches_get_state(sw_2) ? '2' : ' '); lcd_chr(1, 3, switches_get_state(sw_3) ? '3' : ' '); lcd_chr(1, 4, switches_get_state(sw_east) ? 'E' : ' '); lcd_chr(1, 5, switches_get_state(sw_north) ? 'N' : ' '); lcd_chr(1, 6, switches_get_state(sw_south) ? 'S' : ' '); lcd_chr(1, 7, switches_get_state(sw_west) ? 'W' : ' '); lcd_chr(1, 8, switches_get_state(sw_center) ? 'C' : ' '); lcd_chr(1, 9, switches_get_state(sw_rot_a) ? 'a' : ' '); lcd_chr(1, 10, switches_get_state(sw_rot_b) ? 'b' : ' '); unsigned int cnt = switches_get_rot_cnt(); lcd_chr(1, 12, '0' + (cnt >> 9 & 0x7)); lcd_chr(1, 13, '0' + (cnt >> 6 & 0x7)); lcd_chr(1, 14, '0' + (cnt >> 3 & 0x7)); lcd_chr(1, 15, '0' + (cnt & 0x7)); } void leds_uart(void) { unsigned short chr; while (uart_can_rx()) { chr = uart_rx(); if (uart_is_err(chr)) leds_val = 0; else leds_val = chr; leds_set_state(leds_val); } } void eth_task(void) { void *vptr; unsigned int sz, i; unsigned char *ptr; while (eth_rx(&vptr, &sz)) { ptr = vptr; for (i = 0; i < sz; ++i) uart_tx(ptr[i]); ethernet_recv(vptr, sz); } } void tasks(void) { switches(); leds_uart(); eth_task(); } void leds_tick200(void) { leds_val = leds_val << 1 | leds_val >> 7; leds_set_state(leds_val); } void tick200(void) { leds_tick200(); arp_tick200(); } int main() { unsigned int i; leds_set_state(0x01); eth_mac_init(); eth_rx_init(); leds_set_state(0x02); lcd_init(); lcd_str(0, "MIPS I system"); lcd_str(1, ""); leds_set_state(0x04); uart_cfg_scale(62); /* 115200 */ uart_cfg_bits(8); uart_cfg_stop(1); uart_tx('M'); uart_tx('I'); uart_tx('P'); uart_tx('S'); uart_tx(' '); uart_tx('I'); uart_tx('\r'); uart_tx('\n'); leds_set_state(0x08); arp_init(); leds_set_state(0x10); while (1) { for (i = 0; i < 20; ++i) { tasks(); cyc_cnt_delay_ms(10); } tick200(); } return 0; }