Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goodix-tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KED Software Projects
Miscellaneous
Apps and Tools
goodix-tool
Commits
8400b8a9
Commit
8400b8a9
authored
6 years ago
by
Eberhard Stoll
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
Branches
master
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/goodix
+0
-0
0 additions, 0 deletions
bin/goodix
goodix.pro
+6
-0
6 additions, 0 deletions
goodix.pro
main.c
+121
-0
121 additions, 0 deletions
main.c
with
127 additions
and
0 deletions
bin/goodix
0 → 100755
+
0
−
0
View file @
8400b8a9
File added
This diff is collapsed.
Click to expand it.
goodix.pro
0 → 100644
+
6
−
0
View file @
8400b8a9
TEMPLATE
=
app
CONFIG
+=
console
CONFIG
-=
app_bundle
CONFIG
-=
qt
SOURCES
+=
main
.
c
This diff is collapsed.
Click to expand it.
main.c
0 → 100644
+
121
−
0
View file @
8400b8a9
/*
* (c) 2018 Exceet electronics Gmbh: Modified sample code for goodix touch controller
*
* This is goodix tool. Its purpose is to provide some information
* like controller and configuration version about the goodix touch
* controller on the spi bus.
*
* BE AWARE:
* - The bus and the address is hard coded!
* - This tool is simple and assumes to be the only who talks to the goodix touch.
* So it can disturb a running goodix device driver or deliver wrong values.
*/
#include
<stdio.h>
#include
<string.h>
#include
<fcntl.h>
#include
<linux/i2c-dev.h>
#include
<errno.h>
#include
<unistd.h>
#include
<sys/ioctl.h>
#include
<stdlib.h>
#define PROGRAM_VERSION "1.0"
#define I2C_ADDR 0x5d
#define I2C_DEVICE "/dev/i2c-3"
void
print_help
()
{
printf
(
"Usage:
\n
"
);
printf
(
" goodix [-h|DEVICEFILE]
\n
"
);
printf
(
"
\n
"
);
printf
(
"DEVICEFILE i2c bus device like 'i2c-3' (default value)
\n
"
);
printf
(
" -h Help text
\n
"
);
printf
(
"
\n
"
);
printf
(
"Program version %s"
,
PROGRAM_VERSION
);
printf
(
"
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
char
buffer
[
11
];
char
i2c_device
[
50
];
int
fd
;
// set defaults
memset
(
i2c_device
,
'\0'
,
sizeof
(
i2c_device
));
strcpy
(
i2c_device
,
I2C_DEVICE
);
if
(
argc
>
2
){
printf
(
"ERROR: Too many arguments
\n
"
);
print_help
();
exit
(
1
);
}
if
(
2
==
argc
){
if
(
'-'
==
argv
[
1
][
0
]){
print_help
();
exit
(
1
);
}
// Use device from commandline
strncpy
(
i2c_device
,
argv
[
1
],
sizeof
(
i2c_device
)
-
1
);
}
printf
(
"i2c interface : %s
\n
"
,
i2c_device
);
printf
(
"device addr : 0x%02x
\n
"
,
I2C_ADDR
);
fd
=
open
(
i2c_device
,
O_RDWR
);
if
(
fd
<
0
)
{
printf
(
"Error opening file <%s>: %s
\n
"
,
I2C_DEVICE
,
strerror
(
errno
));
return
1
;
}
// I2C_SLAVE
if
(
ioctl
(
fd
,
I2C_SLAVE_FORCE
,
I2C_ADDR
)
<
0
)
{
printf
(
"ioctl error: %s
\n
"
,
strerror
(
errno
));
return
1
;
}
// Product ID
unsigned
int
fw_version
=
0
;
unsigned
int
vendor_id
=
1
;
unsigned
int
xres
;
unsigned
int
yres
;
char
product_id
[
4
];
unsigned
int
config_version
;
// Firmware version etc
buffer
[
0
]
=
0x81
;
buffer
[
1
]
=
0x40
;
write
(
fd
,
buffer
,
2
);
read
(
fd
,
buffer
,
11
);
product_id
[
0
]
=
buffer
[
0
];
product_id
[
1
]
=
buffer
[
1
];
product_id
[
2
]
=
buffer
[
2
];
product_id
[
3
]
=
buffer
[
3
];
fw_version
=
(
buffer
[
5
]
<<
8
)
|
buffer
[
4
];
xres
=
(
buffer
[
7
]
<<
8
)
|
buffer
[
6
];
yres
=
(
buffer
[
9
]
<<
8
)
|
buffer
[
8
];
vendor_id
=
buffer
[
10
];
// Config version
buffer
[
0
]
=
0x80
;
buffer
[
1
]
=
0x47
;
write
(
fd
,
buffer
,
2
);
if
(
-
1
==
read
(
fd
,
buffer
,
2
)){
printf
(
"read error: %s
\n
"
,
strerror
(
errno
));
return
1
;
}
config_version
=
buffer
[
0
];
printf
(
"product id : %c%c%c%c
\n
"
,
product_id
[
0
],
product_id
[
1
],
product_id
[
2
],
product_id
[
3
]);
printf
(
"fw version : 0x%04X
\n
"
,
fw_version
);
printf
(
"config version: %d (0x%02X)
\n
"
,
config_version
,
config_version
);
printf
(
"resolution x/y: %dx%d
\n
"
,
xres
,
yres
);
printf
(
"vendor id : 0x%02X
\n
"
,
vendor_id
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment