/* * Company: cz123 Electronic Technology Co., Ltd. Liyang Milian Electronic Technology Co., Ltd. Brand: MSXBO BBS: www.osrc.cn WEB: www.msxbo.com Author: tjy Copyright: by msxbo 2019-2029 * * * */ #include <stdio.h> #include "xparameters.h" #include "xsdps.h" #include "xil_printf.h" #include "ff.h"
#define H_STRIDE 1280 #define H_ACTIVE 1280 #define V_ACTIVE 720 #define VIDEO_LENGTH (H_STRIDE*V_ACTIVE)
#define VDMA_BASEADDR XPAR_AXI_VDMA_0_BASEADDR #define DDR_BASEADDR 0x00000000 #define VIDEO_BASEADDR0 0x01000000 #define BUF_SIZE 1280*720*3
static FATFS SD_Dev; // File System instance char *SD_Path = "0:/"; // string pointer to the logical drive number
u8 RD_Buf1[BUF_SIZE] __attribute__ ((aligned(32))); u8 RD_Buf2[BUF_SIZE] __attribute__ ((aligned(32))); u8 RD_Buf3[BUF_SIZE] __attribute__ ((aligned(32))); u8 RD_Buf4[BUF_SIZE] __attribute__ ((aligned(32)));
void Xil_DCacheFlush(void);
void show_img( const unsigned char * addr, u32 size_x, u32 size_y) { u32 x=0; u32 y=0; u32 r,g,b; for(y=size_y;y>0;y--) { for(x=0;x<size_x;x++) { b = *(addr++); g = *(addr++); r = *(addr++); Xil_Out32((VIDEO_BASEADDR0+(((y-1)*size_x)+x)*4),((r<<16)|(g<<8)|(b<<0))); } }
Xil_DCacheFlush(); }
void VDMA_init() { int i; for(i=0;i<VIDEO_LENGTH;i++) { Xil_Out32(VIDEO_BASEADDR0+i*4,0); } Xil_DCacheFlush(); Xil_Out32((VDMA_BASEADDR + 0x000), 0x3); Xil_Out32((VDMA_BASEADDR + 0x05c), VIDEO_BASEADDR0); Xil_Out32((VDMA_BASEADDR + 0x060), VIDEO_BASEADDR0); Xil_Out32((VDMA_BASEADDR + 0x064), VIDEO_BASEADDR0); Xil_Out32((VDMA_BASEADDR + 0x058), (H_STRIDE*4)); Xil_Out32((VDMA_BASEADDR + 0x054), (H_ACTIVE*4)); Xil_Out32((VDMA_BASEADDR + 0x050), V_ACTIVE);
}
int SD_init() { FRESULT result; //-----------------------mount dev----------------------------------------------- result = f_mount(&SD_Dev,SD_Path, 0); if (result != 0) { return XST_FAILURE; } return XST_SUCCESS; }
int main() {
VDMA_init(); SD_init(); BMP_Picture((u8 *)"1.bmp" , RD_Buf1 ,BUF_SIZE); BMP_Picture((u8 *)"2.bmp" , RD_Buf2 ,BUF_SIZE); //BMP_Picture((u8 *)"3.bmp" , RD_Buf3 ,BUF_SIZE); //BMP_Picture((u8 *)"4.bmp" , RD_Buf4 ,BUF_SIZE);
while(1) { show_img(RD_Buf1,1280,720); sleep(2); show_img(RD_Buf2,1280,720); sleep(2); //show_img(RD_Buf3,1280,720); //sleep(5); //show_img(RD_Buf4,1280,720); //sleep(5); }
return 0; } |