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
R. Nestler
firmware
Commits
e0824843
Commit
e0824843
authored
5 years ago
by
rahix
Committed by
schneider
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(pmic): Switch off if battery is low
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
46ef3985
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/modules/modules.h
+3
-0
3 additions, 0 deletions
epicardium/modules/modules.h
epicardium/modules/pmic.c
+33
-3
33 additions, 3 deletions
epicardium/modules/pmic.c
with
36 additions
and
3 deletions
epicardium/modules/modules.h
+
3
−
0
View file @
e0824843
...
...
@@ -34,6 +34,9 @@ int personal_state_enabled();
/* ---------- PMIC --------------------------------------------------------- */
void
vPmicTask
(
void
*
pvParameters
);
/* Critical battery voltage */
#define BATTERY_CRITICAL 3.40f
enum
pmic_amux_signal
{
PMIC_AMUX_CHGIN_U
=
0x1
,
PMIC_AMUX_CHGIN_I
=
0x2
,
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/pmic.c
+
33
−
3
View file @
e0824843
...
...
@@ -154,6 +154,36 @@ pmic_poll_interrupts(TickType_t *button_start_tick, TickType_t duration)
}
}
__attribute__
((
noreturn
))
static
void
pmic_die
(
float
u_batt
)
{
/* Stop core 1 */
core1_stop
();
/* Grab the screen */
disp_forcelock
();
/* Draw an error screen */
epic_disp_clear
(
0x0000
);
epic_disp_print
(
0
,
0
,
" Battery"
,
0xffff
,
0x0000
);
epic_disp_print
(
0
,
20
,
" critical"
,
0xffff
,
0x0000
);
epic_disp_print
(
0
,
40
,
" !!!!"
,
0xffff
,
0x0000
);
epic_disp_update
();
/* Vibrate violently */
epic_vibra_set
(
true
);
/* Wait a bit */
for
(
int
i
=
0
;
i
<
50000000
;
i
++
)
__NOP
();
LOG_WARN
(
"pmic"
,
"Poweroff"
);
MAX77650_setSFT_RST
(
0x2
);
while
(
1
)
__WFI
();
}
/*
* Check the battery voltage. If it drops too low, turn card10 off.
*/
...
...
@@ -175,9 +205,9 @@ static void pmic_check_battery()
(
int
)(
u_batt
*
1000
.
0
)
%
1000
);
/*
* TODO: Handle voltage value
*/
if
(
u_batt
<
BATTERY_CRITICAL
)
{
pmic_die
(
u_batt
);
}
}
/*
...
...
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