-
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.
feat(balancing): remove eeprom blocking functions from can interrupt …
…callback
- Loading branch information
Showing
10 changed files
with
3,728 additions
and
3,927 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
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
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 |
---|---|---|
@@ -1,58 +1,81 @@ | ||
/** | ||
* @file bal_fsm.h | ||
* @brief This file contains the balancing functions | ||
* @file bal.h | ||
* @brief This file contains the balancing functions | ||
* | ||
* @date May 09, 2021 | ||
* @date May 09, 2021 | ||
* | ||
* @author Matteo Bonora [matteo.bonora@studenti.unitn.it] | ||
* @author Matteo Bonora [matteo.bonora@studenti.unitn.it] | ||
* @author Antonio Gelain [antonio.gelain@studenti.unitn.it] | ||
*/ | ||
|
||
#ifndef BAL_FSM_H | ||
#define BAL_FSM_H | ||
#ifndef BAL_H | ||
#define BAL_H | ||
|
||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
|
||
#include "../../fenice_config.h" | ||
|
||
#define BAL_THRESHOLD_DEFAULT 300 // mV * 10 | ||
#define BAL_THRESHOLD_MIN 50 // mV * 10 | ||
#define BAL_THRESHOLD_MAX 2000 // mV * 10 | ||
|
||
/** @brief Request a change of state in the balancing status */ | ||
typedef struct { | ||
bool status; | ||
voltage_t threshold; | ||
bool is_new; | ||
} BalRequest; | ||
|
||
|
||
/** @brief Initialize balancing */ | ||
void bal_init(void); | ||
|
||
/** | ||
* @brief Get balancing threshold voltage value | ||
* @brief Request a change to the current balancing status | ||
* | ||
* @return voltage_t The threshold voltage | ||
* @param status The new status to change into | ||
* @param threshold The minimum allowed voltage difference between all cells (in mV * 10) | ||
*/ | ||
voltage_t bal_get_threshold(); | ||
void bal_change_status_request(bool status, voltage_t threshold); | ||
|
||
/** | ||
* @brief Set balancing threshold voltage value | ||
* @brief Get balancing threshold voltage value | ||
* | ||
* @param thresh The new threshold voltage to set | ||
* @return voltage_t The threshold voltage | ||
*/ | ||
void bal_set_threshold(uint16_t thresh); | ||
voltage_t bal_get_threshold(void); | ||
|
||
/** | ||
* @brief Check if the cellboards are balancing or not | ||
* | ||
* @return true If any cellboards is balancing | ||
* @return false If no cellboards are balancing | ||
*/ | ||
bool bal_is_balancing(); | ||
bool bal_is_balancing(void); | ||
|
||
/** | ||
* @brief Set if the cellboards are balancing or not | ||
* @brief Workaround for 'can_bms_send' | ||
* | ||
* @param is_bal True if any cellboard is balancing false | ||
* @return BalRequest The request data | ||
*/ | ||
void bal_set_is_balancing(uint8_t cellboard_id, bool is_bal); | ||
BalRequest bal_get_request(void); | ||
|
||
/** | ||
* @brief Workaround for can_bms_send | ||
* @brief Update the balancing status of a cellboard | ||
* | ||
* @return true during bal_start | ||
* @return false otherwise | ||
* @param cellboard The cellboard ID | ||
* @param status The balancing status of the cellboard | ||
*/ | ||
bool bal_need_balancing(); | ||
void bal_update_status(uint8_t cellboard, bool status); | ||
|
||
/** @brief Initialize balancing */ | ||
void bal_init(); | ||
/** @brief Start balancing */ | ||
void bal_start(); | ||
/** @brief Stop balancing */ | ||
void bal_stop(); | ||
void bal_stop(void); | ||
|
||
/** | ||
* @brief Routine that keep the current balancing status updated | ||
* @details This function handles the start and stop mechanism of the balancing | ||
*/ | ||
void bal_routine(void); | ||
|
||
#endif | ||
#endif // BAL_H |
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
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
Oops, something went wrong.