Exemplo n.º 1
0
int main(int argc, char *argv[]) {
	//uint8_t buf[32];
	//int i = 0;

  hal_disable_ints();	// In case we got here via jmp 0x0

//	delay(10000000);

	//before anything else you might want to blinkenlights just to indicate code startup to the user.

  hal_uart_init();
	spif_init();
//	i2c_init(); //for EEPROM
	puts("USRP2+ UART firmware loader");

//	puts("Debug: loading production image, 10 bytes.");

//	spi_flash_read(PROD_FW_IMAGE_LOCATION_ADDR, 10, buf);
//	for(i=0; i < 10; i++) {
//		puthex8(buf[i]);
//	}

	uart_flash_loader();

 	//shouldn't get here. should reboot.
	puts("shit happened.\n");

	return 0;
}
Exemplo n.º 2
0
Arquivo: hal_io.c Projeto: paneda/uhd
void
hal_toggle_leds(int mask)
{
    int ei = hal_disable_ints();
    leds_shadow ^= mask;
    output_regs->leds = leds_shadow;
    hal_restore_ints(ei);
}
Exemplo n.º 3
0
Arquivo: hal_io.c Projeto: paneda/uhd
// Allow hardware control over leds.  1 = hardware, 0 = software
void
hal_set_led_src(int value, int mask)
{
    int ei = hal_disable_ints();
    led_src_shadow = (led_src_shadow & ~mask) | (value & mask);
    output_regs->led_src = led_src_shadow;
    hal_restore_ints(ei);
}
Exemplo n.º 4
0
/*
 * We ought to arrange for this to be called before main, but for now,
 * we require that the user's main call u2_init as the first thing...
 */
bool
u2_init(void)
{
  hal_disable_ints();
  hal_io_init();

  // init spi, so that we can switch over to the high-speed clock
  spi_init();

  // set up the default clocks
  clocks_init();

  hal_uart_init();

  // init i2c so we can read our rev
  pic_init();	// progammable interrupt controller
  i2c_init();
  hal_enable_ints();

  // flash all leds to let us know board is alive
  hal_set_led_src(0x0, 0x1f); /* software ctrl */
  hal_set_leds(0x0, 0x1f);    mdelay(300);
  hal_set_leds(LED_E, LED_E); mdelay(300);
  hal_set_leds(LED_C, LED_C); mdelay(300);
  hal_set_leds(LED_A, LED_A); mdelay(300);
  for (int i = 0; i < 3; i++){ //blink all
    static const int blinks = LED_E | LED_C | LED_A;
    hal_set_leds(0x0,    0x1f); mdelay(100);
    hal_set_leds(blinks, 0x1f); mdelay(100);
  }
  hal_set_led_src(0x1f & ~LED_D, 0x1f); /* hardware ctrl */
  hal_set_leds(LED_D, 0x1f);  // Leave one on

#if 0
  // test register readback
  int rr, vv;
  vv = ad9777_read_reg(0);
  printf("ad9777 reg[0] = 0x%x\n", vv);
  
  for (rr = 0x04; rr <= 0x0d; rr++){
    vv = ad9510_read_reg(rr);
    printf("ad9510 reg[0x%x] = 0x%x\n", rr, vv);
  }
#endif

  output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN);

  return true;
}
Exemplo n.º 5
0
int main(int argc, char *argv[]) {
	uint16_t i, t;
	uint8_t buf[260];
	const uint8_t testdata[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C};

  hal_disable_ints();	// In case we got here via jmp 0x0
//	spi_init();
  hal_uart_init();
//	clocks_init(); //set up AD9510, enable FPGA clock @ 1x divisor

	puts("SPI Flash test\n");
	puts("Initializing SPI\n");

	spif_init();
	delay(800000);
	puts("Erasing sector 1\n");
	spi_flash_erase(0x00010000, 256);
	delay(800000);
	puts("Reading back data\n");
	spi_flash_read(0x00010000, 256, buf);
	delay(800000);

	t=1;
	for(i=4; i<250; i++) {
		if(buf[i] != 0xFF) t=0;
	}

	if(!t) puts("Data was not initialized to 0xFF. Unsuccessful erase or read\n");
	else puts("Data initialized to 0xFF, erase confirmed\n");

	puts("Writing test buffer\n");
	spi_flash_program(0x00010000, 16, testdata);
	//memset(buf, 0, 256);

	delay(800000);
	puts("Wrote data, reading back\n");

	spi_flash_read(0x00010000, 16, buf);

	if(memcmp(testdata, buf, 16)) puts("Data is not the same between read and write. Unsuccessful write or read\n");
	else puts("Successful write! Flash write correct\n");

	return 0;
}
Exemplo n.º 6
0
int main(int argc, char *argv[]) {

	hal_disable_ints();
  hal_uart_init();
	spi_init();

	puts("Hardware testbed. Init clocks...");

	clocks_init();

	//now, hopefully, we should be running at 100MHz instead of 50MHz, meaning our UART is twice as fast and we're talking at 230400.

	while(1) {
		delay(500000);
		puts("Eat at Joe's.");
	}





	return 0;
}