s3c2451_gpio函数
来源:互联网 发布:linux中复制命令 编辑:程序博客网 时间:2024/06/05 02:56
- #ifndef _S3C2451_GPIO_
- #define _S3C2451_GPIO_
- #define GPACON *((volatile int *)0x56000000)
- #define GPADATA *((volatile int *)0x56000004)
- #define GPBCON *((volatile int *)0x56000010)
- #define GPBDATA *((volatile int *)0x56000014)
- #define GPFCON *((volatile int *)0x56000050)
- #define GPFDATA *((volatile int *)0x56000054)
- #define BIT(n) (1 << (n))
- enum{
- GPAIO = 0,
- GPBIO,
- GPFIO
- };
- enum{
- INPUT = 0,
- OUTPUT
- };
- int GPIO_key();
- int GPIO_init(int gpiox,int pin,int dir);
- int GPIO_writedata(int gpiox,int pin,int data);
- #endif</pre><br>
- <br>
- <pre></pre>
- <pre code_snippet_id="2259825" snippet_file_name="blog_20170312_3_6194001" name="code" class="html">#include"s3c2451_gpio.h"
- char temp = 0;
- char i = 0;
- int GPIO_init(int gpiox,int pin,int dir)
- {
- if(gpiox == GPBIO)
- {
- if(dir == INPUT)
- {
- GPBCON &= ~BIT(pin*2);
- GPBCON &= ~BIT(pin*2 + 1);
- }
- else if(dir == OUTPUT)
- {
- GPBCON |= BIT(pin*2);
- GPBCON &= ~BIT(pin*2 + 1);
- }
- }
- else if(gpiox == GPAIO)
- {
- if(dir == OUTPUT)
- {
- GPACON &= ~BIT(pin);
- }
- }
- else if(gpiox == GPFIO)
- {
- if(dir == INPUT)
- {
- GPFCON &= ~BIT(pin*2);
- GPFCON &= ~BIT(pin*2 + 1);
- }
- else if(dir == OUTPUT)
- {
- GPFCON |= BIT(pin*2);
- GPFCON &= ~BIT(pin*2 + 1);
- }
- }
- return 0;
- }
- int GPIO_writedata(int gpiox,int pin,int data)
- {
- if(gpiox == GPBIO)
- {
- if(data == 0)
- GPBDATA &= ~BIT(pin);
- else
- GPBDATA |= BIT(pin);
- }
- else if(gpiox == GPAIO)
- {
- if(data == 0)
- GPADATA &= ~BIT(pin);
- else
- GPADATA |= BIT(pin);
- }
- return 0;
- }
- int GPIO_key()
- {
- if((GPFDATA & 0x01)== 0)
- {
- i++;
- if(i%2)
- GPIO_writedata(GPBIO,5,0);
- else
- GPIO_writedata(GPBIO,5,1);
- }
- else if((GPFDATA & 0x02)== 0)
- {
- GPIO_writedata(GPBIO,6,temp);
- temp = ~temp;
- temp &= 0x01;
- }
- else if((GPFDATA & 0x04)== 0)
- {
- GPIO_writedata(GPAIO,25,0);
- }
- else if((GPFDATA & 0x08)== 0)
- {
- GPIO_writedata(GPAIO,26,0);
- }
- return 0;
- }
0 0
- s3c2451_gpio函数
- S3C2451_GPIO初始化、置位、读取源码
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 进程终止分析之一
- VQA数据集及评价方法介绍
- LintCode | 408. 二进制求和
- 理解jvm类加载机制(双亲委派模型)
- Android自动打包发包 利用Jenkins
- s3c2451_gpio函数
- 李白打酒(DFS小例子)
- 欢迎使用CSDN-markdown编辑器
- 第三周作业2(LeetCode75)
- 关于操作数据库增删改查
- 系统API接口库中的STDIN_FILENO介绍以及与stdin的区分
- 在图片上进行作画
- Codeforces Beta Round #1 A,B,C
- nginx 1.6 for rhel5 安装配置