4412GPIO初始化,EOF标志,条件运算符

#include<linux/init.h>
#include<linux/module.h>

#include<linux/platform_device.h>

#define DRIVER_NAME "hello_ctl"

MODULE_LICENSE("Dual BSD/GPL);
MODULE_AUTHOR("AL");
static int hello_probe(struct platform_device *pdv)
{
	printk(KERN_EMERG "init\n")
	
	return 0;
}
static inr hello_remove(struct platform_device *pdv)
{
	return 0;
}
static int hello_shutdown(struct platform_device *pdv)
{
	;
}
static int hello_susped(struct platform_device *pdv)
{
	return 0;
}
/*************************4412GPIO*********************/
//GPIO的初始化 

base   = (S5P_VA_GPIO2 + 0x100) – 表示偏移地址和虚拟地址相加
eint_offset = 0x20 – 表示中断部分,介绍中断的时候再讲(IO口可以配置为中断模式)
group = 22 – 给GPIO分组
chip.base = EXYNOS4_GPL2(0), – 宏定义EXYNOS4_GPL2(0)赋值给初始化函数
chip.ngpio = EXYNOS4_GPIO_L2_NR – 表示这一小组中有几个GPIO
chip.label = "GPL2"

//物理地址和虚拟地址的映射关系

virtual = (unsigned long)S5P_VA_GPIO2,表示虚拟地址
pfn = __phys_to_pfn(EXYNOS4_PA_GPIO2),表示物理地址
length = SZ_4K,表示映射的宽度
type = MT_DEVICE,


//条件运算符

#include<stdio.h>
int main()
{
    int score;
    char grade;
    printf("请输入分数: ");
    scanf("%d",&score);
    grade=(score>=90)?'A':((score>=60)?'B':'C');//? :
    printf("%c\n",grade);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define GRADE(x) (x>=90)?'A':((x>=60)?'B':'C')

int main(){
    int score;
	//EOF:End Of File(文件结尾),在stdio.h文件宏定义为-1
    while(scanf("%d",&score)!=EOF)
	{
        printf("%c\n",GRADE(score));
		//exit(1);
    }
    return 0;
}

参考

发布了50 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_41865104/article/details/91307224