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

Onboard #70

Merged
merged 12 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
37 changes: 37 additions & 0 deletions Core/Inc/can_handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef CAN_HANDLER_H
#define CAN_HANDLER_H

#include "can.h"
#include "stm32f4xx_hal.h"
#include <stdint.h>


#define NUM_INBOUND_CAN1_IDS 1
#define NUM_INBOUND_CAN2_IDS 1

extern CAN_HandleTypeDef hcan1;
extern CAN_HandleTypeDef hcan2;

extern ringbuffer_t* can1_rx_queue;
extern ringbuffer_t* can2_rx_queue;

static const uint16_t can1_id_list[NUM_INBOUND_CAN1_IDS] = {
//CANID_X,
0x0000
};

static const uint16_t can2_id_list[NUM_INBOUND_CAN2_IDS] = {
//CANID_X,
0x0000
};


void can_receive_callback(CAN_HandleTypeDef *hcan);

/* for 1st CAN bus */
int8_t get_can1_msg();

/* for 2nd CAN bus */
int8_t get_can2_msg();

#endif // CAN_HANDLER_H
1 change: 1 addition & 0 deletions Core/Inc/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "datastructs.h"
#include "stateMachine.h"
#include "ringbuffer.h"

#define CURRENT_SENSOR_PIN_L A1
#define CURRENT_SENSOR_PIN_H A0
Expand Down
242 changes: 121 additions & 121 deletions Core/Inc/main.h
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdlib.h>
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define FPGA_Reset_Pin GPIO_PIN_13
#define FPGA_Reset_GPIO_Port GPIOC
#define Communication_GPIO_Pin GPIO_PIN_14
#define Communication_GPIO_GPIO_Port GPIOC
#define Communication_GPIOC15_Pin GPIO_PIN_15
#define Communication_GPIOC15_GPIO_Port GPIOC
#define Communication_GPIOC0_Pin GPIO_PIN_0
#define Communication_GPIOC0_GPIO_Port GPIOC
#define SPI_2_CS_Pin GPIO_PIN_1
#define SPI_2_CS_GPIO_Port GPIOC
#define Interlock_Read_Pin GPIO_PIN_2
#define Interlock_Read_GPIO_Port GPIOA
#define Fault_Output_Pin GPIO_PIN_3
#define Fault_Output_GPIO_Port GPIOA
#define SPI_1_CS_Pin GPIO_PIN_4
#define SPI_1_CS_GPIO_Port GPIOA
#define Debug_LED_Pin GPIO_PIN_4
#define Debug_LED_GPIO_Port GPIOC
#define I_Sense_Pin GPIO_PIN_5
#define I_Sense_GPIO_Port GPIOC
#define I_SenseB0_Pin GPIO_PIN_0
#define I_SenseB0_GPIO_Port GPIOB
#define I_SenseB1_Pin GPIO_PIN_1
#define I_SenseB1_GPIO_Port GPIOB
#define I_SenseB2_Pin GPIO_PIN_2
#define I_SenseB2_GPIO_Port GPIOB
#define Debug_LEDB11_Pin GPIO_PIN_11
#define Debug_LEDB11_GPIO_Port GPIOB
#define Watchdog_Out_Pin GPIO_PIN_14
#define Watchdog_Out_GPIO_Port GPIOB
#define Fan_PWM_Pin GPIO_PIN_6
#define Fan_PWM_GPIO_Port GPIOC
#define Fan_PWMC7_Pin GPIO_PIN_7
#define Fan_PWMC7_GPIO_Port GPIOC
#define Fan_PWMC8_Pin GPIO_PIN_8
#define Fan_PWMC8_GPIO_Port GPIOC
#define Fan_PWMC9_Pin GPIO_PIN_9
#define Fan_PWMC9_GPIO_Port GPIOC
#define Fan_PWMA8_Pin GPIO_PIN_8
#define Fan_PWMA8_GPIO_Port GPIOA
#define Fan_PWMA10_Pin GPIO_PIN_10
#define Fan_PWMA10_GPIO_Port GPIOA
#define SPI_3_CS_Pin GPIO_PIN_15
#define SPI_3_CS_GPIO_Port GPIOA
#define External_GPIO_Pin GPIO_PIN_2
#define External_GPIO_GPIO_Port GPIOD
#define External_GPIOB3_Pin GPIO_PIN_3
#define External_GPIOB3_GPIO_Port GPIOB
#define External_GPIOB4_Pin GPIO_PIN_4
#define External_GPIOB4_GPIO_Port GPIOB
#define External_GPIOB5_Pin GPIO_PIN_5
#define External_GPIOB5_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdlib.h>
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define FPGA_Reset_Pin GPIO_PIN_13
#define FPGA_Reset_GPIO_Port GPIOC
#define Communication_GPIO_Pin GPIO_PIN_14
#define Communication_GPIO_GPIO_Port GPIOC
#define Communication_GPIOC15_Pin GPIO_PIN_15
#define Communication_GPIOC15_GPIO_Port GPIOC
#define Communication_GPIOC0_Pin GPIO_PIN_0
#define Communication_GPIOC0_GPIO_Port GPIOC
#define SPI_2_CS_Pin GPIO_PIN_1
#define SPI_2_CS_GPIO_Port GPIOC
#define Interlock_Read_Pin GPIO_PIN_2
#define Interlock_Read_GPIO_Port GPIOA
#define Fault_Output_Pin GPIO_PIN_3
#define Fault_Output_GPIO_Port GPIOA
#define SPI_1_CS_Pin GPIO_PIN_4
#define SPI_1_CS_GPIO_Port GPIOA
#define Debug_LED_Pin GPIO_PIN_4
#define Debug_LED_GPIO_Port GPIOC
#define I_Sense_Pin GPIO_PIN_5
#define I_Sense_GPIO_Port GPIOC
#define I_SenseB0_Pin GPIO_PIN_0
#define I_SenseB0_GPIO_Port GPIOB
#define I_SenseB1_Pin GPIO_PIN_1
#define I_SenseB1_GPIO_Port GPIOB
#define I_SenseB2_Pin GPIO_PIN_2
#define I_SenseB2_GPIO_Port GPIOB
#define Debug_LEDB11_Pin GPIO_PIN_11
#define Debug_LEDB11_GPIO_Port GPIOB
#define Watchdog_Out_Pin GPIO_PIN_14
#define Watchdog_Out_GPIO_Port GPIOB
#define Fan_PWM_Pin GPIO_PIN_6
#define Fan_PWM_GPIO_Port GPIOC
#define Fan_PWMC7_Pin GPIO_PIN_7
#define Fan_PWMC7_GPIO_Port GPIOC
#define Fan_PWMC8_Pin GPIO_PIN_8
#define Fan_PWMC8_GPIO_Port GPIOC
#define Fan_PWMC9_Pin GPIO_PIN_9
#define Fan_PWMC9_GPIO_Port GPIOC
#define Fan_PWMA8_Pin GPIO_PIN_8
#define Fan_PWMA8_GPIO_Port GPIOA
#define Fan_PWMA10_Pin GPIO_PIN_10
#define Fan_PWMA10_GPIO_Port GPIOA
#define SPI_3_CS_Pin GPIO_PIN_15
#define SPI_3_CS_GPIO_Port GPIOA
#define External_GPIO_Pin GPIO_PIN_2
#define External_GPIO_GPIO_Port GPIOD
#define External_GPIOB3_Pin GPIO_PIN_3
#define External_GPIOB3_GPIO_Port GPIOB
#define External_GPIOB4_Pin GPIO_PIN_4
#define External_GPIOB4_GPIO_Port GPIOB
#define External_GPIOB5_Pin GPIO_PIN_5
#define External_GPIOB5_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
5 changes: 4 additions & 1 deletion Core/Inc/stateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "analyzer.h"
#include "timer.h"

/* global that can be read for debugging in main */
extern BMSState_t current_state;

#define NUM_FAULTS 8

/**
Expand Down Expand Up @@ -43,7 +46,7 @@ uint32_t sm_fault_return(acc_data_t *accData);
* @param index
* @return fault_code
*/
uint32_t sm_fault_eval(fault_eval_t index);
uint32_t sm_fault_eval(fault_eval_t* index);

/**
* @brief handles the state machine, calls the appropriate handler function and runs every loop functions
Expand Down
Loading
Loading