📄 main.c
字号:
/********************************************************************************/
/* filename : MAIN.c */
/* created : xillinx */
/* descript : 系统的C函数入口 */
/********************************************************************************/
#include "../CPU/CPU.h"
#include "../CFG/CFG.h"
#include "../UART/UART.h"
#include "../LED/LED.h"
#include "../SEG7/SEG7.h"
#include "../HC595/HC595.h"
#include "main.h"
unsigned int system_timer;
u8_t arptimer;
u8_t tcptimer;
/********************************************************************************/
/* fun_name : MAIN_uip_timer() */
/* version : v1.00 */
/* created : xillinx */
/********************************************************************************/
void MAIN_uip_timer(void)
{ arptimer++;
tcptimer++;
}
/********************************************************************************/
/* fun_name : MAIN_interrupt_hook_process() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 定时器钩子函数的处理,如果需要使用这些函数,需要重新挂接,如果不需要 */
/* 不需要做任何事情 */
/********************************************************************************/
void MAIN_interrupt_hook_process (void)
{ CPU_001_tick_process = CPU_interrupt_proc_null; //* 定时器钩子函数的缺省处理,如果需要使用这些函数,需要重新挂接
CPU_002_tick_process = CPU_interrupt_proc_null;
CPU_004_tick_process = CPU_interrupt_proc_null;
CPU_008_tick_process = CPU_interrupt_proc_null;
CPU_010_tick_process = CPU_interrupt_proc_null;
CPU_020_tick_process = CPU_interrupt_proc_null;
CPU_040_tick_process = CPU_interrupt_proc_null;
CPU_080_tick_process = CPU_interrupt_proc_null;
CPU_100_tick_process = CPU_interrupt_proc_null;
CPU_200_tick_process = CPU_interrupt_proc_null;
CPU_400_tick_process = CPU_interrupt_proc_null;
CPU_extern_0_process = CPU_interrupt_proc_null;
CPU_extern_1_process = CPU_interrupt_proc_null;
CPU_timer_02_process = CPU_interrupt_proc_null;
//* 重新挂接HOOK函数
CPU_001_tick_process = HC595_refresh; //* 2MS
CPU_080_tick_process = LED_refresh; //* 128x2=256MS
CPU_040_tick_process = MAIN_uip_timer; //* 64*2=128MS
}
void main(void)
{
u8_t i, arptimer;
MAIN_interrupt_hook_process();
UART_buffer_initilize();
CPU_timer_0_initialize();
CPU_timer_2_initialize();
CPU_uart_serial_initial();
CPU_source_initialize(); //* 控制CPU的资源
SEG7_clear_screen();
SEG7_clear_screen();
rtl8019_reset();
rtl8019_initialize();
SEG7_printf_ascii("1234.567"); //* 测试七段数码管
UART_printf("融益通讯学习板\r\n"); //* 测试UART串口
/* Initialise the uIP TCP/IP stack. */
uip_init();
/* Initialise the app. */
httpd_init();
/* Initialise the ARP cache. */
uip_arp_init();
arptimer = 0;
while(1)
{
uip_len = etherdev_read();
if(uip_len == 0)
{ if(tcptimer<8)
{ continue;
}
tcptimer=0x0;
for(i = 0; i < UIP_CONNS; i++)
{
uip_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0)
{
uip_arp_out();
etherdev_send();
}
}
#if UIP_UDP
for(i = 0; i < UIP_UDP_CONNS; i++)
{
uip_udp_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0)
{
uip_arp_out();
etherdev_send();
}
}
#endif /* UIP_UDP */
/* Call the ARP timer function every 10 seconds, 80 tick=10S * */
if(arptimer >= 80)
{
uip_arp_timer();
arptimer = 0;
}
}
else /* (uip_len != 0) Process incoming */
{
if(BUF->type == htons(UIP_ETHTYPE_IP))
{
uip_arp_ipin();
uip_input();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0)
{
uip_arp_out();
etherdev_send();
}
}
else if(BUF->type == htons(UIP_ETHTYPE_ARP))
{
uip_arp_arpin();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0)
{
etherdev_send();
}
}
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -