Example #1
0
// delay about ms milliseconds
void
mdelay(int ms)
{
  static int loop_count = -1;

  if (hwconfig_simulation_p())
    return;

  if (loop_count < 0){
    // set correct loop_count
    static unsigned short lc[8] = {
      0,
      LOOPCNT(1),
      LOOPCNT(2),
      LOOPCNT(3),
      LOOPCNT(4),
      LOOPCNT(5),
      LOOPCNT(6),
      LOOPCNT(7)
    };

    loop_count = lc[hwconfig_wishbone_divisor() & 0x7];
  }

  int i;
  for (i = 0; i < ms; i++)
    delay_1ms(loop_count);
}
Example #2
0
int
main(void)
{
  u2_init();

  // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
  //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
  //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");

  putstr("\ntx_only\n");
  
  // Control LEDs
  hal_set_leds(0x0, 0x3);

  if (USE_BUFFER_INTERRUPT)
    pic_register_handler(IRQ_BUFFER,   buffer_irq_handler);

  pic_register_handler(IRQ_OVERRUN,  overrun_irq_handler);
  pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler);

  //pic_register_handler(IRQ_TIMER, timer_irq_handler);
  //hal_set_timeout(timer_delta);

  ethernet_register_link_changed_callback(link_changed_callback);

  ethernet_init();

  // initialize double buffering state machine for DSP RX -> Ethernet
  dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0,
	    &dsp_rx_recv_args, &dsp_rx_send_args,
	    dbsm_nop_inspector);

  // setup receive from ETH
  // bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, BP_LAST_LINE);

#if 0
  if (hwconfig_simulation_p()){
    // If we're simulating, pretend that we got a start command from the host
    u2_mac_addr_t host = {{ 0x00, 0x0A, 0xE4, 0x3E, 0xD2, 0xD5 }};
    start_rx_cmd(&host);
  }
#endif

  start_tx_transfers();		// send constant buffers to DSP TX

  while(1){
    if (!USE_BUFFER_INTERRUPT)
      buffer_irq_handler(0);
  }
}