Skip to content

Commit 90d7c4e

Browse files
author
Daniel Campora
committed
cc3200: Make HeartBeat.disable() thread safe.
1 parent 1a97f67 commit 90d7c4e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cc3200/misc/mperror.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct mperror_heart_beat {
6868
uint32_t on_time;
6969
bool beating;
7070
bool enabled;
71-
} mperror_heart_beat = {.off_time = 0, .on_time = 0, .beating = false, .enabled = false};
71+
bool do_disable;
72+
} mperror_heart_beat = {.off_time = 0, .on_time = 0, .beating = false, .enabled = false, .do_disable = false};
7273

7374
/******************************************************************************
7475
DEFINE PUBLIC FUNCTIONS
@@ -142,12 +143,16 @@ void mperror_heartbeat_switch_off (void) {
142143
}
143144

144145
void mperror_disable_heartbeat (void) {
145-
mperror_heart_beat.enabled = false;
146-
mperror_heartbeat_switch_off();
146+
mperror_heart_beat.do_disable = true;
147147
}
148148

149149
void mperror_heartbeat_signal (void) {
150-
if (mperror_heart_beat.enabled) {
150+
if (mperror_heart_beat.do_disable) {
151+
mperror_heart_beat.enabled = false;
152+
mperror_heart_beat.do_disable = false;
153+
mperror_heartbeat_switch_off();
154+
}
155+
else if (mperror_heart_beat.enabled) {
151156
if (!mperror_heart_beat.beating) {
152157
if ((mperror_heart_beat.on_time = HAL_GetTick()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
153158
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);

0 commit comments

Comments
 (0)