操做系統: 使用的是官方網站上的ubuntu sd card 1.1
1. 安裝python的庫和cubie的gpio庫php
sudo apt-get install python-dev
python
wget http://dl.linux-sunxi.org/users/tom/pySUNXI-0.1.12.tar.gz
linux
tar zxf pySUNXI-0.1.12.tar.gz
ubuntu
sudo python setup.py install網站
複製代碼ui
2. 用Python GPIO裏面的GPIO C庫文件直接編寫 C應用程序
在/home/cubie/pySUNXI-0.1.12/source目錄下編寫:
pyinclude.c文件(見附件)
pyinclude.h文件(見附件)
LCD12864Serial.c文件(見附件)
LCD12864Serial.h文件 (見附件)
test12864.c文件以下:spa
#include "pyinclude.h"
操作系統
#include "LCD12864Serial.h"
orm
int main(void)
ip
{
if(SETUP_OK!=sunxi_gpio_init())
{
printf("Failed to initialize GPIO\n");
return -1;
}
LCD12864Init();
while(1)
{
Test12864();
}
sunxi_gpio_cleanup();
return 0;
}
複製代碼
3.硬件鏈接:
cubie LCD12864
PD6 CS (RS)
PD7 SID (RW)
PD8 SCLK (EN)
PD9 RST
4. 編譯運行:
gcc LCD12864Serial.c -c
gcc gpio_lib.c -c
gcc pyinclude.c -c
gcc test12864.c -c
gcc test12864.o gpio_lib.o pyinclude.o LCD12864Serial.o -o test12864
./test12864
複製代碼
5.有圖有真相:
附上代碼: 串行12864-1-1.zip (1.61 KB, 下載次數: 17) 串行12864-1-0.zip (1.08 KB, 下載次數: 16) Makefile.zip (297 Bytes, 下載次數: 13)
原文做者:SUNROC1
原文連接:http://forum.cubietech.com/forum.php?mod=viewthread&tid=918