Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mauro Morales
reform
Commits
932aaf28
Commit
932aaf28
authored
1 year ago
by
minute
Browse files
Options
Downloads
Patches
Plain Diff
lpc-fw: disable brownout reset during sleep; clean up status prints
parent
0ef65dbc
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
reform2-lpc-fw/src/boards/reform2/board_reform2.c
+22
-12
22 additions, 12 deletions
reform2-lpc-fw/src/boards/reform2/board_reform2.c
with
22 additions
and
12 deletions
reform2-lpc-fw/src/boards/reform2/board_reform2.c
+
22
−
12
View file @
932aaf28
...
...
@@ -39,7 +39,7 @@
// don't forget to set this to the correct rev for your motherboard!
// if you have a motherboard made in 2023 (2.5 R-2):
#define REFORM_MOTHERBOARD_REV REFORM_MBREV_25_R2
//
#define REFORM_MOTHERBOARD_REV REFORM_MBREV_25_R2
// if you have a motherboard made before 2023 (2.0 R-3):
//#define REFORM_MOTHERBOARD_REV REFORM_MBREV_20_R3
...
...
@@ -526,12 +526,17 @@ void turn_aux_power_off(void) {
//LPC_GPIO->CLR[0] = (1 << 7); // AUX 3v3 off (R1+)
}
void
brownout_
setup
(
void
)
{
void
brownout_
enable
(
void
)
{
// Set brownout threshold to 1.46-1.63V (lowest level)
// and enable brownout reset (BODRSTENA)
LPC_SYSCON
->
BODCTRL
=
0x0
|
(
1
<<
4
);
}
void
brownout_disable
(
void
)
{
// disable brownout reset (BODRSTENA)
LPC_SYSCON
->
BODCTRL
=
0x0
;
}
void
watchdog_feed
(
void
)
{
__disable_irq
();
LPC_WWDT
->
FEED
=
0xAA
;
...
...
@@ -544,7 +549,7 @@ void watchdog_feed(void) {
void
boardInit
(
void
)
{
brownout_
setup
();
brownout_
enable
();
SystemCoreClockUpdate
();
GPIOInit
();
...
...
@@ -748,26 +753,27 @@ void handle_commands() {
uartSend
((
uint8_t
*
)
uartBuffer
,
strlen
(
uartBuffer
));
}
else
if
(
remote_cmd
==
's'
)
{
int
acc_mah
=
(
int
)(
capacity_accu_ampsecs
/
3
.
6
);
int
min_mah
=
(
int
)(
capacity_min_ampsecs
/
3
.
6
);
int
acc_mah
=
(
int
)(
capacity_accu_ampsecs
/
3
.
6
);
int
max_mah
=
(
int
)(
capacity_max_ampsecs
/
3
.
6
);
// get charger system state
if
(
state
==
ST_CHARGE
)
{
sprintf
(
uartBuffer
,
"norm
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"norm:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_OVERVOLTED
)
{
sprintf
(
uartBuffer
,
"baln
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"baln:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_COOLDOWN
)
{
sprintf
(
uartBuffer
,
"cool
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"cool:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_UNDERVOLTED
)
{
sprintf
(
uartBuffer
,
"uvol
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"uvol:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_MISSING
)
{
sprintf
(
uartBuffer
,
"miss:%d
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
missing_reason
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"miss:%d:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
missing_reason
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_FULLY_CHARGED
)
{
sprintf
(
uartBuffer
,
"full
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"full:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
if
(
state
==
ST_POWERSAVE
)
{
sprintf
(
uartBuffer
,
"psav
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"psav:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
else
{
sprintf
(
uartBuffer
,
"unkn:%d
(%d) min
:%d mAh:%d up:%d
rev:
"
FW_REV
"
\r
"
,
state
,
cycles_in_state
,
min_mah
,
acc_mah
,
cycles_uptime
);
sprintf
(
uartBuffer
,
"unkn:%d:%d mAh:%d
:%d:%d
up:%d "
FW_REV
"
\r
"
,
state
,
cycles_in_state
,
min_mah
,
acc_mah
,
max_mah
,
cycles_uptime
);
}
uartSend
((
uint8_t
*
)
uartBuffer
,
strlen
(
uartBuffer
));
...
...
@@ -1089,6 +1095,8 @@ void WDT_IRQHandler(void) {
// WARNING: take care not to overflow TC (11786 * secs)
void
deep_sleep_seconds
(
int
secs
)
{
// brownout reset seems to interfere with deep sleep
brownout_disable
();
// make WWDTINT wake the LPC up from sleep
// STARTERP1 WWDTINT bit 12
...
...
@@ -1140,6 +1148,8 @@ void deep_sleep_seconds(int secs) {
NVIC_DisableIRQ
(
WDT_IRQn
);
LPC_WWDT
->
MOD
=
0
;
brownout_enable
();
}
int
main
(
void
)
{
...
...
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