DE2 NIOS uCGUI
簡易的ucgui porting,無os,純測式可整合自定的framebuffer
(1)software altera9.1/ucgui3.98
altera9.1 eclipse所產生的make file加入太多檔案會有問題
這裡是採用撰寫makefile然後在 nios eds的command shell進行編譯產生libucgui.a
然後再於porject加入該library
ucgui相關修改說明
設定config配合所使用的lcd,這裡lcd使用的解析度是320x240 32bpp (XRGB888)
修改\Config\LCDConf.h
#ifndef LCDCONF_H #define LCDCONF_H /********************************************************************* * * General configuration of LCD * ********************************************************************** */ #undef WIN32 #define LCD_XSIZE (320) /* X-resolution of LCD, Logical coor. */ #define LCD_YSIZE (240) /* Y-resolution of LCD, Logical coor. */ #define LCD_BITSPERPIXEL (32) #define LCD_FIXEDPALETTE 888 #define LCD_SWAP_RB 1 #define LCD_CONTROLLER 3200 #define LCD_VRAM_ADR 0x01000000 #define LCD_ENDIAN_BIG 0 /********************************************************************* * * Full bus configuration * ********************************************************************** */ extern void UCGUI_IOWR(unsigned int base,unsigned int offset,unsigned int value); extern unsigned int UCGUI_IORD(unsigned int base,unsigned int offset); #define LCD_READ_MEM(Off) UCGUI_IORD(LCD_VRAM_ADR,Off)//(*((U32 *)LCD_VRAM_ADR + ((U32)Off))) #define LCD_WRITE_MEM(Off, Data) UCGUI_IOWR(LCD_VRAM_ADR,Off,Data)//*((U32 *)LCD_VRAM_ADR + ((U32)Off)) = Data #endif /* LCDCONF_H */
這裡指定LCD_CONTROLLER 3200會啟用\LCDDriver\LCDLin32.c ( #if (LCD_CONTROLLER == 3200) )
32bpp的部分ucgui3.98好像還沒有支持
實作在這裡找到的http://electronix.ru/forum/index.php?act=Attach&type=post&id=53037
LCD_VRAM_ADR是指framebuffer的位址,因為我是拿16bit sram來擴展使用,所以就強制sram規畫的位址上
如果是在sdram alloc來的,就把LCD_VRAM_ADR改成變數然後加一funcion讓alloc來的framebuffer的位址可以set進來
接著指定好framebuffer後就是實作讀寫的函式了
讀: LCD_READ_MEM = UCGUI_IORD
寫: LCD_WRITE_MEM = UCGUI_IOWR
這裡的UCGUI_IORD/UCGUI_IOWR就只是一個wapper轉到IORD/IOWR,直接當記憶體操作好像會有cache的問題
其它部分就不用什麼修改了
GUI_X_uCOS.c/GUI_X.c 不要跟library綁在一起應該比較好
makefile (編譯目錄下所有的.c檔並打包為static library)
CC = nios2-elf-gcc AR = nios2-elf-ar CFLAGS = -Wall -g INCLUDE_PATH = -ICore -IWidget -IWM -IConfig SUBDIR = AntiAlias ConvertColor ConvertMono Core Font LCDDriver MemDev MultiLayer Widget WM #SUBDIRS=$(shell ls -d */ | grep -v 'bin' | grep -v 'lib' | grep -v 'include') ELF = libucgui.a TOPSRC=$(wildcard *.c) TOPOBJ=$(TOPSRC:%.c=%.o) SUBSRC=$(shell find $(SUBDIR) -name '*.c') SUBOBJ=$(SUBSRC:%.c=%.o) $(ELF) : $(TOPOBJ) $(SUBOBJ) $(AR) rcs $(ELF) $(TOPOBJ) $(SUBOBJ) .c.o: $(CC) $(INCLUDE_PATH) $(CFLAGS) -c $(@D)/$(<F) -o $(@D)/$(@F) clean: rm $(ELF) $(TOPOBJ) $(SUBOBJ)
執行make
產生libucgui.a
(2)hardware
LCD格式為320x240 BPP=32bits
(3)執行畫面
若IE無法下載可測試使用Chrome
完整專案程式碼:NIOS_uCGUI.7z