BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
arduino_i2c_keyboard
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
arduino_i2c_keyboard
Commits
6d86e143
Commit
6d86e143
authored
Jun 20, 2018
by
Forest Godfrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic interrupt registration.
parent
acc0c891
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
9 deletions
+38
-9
arduino_i2c.c
linux_driver/arduino_i2c.c
+38
-9
No files found.
linux_driver/arduino_i2c.c
View file @
6d86e143
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#define IRQ_GPIO_PIN 22
#define GPIO_IRQ_NAME "ai2c_keyboard_irq"
static
int
irq_num
=
-
1
;
static
int
count
=
0
;
static
irqreturn_t
ai2c_intr_lower
(
int
irq
,
void
*
data
)
{
if
(
count
++
<
10
)
{
printk
(
"ai2c_intr_lower: entered
\n
"
);
}
return
IRQ_HANDLED
;
}
int
ai2c_init
(
void
)
{
int
i
;
int
ret
;
int
flags
=
0
;
void
*
drv_info
=
NULL
;
printk
(
KERN_INFO
"Arduino I2C Keyboard Starting
\n
"
);
for
(
i
=
20
;
i
<
35
;
i
++
)
{
int
g
;
ret
=
gpio_request
(
IRQ_GPIO_PIN
,
GPIO_IRQ_NAME
);
if
(
ret
<
0
)
{
printk
(
KERN_ERR
"ai2c: IRQ pin reservation failed: error %d
\n
"
,
ret
);
return
ret
;
}
gpio_direction_input
(
IRQ_GPIO_PIN
);
irq_num
=
gpio_to_irq
(
IRQ_GPIO_PIN
);
g
=
gpio_to_irq
(
i
);
printk
(
KERN_INFO
"ai2c: gpio[%d]: irq = %d
\n
"
,
i
,
g
);
printk
(
KERN_INFO
"ai2c: Reserved pin [%d]: irq = %d
\n
"
,
IRQ_GPIO_PIN
,
irq_num
);
ret
=
request_irq
(
irq_num
,
ai2c_intr_lower
,
flags
,
"ai2c_keyboard"
,
drv_info
);
if
(
ret
<
0
)
{
printk
(
KERN_ERR
"ai2c: request_irq failed: error %d
\n
"
,
ret
);
return
ret
;
}
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
irq_set_irq_type
(
irq_num
,
IRQ_TYPE_EDGE_FALLING
);
return
0
;
}
void
ai2c_shutdown
(
void
)
{
printk
(
KERN_INFO
"Arduino I2C Keyboard Shutting Down
\n
"
);
if
(
irq_num
>
0
)
{
free_irq
(
irq_num
,
ai2c_intr_lower
);
}
}
module_init
(
ai2c_init
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment