示例#1
0
文件: main.c 项目: Tikiwinkie/PJE
void pinpon (void)
{
	int status = rflpc_eth_link_state () ;

	if (status)
	{	

		while(rflpc_eth_link_state ()){
		rflpc_led_set(RFLPC_LED_1);
		rflpc_led_set(RFLPC_LED_2);
		wait(1);
		rflpc_led_set(RFLPC_LED_3);
		rflpc_led_set(RFLPC_LED_4);
		rflpc_led_clr(RFLPC_LED_1);
		rflpc_led_clr(RFLPC_LED_2);
		wait(1);
		rflpc_led_clr(RFLPC_LED_3);
		rflpc_led_clr(RFLPC_LED_4);
		}

	}
	else
	{
		rflpc_led_clr(RFLPC_LED_1);
		rflpc_led_clr(RFLPC_LED_2);
		rflpc_led_clr(RFLPC_LED_3);
		rflpc_led_clr(RFLPC_LED_4);

	}

}
示例#2
0
文件: hardware.c 项目: 12019/smews
void mbed_eth_hardware_init(void)
{
    /* Configure and start the timer. Timer 0 will be used for timestamping */
    rflpc_timer_enable(RFLPC_TIMER0);   
    /* Clock the timer with the slower clock possible. Enough for millisecond precision */
    rflpc_timer_set_clock(RFLPC_TIMER0, RFLPC_CCLK_8);
    /* Set the pre scale register so that timer counter is incremented every 1ms */
    rflpc_timer_set_pre_scale_register(RFLPC_TIMER0, rflpc_clock_get_system_clock() / 8000);
    /* Start the timer */
    rflpc_timer_start(RFLPC_TIMER0);
    /* Init the GDMA */
    rflpc_dma_init();


    /* Init output buffers */
    mbed_eth_init_tx_buffers();

    printf(" #####                                          #     # ######  ####### ######\r\n");
    printf("#     #  #    #  ######  #    #   ####          ##   ## #     # #       #     #\r\n");
    printf("#        ##  ##  #       #    #  #              # # # # #     # #       #     #\r\n");
    printf(" #####   # ## #  #####   #    #   ####          #  #  # ######  #####   #     #\r\n");
    printf("      #  #    #  #       # ## #       #         #     # #     # #       #     #\r\n");
    printf("#     #  #    #  #       ##  ##  #    #         #     # #     # #       #     #\r\n");
    printf(" #####   #    #  ######  #    #   ####          #     # ######  ####### ######\r\n");
    printf("\r\n");

    printf(".data  size: %d\r\n", &_data_end - &_data_start);
    printf(".bss   size: %d\r\n", &_bss_end - &_bss_start);
    printf(".stack size: %d\r\n", RFLPC_STACK_SIZE);
    printf("Total: %d\r\n", (&_data_end - &_data_start) + (&_bss_end - &_bss_start) + RFLPC_STACK_SIZE);



    /* Set the MAC addr from the local ip */
    /* @todo: use hardware ID chip from MBED */
    local_eth_addr.addr[0] = 2;
    local_eth_addr.addr[1] = 3;
    local_eth_addr.addr[2] = local_ip_addr[3];
    local_eth_addr.addr[3] = local_ip_addr[2];
    local_eth_addr.addr[4] = local_ip_addr[1];
    local_eth_addr.addr[5] = local_ip_addr[0];

    printf("ETH Init...");
    rflpc_eth_init();
    rflpc_eth_set_mac_address(local_eth_addr.addr);
    _init_buffers();

    while (!rflpc_eth_link_state());
    printf(" done! Link is up\r\n");
    printf("My MAC: %02x:%02x:%02x:%02x:%02x:%02x\r\n", local_eth_addr.addr[0],
           local_eth_addr.addr[1],
           local_eth_addr.addr[2],
           local_eth_addr.addr[3],
           local_eth_addr.addr[4],
           local_eth_addr.addr[5]);
    printf("My ip: %d.%d.%d.%d\r\n", local_ip_addr[3], local_ip_addr[2], local_ip_addr[1], local_ip_addr[0]);
    printf("Starting system takes %d ms\r\n", rflpc_timer_get_counter(RFLPC_TIMER0));
    mbed_console_prompt();
    rflpc_uart0_set_rx_callback(_uart_irq);
}
void enableled(){
  if(rflpc_eth_link_state()){
    rflpc_led_set(RFLPC_LED_1);
  }
  else
    {
      rflpc_led_clr(RFLPC_LED_1);
    }
  

}
int main()
{
  rflpc_eth_init();
  rflpc_led_init();
  while(1){
    if(rflpc_eth_link_state()){
      rflpc_led_set(RFLPC_LED_1);
    }
    else{
      rflpc_led_clr(RFLPC_LED_1);
    }
  }
  return 0;
}