XINU
gpiohandler.c
Go to the documentation of this file.
1 /* gpiohandler.c - gpiohandler */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * gpiohandler - Handle an interrupt for a gpio device
7  *------------------------------------------------------------------------
8  */
10  uint32 xnum /* IRQ number */
11  )
12 {
13  struct gpio_csreg *csrptr; /* GPIO CSR pointer */
14  gpiointhook gphookfn; /* The inerrupt function */
15 
16  /* Clear all interrupts */
17 
18  if(xnum == GPIO0_INT_A) {
19  csrptr = (struct gpio_csreg *)(GPIO0_BASE);
20  gphookfn = gpiotab[0].gphookfn;
21  if(gphookfn != NULL)
22  gphookfn(xnum, csrptr->irqstatus0);
23  csrptr->irqstatus0 = 0xFFFFFFFF;
24  return;
25  }
26  if(xnum == GPIO0_INT_B) {
27  csrptr = (struct gpio_csreg *)(GPIO0_BASE);
28  gphookfn = gpiotab[0].gphookfn;
29  if(gphookfn != NULL)
30  gphookfn(xnum, csrptr->irqstatus1);
31  csrptr->irqstatus1 = 0xFFFFFFFF;
32  return;
33  }
34 
35  if(xnum == GPIO1_INT_A) {
36  csrptr = (struct gpio_csreg *)(GPIO1_BASE);
37  gphookfn = gpiotab[1].gphookfn;
38  if(gphookfn != NULL)
39  gphookfn(xnum, csrptr->irqstatus0);
40  csrptr->irqstatus0 = 0xFFFFFFFF;
41  return;
42  }
43  if(xnum == GPIO1_INT_B) {
44  csrptr = (struct gpio_csreg *)(GPIO1_BASE);
45  gphookfn = gpiotab[1].gphookfn;
46  if(gphookfn != NULL)
47  gphookfn(xnum, csrptr->irqstatus1);
48  csrptr->irqstatus1 = 0xFFFFFFFF;
49  return;
50  }
51 
52  if(xnum == GPIO2_INT_A) {
53  csrptr = (struct gpio_csreg *)(GPIO2_BASE);
54  gphookfn = gpiotab[2].gphookfn;
55  if(gphookfn != NULL)
56  gphookfn(xnum, csrptr->irqstatus0);
57  csrptr->irqstatus0 = 0xFFFFFFFF;
58  return;
59  }
60  if(xnum == GPIO2_INT_B) {
61  csrptr = (struct gpio_csreg *)(GPIO2_BASE);
62  gphookfn = gpiotab[2].gphookfn;
63  if(gphookfn != NULL)
64  gphookfn(xnum, csrptr->irqstatus1);
65  csrptr->irqstatus1 = 0xFFFFFFFF;
66  return;
67  }
68 
69  if(xnum == GPIO3_INT_A) {
70  csrptr = (struct gpio_csreg *)(GPIO3_BASE);
71  gphookfn = gpiotab[3].gphookfn;
72  if(gphookfn != NULL)
73  gphookfn(xnum, csrptr->irqstatus0);
74  csrptr->irqstatus0 = 0xFFFFFFFF;
75  return;
76  }
77  if(xnum == GPIO3_INT_B) {
78  csrptr = (struct gpio_csreg *)(GPIO3_BASE);
79  gphookfn = gpiotab[3].gphookfn;
80  if(gphookfn != NULL)
81  gphookfn(xnum, csrptr->irqstatus1);
82  csrptr->irqstatus1 = 0xFFFFFFFF;
83  return;
84  }
85 }
#define NULL
連結リスト用のNULLポインタ
Definition: kernel.h:68
#define GPIO0_BASE
Definition: gpio.h:121
struct gpiocblk gpiotab[]
Definition: gpioinit.c:5
void gpiohandler(uint32 xnum)
Definition: gpiohandler.c:9
#define GPIO1_INT_B
Definition: gpio.h:131
全てのシステムヘッダファイルをインクルードする。
#define GPIO3_INT_B
Definition: gpio.h:135
#define GPIO0_INT_A
Definition: gpio.h:128
#define GPIO3_BASE
Definition: gpio.h:124
gpiointhook gphookfn
Definition: gpio.h:49
#define GPIO2_INT_B
Definition: gpio.h:133
#define GPIO1_INT_A
Definition: gpio.h:130
#define GPIO2_BASE
Definition: gpio.h:123
void(* gpiointhook)(uint32, uint32)
Definition: gpio.h:46
#define GPIO0_INT_B
Definition: gpio.h:129
#define GPIO1_BASE
Definition: gpio.h:122
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
#define GPIO3_INT_A
Definition: gpio.h:134
volatile uint32 irqstatus1
Definition: gpio.h:21
#define GPIO2_INT_A
Definition: gpio.h:132
volatile uint32 irqstatus0
Definition: gpio.h:20