嵌入式開發入門-01

嵌入式開發入門01

1、開發板簡介:

GEC6818:

       開發板          1塊

       泡沫板           1塊(圖略)

       電源線           1根

       串口線           1根

       USB轉串口線       1根

       網線              1根(圖略)

       OTG線          1根(圖略)

 

2、登錄開發板:

       在開發板上存在一個Linux操作系統,我們要使用開發板進行項目開發,必須

先登錄到開發板系統中。

 

       1,連接串口線

       開發板 《--》 串口線  《--》USB轉串口線 《--》電腦

       2,查看設備管理器 com口

       如果沒有找到usb轉串口的com口,就安裝USB轉串口驅動

       雙擊安裝PL2303_Prolific_GPS_1013_20090319.exe --》finish

             

       -->查看USB-to-serial comm port(com?)     記住這個com口

 

       3,使用仿真軟件登錄開發板

       secureCRT.RAR     --> 解壓文件 --> 進入secureCRT文件夾

--> 雙擊運行 secureCRT.exe

      

       文件 --》 快速連接 --》配置連接信息

       協議:serial

       端口:com?   (自己在設備管理器中看到的端口號)

       波特率:115200

       流控:把√去掉

       ==》點擊連接

       按下ctrl + c ,再按下回車,出現以下現象說明連接成功

^C[root@GEC6818 /IOT]#

[root@GEC6818 /IOT]#

[root@GEC6818 /IOT]#

[root@GEC6818 /IOT]#

[root@GEC6818 /IOT]#

 

3.第一個嵌入式開發程序實驗:

1,在共享文件夾下新建一個嵌入式工程

gec@ubuntu:/mnt/hgfs/zdnf/day2/code$ touch helloworld.c

gec@ubuntu:/mnt/hgfs/zdnf/day2/code$ ls

helloworld.c

      

2,編輯工程文件

3,編譯工程文件                      

gec@ubuntu:/mnt/hgfs/zdnf/day2/code$ arm-linux-gcc helloworld.c -o helloworld

gec@ubuntu:/mnt/hgfs/zdnf/day2/code$ ls

helloworld  helloworld.c

 

arm-linux-gcc:     交叉工具鏈(在Linux系統下編譯arm架構運行的C語言程序)

helloworld.c:       C語言文件

 -o :                  輸出 -output

helloworld      :   可執行文件 (最終程序)

 

4,燒寫程序 (程序下載到開發板) 在secureCRT上執行下載命令

       mkdir /zdnf16

       cd /zdnf16

       燒寫命令: rx 程序名

rx helloworld --> 點擊回車 --> "傳輸" --> 發送“xmodem” -->選擇 helloworld文件

--》點擊發送

[root@GEC6818 /zdnf16]#rx helloworld

CCC

  100%       5 KB    5 KB/s 00:00:01       0 Errors

 

[root@GEC6818 /zdnf16]#ls

Helloworld

 

5,測試程序

              執行程序 ./程序名       ==》 ./helloworld

[root@GEC6818 /zdnf16]#chmod 777 helloworld

[root@GEC6818 /zdnf16]#./helloworld

hello world!   

 

46818LCD使用

       如何使用LCD顯示圖案?

       Linux下一切都是文件 --》LCD也是一個文件 --》 "/dev/fb0" --> 文件IO (linux提供的操作文件的函數接口)

      

       open(), read(), write(), close();     

 

如何使用函數?    ==》使用Linux提供的函數手冊 man

       man man

 

NAME

   man - an interface to the on-line reference manuals

 

       1   Executable programs or shell commands      //shell命令 (Linux命令)ls cd mkdir rm ...

       2   System calls (functions provided by the kernel)    //系統調用函數,文件IO

       3   Library calls (functions within program libraries) //庫調用函數,printf()

       4   Special files (usually found in /dev)

       5   File formats and conventions eg /etc/passwd

       6   Games

       7   Miscellaneous  (including macro packages and conventions), e.g. man(7),

          groff(7)

       8   System administration commands (usually only for root)

       9   Kernel routines [Non standard]

 

1,查看open函數的用法 --》 man 2 open

NAME    //函數功能簡介

   open, creat - open and possibly create a file or device           //打開一個文件或者設備

 

SYNOPSIS

   #include <sys/types.h>

   #include <sys/stat.h>

   #include <fcntl.h>                  //頭文件,告訴編譯器函數的定義和用法

 

   int open(const char *pathname, int flags);              //函數原型,參數個數看逗號個數,一個逗號2個參數

       int : 返回值類型,整型

       pathname :文件 路徑名    ==》 需要打開的文件名

       flags :標誌  打開文件的操作權限

                                   O_RDONLY, //只讀

                                   O_WRONLY,        //只寫

                                   or O_RDWR.  //讀寫

       返回值:返回一個新的文件描述符,本質是一個整數           ==》把硬盤當成一座大樓,把文件當成大樓裏面的房間

                     (文件的操作鑰匙)

                     失敗返回 -1

例子:使用open函數打開LCD文件 參考代碼:open.c

       查看是否能打開LCD成功?

       查看文件描述符的數值是否爲3?

 

觀察現象 --》LCD屏幕是否有變化?      ==》 沒有圖像顯示,

 

2,write函數 man 2 write函數

 

#include <unistd.h>

 

ssize_t write(int fd, const void *buf, size_t count);

              fd: 文件描述符

              buf:數據緩衝區 ,存放將要寫入的文件的數據

              count:想要寫入到文件的字節數

       返回值:實際寫入到文件的字節數

              失敗: -1

      

3,close

       close(fd);

 

1.俄羅斯國旗

 

2、 xx國旗

3、xx國旗

 

 

  1. LCD屏幕的分辨率是多大?代表着什麼?像素點是哪些數據?

答:GEC6818的LCD屏幕的分辨率爲800*480, 代表有800*480個像素點,每個像素點由4個字節組成。像素點是由ARGB(即A: 透明度, R: 三原色中的紅色,G: 三原色中的綠色,B:三原色中的藍色)組成,也就是包含了4個字節的數據,例如: 紅色:0x00ff0000(採用十六進制計法).

 

  1. 編寫完代碼之後都要進行哪些操作查看到效果?

答:

首先按照要求連接開發板與電腦的線路,然後按如下步驟操作:

1)將代碼在Ubuntu下編譯好。

2)將Ubuntu下編譯好的代碼移動或複製到共享文件夾下。

3)將共享文件夾下的文件通過SecureCRT傳輸至開發板。

4)在開發板上運行編譯好的對應文件(在運行前,應給足文件權限)。

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章