moved libraries to .h

This commit is contained in:
hamza 2024-06-03 01:31:54 +03:00
parent cdf15b1860
commit f52abb8ef0
4 changed files with 21 additions and 18 deletions

View File

@ -11,6 +11,12 @@
#include "ADBMS_Abstraction.h"
#include "ADBMS_CMD_MAKROS.h"
#include "ADBMS_LL_Driver.h"
#include "can.h"
#include "TMP1075.h"
#include "can-halal.h"
#include "errors.h"
#include "stm32f3xx_hal.h"
#include <stdint.h>
typedef enum {
AMSDEACTIVE,

View File

@ -1,8 +1,12 @@
#ifndef INC_CAN_H
#define INC_CAN_H
#include "stm32f3xx_hal.h"
#include <string.h>
#include <stdint.h>
#include "stm32f3xx_hal.h"
#include "stm32f3xx_hal_can.h"
#include "stm32f3xx_hal_def.h"
#include "ADBMS_Abstraction.h"
#include "main.h"
#include "state_machine.h"
#include "can-halal.h"

View File

@ -6,14 +6,7 @@
*/
#include "AMS_HighLevel.h"
#include "ADBMS_Abstraction.h"
#include "ADBMS_LL_Driver.h"
#include "can.h"
#include "TMP1075.h"
#include "can-halal.h"
#include "errors.h"
#include "stm32f3xx_hal.h"
#include <stdint.h>
Cell_Module module = {};
uint32_t balancedCells = 0;

View File

@ -5,15 +5,14 @@
*/
#include "can.h"
#include "ADBMS_Abstraction.h"
#include "state_machine.h"
#include "stm32f3xx_hal.h"
//#define CAN_ID_IN 0x501
//#define CAN_ID_OUT 0x502
int can_delay_manager = 0;
void can_init(CAN_HandleTypeDef* hcan) { ftcan_init(hcan); }
void can_init(CAN_HandleTypeDef* hcan) {
ftcan_init(hcan);
ftcan_add_filter(CAN_ID_IN, 0xFFF);
}
/*
This function sends the status of the mvbms, the battery and of powerground.
once every 1s in states: INACTIVE, PRECHARGE, DISCHARGE, CHARGING, ERROR.
@ -43,8 +42,8 @@ void can_handle_send_status() {
uint8_t data[8] = {};
data[0] = (state.current_state << 5); // save 5 bit since codes are from 0-7 61 bits left
//data[1] = // in 8 bits from 0-100%
data[2] = mV_from_ADBMS6830(RELAY_BAT_SIDE_VOLTAGE); // Battery voltage 16 bit 45 bit
data[4] = CURRENT_MEASUREMENT; // 16 bit measurement
ftcan_marshal_unsigned(&data[2], RELAY_BAT_SIDE_VOLTAGE, 2); // Battery voltage 16 bit 45 bit
ftcan_marshal_unsigned(&data[4], CURRENT_MEASUREMENT, 2); // 16 bit measurement
int8_t id = -1;
int16_t temp = INT16_MIN;
@ -60,12 +59,13 @@ to the sm_handle_ams_in() which handles the state machine transition.
void can_handle_recieve_command(const uint8_t *data){
if (data[0] == 0x00 && data[1] == 0x00){
sm_handle_ams_in(data);
} else if (data[0] == 0b1000000 && data[1] == 0x00){
} else if (data[0] == 0b10000000 && data[1] == 0x00){
sm_handle_ams_in(data);
} else if (data[0] == 0b1100000 && data[1] <= 100) {
} else if (data[0] == 0b11000000 && data[1] <= 100) {
sm_handle_ams_in(data);
}
}
/*
implements the _weak method ftcan_msg_recieved_cb() which throws an interrupt when a CAN message is recieved.
it only checks if the id is and datalen is correct thans hands data over to can_handle_recieve_command().