-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Summary Created an InverterOn state in-between Init and Precharge in BMS. Should wait 200ms then go into precharge. ### Changelist - Created InverterOn State - Init goes to InverterOn instead of Precharge now - Made small changes to App_Timer ### Testing Done Created test check_inverter_on_state_is_broadcasted_over_can Created test check_state_transition_from_init_to_inverter_to_precharge Made small changes in other tests so they would take into account the 200ms InverterOn Stat ### Checklist *Please change `[ ]` to `[x]` when you are ready.* - [X] I have read and followed the code conventions detailed in [README.md](../README.md) (*This will save time for both you and the reviewer!*). - [X] If this pull request is longer then **500** lines, I have provided *explicit* justification in the summary above explaining why I *cannot* break this up into multiple pull requests (*Small PR's are faster and less painful for everyone involved!*).
- Loading branch information
1 parent
cb34abb
commit b377f77
Showing
11 changed files
with
114 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "App_SharedStateMachine.h" | ||
|
||
/** | ||
* Get a pointer to the Inverter State. | ||
* @return A pointer to the Inverter State. | ||
*/ | ||
const struct State *App_GetInverterOnState(void); | ||
|
||
/** | ||
* Reset hasTimePassed bool | ||
*/ | ||
void App_InverterOnState_Init(void); |
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,59 @@ | ||
#include "states/App_AllStates.h" | ||
#include "states/App_PreChargeState.h" | ||
#include "states/App_InverterOnState.h" | ||
#include "App_SetPeriodicCanSignals.h" | ||
#include "App_SharedMacros.h" | ||
#include "App_Timer.h" | ||
|
||
#define CHARGING_MILLISECONDS 200 | ||
TimerChannel timer; | ||
static bool hasTimePassed; | ||
|
||
static void InverterOnStateRunOnEntry(struct StateMachine *const state_machine) | ||
{ | ||
App_CanTx_BMS_State_Set(BMS_INVERTER_ON_STATE); | ||
App_Timer_InitTimer(&timer, CHARGING_MILLISECONDS); | ||
App_Timer_Restart(&timer); | ||
} | ||
|
||
void App_InverterOnState_Init() | ||
{ | ||
hasTimePassed = false; | ||
} | ||
|
||
static void InverterOnStateRunOnTick1Hz(struct StateMachine *const state_machine) | ||
{ | ||
App_AllStatesRunOnTick1Hz(state_machine); | ||
} | ||
|
||
static void InverterOnStateRunOnTick100Hz(struct StateMachine *const state_machine) | ||
{ | ||
if (App_AllStatesRunOnTick100Hz(state_machine)) | ||
{ | ||
TimerState timer_state = App_Timer_UpdateAndGetState(&timer); | ||
|
||
if (timer_state == TIMER_STATE_EXPIRED || hasTimePassed) | ||
{ | ||
App_SharedStateMachine_SetNextState(state_machine, App_GetPreChargeState()); | ||
hasTimePassed = true; | ||
} | ||
} | ||
} | ||
|
||
static void InverterOnStateRunOnExit(struct StateMachine *const state_machine) | ||
{ | ||
UNUSED(state_machine); | ||
} | ||
|
||
const struct State *App_GetInverterOnState(void) | ||
{ | ||
static struct State inverter_state = { | ||
.name = "INVERTER_ON", | ||
.run_on_entry = InverterOnStateRunOnEntry, | ||
.run_on_tick_1Hz = InverterOnStateRunOnTick1Hz, | ||
.run_on_tick_100Hz = InverterOnStateRunOnTick100Hz, | ||
.run_on_exit = InverterOnStateRunOnExit, | ||
}; | ||
|
||
return &inverter_state; | ||
} |
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
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