Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
80b2a1de
Verified
Commit
80b2a1de
authored
Aug 21, 2019
by
Rahix
Browse files
fix(buttons): Acquire I2C lock before accessing bus
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
921ba019
Changes
1
Hide whitespace changes
Inline
Side-by-side
epicardium/modules/buttons.c
View file @
80b2a1de
#include
"epicardium.h"
#include
"modules/modules.h"
#include
"modules/log.h"
#include
"portexpander.h"
#include
"MAX77650-Arduino-Library.h"
...
...
@@ -15,12 +17,19 @@ uint8_t epic_buttons_read(uint8_t mask)
{
uint8_t
ret
=
0
;
if
(
portexpander_detected
()
&&
(
mask
&
0x7
))
{
if
(
hwlock_acquire
(
HWLOCK_I2C
,
pdMS_TO_TICKS
(
100
))
<
0
)
{
LOG_ERR
(
"buttons"
,
"Can't acquire I2C bus"
);
return
0
;
}
/*
* Not using PB_Get() here as that performs one I2C transcation
* per button.
*/
uint8_t
pin_status
=
~
portexpander_get
();
hwlock_release
(
HWLOCK_I2C
);
for
(
uint8_t
m
=
1
;
m
<
0x8
;
m
<<=
1
)
{
if
(
mask
&
m
&&
pin_status
&
pin_mask
[
m
])
{
ret
|=
m
;
...
...
Write
Preview
Supports
Markdown
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