Go to the documentation of this file.00001
00037 #include <arch/arm.h>
00038
00039 #include <stdlib.h>
00040 #include <string.h>
00041
00042 #include <dev/gpio.h>
00043
00044
00045 #if defined(PIO_ISR)
00046 #define PIOA_ISR PIO_ISR
00047 #define PIOA_IMR PIO_IMR
00048 #define PIOA_IER PIO_IER
00049 #define PIOA_IDR PIO_IDR
00050 #endif
00051
00052 #if defined(PIOA_ISR)
00053
00057 static void PioIsrA(void *arg)
00058 {
00059 GPIO_VECTOR *vct = (GPIO_VECTOR *)arg;
00060 unsigned int isr = inr(PIOA_ISR);
00061
00062 while (isr) {
00063 if ((isr & 1) != 0 && vct->iov_handler) {
00064 (vct->iov_handler) (vct->iov_arg);
00065 }
00066 isr >>= 1;
00067 vct++;
00068 }
00069 }
00070
00074 static int PioCtlA(int cmd, void *param, int bit)
00075 {
00076 int rc = 0;
00077 unsigned int *ival = (unsigned int *) param;
00078 uint32_t enabled = inr(PIOA_IMR) & _BV(bit);
00079
00080
00081 if (enabled) {
00082 outr(PIOA_IDR, _BV(bit));
00083 }
00084 switch (cmd) {
00085 case NUT_IRQCTL_STATUS:
00086 if (enabled) {
00087 *ival |= 1;
00088 } else {
00089 *ival &= ~1;
00090 }
00091 break;
00092 case NUT_IRQCTL_ENABLE:
00093 enabled = 1;
00094 break;
00095 case NUT_IRQCTL_DISABLE:
00096 enabled = 0;
00097 break;
00098 default:
00099 rc = -1;
00100 break;
00101 }
00102
00103
00104 if (enabled) {
00105 outr(PIOA_IER, _BV(bit));
00106 }
00107 return rc;
00108 }
00109
00110 #if defined(PIO_ISR)
00111 GPIO_SIGNAL sig_GPIO = {
00112 &sig_PIO,
00113 PioIsrA,
00114 PioCtlA,
00115 NULL
00116 };
00117 #else
00118 GPIO_SIGNAL sig_GPIO1 = {
00119 &sig_PIOA,
00120 PioIsrA,
00121 PioCtlA,
00122 NULL
00123 };
00124 #endif
00125
00126 #endif