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
39e41950
Commit
39e41950
authored
Jul 04, 2018
by
Forest Godfrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic device interaction to get revision and firmware version.
parent
14d9b079
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
ai2c_interface.h
linux_driver/ai2c_interface.h
+2
-0
arduino_i2c.c
linux_driver/arduino_i2c.c
+54
-0
No files found.
linux_driver/ai2c_interface.h
0 → 120000
View file @
39e41950
..
/
arduino_sketch
/
ai2c_interface
.
h
\ No newline at end of file
linux_driver/arduino_i2c.c
View file @
39e41950
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
*/
*/
#include "ai2c.h"
#include "ai2c.h"
#include "ai2c_platform_data.h"
#include "ai2c_platform_data.h"
#include "ai2c_interface.h"
#define IRQ_GPIO_PIN 9
#define IRQ_GPIO_PIN 9
#define GPIO_IRQ_NAME "ai2c_keyboard_irq"
#define GPIO_IRQ_NAME "ai2c_keyboard_irq"
...
@@ -51,6 +52,42 @@ static LIST_HEAD(driver_list);
...
@@ -51,6 +52,42 @@ static LIST_HEAD(driver_list);
static
DEFINE_MUTEX
(
driver_list_lock
);
static
DEFINE_MUTEX
(
driver_list_lock
);
static
void
static
void
device_write_register
(
struct
i2c_client
*
client
,
uint8_t
raddr
,
uint8_t
value
)
{
uint8_t
tmp
[
2
];
tmp
[
0
]
=
raddr
;
tmp
[
1
]
=
value
;
i2c_master_send
(
client
,
tmp
,
2
);
}
#if 0
static uint8_t
device_read_byte(struct i2c_client *client) {
uint8_t tmp;
i2c_master_recv(client, &tmp, 1);
return tmp;
}
static uint16_t
device_read_word(struct i2c_client *client) {
uint16_t tmp;
i2c_master_recv(client, (unsigned char *)&tmp, 1);
return tmp;
}
#endif
static
void
device_read_register
(
struct
i2c_client
*
client
,
void
*
buffer
,
uint8_t
raddr
,
uint8_t
len
)
{
device_write_register
(
client
,
AI2C_REGISTER_READ_ADDR
,
raddr
);
device_write_register
(
client
,
AI2C_REGISTER_READ_BYTES
,
len
);
i2c_master_recv
(
client
,
(
unsigned
char
*
)
buffer
,
len
);
}
static
void
ai2c_intr
(
struct
work_struct
*
work
)
{
ai2c_intr
(
struct
work_struct
*
work
)
{
arduino_i2c_driver_data_t
*
drv_info
=
container_of
(
arduino_i2c_driver_data_t
*
drv_info
=
container_of
(
work
,
arduino_i2c_driver_data_t
,
intr_upper_work
);
work
,
arduino_i2c_driver_data_t
,
intr_upper_work
);
...
@@ -81,8 +118,12 @@ ai2c_intr_lower(int irq, void *data) {
...
@@ -81,8 +118,12 @@ ai2c_intr_lower(int irq, void *data) {
static
int
static
int
ai2c_probe
(
struct
i2c_client
*
client
,
const
struct
i2c_device_id
*
id
)
{
ai2c_probe
(
struct
i2c_client
*
client
,
const
struct
i2c_device_id
*
id
)
{
int
i
;
int
ret
=
0
;
int
ret
=
0
;
int
flags
=
0
;
int
flags
=
0
;
uint16_t
dev_id
;
uint8_t
dev_rev
;
char
dev_build_str
[
AI2C_VER_STR_LEN
];
const
arduino_i2c_keyboard_platform_data_t
*
pdata
=
const
arduino_i2c_keyboard_platform_data_t
*
pdata
=
dev_get_platdata
(
&
client
->
dev
);
dev_get_platdata
(
&
client
->
dev
);
arduino_i2c_driver_data_t
*
drv_info
=
NULL
;
arduino_i2c_driver_data_t
*
drv_info
=
NULL
;
...
@@ -94,6 +135,19 @@ ai2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {
...
@@ -94,6 +135,19 @@ ai2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {
goto
out
;
goto
out
;
}
}
/*
* Get/validate/print device information
*/
device_read_register
(
client
,
&
dev_id
,
AI2C_REGISTER_ID_LOW
,
2
);
device_read_register
(
client
,
&
dev_rev
,
AI2C_REGISTER_REG_REV
,
1
);
for
(
i
=
0
;
i
<
AI2C_VER_STR_LEN
;
i
++
)
{
device_read_register
(
client
,
&
(
dev_build_str
[
i
]),
AI2C_REGISTER_VERS_STR
+
i
,
1
);
}
dev_build_str
[
sizeof
(
dev_build_str
)
-
1
]
=
'\0'
;
dev_info
(
&
client
->
dev
,
"Device ID: 0x%04x
\n
Device Revision: 0x%02x
\n
Device Firmware Build:
\"
%s
\"\n
"
,
dev_id
,
dev_rev
,
dev_build_str
);
drv_info
=
(
arduino_i2c_driver_data_t
*
)
kmalloc
(
sizeof
(
arduino_i2c_driver_data_t
),
GFP_KERNEL
);
drv_info
=
(
arduino_i2c_driver_data_t
*
)
kmalloc
(
sizeof
(
arduino_i2c_driver_data_t
),
GFP_KERNEL
);
if
(
!
drv_info
)
{
if
(
!
drv_info
)
{
dev_err
(
&
client
->
dev
,
"Unable to allocate driver memory"
);
dev_err
(
&
client
->
dev
,
"Unable to allocate driver memory"
);
...
...
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