一、Block Design搭建
二、Linux下AXI Uartile驱动配置
1.在pl.dtsi添加设备树节点
/{ amba_pl: amba_pl {#address-cells = <1>;#size-cells = <1>; compatible = "simple-bus"; ranges ; axi_uartlite_0: serial@42c00000 { clock-names = "s_axi_aclk"; clocks = <&clkc 15>; compatible = "xlnx,axi-uartlite-2.0", "xlnx,xps-uartlite-1.00.a"; current-speed = <115200>; device_type = "serial"; interrupt-names = "interrupt"; interrupt-parent = <&intc>; interrupts = <0 29 1>; /*61 - 32*/ port-number = <0>; reg = <0x42c00000 0x400>; xlnx,baudrate = <0x1c200>; xlnx,data-bits = <0x8>; xlnx,odd-parity = <0x0>; xlnx,s-axi-aclk-freq-hz-d = "100.0"; xlnx,use-parity = <0x0>; };};
2.驱动配置
三、应用程序测试
int AXIuartLite0(){ int fd = open("/dev/ttyUL0", O_RDWR | O_NOCTTY); if (fd < 0) { perror("open uartlite failed"); return -1; } struct termios t; tcgetattr(fd, &t); //UARTLite固定8N1,不要设置波特率 t.c_cflag = CS8 | CLOCAL | CREAD; t.c_iflag = 0; t.c_oflag = 0; t.c_lflag = 0; t.c_cc[VMIN] = 0; t.c_cc[VTIME] = 1; tcsetattr(fd, TCSANOW, &t); tcflush(fd, TCIOFLUSH); char buf[64]; int cnt = 0; int n = 0; int nWrite = 0; while (1) { nWrite = write(fd, "1234\n", 5); printf("nWrite: %d\n", nWrite); n = read(fd, buf, 5); if (n > 0) { //buf[n] = '\0'; for(cnt = 0; cnt < n; cnt++) { printf("RECV: 0x%x\n", buf[cnt]); } } sleep(1); } close(fd); return 0;}