arm電子相簿專案 串列埠模組篇uart c

2021-07-22 10:25:06 字數 3140 閱讀 1104

《arm電子相簿專案——串列埠模組篇uart.c》

工具:keil4 , arm開發板(mini2451)(s3c2451) , 串列埠線

功能:顯示**(自動切換 / 手動切換 / 暫停切換 / 可設定)

顯示時鐘(精確顯示 / 可設定)

描述:串列埠模組主要負責接收 / 傳送給串列埠的資訊並通過串列埠助手顯示出來,方便除錯,還可以用到串列埠中斷,通過串列埠修改專案中時鐘的時間。

author:ivan    version:0.1    date:

file name:uart.h

#ifndef uart_h_

#define uart_h_

#define ulcon0   (*(volatile unsigned long *)0x50000000)

#define ucon0   (*(volatile unsigned long *)0x50000004)

#define ufcon0   (*(volatile unsigned long *)0x50000008)

#define umcon0    (*(volatile unsigned long *)0x5000000c)

#define utrstat0  (*(volatile unsigned long *)0x50000010)

#define ufstat0   (*(volatile unsigned long *)0x50000018)

#define utxh0     (*(volatile unsigned long *)0x50000020)

#define urxh0     (*(volatile unsigned long *)0x50000024)

#define ubrdiv0   (*(volatile unsigned long *)0x50000028)

#define udivslot0 (*(volatile unsigned long *)0x5000002c)

#define gphcon    (*(volatile unsigned long *)0x56000070)

extern void uart_init(void);

#endif

author:ivan    version:0.1    date:

file name:uart.c

description:uart串列埠模組初始化

#include "uart.c"

void uart_init(void)

gphcon = 0xa;    //h埠設定為txd[0],rxd[0]

ulcon0 = 0x03;    //設定接收的資料位字長為8

ucon0 = 0x05;    //設定接收模式和傳送模式

ufcon0 = 0x01;    //開啟(使能)串列埠0的fifo

ubrdiv0 = 0x23;    //設定波特率

udivslot0 = 0x0111;    //設定分流槽

void putchar(unsigned char c)

while(ufstat0 & ( 1<<14 ));    //通道0不滿時,

utxh0 = c;    //將緩衝區裡的資料賦值給c

unsigned char getchar(void)

while((ufstat0 & 0x7f) == 0);    //若通道0中沒資料,等待

return urxh0;    //將資料返回

author:ivan    version:0.1    date:

file name:main.h

description:包含所有用到的.h檔案

#ifndef main_h_

#define main_h_

#include "uart.h"

#include "led.h"

#endif

author:ivan    version:0.1    date:

file name:main.c

description:主函式(串列埠輸入輸出)

#include "main.h" 

void main()

unsigned char c;

gpacon = 0x0;

gpbcon = (0x5 << 10);

gpbsel = 0x0;

uart_init();

while(1)

c = getchar();

putchar(c);

if(c == 0x30)

gpadat = 0xffffffff;

gpbdat = 0xffffffff;

if(c == 0x31)

gpadat = 0xffffffff;

gpbdat = 0xffffffcf;

if(c == 0x32)

gpadat = 0xffffffff;

gpbdat = 0xffffff3f;

if(c == 0x33)

gpadat = 0xffffffff;

gpbdat = 0xffffff0f;

if(c == 0x34)

gpadat = 0xfcffffff;

gpbdat = 0xffffffff;

if(c == 0x35)

gpadat = 0xfcffffff;

gpbdat = 0xffffffcf;

if(c == 0x36)

gpadat = 0xfcffffff;

gpbdat = 0xffffff3f;

if(c == 0x37)

gpadat = 0xfcffffff;

gpbdat = 0xffffff0f;

if(c == 0x38)

gpadat = 0xf3ffffff;

gpbdat = 0xffffffff;

if(c == 0x39)

gpadat = 0xf3ffffff;

gpbdat = 0xffffffcf;

arm電子相簿專案 專案要求篇(描述功能)

arm電子相簿專案 專案要求篇 描述功能 工具 keil4 arm開發板 mini2451 s3c2451 串列埠線 功能 顯示 自動切換 手動切換 暫停切換 可設定 顯示時鐘 精確顯示 可設定 進度 準備篇 專案要求 基本功能 提高功能 三大塊 時鐘 相簿 系統 時鐘 基本功能 1.時間執行準確 ...

電子相簿特效

初入前端這行不久,對很多東西還是很陌生,頁面布局 合理使用html標籤 css屬性 js書寫習慣等等還都不是很熟悉,所以看到感興趣的東西就想看看原始碼,看看實現原理,用來學習。前幾天看到tattoo寫的乙個jquery版結婚電子請帖,對首頁的相簿效果感興趣,所以把原始碼開啟看了兩遍,自己再敲了一遍。...

電子相簿之bitmap

位 件主要分為3部分 1.檔案資訊頭 14byte 2.位圖資訊頭 40byte 3.rgb顏色陣列 由影象長寬尺寸決定 1.檔案資訊頭 定義結構體 typedef struct tagbitmapfileheader bitmapfileheader bftype 必須是0x4d42 bfsize...