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
7ff1d3ae
Commit
7ff1d3ae
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
refact(pmic): Use new style HW locks
parent
1fd7e6f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!379
Remove legacy HW lock interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/pmic.c
+7
-31
7 additions, 31 deletions
epicardium/modules/pmic.c
with
7 additions
and
31 deletions
epicardium/modules/pmic.c
+
7
−
31
View file @
7ff1d3ae
...
...
@@ -18,8 +18,6 @@
#include
<stdio.h>
#include
<string.h>
#define LOCK_WAIT portMAX_DELAY
/* Task ID for the pmic handler */
static
TaskHandle_t
pmic_task_id
=
NULL
;
...
...
@@ -46,23 +44,14 @@ void pmic_interrupt_callback(void *_)
int
pmic_read_amux
(
enum
pmic_amux_signal
sig
,
float
*
result
)
{
int
ret
=
0
;
int
i2c_ret
=
0
;
int
ret
=
0
;
if
(
sig
>
_PMIC_AMUX_MAX
)
{
return
-
EINVAL
;
}
int
adc_ret
=
hwlock_acquire_timeout
(
HWLOCK_ADC
,
LOCK_WAIT
);
if
(
adc_ret
<
0
)
{
ret
=
adc_ret
;
goto
done
;
}
i2c_ret
=
hwlock_acquire_timeout
(
HWLOCK_I2C
,
LOCK_WAIT
);
if
(
i2c_ret
<
0
)
{
ret
=
i2c_ret
;
goto
done
;
}
hwlock_acquire
(
HWLOCK_ADC
);
hwlock_acquire
(
HWLOCK_I2C
);
/* Select the correct channel for this measurement. */
MAX77650_setMUX_SEL
(
sig
);
...
...
@@ -75,11 +64,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
hwlock_release
(
HWLOCK_I2C
);
vTaskDelay
(
pdMS_TO_TICKS
(
5
));
i2c_ret
=
hwlock_acquire_timeout
(
HWLOCK_I2C
,
LOCK_WAIT
);
if
(
i2c_ret
<
0
)
{
ret
=
i2c_ret
;
goto
done
;
}
hwlock_acquire
(
HWLOCK_I2C
);
uint16_t
adc_data
;
ADC_StartConvert
(
ADC_CH_0
,
0
,
0
);
...
...
@@ -120,14 +105,8 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
ret
=
-
EINVAL
;
}
done:
if
(
i2c_ret
==
0
)
{
hwlock_release
(
HWLOCK_I2C
);
}
if
(
adc_ret
==
0
)
{
hwlock_release
(
HWLOCK_ADC
);
}
hwlock_release
(
HWLOCK_I2C
);
hwlock_release
(
HWLOCK_ADC
);
return
ret
;
}
...
...
@@ -138,10 +117,7 @@ done:
*/
static
uint8_t
pmic_poll_interrupts
(
void
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
LOCK_WAIT
)
<
0
)
{
LOG_WARN
(
"pmic"
,
"Failed to acquire I2C. Retrying ..."
);
vTaskDelay
(
pdMS_TO_TICKS
(
100
));
}
hwlock_acquire
(
HWLOCK_I2C
);
uint8_t
int_flag
=
MAX77650_getINT_GLBL
();
hwlock_release
(
HWLOCK_I2C
);
...
...
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