Added current factors. Various fixes for temperature monitor. Added partial implementation for can1 and can2
This commit is contained in:
56
Core/Inc/can.h
Normal file
56
Core/Inc/can.h
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Created by enik on 02.06.22.
|
||||
//
|
||||
|
||||
#ifndef USBCANV1_CAN_H
|
||||
#define USBCANV1_CAN_H
|
||||
|
||||
//#include "libs.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
typedef uint8_t u8_t; ///< 8-bit unsigned
|
||||
typedef int8_t i8_t; ///< 8-bit signed
|
||||
typedef uint16_t u16_t; ///< 16-bit unsigned
|
||||
typedef int16_t i16_t; ///< 16-bit signed
|
||||
typedef uint32_t u32_t; ///< 32-bit unsigned
|
||||
typedef int32_t i32_t; ///< 32-bit signed
|
||||
typedef float fl_t; ///< float type
|
||||
|
||||
#define __USR_BKPT() __asm__ __volatile__("BKPT")
|
||||
|
||||
|
||||
/**
|
||||
* @brief CAN Speed in KBit/s
|
||||
*/
|
||||
typedef enum CAN_SPEED {
|
||||
CAN_SPD_1000,
|
||||
CAN_SPD_800,
|
||||
CAN_SPD_500,
|
||||
CAN_SPD_250,
|
||||
CAN_SPD_125,
|
||||
CAN_SPD_100,
|
||||
CAN_SPD_50,
|
||||
CAN_SPD_20,
|
||||
CAN_SPD_10,
|
||||
} CAN_SPEED;
|
||||
|
||||
void CAN_SetSpeed(CAN_SPEED spd, CAN_HandleTypeDef *can); //
|
||||
void CAN_SetMode(bool is_silent, CAN_HandleTypeDef *can); //
|
||||
void CAN_SetLoopback(bool is_loopback, CAN_HandleTypeDef *can); //
|
||||
bool CAN_IsOpened(CAN_HandleTypeDef *can); //
|
||||
bool CAN_IsSilent(CAN_HandleTypeDef *can); //
|
||||
bool CAN_IsLoopback(CAN_HandleTypeDef *can); //
|
||||
|
||||
void CAN_SetFilterMode(bool id_only, CAN_HandleTypeDef *can); //
|
||||
void CAN_SetFilterID(u8_t *filt_id, CAN_HandleTypeDef *can); //
|
||||
void CAN_SetFilterMask(u8_t *filt_mask, CAN_HandleTypeDef *can); //
|
||||
|
||||
void CAN_Transmit(u32_t id, u8_t *data, u8_t len, CAN_HandleTypeDef *can); //
|
||||
void CAN_TransmitExt(u32_t id, u8_t *data, u8_t len, CAN_HandleTypeDef *can); //
|
||||
void CAN_TransmitRTR(u32_t id, u8_t len, CAN_HandleTypeDef *can); //
|
||||
void CAN_TransmitExtRTR(u32_t id, u8_t len, CAN_HandleTypeDef *can); //
|
||||
|
||||
#endif //USBCANV1_CAN_H
|
||||
@@ -21,7 +21,7 @@
|
||||
//#define ADDR_FLASH_PAGE_2 ((uint32_t)0x0807E000) /* Base @ of Page 252, 2 Kbytes */
|
||||
|
||||
|
||||
#define ADDR_EEPROM_PAGE_0 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
#define ADDR_EEPROM_PAGE_0 ((uint32_t)0x0803E000) /* Base @ of Page 125, 2 Kbytes */
|
||||
#define ADDR_EEPROM_PAGE_1 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */
|
||||
//#define ADDR_EEPROM_PAGE_2 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
|
||||
@@ -287,7 +287,7 @@
|
||||
//#define ADDR_FLASH_PAGE_255 ((uint32_t)0x0807F800) /* Base @ of Page 255, 2 Kbytes */
|
||||
|
||||
/* Define the size of the sectors to be used */
|
||||
#define PAGE_SIZE (uint32_t)FLASH_PAGE_SIZE /* Page size */
|
||||
#define PAGE_SIZE (uint32_t)FLASH_PAGE_SIZE * 2 /* Page size */ // Extended to 4KB
|
||||
|
||||
/* EEPROM start address in Flash */
|
||||
#define EEPROM_START_ADDRESS ((uint32_t)ADDR_EEPROM_PAGE_0) /* EEPROM emulation start address */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
// Settings
|
||||
#define PACKET_RX_TIMEOUT 10
|
||||
#define PACKET_HANDLERS 2
|
||||
#define PACKET_HANDLERS 1
|
||||
#define PACKET_MAX_PL_LEN 1024
|
||||
|
||||
// Functions
|
||||
|
||||
@@ -152,6 +152,11 @@ typedef struct {
|
||||
bool heatingOutputChecked;
|
||||
int16_t heatingStartThreshold;
|
||||
int16_t heatingStopThreshold;
|
||||
|
||||
float floatCurrentK1; // First factor of current calculation
|
||||
float floatCurrentK2; // Second factor of current calculation
|
||||
|
||||
// uint8_t dummy;
|
||||
} modConfigGeneralConfigStructTypedef;
|
||||
|
||||
modConfigGeneralConfigStructTypedef* modConfigInit(void);
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#define NoOfExpPossibleOnBMS 72
|
||||
#define NoOfExpMonitorPossibleOnBMS 9
|
||||
|
||||
#define NoOfTempSensors 14
|
||||
#define NoOfTempSensors 16
|
||||
#define VinErrorThreshold 10
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "libPacket.h"
|
||||
#include "modCommands.h"
|
||||
|
||||
#define PACKET_HANDLER_UART 1
|
||||
#define PACKET_HANDLER_UART 0
|
||||
|
||||
typedef enum {
|
||||
MESSAGE_DEBUG = 0,
|
||||
|
||||
Reference in New Issue
Block a user