Linux?豸??????????豸????
???????????? ???????[ 2016/5/5 11:17:34 ] ?????????????? Linux
??????????????????в????У?????????????????????????????????????????????I/O????????????????????????豸?????????????????????????????????????????豸???????????????????????ж????????????????????????????У???????????????????????????????軔???????????ж???????????????????????????????????
????1.?????????????????
????2 ?????????е??й??????
????2.1 ?????豸????????????
#define MAX KEY BUF 16 // ??????????С
typedef unsigned char KEY RET;
//?豸???壺
typedef struct
{
unsigned int keyStatus[KEY NUM]; //4?? ???? ????
KEY RET buf[MAX KEY BUF]; // ????????
unsigned int head?? tail; // ???????????β
wait queue head t wq; //???????
struct cdev cdev; //cdev ????
} KEY DEV;
static struct timer list key timer[KEY NUM];//4?? ??????????
????2.2 ??????????????????????
static struct key info
{
int irq no; //?ж??
unsigned int gpio port; //GPIO???
int key no; //???
} key info tab [4] =
{
/* ????????CPU ???*/
{ IRQ EINT10?? GPIO G2?? 1
}
??
{
IRQ EINT13?? GPIO G5?? 2
}
??
{
IRQ EINT14?? GPIO G6?? 3
}
??
{
IRQ EINT15?? GPIO G7?? 4
}
??
};
????2.3 ?????豸???????????????
????static struct file operations s3c2410 key fops =
????{
????owner: THIS MODULE??
????open: s3c2410 key open?? //????豸
????release: s3c2410 key release?? //????豸
????read: s3c2410 key read?? //??? ??????
????};
????3 ?????豸?????????ж??????
????3.1 ???????
static int init s3c2410 key init (void)
{
...//?????豸??????cdev
request irqs(); //????ж????
keydev .head = keydev .tail = 0; //?????????
for (i = 0; i < KEY NUM; i++)
keydev.keyStatus[i] = KEYSTATUS UP;
init waitqueue head (&(keydev .wq)); //???????
//?????????????????????????
for (i = 0; i < KEY NUM; i++)
setup timer (&key timer[i]?? key timer handler?? i);
//?? ?????????????????????????????
}
????3.2 ж?????
????static void exit s3c2410 key exit (void)
????{
????free irqs(); //????ж?
????...//????豸??????cdev
????}
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11