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
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pete
firmware
Commits
e489b211
Commit
e489b211
authored
5 years ago
by
rahix
Committed by
schneider
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
chore(leds): Convert LEDs module to new mutex API
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
3b436505
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/leds.c
+13
-35
13 additions, 35 deletions
epicardium/modules/leds.c
with
13 additions
and
35 deletions
epicardium/modules/leds.c
+
13
−
35
View file @
e489b211
...
...
@@ -7,15 +7,16 @@
#include
<stdbool.h>
//TODO: create smth like vTaskDelay(pdMS_TO_TICKS(//put ms here)) for us, remove blocking delay from /lib/leds.c to avoid process blocking
/*
* TODO: create smth like vTaskDelay(pdMS_TO_TICKS(//put ms here)) for us,
* remove blocking delay from /lib/leds.c to avoid process blocking
*/
#define NUM_LEDS 15
/* Take from lib/card10/leds.c */
static
void
do_update
()
static
void
do_update
(
void
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_LED
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_LED
);
leds_update_power
();
leds_update
();
...
...
@@ -96,12 +97,8 @@ void epic_leds_dim_top(uint8_t value)
{
leds_set_dim_top
(
value
);
if
(
personal_state_enabled
()
==
0
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_I2C
);
leds_update
();
hwlock_release
(
HWLOCK_I2C
);
}
}
...
...
@@ -110,35 +107,24 @@ void epic_leds_dim_bottom(uint8_t value)
{
leds_set_dim_bottom
(
value
);
if
(
personal_state_enabled
()
==
0
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_I2C
);
leds_update
();
hwlock_release
(
HWLOCK_I2C
);
}
}
void
epic_leds_set_rocket
(
int
led
,
uint8_t
value
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
value
=
value
>
31
?
31
:
value
;
pmic_set_led
(
led
,
value
);
hwlock_acquire
(
HWLOCK_I2C
);
pmic_set_led
(
led
,
value
>
31
?
31
:
value
);
hwlock_release
(
HWLOCK_I2C
);
}
int
epic_leds_get_rocket
(
int
led
)
{
int
ret
=
0
;
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_I2C
);
ret
=
pmic_get_led
(
led
);
hwlock_release
(
HWLOCK_I2C
);
return
ret
;
...
...
@@ -146,12 +132,8 @@ int epic_leds_get_rocket(int led)
void
epic_set_flashlight
(
bool
power
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_I2C
);
leds_flashlight
(
power
);
hwlock_release
(
HWLOCK_I2C
);
}
...
...
@@ -162,12 +144,8 @@ void epic_leds_update(void)
void
epic_leds_set_powersave
(
bool
eco
)
{
while
(
hwlock_acquire_timeout
(
HWLOCK_I2C
,
portMAX_DELAY
)
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
hwlock_acquire
(
HWLOCK_I2C
);
leds_powersave
(
eco
);
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