Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
01f45a96
Commit
01f45a96
authored
5 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(pmic): properly release the two locks
parent
7d7b6816
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!192
fix(pmic): properly release the two locks
Pipeline
#2943
passed
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/pmic.c
+25
-12
25 additions, 12 deletions
epicardium/modules/pmic.c
with
25 additions
and
12 deletions
epicardium/modules/pmic.c
+
25
−
12
View file @
01f45a96
...
...
@@ -43,19 +43,22 @@ void pmic_interrupt_callback(void *_)
int
pmic_read_amux
(
enum
pmic_amux_signal
sig
,
float
*
result
)
{
int
ret
=
0
;
int
ret
=
0
;
int
i2c_ret
=
0
;
if
(
sig
>
_PMIC_AMUX_MAX
)
{
return
-
EINVAL
;
}
ret
=
hwlock_acquire
(
HWLOCK_ADC
,
pdMS_TO_TICKS
(
100
));
if
(
ret
<
0
)
{
return
ret
;
int
adc_ret
=
hwlock_acquire
(
HWLOCK_ADC
,
pdMS_TO_TICKS
(
100
));
if
(
adc_ret
<
0
)
{
ret
=
adc_ret
;
goto
done
;
}
ret
=
hwlock_acquire
(
HWLOCK_I2C
,
pdMS_TO_TICKS
(
100
));
if
(
ret
<
0
)
{
return
ret
;
i2c_ret
=
hwlock_acquire
(
HWLOCK_I2C
,
pdMS_TO_TICKS
(
100
));
if
(
i2c_ret
<
0
)
{
ret
=
i2c_ret
;
goto
done
;
}
/* Select the correct channel for this measurement. */
...
...
@@ -67,10 +70,13 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
* release the I2C mutex.
*/
hwlock_release
(
HWLOCK_I2C
);
i2c_ret
=
0
;
vTaskDelay
(
pdMS_TO_TICKS
(
5
));
ret
=
hwlock_acquire
(
HWLOCK_I2C
,
pdMS_TO_TICKS
(
100
));
if
(
ret
<
0
)
{
return
ret
;
i2c_ret
=
hwlock_acquire
(
HWLOCK_I2C
,
pdMS_TO_TICKS
(
100
));
if
(
i2c_ret
<
0
)
{
ret
=
i2c_ret
;
goto
done
;
}
uint16_t
adc_data
;
...
...
@@ -112,8 +118,15 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
ret
=
-
EINVAL
;
}
hwlock_release
(
HWLOCK_I2C
);
hwlock_release
(
HWLOCK_ADC
);
done:
if
(
i2c_ret
==
0
)
{
hwlock_release
(
HWLOCK_I2C
);
}
if
(
adc_ret
==
0
)
{
hwlock_release
(
HWLOCK_ADC
);
}
return
ret
;
}
...
...
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