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
258f589f
Commit
258f589f
authored
Jul 02, 2018
by
Forest Godfrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic structure of evdev to send messages.
parent
90f2e9ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
ai2c.h
linux_driver/ai2c.h
+1
-0
arduino_i2c.c
linux_driver/arduino_i2c.c
+37
-1
No files found.
linux_driver/ai2c.h
View file @
258f589f
...
...
@@ -24,6 +24,7 @@ typedef struct arduino_i2c_driver_data_s {
struct
list_head
driver_list
;
struct
work_struct
intr_upper_work
;
struct
i2c_client
*
client
;
struct
input_dev
*
indev
;
int
irq_num
;
int
irq_pin
;
int
irq_count
;
...
...
linux_driver/arduino_i2c.c
View file @
258f589f
...
...
@@ -27,6 +27,7 @@
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/list.h>
...
...
@@ -58,6 +59,11 @@ ai2c_intr(struct work_struct *work) {
dev_info
(
&
drv_info
->
client
->
dev
,
"ai2c_intr: entered
\n
"
);
i2c_smbus_write_byte_data
(
drv_info
->
client
,
50
,
48
);
input_report_key
(
drv_info
->
indev
,
BTN_0
,
1
);
input_sync
(
drv_info
->
indev
);
input_report_key
(
drv_info
->
indev
,
BTN_0
,
0
);
input_sync
(
drv_info
->
indev
);
return
;
}
...
...
@@ -118,10 +124,34 @@ ai2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {
flags
|=
IRQF_TRIGGER_FALLING
;
ret
=
request_irq
(
drv_info
->
irq_num
,
ai2c_intr_lower
,
flags
,
"ai2c_keyboard"
,
drv_info
);
if
(
ret
<
0
)
{
dev_err
(
&
client
->
dev
,
"ai2c: request_irq failed: error %d
\n
"
,
ret
);
dev_err
(
&
client
->
dev
,
"ai2c: request_irq failed: error %d"
,
ret
);
goto
out_cleanup
;
}
drv_info
->
indev
=
devm_input_allocate_device
(
&
client
->
dev
);
if
(
!
drv_info
->
indev
)
{
ret
=
-
ENOMEM
;
dev_err
(
&
client
->
dev
,
"ai2c: unable to allocate input device"
);
goto
out_cleanirq
;
}
drv_info
->
indev
->
name
=
"arduino_i2c"
;
drv_info
->
indev
->
phys
=
"arduino_i2c/input0"
;
drv_info
->
indev
->
dev
.
parent
=
&
client
->
dev
;
drv_info
->
indev
->
id
.
bustype
=
BUS_I2C
;
drv_info
->
indev
->
id
.
vendor
=
0x4242
;
drv_info
->
indev
->
id
.
product
=
0x4242
;
drv_info
->
indev
->
id
.
version
=
0x0001
;
drv_info
->
indev
->
keycodesize
=
sizeof
(
unsigned
short
);
drv_info
->
indev
->
keycodemax
=
BTN_0
+
1
;
drv_info
->
indev
->
evbit
[
0
]
=
BIT_MASK
(
EV_KEY
);
drv_info
->
indev
->
keybit
[
BIT_WORD
(
BTN_0
)]
=
BIT_MASK
(
BTN_0
);
ret
=
input_register_device
(
drv_info
->
indev
);
if
(
ret
)
{
dev_err
(
&
client
->
dev
,
"ai2c: unable to register input device: %d"
,
ret
);
goto
out_cleanindev
;
}
irq_set_irq_type
(
drv_info
->
irq_num
,
IRQ_TYPE_EDGE_FALLING
);
drv_info
->
client
=
client
;
...
...
@@ -136,6 +166,10 @@ ai2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {
return
0
;
out_cleanindev:
input_free_device
(
drv_info
->
indev
);
out_cleanirq:
free_irq
(
drv_info
->
irq_num
,
drv_info
);
out_cleanup:
gpio_free
(
drv_info
->
irq_num
);
out_dealloc:
...
...
@@ -157,6 +191,8 @@ ai2c_remove(struct i2c_client *client) {
dev_set_drvdata
(
&
drv_info
->
client
->
dev
,
NULL
);
input_unregister_device
(
drv_info
->
indev
);
mutex_lock
(
&
driver_list_lock
);
list_del
(
&
drv_info
->
driver_list
);
mutex_unlock
(
&
driver_list_lock
);
...
...
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