-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SOFT-452] Regen braking toggling: MCI (#416)
Implemented the regen braking on MCI side by - Adding a regen braking state in regen_braking.c - Making test cases in test_regen_braking.c to ensure the functionality of regen_braking.c - Adding the internal regen_brake state to mci_output.c to set the current to zero when regen is diabled and the target velocity is less than the current velocity. - Added additional test cases to 'test_mci_output.c` to test all driving and pedal modes both when regen barking is enabled and disabled.
- Loading branch information
Showing
8 changed files
with
413 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
// A module to set the regen braking state in MCI | ||
// upon receiving a CAN_TRANSMIT_REGEN_BRAKING can | ||
// message. The regen braking state is used in | ||
// mci_output.c which determines whether we are | ||
// regen braking. | ||
// Requires CAN to be initialized. | ||
|
||
#include <stdbool.h> | ||
|
||
#include "can.h" | ||
#include "can_msg_defs.h" | ||
#include "can_unpack.h" | ||
#include "status.h" | ||
|
||
StatusCode regen_braking_init(void); | ||
|
||
bool get_regen_braking_state(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
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,26 @@ | ||
#include "regen_braking.h" | ||
|
||
#include "can.h" | ||
#include "can_msg_defs.h" | ||
#include "can_unpack.h" | ||
#include "status.h" | ||
|
||
static bool s_regen_braking_state; | ||
|
||
// Callback function to set the regen braking state | ||
static StatusCode prv_regen_braking_callback(const CanMessage *msg, void *context, | ||
CanAckStatus *ack_reply) { | ||
CAN_UNPACK_REGEN_BRAKING(msg, (uint8_t *)&s_regen_braking_state); | ||
return STATUS_CODE_OK; | ||
} | ||
|
||
StatusCode regen_braking_init(void) { | ||
// Default to enabled | ||
s_regen_braking_state = true; | ||
can_register_rx_handler(SYSTEM_CAN_MESSAGE_REGEN_BRAKING, prv_regen_braking_callback, NULL); | ||
return STATUS_CODE_OK; | ||
} | ||
|
||
bool get_regen_braking_state(void) { | ||
return s_regen_braking_state; | ||
} |
Oops, something went wrong.