-
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.
Merge pull request #3 from fedebone00/cellboard
Cellboard integration with working can
- Loading branch information
Showing
1,082 changed files
with
878,818 additions
and
128,611 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 |
---|---|---|
|
@@ -9,3 +9,4 @@ Backup/ | |
|
||
**/.vscode/* | ||
!**/.vscode/extensions.json | ||
Backup/ |
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 |
---|---|---|
|
@@ -8,4 +8,10 @@ | |
[submodule "mainboard/lib/micro-libs"] | ||
path = mainboard/lib/micro-libs | ||
url = [email protected]:eagletrt/micro-libs.git | ||
branch = master | ||
[submodule "cellboard/Core/Lib/can-cicd"] | ||
path = cellboard/Core/Lib/can-cicd | ||
url = [email protected]:eagletrt/can-cicd | ||
branch = build | ||
[submodule "cellboard/Core/Lib/micro-libs"] | ||
path = cellboard/Core/Lib/micro-libs | ||
url = [email protected]:eagletrt/micro-libs |
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,154 @@ | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: false | ||
AlignConsecutiveMacros: true | ||
AlignEscapedNewlines: Left | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: InlineOnly | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 120 | ||
CommentPragmas: "^ IWYU pragma:" | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '^"(general\.h)"$' | ||
Priority: -1 | ||
SortPriority: -1 | ||
- Regex: '^"ltc_defs.h"$' | ||
Priority: 5 | ||
SortPriority: 5 | ||
- Regex: '^"(Mock).*' | ||
Priority: 0 | ||
SortPriority: 4 | ||
- Regex: '^"(.*)_cfg.h"$' | ||
Priority: 5 | ||
SortPriority: 7 | ||
- Regex: '^"(unity)' | ||
Priority: 0 | ||
SortPriority: 2 | ||
- Regex: '^"HL_.*' | ||
Priority: 10 | ||
SortPriority: 10 | ||
- Regex: '^"ti_.*' | ||
Priority: 10 | ||
SortPriority: 12 | ||
- Regex: '^"(FreeRTOS)' | ||
Priority: 15 | ||
SortPriority: 15 | ||
- Regex: '^"(atomic|croutine|event_groups|message_buffer|queue|semphr|stream_buffer|task|timers)\.h' | ||
Priority: 15 | ||
SortPriority: 17 | ||
- Regex: '".*"' | ||
Priority: 20 | ||
SortPriority: 20 | ||
IncludeIsMainRegex: "(_cfg)?$" | ||
IncludeIsMainSourceRegex: "" | ||
IndentCaseLabels: true | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: true | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: "" | ||
MacroBlockEnd: "" | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 20 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 100000 | ||
PointerAlignment: Right | ||
ReflowComments: false | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpaceBeforeSquareBrackets: false | ||
Standard: Latest | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 4 | ||
UseCRLF: true | ||
UseTab: Never |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
/** | ||
* @file bal.h | ||
* @brief This file contains the balancing functions | ||
* | ||
* @date Oct 28, 2019 | ||
* | ||
* @author Matteo Bonora [[email protected]] | ||
* @author Simone Ruffini [[email protected]] | ||
*/ | ||
|
||
#ifndef BAL_H | ||
#define BAL_H | ||
|
||
#include "cellboard_config.h" | ||
|
||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
|
||
#define BAL_NULL_INDEX UINT8_MAX | ||
#define HYSTERESIS 10 | ||
|
||
/** | ||
* @brief Wrapper function around bal_compute_imbalance and bal_exclude_neighbors | ||
* | ||
* @param volts Array of cell voltages | ||
* @param count Size of `volts` | ||
* @param threshold Balancing tolerance (voltage + threshold) | ||
* @param indexes Output array of indexes to be balanced | ||
* @param cells array of cell's indexes that need to be discharged | ||
* | ||
* @returns amount of cells to be discharged | ||
*/ | ||
uint16_t bal_get_cells_to_discharge(voltage_t volts[], uint16_t count, voltage_t threshold, uint16_t cells[]); | ||
|
||
/** | ||
* @brief Computes the cells with voltage exceeding the given threshold + lowest cell voltage | ||
* | ||
* @param volts Array of cell voltages | ||
* @param count Size of `volts` | ||
* @param threshold Balancing tolerance (voltage + threshold) | ||
* @param indexes Output array of indexes to be balanced | ||
* @param cells array of cell's indexes that need to be discharged | ||
* | ||
* @returns amount of cells to be discharged | ||
*/ | ||
uint16_t bal_compute_imbalance(voltage_t volts[], uint16_t count, voltage_t threshold, uint16_t cells[]); | ||
|
||
/** | ||
* @brief Exclude adjacent cells to work around an hardware limitation on Fenice | ||
* | ||
* @param indexes output array of cell's indexes that need to be discharged | ||
* @param count amount of voltages | ||
* @param cells output array of cell's indexes that need to be discharged | ||
* | ||
* @returns amount of cells to be discharged | ||
*/ | ||
uint16_t bal_exclude_neighbors(uint16_t indexes[], uint16_t count, uint16_t cells[]); | ||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @file bal_fsm.h | ||
* @brief This file contains the balancing functions | ||
* | ||
* @date Jul 07, 2021 | ||
* | ||
* @author Matteo Bonora [[email protected]] | ||
*/ | ||
|
||
#ifndef BAL_FSM_H | ||
#define BAL_FSM_H | ||
|
||
//#include "bal.h" | ||
#include "cellboard_config.h" | ||
#include "fsm.h" | ||
#include "tim.h" | ||
|
||
#include <inttypes.h> | ||
|
||
enum { BAL_OFF = 0, BAL_COMPUTE, BAL_DISCHARGE, BAL_NUM_STATES }; | ||
enum { EV_BAL_STOP = 0, EV_BAL_START, EV_BAL_CHECK_TIMER, BAL_EV_NUM }; | ||
|
||
typedef struct { | ||
fsm fsm; | ||
|
||
uint16_t cells[PACK_CELL_COUNT]; | ||
size_t cells_length; | ||
uint32_t discharge_time; | ||
uint32_t cycle_length; | ||
} bal_fsm; | ||
|
||
extern bal_fsm bal; | ||
|
||
void bal_fsm_init(); | ||
void bal_timers_handler(TIM_HandleTypeDef* htim, fsm handle); | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
****************************************************************************** | ||
* @file can.h | ||
* @brief This file contains all the function prototypes for | ||
* the can.c file | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© Copyright (c) 2021 STMicroelectronics. | ||
* All rights reserved.</center></h2> | ||
* | ||
* This software component is licensed by ST under BSD 3-Clause license, | ||
* the "License"; You may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* opensource.org/licenses/BSD-3-Clause | ||
* | ||
****************************************************************************** | ||
*/ | ||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef __CAN_H__ | ||
#define __CAN_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Includes ------------------------------------------------------------------*/ | ||
#include "main.h" | ||
|
||
/* USER CODE BEGIN Includes */ | ||
|
||
/* USER CODE END Includes */ | ||
|
||
extern CAN_HandleTypeDef hcan1; | ||
|
||
/* USER CODE BEGIN Private defines */ | ||
#define BMS_CAN hcan1 | ||
|
||
#define CAN_WAIT(C) \ | ||
{ \ | ||
uint32_t tick = HAL_GetTick(); \ | ||
while (HAL_GetTick() - tick < 10 && \ | ||
HAL_CAN_GetTxMailboxesFreeLevel(C) == 0); \ | ||
} | ||
/* USER CODE END Private defines */ | ||
|
||
void MX_CAN1_Init(void); | ||
|
||
/* USER CODE BEGIN Prototypes */ | ||
|
||
/* USER CODE END Prototypes */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __CAN_H__ */ | ||
|
||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
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,17 @@ | ||
/** | ||
* @file can_comms.h | ||
* @brief CAN communication stuff | ||
* | ||
* @date Jul 16, 2021 | ||
* @author Matteo Bonora [[email protected]] | ||
*/ | ||
|
||
#ifndef _CAN_COMMS_ | ||
|
||
#include "../../bms/c/bms.h" | ||
#include "../bms/ids.h" | ||
|
||
void can_send(uint16_t id); | ||
void can_init_with_filter(); | ||
|
||
#endif |
Oops, something went wrong.