?? gpio_led.c
字號:
/*
*********************************************************
* Copyright (c)
* All rights reserved.
*
* 文件名稱:Gpio_led.c
* 文件標識:
* 摘 要:S3C2410 io Test Program
* 當前版本:1.0
* 作 者:劉征
* 完成日期:2005.4.3
*
* 取代版本:
* 作 者:
* 完成日期:
*********************************************************
*/
/*
*********************************************************
* 頭文件
*********************************************************
*/
#include <string.h>
#include "def.h"
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
/*
*********************************************************
* 函數原型
*********************************************************
*/
void Led_Display(int data);
void Led_Close(void);
//Active is low.(LED On)
// GPF8 GPF7 GPF6 GPF5
//nLED_4 nLED3 nLED_2 nLED_1
/*
*********************************************************
* 函數介紹:本函數是Gpio_led驅動點亮程序。
* 輸入參數:data--被點亮的LED的編號
* 輸出參數:無
* 返回值 :無
*********************************************************
*/
void Led_Display(int data)
{
//將要點亮的LED所用的IO口拉低,即該LED被點亮
switch(data)
{
case '1':
rGPBDAT = ((rGPBDAT | 0x7ff) & (~0x020));
break;
case '2':
rGPBDAT = ((rGPBDAT | 0x7ff) & (~0x040));
break;
case '3':
rGPBDAT = ((rGPBDAT | 0x7ff) & (~0x080));
break;
case '4':
rGPBDAT = ((rGPBDAT | 0x7ff) & (~0x100));
break;
case '5':
rGPBDAT = ((rGPBDAT | 0x7ff) & (~0x1e0));
break;
default:
rGPBDAT = (rGPBDAT | 0x7ff); //其他值就熄滅所有LED
break;
}
}
/*
*********************************************************
* 函數介紹:本函數是熄滅led程序。
* 輸入參數:無
* 輸出參數:無
* 返回值 :無
*********************************************************
*/
void Led_Close(void)
{
//熄滅所有LED
rGPBDAT = (rGPBDAT | 0x7ff);
}
/*
*********************************************************
* 函數介紹:本函數是Gpio_led測試程序。
* 輸入參數:無
* 輸出參數:無
* 返回值 :無
*********************************************************
*/
void Test_Gpio(void)
{
volatile unsigned int save_gpb;
int extNum;
save_gpb = rGPBCON;//保存GPB口原設置
Uart_Printf("[GpIO Test through PB 5/6/7/8]\n");
Uart_Printf("1.D1 2.D2 3.D3 4.D4 5.ALL\n");
Uart_Printf("Select the LED NUM.\n");
extNum=Uart_Getch();
Uart_Printf("The LED NUM is : =%c\n",extNum);
rGPBCON = (rGPBCON & 0x3ff00)|(1<<16)|(1<<14)|(1<<12)|(1<<10); //PB5/6/7/8= outport
Led_Display(extNum);
if(extNum == '5')
{
Uart_Printf("See board all led is lighted!\n");
}
else
{
Uart_Printf("See board the %c led is lighted!\n",extNum);
}
Uart_Printf("Press any key to exit.\n");
Uart_Getch();
Led_Close();
rGPBCON = save_gpb;//還原GPB口設置
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -