硬件:M451RG6AE+SSD1306驱动芯片
软件:FreeRTOS8.1.0+ugfx2.5
开发环境:coocox IDEV2 + arm-linux-gcc
移植目标:简单移植使用最基本的画图功能
/drivers/gdisp/SSD1306
查看里面的一份说明文档:
/drivers/gdisp/SSD1306/readme.txt
里面有移植说明如下:
Description(概述):
Driver for OLED with 4-wire serial interface and I2C/SPI interface(接口介绍,四线制)
Know restictions:
- Driver works only with SSD1306 hooked up over I2C or SPI (include corresponding header)
- Driver is written for 128x64 pixel displays (128x32 are only partly supported and need small further work)
- after using uGFX subsystem gdisp_lld_display() has to be called "by hand" to push framebuffer to display
- (注意:调用gdisp_lld_display()函数后必须手动将显示数据刷到显示屏上)
To use this driver:(步骤如下:)
1. Add in your gfxconf.h:(添加gfxconf.h文件:)
a) #define GFX_USE_GDISP TRUE(开启这个宏)
b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
(其它高级宏使用参考gdisp.h文件)
c) The following are optional - define them if you are not using the defaults below:
#define GDISP_SCREEN_WIDTH 128
#define GDISP_SCREEN_HEIGHT 64
2. If you are not using a known board then create a gdisp_lld_board.h file according to
given example files (or just stick with them) and ensure it is on your include path.
(如果你用的不是共有的开发板,那么你就必须建立自己的gdisp_lld_board.h头文件,可以参考给的例子文件,必须确保他被头文件包含)
3. To your makefile add the following lines:
include $(GFXLIB)/drivers/gdisp/SSD1306/gdisp_lld.mk
4. Call gdisp_lld_display() every time you want to update display content
(记得每次要显示时都得调用gdisp_lld_display() 函数哦)
可以说这个文件已经介绍的很详细了。我都不想啰嗦了。
1 在工程下单独建立一个ugfx文件
2 拷贝配置头文件gfxconf.h和gfx.h
3 拷贝源码文件/src
4 将源码添加到工程下,删除不需要的
5 添加驱动芯片的驱动文件到ugfx下。驱动代码在驱动芯片文件下/drivers/gdisp/SSD1306,如下:
board_SSD1306_template.h (这个需要修改为board_SSD1306.h)
gdisp_lld_config.h
gdisp_lld_SSD1306.c
SSD1306.h
6 增加自己的板级文件
board_SSD1306.c
7 实现相关缺少函数,见《移植ugfx》文件
我添加后的文件目录如下: