-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
190 debounce function, cerb_utils, fault handler task notis
- Loading branch information
Showing
9 changed files
with
197 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @file cerb_utils.h | ||
* @author Scott Abramson | ||
* @brief Utility functions for Cerberus. | ||
* @version 0.1 | ||
* @date 2024-08-04 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#ifndef CERB_UTILS_H | ||
#define CERB_UTILS_H | ||
|
||
#include "cmsis_os.h" | ||
#include "stdbool.h" | ||
|
||
/** | ||
* @brief Function to debounce an input with an RTOS timer. Debounce is started and maintained by a high signal, and it is interrupted by a low signal. | ||
* | ||
* @param input Input to debounce. | ||
* @param timer RTOS timer with callback to be called at end of debounce period. | ||
* @param period The period of time, in milliseconds, to debounce the input for. | ||
*/ | ||
void debounce(bool input, osTimerAttr_t *timer, uint32_t period); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file cerb_utils.c | ||
* @author Scott Abramson | ||
* @brief Utility functions for Cerberus. | ||
* @version 0.1 | ||
* @date 2024-08-04 | ||
* | ||
* @copyright Copyright (c) 2024 | ||
* | ||
*/ | ||
|
||
#include "cerb_utils.h" | ||
|
||
void debounce(bool input, osTimerAttr_t *timer, uint32_t period) | ||
{ | ||
if (input && !osTimerIsRunning(timer)) { | ||
/* Start timer if a button has been pressed */ | ||
osTimerStart(timer, period); | ||
} else if (!input && osTimerIsRunning(timer)) { | ||
/* Button stopped being pressed. Kill timer. */ | ||
osTimerStop(timer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.