Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge test branch into production M2 #429

Open
wants to merge 27 commits into
base: production/M2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9a35ef3
UART_2 Read and Write Working
MichaelMohn Mar 16, 2024
13f81d1
Printf and Scanf working
MichaelMohn Mar 16, 2024
fe1e5ea
UART_3 Working
MichaelMohn Mar 16, 2024
fc75c76
working BSP_ADC test with actual potentiometer
IshDeshpa Mar 22, 2024
b65e692
remove test bsp
IshDeshpa Mar 22, 2024
4fbe4e5
added return
IshDeshpa Mar 22, 2024
316917e
fixed up uart test comments and naming
IshDeshpa Mar 22, 2024
2a3ea1b
clerical changes
IshDeshpa Mar 22, 2024
c96fe92
Added BSP_CAN test and deleted some olde tests
NathanielDelgado Mar 23, 2024
05113fe
Wrote tests for Minions and Pedals
NathanielDelgado Mar 23, 2024
6d531d4
Rewrote tests for Display, Contactors, and CANbus
NathanielDelgado Mar 23, 2024
d941cf2
CANbus drive test fix
MichaelMohn Mar 23, 2024
bdec7c8
Contactor Code (DOESNT WORK ON GOOD BOARD)
MichaelMohn Mar 24, 2024
b397118
Comments added (not tested)
MichaelMohn Mar 30, 2024
4a8ebd3
untested but done?
guytonde Mar 30, 2024
bb5b861
Merge branch 'production/M2' into feature/bsp-m2-test-423
KnockbackNemo Mar 30, 2024
64e6f2f
Contactor Fix perhaps???
diyarajon Mar 30, 2024
3d75cec
Updating SendTritium and its test file for Renode simulation so that …
KnockbackNemo Mar 31, 2024
a00f519
Merge branch 'feature/bsp-m2-test-423' of github.com:lhr-solar/Contro…
KnockbackNemo Mar 31, 2024
8a5155d
Updated SendTritium & Test_App_SendTritium for a working Renode test.…
KnockbackNemo Apr 7, 2024
0ff5c8a
Uncommented-out cruise control tests; all tests now passed. Issue may…
KnockbackNemo Apr 8, 2024
514b823
Renamed SendTritium test to indicate that it is intended for Renode s…
KnockbackNemo Apr 8, 2024
35d38dd
Deleted outdated Faultstate test.
KnockbackNemo Apr 13, 2024
2b659a6
Updated assertOSError calls to no longer inclue OS_ERR_LOC parameter.
KnockbackNemo Apr 13, 2024
b0c4622
Renamed ReadCarCan test to match naming scheme.
KnockbackNemo Apr 13, 2024
2a6240e
Renamed Test_ReadTritium to match the naming scheme of App_Testname. …
KnockbackNemo Apr 14, 2024
9b81504
Commented out test macro for SendTritium software test.
KnockbackNemo Apr 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"STM32F413_423xx",
"USE_STDPERIPH_DRIVER"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"intelliSenseMode": "clang-x64"
}
Expand Down
27 changes: 14 additions & 13 deletions Apps/Inc/SendTritium.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "common.h"

//#define SENDTRITIUM_PRINT_MES
//#define SENDTRITIUM_EXPOSE_VARS

#define MOTOR_MSG_PERIOD 100 // in ms
#define FSM_PERIOD 100 // in ms
Expand Down Expand Up @@ -49,22 +50,22 @@ typedef struct TritiumState{
void (*stateDecider)(void);
} TritiumState_t;

#ifdef SENDTRITIUM_EXPOSE_VARS
// Inputs
extern bool cruiseEnable;
extern bool cruiseSet;
extern bool onePedalEnable;
extern bool regenEnable;
// #ifdef SENDTRITIUM_EXPOSE_VARS
// // Inputs
// extern bool cruiseEnable;
// extern bool cruiseSet;
// extern bool onePedalEnable;
// extern bool regenEnable;

extern uint8_t brakePedalPercent;
extern uint8_t accelPedalPercent;
// extern uint8_t brakePedalPercent;
// extern uint8_t accelPedalPercent;

extern Gear_t gear;
// extern Gear_t gear;

extern TritiumState_t state;
extern float velocityObserved;
extern float cruiseVelSetpoint;
#endif
// extern TritiumState_t state;
// extern float velocityObserved;
// extern float cruiseVelSetpoint;
// #endif

// Getter functions for local variables in SendTritium.c
EXPOSE_GETTER(bool, cruiseEnable)
Expand Down
6 changes: 3 additions & 3 deletions Apps/Src/ReadCarCAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static void handler_ReadCarCAN_chargeDisable(void) {
updateHVArraySaturation(DISABLE_SATURATION_MSG);

// Kill contactor using a direct write to avoid blocking calls when the scheduler is locked
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(ARRAY_CONTACTOR_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);

// Check that the contactor was successfully turned off
bool ret = (bool)Contactors_Get(ARRAY_PRECHARGE_BYPASS_CONTACTOR);
Expand All @@ -423,8 +423,8 @@ static void handler_ReadCarCAN_contactorsDisable(void) {
updateHVPlusMinusSaturation(DISABLE_SATURATION_MSG);

// Kill contactor using a direct write to avoid blocking calls when the scheduler is locked
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(ARRAY_CONTACTOR_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(MCONT_CONTACTOR_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, false);

// Fills buffers with disable messages
memset(HVArrayChargeMsgBuffer, DISABLE_SATURATION_MSG, sizeof(HVArrayChargeMsgBuffer));
Expand Down
11 changes: 8 additions & 3 deletions Apps/Src/SendTritium.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ float cruiseVelSetpoint = 0;

// Current observed velocity
static float velocityObserved = 0;

#ifndef SENDTRITIUM_EXPOSE_VARS
// Counter for sending setpoints to motor
static uint8_t motorMsgCounter = 0;

Expand All @@ -78,7 +78,7 @@ static bool onePedalPrevious = false;

static bool cruiseEnableButton = false;
static bool cruiseEnablePrevious = false;

#endif
// FSM
static TritiumState_t prevState; // Previous state
static TritiumState_t state; // Current state
Expand Down Expand Up @@ -323,6 +323,7 @@ static uint8_t map(uint8_t input, uint8_t in_min, uint8_t in_max, uint8_t out_mi
* @brief Put the CONTROL_MODE message onto the CarCAN bus, detailing
* the current mode of control.
*/
#ifndef SENDTRITIUM_EXPOSE_VARS
static void putControlModeCAN(){
CANDATA_t message;
memset(&message, 0, sizeof(message));
Expand All @@ -331,6 +332,7 @@ static void putControlModeCAN(){

SendCarCAN_Put(message);
}
#endif

// State Handlers & Deciders

Expand Down Expand Up @@ -682,9 +684,12 @@ void Task_SendTritium(void *p_arg){
}else{
motorMsgCounter++;
}

putControlModeCAN();

#endif

putControlModeCAN();


// Delay of MOTOR_MSG_PERIOD ms
OSTimeDlyHMSM(0, 0, 0, MOTOR_MSG_PERIOD, OS_OPT_TIME_HMSM_STRICT, &err);
Expand Down
4 changes: 2 additions & 2 deletions Apps/Src/Tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ void throwTaskError(error_code_t errorCode, callback_t errorCallback, error_sche
*/
void EmergencyContactorOpen() {
// Array motor kill
BSP_GPIO_Write_Pin(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, OFF);
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, OFF);
BSP_GPIO_Write_Pin(MCONT_CONTACTOR_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, OFF);
BSP_GPIO_Write_Pin(ARRAY_CONTACTOR_PORT, ARRAY_PRECHARGE_BYPASS_PIN, OFF);

// Turn additional brakelight on to indicate critical error
BSP_GPIO_Write_Pin(PININFO_LUT[BRAKELIGHT].port, PININFO_LUT[BRAKELIGHT].pinMask, true);
Expand Down
4 changes: 2 additions & 2 deletions BSP/STM32F413/Src/retarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ int _write(int fd, char *buffer, unsigned int len) {

int _read(int const fd, char *buffer, unsigned const len) {
if(buffer != NULL) {

BSP_UART_Read(UART_2, buffer);
}
return 1;
return len;
}

int _close(int file)
Expand Down
8 changes: 5 additions & 3 deletions Drivers/Inc/Contactors.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
#include "stm32f4xx_gpio.h"


#define CONTACTORS_PORT PORTC
#define ARRAY_PRECHARGE_BYPASS_PIN GPIO_Pin_10
#define MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN GPIO_Pin_12
#define ARRAY_CONTACTOR_PORT PORTC
#define MCONT_CONTACTOR_PORT PORTD

#define ARRAY_PRECHARGE_BYPASS_PIN GPIO_Pin_11
#define MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN GPIO_Pin_2

#define FOREACH_contactor(contactor) \
contactor(ARRAY_PRECHARGE_BYPASS_CONTACTOR), \
Expand Down
54 changes: 0 additions & 54 deletions Drivers/Inc/GPIOExpander.h

This file was deleted.

15 changes: 9 additions & 6 deletions Drivers/Src/Contactors.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static OS_MUTEX contactorsMutex;
static void setContactor(contactor_t contactor, bool state) {
switch (contactor) {
case ARRAY_PRECHARGE_BYPASS_CONTACTOR :
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, state);
BSP_GPIO_Write_Pin(ARRAY_CONTACTOR_PORT, ARRAY_PRECHARGE_BYPASS_PIN, state);
break;
case MOTOR_CONTROLLER_PRECHARGE_BYPASS_CONTACTOR :
BSP_GPIO_Write_Pin(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, state);
BSP_GPIO_Write_Pin(MCONT_CONTACTOR_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, state);
break;
default:
break;
Expand All @@ -38,8 +38,11 @@ static void setContactor(contactor_t contactor, bool state) {
* @return None
*/
void Contactors_Init() {
BSP_GPIO_Init(CONTACTORS_PORT,
(ARRAY_PRECHARGE_BYPASS_PIN) |
BSP_GPIO_Init(ARRAY_CONTACTOR_PORT,
(ARRAY_PRECHARGE_BYPASS_PIN),
1);

BSP_GPIO_Init(MCONT_CONTACTOR_PORT,
(MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN),
1);

Expand All @@ -66,10 +69,10 @@ bool Contactors_Get(contactor_t contactor) {
switch (contactor) {

case ARRAY_PRECHARGE_BYPASS_CONTACTOR :
state = BSP_GPIO_Get_State(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN);
state = BSP_GPIO_Get_State(ARRAY_CONTACTOR_PORT, ARRAY_PRECHARGE_BYPASS_PIN);
break;
case MOTOR_CONTROLLER_PRECHARGE_BYPASS_CONTACTOR :
state = BSP_GPIO_Get_State(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN);
state = BSP_GPIO_Get_State(MCONT_CONTACTOR_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN);
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion Embedded-Sharepoint
69 changes: 0 additions & 69 deletions Tests/Test_App_FaultState.c

This file was deleted.

Loading
Loading