Ejemplo n.º 1
1
int main()
{

	init_platform();
		u32 data,data2;
		unsigned int empty_L;
		unsigned int full_E;
		unsigned int i;

		XIOModule iomodule;
		data = XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
		data = XIOModule_Start(&iomodule);

		DIR_FIFO_ESCRITURA_DT = (u32) 'H';
		DIR_FIFO_ESCRITURA_DT = (u32) 'O';
		DIR_FIFO_ESCRITURA_DT = (u32) 'L';
		DIR_FIFO_ESCRITURA_DT = (u32) 'A';
		DIR_FIFO_ESCRITURA_DT = (u32) '\n';


		while (1) {
			do{
				data = DIR_FIFO_LECTURA_ST;
				empty_L = (unsigned int) data;
			}while(empty_L != 0);
			data2 = DIR_FIFO_LECTURA_DT;

			do{
				data = DIR_FIFO_ESCRITURA_ST;
				full_E = (unsigned int) data;
			}while(full_E != 0);

			DIR_FIFO_ESCRITURA_DT = data2;

			data = DIR_SWITCHES;
			DIR_LEDS = data;
		}

		cleanup_platform();
		return 0;
/*	init_platform();
	u32 data;

	XIOModule iomodule;
	xil_printf("Reading switches and writing to LED port\n\r");
	data = XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
	data = XIOModule_Start(&iomodule);

	while (1)
	{
		data = DIRSWIT;
		xil_printf("Valor: %x\n\r",data);
		DIRLEDS = data;
	}
	cleanup_platform();
	return 0;*/
}
int main() {
    init_platform();

    // Initialize the GPIO peripherals.
	XGpio_Initialize(&gpPB, XPAR_PUSH_BUTTONS_5BITS_DEVICE_ID);
	// Set the push button peripheral to be inputs.
	XGpio_SetDataDirection(&gpPB, 1, 0x0000001F);
	// Enable the global GPIO interrupt for push buttons.
	XGpio_InterruptGlobalEnable(&gpPB);
	// Enable all interrupts in the push button peripheral.
	XGpio_InterruptEnable(&gpPB, 0xFFFFFFFF);

    interrupts_init();

    print("made it past interrupts_init\n\r");

    // apparently we don't need to init it, just HardReset
    XAC97_HardReset(XPAR_AXI_AC97_0_BASEADDR);
    XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_ExtendedAudioStat, 1);
    XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_PCM_DAC_Rate, AC97_PCM_RATE_11025_HZ);
    XAC97_mSetControl(XPAR_AXI_AC97_0_BASEADDR, AC97_ENABLE_IN_FIFO_INTERRUPT);
    XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_MasterVol, AC97_VOL_MAX);
    XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_PCMOutVol, AC97_VOL_MAX);


    while (1);

    cleanup_platform();

    return 0;
}
Ejemplo n.º 3
0
int main()
   {
        init_platform();

        xil_printf( "----------The test is start......----------\n\r" );

        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0x30 , 0x4 ); //reset    S2MM  VDMA  Control  Register 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0x30 , 0x8 ); //genlock 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xAC , 0x08000000 ); // S2MM  Start  Addresses 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xAC + 4 , 0x0A000000 );
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xAC + 8 , 0x09000000 );
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xA4 , 1920 * 3 ); // S2MM  Horizontal  Size 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xA8 , 0x01002000 ); // S2MM  Frame  Delay  and  Stride 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0x30 , 0x3 ); // S2MM  VDMA  Control  Register 
        Xil_Out32 ( XPAR_AXI_VDMA_0_BASEADDR + 0xA0 , 1080 ); // S2MM  Vertical  Size   start an S2MM transfer

        //AXI VDMA1
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x4); //reset MM2S VDMA Control Register
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x8); //gen-lock
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C, 0x08000000); //MM2S Start Addresses
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C+4, 0x0A000000);
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C+8, 0x09000000);
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x54, 1920*3);//MM2S HSIZE Register
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x58, 0x01002000);//S2MM FRMDELAY_STRIDE Register 1920*3=5760對齊之後為8192=0x2000
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x03);//MM2S VDMA Control Register
        Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, 1080);//MM2S_VSIZE啟動傳輸

        cleanup_platform();
        return 0;
    }
Ejemplo n.º 4
0
int main()
{
    init_platform();

    int pin1 = 0;
    int pin2 = 0;
    int pin3 = 0;
    int pin4 = 0;
    int all_pins = 0;

    print("GPIO Demo\n\r");

    GPIO_begin(&myDevice, XPAR_PMODGPIO_0_AXI_LITE_GPIO_BASEADDR, 0xFF);

    while(1){
		//read individually
    	pin1 = GPIO_getPin(&myDevice, 1);
    	pin2 = GPIO_getPin(&myDevice, 2);
    	pin3 = GPIO_getPin(&myDevice, 3);
    	pin4 = GPIO_getPin(&myDevice, 4);
		//read all together
    	all_pins = GPIO_getPins(&myDevice);
		//print individual reads and the total read masked to the first four bits
    	xil_printf("switch 1: %d   switch 2: %d   switch 3: %d   switch 4: %d   all pins: %d\n\r", pin1, pin2, pin3, pin4, all_pins & 0x0f);
    }

    cleanup_platform();
    return 0;
}
Ejemplo n.º 5
0
void DemoRun()
{


	xil_printf("starting...\n\r");

    while(1)
    {
    	 // increase physical value from minimum to maximum value
    	  for(dValue = dMinValue; dValue <= dMaxValue; dValue += dStep)
    	  {
    		  whole = dValue; // getting whole number for the physical value
    		  not_whole= (dValue - whole) * 1000; // getting the non whole number of the physical value
    	    // send value to the DA converter
    	    status = DA1_WritePhysicalValue(dValue,&myDevice);
    	
    	  }

    	  // decrease physical value from maximum to minimum value
    	   for(dValue = dMaxValue; dValue >= dMinValue; dValue -= dStep)
    	   {
    		   whole = dValue; // getting whole number for the physical value
    		   not_whole= (dValue - whole) * 1000; // getting the non whole number of the physical value
    	     // send value to the DA converter
    		   status= DA1_WritePhysicalValue(dValue,&myDevice);
    		
    	   }

    }

    DA1_end(&myDevice);
    cleanup_platform();
}
Ejemplo n.º 6
0
int main()
{
    int aliveLed = 0;
    static int BlinkCount = 0;
    init_platform();
    if(SetupPeripherals() != XST_SUCCESS)
    	return -1;

    if ( Chilipepper_Initialize() != 0 )
    	return -1;

    Chilipepper_SetPA( 1 );
    Chilipepper_SetTxRxSw( 1 ); // 0- transmit, 1-receive
    while (1)
    {
	   Chilipepper_ControlAgc(); //update the Chilipepper AGC
	   BlinkCount += 1;
	   if (BlinkCount > 500000)
	   {
		 if (aliveLed == 0)
			aliveLed = 1;
		 else
			aliveLed = 0;
		 BlinkCount = 1;
		 XGpio_DiscreteWrite(&gpio_blinky, 2, aliveLed);  //blink LEDs
		 XGpio_DiscreteWrite(&gpio_blinky, 1, ~aliveLed);
	   }
    }
    cleanup_platform();
    return 0;
}
Ejemplo n.º 7
0
int main()
{
    init_platform();
    initInterrupts();

	int source_word[16];
	int destination_word[16];
	setArray(source_word, 16, 0);
	setArray(destination_word, 16, 1);

    printf("Printing value before DMA transfer.\n\r");
    printArray(destination_word, 16);

    DMA_CONTROLLER_InitiateTransfer(XPAR_DMA_CONTROLLER_0_BASEADDR, (Xuint32) &source_word, (Xuint32) &destination_word, 4 * 10);

    printf("Printing value after DMA transfer.\n\r");
    printArray(destination_word, 16);

	setArray(source_word, 6, 1);
    DMA_CONTROLLER_InitiateTransfer(XPAR_DMA_CONTROLLER_0_BASEADDR, (Xuint32) &source_word, (Xuint32) &destination_word, 4 * 10);

    printf("Printing value after 2nd DMA transfer.\n\r");
    printArray(destination_word, 16);

    cleanup_platform();

    return 0;
}
Ejemplo n.º 8
0
int main()
{
    init_platform();

    print("Hello World\n\r");

    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x4); //reset   MM2S VDMA Control Register
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x8); //gen-lock
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x5C,   0x04000000);   //MM2S Start Addresses

    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x54, 640*3);//MM2S HSIZE Register---buffer length
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x58, 0x01000780);//S2MM FRMDELAY_STRIDE Register 1920*3=5760 对齐之后为8192=0x2000

    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x0, 0x03);//MM2S VDMA Control Register

    //Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, 480);//MM2S_VSIZE    启动传输





    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xAC, 0x08000000);//S2MM Start Addresses
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA4, 640*3);
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA8, 0x01000780);//S2MM Frame Delay and Stride
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x30, 0x3);//S2MM VDMA Control Register



    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0x50, 480);//MM2S_VSIZE    启动传输
    Xil_Out32(XPAR_AXI_VDMA_0_BASEADDR + 0xA0, 480);//S2MM Vertical Size  start an S2MM transfer

    cleanup_platform();
    return 0;
}
Ejemplo n.º 9
0
int main(void)
{
	u32 Data;
	u32 InData;
	int Status;
	volatile int Delay;
	char test_vect_idx =0;
	char charidx = 0;
	u8 DataWrittenDone = 0;
	char curchar;

	 init_platform();



	/*
	 * Initialize the GPIO driver
	 */
	Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


	for (test_vect_idx=0;test_vect_idx<num_test_vectors;test_vect_idx++)
	{
		for (charidx=0;charidx<64;charidx++)
		{
			curchar = testvector[test_vect_idx][charidx]; //Read the current character
			Data = createDataPacket(curchar,charidx,test_vect_idx); //Send the 'A' character to byte 3 of testvector 1
			print("Sending character \n");
			XGpio_DiscreteWrite(&Gpio, OUPTPUT_CHANNEL, Data); //Write into the PL
			//Double check by reading from the PL
			for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while
			//Read back the data from the PL side to see its status
			do
			{
				InData = XGpio_DiscreteRead(&Gpio, INPUT_CHANNEL);
				for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while before recheck
			}
			while (InData&(1<<31));
			if ((InData&0xFF)==(Data&0xFF))
			{
				print("Correct\n");
			}
			else
			{
				print("Incorrect\n");
			}
			XGpio_DiscreteWrite(&Gpio, OUPTPUT_CHANNEL, 0x00000000); //Release the bus immediately
			for (Delay = 0; Delay < LED_DELAY; Delay++); //Wait for a while

		}
	}
	print("Done sending. Please press the center button to begin...");

	cleanup_platform();
	return XST_SUCCESS;
}
Ejemplo n.º 10
0
int main(void)
{
    DemoInitialize();
    DemoRun();

    cleanup_platform();
    return 0;
}
Ejemplo n.º 11
0
int main()
{
    init_platform();

    xil_printf("%s\n\r", "Welcome to Brutus cracker system!");

    while (1) {
    	xil_printf("%s\n\r", "Enter hash: ");
		char recv = XUartLite_RecvByte(STDIN_BASEADDRESS); // read first char


		/* Read password hash */
		char buff[32];
		int idx_buff = 0;
		while (recv != '\r') {
			buff[idx_buff++] = recv;
			recv = XUartLite_RecvByte(STDIN_BASEADDRESS);
		}

		unsigned int i_buff[4] = {0};
		unsigned num = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 8; j++) {
				num = ctox(buff[j + i*8]);
				i_buff[i] += (pow(16, 7-j) * num);
			}
			//xil_printf("%x\n\r", i_buff[i]);
		}

		//xil_printf("%u\n\r", i_buff[0]);


		putfsl(i_buff[0], 0);
		putfsl(i_buff[1], 0);
		putfsl(i_buff[2], 0);
		putfsl(i_buff[3], 0);
		xil_printf("Cracking...\n\r");

		unsigned int resp;
		char *str = &resp; // c-magic

		getfsl(resp, 0);
		unsigned i;
		xil_printf("password: "******"%c", *(str+i));
		}
		getfsl(resp, 0);
		for (i = 0; i < 4; i++) {
			xil_printf("%c", *(str+i));
		}
		xil_printf("\n\r");
    }
    cleanup_platform();

    return 0;
}
Ejemplo n.º 12
0
Archivo: main.c Proyecto: Tassadus/hdl
int main()
{
	init_platform();

    // Specify configuration for hardware design.
    demo.ali3_resolution = VIDEO_RESOLUTION_WXGA;
    demo.ali3_width  = vres_get_width(VIDEO_RESOLUTION_WXGA);
    demo.ali3_height = vres_get_height(VIDEO_RESOLUTION_WXGA);
    demo.uDeviceId_VDMA_FrameBuffer = XPAR_AXIVDMA_0_DEVICE_ID;
    demo.uBaseAddr_MEM_FrameBuffer  = XPAR_DDR_MEM_BASEADDR + 0x10000000;
    demo.uNumFrames_FrameBuffer     = XPAR_AXIVDMA_0_NUM_FSTORES;
    //
    demo.uBaseAddr_IIC_Touch        = XPAR_IIC_0_BASEADDR;
    //
    demo.uDeviceId_IRQ_Touch        = XPAR_PS7_SCUGIC_0_DEVICE_ID;
    demo.uInterruptId_IRQ_Touch     = XPS_FPGA0_INT_ID;

    // Initialize the PS GPIO controls.
    if (ps_gpio_polled_init(&demo) != 0)
    {
    	xil_printf("Failed to initialize PS GPIO driver\n\r");
    }

	// Wait while the display powers up fully before accessing any hardware.
    sleep(1);
	
    // Initialize hardware design for the display.
    zed_ali3_controller_demo_init(&demo);

    // Initialize Serial Console.
    start_avnet_console_serial_application();

    // Wait while peripherals become calibrated and configured.
    sleep(1);

    // Check for calibration request.
    zed_ali3_controller_demo_check_calibrate_request(&demo);

    // Display the logo screen to show that the system is configured.
    zed_ali3_controller_demo_logo(&demo);

    while (1)
    {
        // Process user input from Serial Console.
        transfer_avnet_console_serial_data();

        // Process user input from the touch screen.
        zed_ali3_controller_demo_touch_process(&demo);

        // Process user input from the board hardware.
        zed_ali3_controller_demo_board_process(&demo);
    }

    cleanup_platform();

    return 0;
}
Ejemplo n.º 13
0
int main()
{
	struct netif *netif, server_netif;
	struct ip_addr ipaddr, netmask, gw;

	/* the mac address of the board. this should be unique per board */
	unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	netif = &server_netif;

	init_platform();

	/* initliaze IP addresses to be used */
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);

	print_app_header();


	print_ip_settings(&ipaddr, &netmask, &gw);

	lwip_init();

  	/* Add network interface to the netif_list, and set it as default */
	if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\n\r");
		return -1;
	}
	netif_set_default(netif);
	
	/* Create a new DHCP client for this interface.
	 * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
	 * the predefined regular intervals after starting the client.
	 */
	/* dhcp_start(netif); */

	/* now enable interrupts */
	platform_enable_interrupts();

	/* specify that the network if is up */
	netif_set_up(netif);

	/* start the application (web server, rxtest, txtest, etc..) */
	start_application();

	/* receive and process packets */
	while (1) {
		xemacif_input(netif);
		transfer_data();
	}
  
	/* never reached */
	cleanup_platform();

	return 0;
}
Ejemplo n.º 14
0
Archivo: twofish.c Proyecto: slomo/ske
int main() {

	volatile unsigned int *gpio = (unsigned int *) XPAR_XPS_GPIO_0_BASEADDR,
                          *gpio_tristate = (unsigned int *) (XPAR_XPS_GPIO_0_BASEADDR + 0x04),
                          *gpio2 = (unsigned int *) (XPAR_XPS_GPIO_0_BASEADDR + 0x08);
	init_platform();

	*gpio_tristate = 0x0;
	int i, j;

	xil_printf("Foo\r\n");

	*gpio = RESET;
	*gpio = 0;

	xil_printf("reset\n\r");

	// key schreiben 128 bits

	volatile unsigned int *mem = (unsigned int *) XPAR_XPS_BRAM_IF_CNTLR_0_BASEADDR;

	for (i = 0; i < 4; i++) {
		mem[i+4] = i+1;
	}

	xil_printf("Key: %X %X %X %X \r\n", mem[0], mem[1], mem[2], mem[3]);

	// enable set
	*gpio = SET;

	WAIT_FOR_DONE(gpio2);

	xil_printf("set done\n\r");

	*gpio = 0;

	for (j = 0; j < 10; j++) {
		// write data
		for (i = 0; i < 4; i ++) {
			mem[i] = j;
		}

		//xil_printf("data written\n\r");

		*gpio = ENABLE;
		*gpio = 0;
		WAIT_FOR_DONE(gpio2);

		// xil_printf("encryption done\n\r");
		xil_printf("Result: %X %X %X %X \r\n", mem[0], mem[1], mem[2], mem[3]);

	}

	cleanup_platform();

	return 0;
}
Ejemplo n.º 15
0
int main()
{
    init_platform();

    run_mac_eeprom_test();

    cleanup_platform();

    return 0;
}
Ejemplo n.º 16
0
int main()
{
    init_platform();

    print("Int Sim Example\n\r");
    IntcExample(INTC_DEVICE_ID);

    cleanup_platform();
    return 0;
}
Ejemplo n.º 17
0
int main()
{
    init_platform();

    print("Hello World\n\r");

    cleanup_platform();

    return 0;
}
Ejemplo n.º 18
0
int main() {
	// Optical__value_all
	u8 Optical_value_all;
	// Optical__value_signal
	u8 Optical_value_signal;
	int Speed, Dir;

	float Ultrasonic_value_all[3];
	int i;

	init_platform();
	OptInit();
	MotorInit();
	BluetoothInit();

	while (1) {
		Optical_value_all = OptGetAll();
		printf("optical_all : %X \r\n", Optical_value_all);
		OptGetSingle(Opt1, &Optical_value_signal);
		printf("optical_CH1 : %X \r\n", Optical_value_signal);
		OptGetSingle(Opt2, &Optical_value_signal);
		printf("optical_CH2 : %X \r\n", Optical_value_signal);
		OptGetSingle(Opt3, &Optical_value_signal);
		printf("optical_CH3 : %X \r\n", Optical_value_signal);
		OptGetSingle(Opt4, &Optical_value_signal);
		printf("optical_CH4 : %X \r\n", Optical_value_signal);
		OptGetSingle(Opt5, &Optical_value_signal);
		printf("optical_CH5 : %X \r\n\r\n", Optical_value_signal);

		UltraGetAll(Ultrasonic_value_all);
		for (i = 0; i < 3; i++) {
			printf("u%d : %f mm\r\n", i, Ultrasonic_value_all[i]);
			usleep(1000);
		}
		printf("\r\n");

		SetMotorSpeed(MotorL, 30);
		SetMotorSpeed(MotorR, -80);
		Speed = GetMotorSpeed(MotorL);
		printf("MotorL Speed : %d \r\n", Speed);
		Speed = GetMotorSpeed(MotorR);
		printf("MotorR Speed : %d \r\n", Speed);
		Dir = GetMotorDir(MotorL);
		printf("MotorL Dir : %d \r\n", Dir);
		Dir = GetMotorDir(MotorR);
		printf("MotorR Dir : %d \r\n\r\n", Dir);
		usleep(50 * 1000);

		BluetoothSend("Hello World\r\n",11);
	}

	cleanup_platform();
	return 0;
}
int main()
{
	init_platform();

	// Declare some variables that we'll use later
	int Status;
	int timer_value;
	int counter = 0;

	// Declare two structs.  One for the Timer instance, and
	// the other for the timer's config information
	XScuTimer my_Timer;
	XScuTimer_Config *Timer_Config;

	// Look up the the config information for the timer
	Timer_Config = XScuTimer_LookupConfig(XPAR_PS7_SCUTIMER_0_DEVICE_ID);

	// Initialise the timer using the config information
	Status = XScuTimer_CfgInitialize(&my_Timer, Timer_Config, Timer_Config->BaseAddr);

	// Load the timer with a value that represents one second
	// The SCU Timer is clocked at half the freq of the CPU.
	XScuTimer_LoadTimer(&my_Timer, XPAR_PS7_CORTEXA9_0_CPU_CLK_FREQ_HZ / 2);

	// Start the timer running (it counts down)
	XScuTimer_Start(&my_Timer);

	// An infinite loop
	while(1)
	{
		// Read the value of the timer
		timer_value = XScuTimer_GetCounterValue(&my_Timer);

		// If the timer has reached zero
		if (timer_value == 0)
		{
			// Re-load the original value into the timer and re-start it
			XScuTimer_RestartTimer(&my_Timer);

			// Write something to the UART (and count the seconds)
			printf("Timer has reached zero %d times\n\r", counter++);
		}
		else
		{
			// Show the value of the timer's counter value, for debugging purposes
			//printf("Timer is still running (Timer value = %d)\n\r", timer_value);
		}
	}

	cleanup_platform();

	return 0;
}
Ejemplo n.º 20
0
int main(void)
{
	Xil_ICacheEnable();
	Xil_DCacheEnable();

	DemoInitialize();
	DemoRun();

	cleanup_platform();

	return 0;
}
int main()
{
	// our variables that we will be using to read and write to our hardware register
	int current_value;
	int write_value = 123456789;
	int read_value = 0;

    init_platform();


    printf("Application Loaded.\r\n\r\n\r\n");

    printf("Getting current register value ... ");

    // read out the current value from our peripheral, at register zero
    current_value = SIMPLE_REGISTER_mReadReg(
    					SIMPLE_REGISTER_BASE_ADDRESS,
    					REGISTER_0
    					);

    printf("Done.\r\n");

    printf("Register value = %i\r\n\r\n",current_value);

    printf("Writing %i to the hardware register ... ", write_value);

    // write our value to our peripheral at register 0
    SIMPLE_REGISTER_mWriteReg(
    		SIMPLE_REGISTER_BASE_ADDRESS,
    		REGISTER_0,
    		write_value
    		);

    printf(" Done.\r\n");

    printf("Reading register value ... ");

    // read out the current value from our peripheral, at register zero
	read_value = SIMPLE_REGISTER_mReadReg(
						SIMPLE_REGISTER_BASE_ADDRESS,
						REGISTER_0
						);

    printf("Done.\r\n");

    printf("Register value = %i\r\n\r\n",read_value);

    printf("Exiting Application, ta ta!\r\n");

    cleanup_platform();

    return 0;
}
Ejemplo n.º 22
0
Archivo: sw_top.c Proyecto: Hilx/SynADT
int main()
{
	init_platform();

	print("Hello World\n\r");



	int *hdList;
	int i,j;
	for(i =0; i < 21; i++){
		SysAlloc_init();

		int log2ListSize = i;
		int *hdList = NULL;

		putnum(log2ListSize);
		print(" ");

		XIo_Out32(COUNTER_BASE + 4 * 1, START);
		hdList = RandListGen(log2ListSize, hdList);
		XIo_Out32(COUNTER_BASE + 4 * 1, STOP);

		XIo_Out32(COUNTER_BASE + 4 * 2, START);
		hdList = ReverseList(hdList);
		XIo_Out32(COUNTER_BASE + 4 * 2, STOP);

		XIo_Out32(COUNTER_BASE + 4 * 3, START);
		hdList = DeleteList(hdList);
		XIo_Out32(COUNTER_BASE + 4 * 3, STOP);



		for(j = 1; j <4; j++){
			// read counter result back
			int high_value = XIo_In32(COUNTER_BASE + 4 * (j + 8));
			if(high_value != 0){
				putnum(high_value);
			}
			putnum(XIo_In32(COUNTER_BASE + 4 * j));
			print(" ");

			// reset counter
			XIo_Out32(COUNTER_BASE + 4 * j,RESET);
		}
		print("\n");
	}

	print("\n all done\n");

	cleanup_platform();
	return 0;
}
Ejemplo n.º 23
0
int main() {

    unsigned int value=0;
    int i;
    u32 input;

    unsigned int my_array[] = {
    		1841,1371,1356,1435,1364,1474,1741,1790,1720,1770,6770,7460,3660,5045,1111,9481 ,99,100,99,92,159,163,114,177,101,44,55,192,58,81,129,193,124,76,38,181,147,182,77,71,
    		17,164,149,193,62,45,81,176,184,165,28,199,1,199,1,199,1,199,1,199,1,199,1,199,15,12,9,98,9,134,14,15,
    		16,7,2,6,1,4,7,18,1,5,20,21,22,23,24,25,15,15,15,101,199,102,198,103,197,104,196,105,195,111,189,122,
    		184,137,136,135,134,144,141,190,120,170,60,70,30,50,111,981,141,171

    };

    GPIO_0_conf.BaseAddress = XPAR_AXI_GPIO_0_BASEADDR;
    GPIO_0_conf.DeviceId = XPAR_GPIO_0_DEVICE_ID;
    GPIO_0_conf.InterruptPresent = XPAR_GPIO_0_INTERRUPT_PRESENT;
    GPIO_0_conf.IsDual = XPAR_GPIO_0_IS_DUAL;

    //Initialize the XGpio instance
    XGpio_CfgInitialize(&GPIO_0, &GPIO_0_conf, GPIO_0_conf.BaseAddress);

    init_platform();
    print("*Init*\n\r");

    for(i=0;i<size;i++){
    	value = 0xe0000000 | (i<<16) | my_array[i];
    	XGpio_DiscreteWrite(&GPIO_0, 1, value);
    	print("Preencheu RAM! \n\r");
    }

    print("Fim do preenchimento\n\r");
    print("Pressionar btnC\n\r");


	input = XGpio_DiscreteRead(&GPIO_0, 2);


	// Separar valor para mostrar
	outbyte((char)((input/100)+0x30));
	outbyte((char)((input/10)%10+0x30));
	outbyte((char)(input%10+0x30));
	print("\n");







    cleanup_platform();
    return 0;
}
int main()
{
    init_platform();

    printf("status => ");
    printf("done: %u  ",XEncrypt_IsDone());
    printf("idle: %u\n",XEncrypt_IsIdle());

    int i,j;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            microblaze_bwrite_datafsl(PlainText[i][j], 0) ;
            microblaze_bwrite_datafsl(Key[i][j], 1) ;
        }
    }

    printf("wrote data\n");

    unsigned CipherText[4][4];
    XEncrypt_Start();

    unsigned val;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            microblaze_bread_datafsl(val, 2) ;
            CipherText[i][j] = val;
        }
    }

    printf("status => ");
    printf("done: %u  ",XEncrypt_IsDone());
    printf("idle: %u\n",XEncrypt_IsIdle());

    //check
    int errors = 0;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            if(CipherText[i][j] != GoldenCipherText[i][j]) {
                printf("Error! Calculated key does NOT match golden key at index: [%d][%d] !!!\n",i,j);
                errors++;
            }
        }
    }

    printf("-- CipherText Check Completed - Found %d errors.\n",errors);

    print("Hello World\n\r");

    cleanup_platform();

    return 0;
}
int main()
{

	XCsuDma_Config *Config;
	s32 Status;
	u32 Index;
	u8 EncData[XSECURE_DATA_SIZE + XSECURE_SECURE_GCM_TAG_SIZE]__attribute__ ((aligned (64)));


    init_platform();

    print("Adiuvo Engineering & Training AES CSU Example \n\r");

	Config = XCsuDma_LookupConfig(XSECURE_CSUDMA_DEVICEID);
	if (NULL == Config) {
		return XST_FAILURE;
	}

	Status = XCsuDma_CfgInitialize(&CsuDma, Config, Config->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	XSecure_AesInitialize(&Secure_Aes, &CsuDma,
				XSECURE_CSU_AES_KEY_SRC_KUP,
				(u32 *)Iv, (u32 *)Key);

	xil_printf("Data to be encrypted: \n\r");
	for (Index = 0; Index < XSECURE_DATA_SIZE; Index++) {
		xil_printf("%02x", Data[Index]);
	}
	xil_printf( "\r\n\n");

	XSecure_AesEncryptInit(&Secure_Aes, EncData, XSECURE_DATA_SIZE);
	XSecure_AesEncryptUpdate(&Secure_Aes, Data, XSECURE_DATA_SIZE);

	xil_printf("Encrypted data: \n\r");
	for (Index = 0; Index < XSECURE_DATA_SIZE; Index++) {
		xil_printf("%02x", EncData[Index]);
	}
	xil_printf( "\r\n");

	xil_printf("GCM tag: \n\r");
	for (Index = 0; Index < XSECURE_SECURE_GCM_TAG_SIZE; Index++) {
		xil_printf("%02x", EncData[XSECURE_DATA_SIZE + Index]);
	}
	xil_printf( "\r\n\n");

    cleanup_platform();
    return 0;
}
Ejemplo n.º 26
0
int main()
{
	xil_printf("Program Started\n\r");
    init_platform();
    init_spi(&SpiInstance);
    init_gpio(&GpioInstance);

    u8 LED_data = 0x1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    xil_printf("Tests started.\n\r");
    LED_data |= 0x1<<1;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);

    // Test for proper initial read/write
    int addr = 0;
    int value = 10;
	spi_write(&SpiInstance, addr, value);
	u8 res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X. %d transmitted. %d read back. The send and received values should match.\n\r", addr, value, res);
	// Test for proper overwriting of same address with new value
	value = 16;
	spi_write(&SpiInstance, addr, value);
	res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X again. %d transmitted. %d read back. The received value should be updated to the new sent value.\n\r", addr, value, res);
	// Test for making sure multiple addresses work
	addr = 1;
	value = 20;
	spi_write(&SpiInstance, addr, value);
	res = spi_read(&SpiInstance, addr);
	xil_printf("Wrote to %X. %d transmitted. %d read back. The new address should function as well as the old one.\n\r", addr, value, res);
	// Test to make sure every address works
	xil_printf("Writing and reading to all 32 memory addresses:\r\n(sent and received values should match, value + address should sum to 32)\n\r");
	int i;
	for (i = 0; i < 32; ++i){
		addr = i;
		value = 32 - i;
		spi_write(&SpiInstance, addr, value);
		res = spi_read(&SpiInstance, addr);
		xil_printf("Wrote to %X. %d transmitted. %d read back.\n\r", addr, value, res);
	}


    LED_data |= 0x1<<2;
    xil_printf("Tests complete. Please review results.\n\r");

    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    LED_data |= 0x1<<3;
    XGpio_DiscreteWrite(&GpioInstance, LED_CHANNEL, LED_data);
    cleanup_platform();
    return 0;
}
Ejemplo n.º 27
0
int main()
{	
	int bufId = 0;
    init_platform();

    printf("Hello World\n\r");
    if(i2c_init_clk() != XST_SUCCESS)
    	return -1;

    while(1);

    cleanup_platform();
    return 0;
}
Ejemplo n.º 28
0
int main()
{
    u32 uDevId = XPAR_IOMODULE_0_DEVICE_ID;
    XIOModule mcsIOMdule;
    init_platform();
    //MicroBlaze MCS IOModule Initialize
    XIOModule_Initialize(&mcsIOMdule, uDevId);
    //set GPO1
    XIOModule_DiscreteWrite(&mcsIOMdule, 1,2);
    //UART
    print("Hello World\n\r");
    cleanup_platform();
    return 0;
}
Ejemplo n.º 29
0
int main()
{
	RESULT * rs;
	int * iptr1, * iptr2;
	int i, j;
	int len1, len2;

    init_platform();

    print("\n\r************"); xil_printf("%s %s", __DATE__, __TIME__); print("************\n\r");

    microblaze_disable_interrupts();

    len1 = 0;
    len2 = 0;
    len1 = len1 / 4 + 1;
    len2 = len2 / 4 + 1;

    iptr1 = (int *)DDR2;
    iptr2 = iptr1 + len1 + 10;
    iptr3 = iptr2 + len2 + 10;
    tmp = 0;
    items = 0;
    running = 1;

    i = j = 0;
    while(i<len1 || j<len2)
    {
    	if(i < len1) { putfsl_interruptible(iptr1[i++], 0);}
    	if(j < len2) { putfsl_interruptible(iptr2[j++], 1);}
    	if(running == 0) break;
    }

    while(tmp < items)
    {
    	bsw_0_has_data_handler();
    }

    rs = (RESULT *) iptr3;
    for(i=0; i<(items>>1); i++)
    {
    	xil_printf("%d[%d, %d] \r\n", rs[i].score, rs[i].phase, rs[i].index);
    }

    print("\n\r************ END ************\n\r");
    cleanup_platform();

    return 0;
}
Ejemplo n.º 30
0
int main()
{
	init_platform();
	init_ddr();
	print("Hello World\n\r");

	int log2ListSize;

	XClistnew myIP;
	int list_set_up;

	int i;
	for(i = 0; i < 21; i++){

		log2ListSize = i;

		list_set_up = XClistnew_Initialize(&myIP, XPAR_CLISTNEW_0_DEVICE_ID);
		list_set_up = XClistnew_IsReady(&myIP);

		Xil_Out32(LIST_BASE + 0x20, log2ListSize);

		// start list IP
		XClistnew_Start(&myIP);

		// check if list IP is done
		int flag_done = 0;
		flag_done = XClistnew_IsDone(&myIP);
		while(flag_done != 1){
			flag_done = XClistnew_IsDone(&myIP);
		}

		// read counter result back
		putnum(Xil_In32(COUNTER_BASE + 4 * 1));
		print(" ");
		putnum(Xil_In32(COUNTER_BASE + 4 * 2));
		print(" ");
		putnum(Xil_In32(COUNTER_BASE + 4 * 3));
		print("\n");

		// reset counter
		Xil_Out32(COUNTER_BASE + 4 * 1,RESET);
		Xil_Out32(COUNTER_BASE + 4 * 2,RESET);
		Xil_Out32(COUNTER_BASE + 4 * 3,RESET);
	}
	print("\n all done\n");

	cleanup_platform();
	return 0;
}