Advertisement
filip710

LV7Z1

Jan 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "xparameters.h"
  3. #include "xil_types.h"
  4. #include "xuartlite_l.h"
  5. #include "xgpio.h"
  6.  
  7. void print(char *str);
  8.  
  9. int main()
  10. {
  11.     u8 data;
  12.     int address;
  13.     int n;
  14.     XGpio switches;
  15.  
  16.     XGpio_Initialize(&switches,XPAR_DIP_SWITCHES_8BITS_DEVICE_ID);
  17.     XGpio_SetDataDirection(&switches,1,0xFF);
  18.     while(1)
  19.     {
  20.         //*********************************************TO DO 1*************************************************//
  21.         //*********************************Primiti 1 bajt podataka putem UART-a********************************//
  22.  
  23.         data = XUartLite_RecvByte(XPAR_RS232_UART_1_BASEADDR);
  24.         n= XGpio_DiscreteRead(&switches,1);
  25.         address = XPAR_MICRON_RAM_MEM0_BASEADDR + n * 4;
  26.         Xil_Out32LE(address,data);
  27.         //*****************************************************************************************************//
  28.  
  29.        xil_printf("Primljeni podatak je: %d, a ispisan kao character: %c\r\n", data, data);
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement