global refactoring
This commit is contained in:
@@ -21,5 +21,7 @@ void Init_Peripheral();
|
||||
uint8_t GBT_LockGetState();
|
||||
void GBT_Lock(uint8_t state);
|
||||
uint8_t SW_GetAddr();
|
||||
void ADC_Select_Channel(uint32_t ch);
|
||||
|
||||
|
||||
#endif /* SRC_BOARD_H_ */
|
||||
|
||||
@@ -8,6 +8,21 @@
|
||||
#ifndef INC_CHARGER_GBT_H_
|
||||
#define INC_CHARGER_GBT_H_
|
||||
#include "main.h"
|
||||
#include "connector.h"
|
||||
|
||||
#define GBT_CST_NO_REASON 0x0000F0F0
|
||||
#define GBT_CST_CONDITION_REACHED 0x0100F0F0 // заряд завершен
|
||||
#define GBT_CST_SUSPENDS_ARTIFICIALLY 0x0400F0F0
|
||||
#define GBT_CST_FAULT_SUSPENSION 0x1000F0F0
|
||||
#define GBT_CST_BMS_ACTIVELY_SUSPENDS 0x4000F0F0 //завершение по инициативе BMS
|
||||
#define GBT_CST_CONNECTOR_OVER_TEMP 0x0001F0F0
|
||||
#define GBT_CST_INT_PART_OVER_TEMP 0x0010F0F0
|
||||
#define GBT_CST_CANNOT_SUPPLY_REQ_ELQ 0x0040F0F0
|
||||
#define GBT_CST_SUDDENSTOP 0x0000F1F0
|
||||
#define GBT_CST_OTHERFALUT 0x0000F4F0
|
||||
#define GBT_CST_CURRENT_MISMATCH 0x0000F0F1
|
||||
#define GBT_CST_ABNORMALVOLTAGEERROR 0x0000F0F4
|
||||
|
||||
|
||||
typedef enum{
|
||||
GBT_CC_UNKNOWN,
|
||||
@@ -19,20 +34,22 @@ typedef enum{
|
||||
}gbtCcState_t;
|
||||
|
||||
typedef enum{
|
||||
GBT_DISABLED,
|
||||
GBT_S0_UNCONNECTED, //СС1 12V/6V СС2 12V
|
||||
GBT_S1_CONNECTED, //СС1 4V СС2 4V (6V)
|
||||
GBT_S2_LOCKED, //
|
||||
GBT_S3_STARTED, // 12V AUX
|
||||
GBT_S4_ISOTEST, // testing isolation, send CHM receive BHM
|
||||
GBT_S5_BAT_INFO, // identifying BMS, send CRM receive BRM (long)
|
||||
GBT_S6_BAT_STAT, // send CRM(AA), receive BCP (long)
|
||||
GBT_S7_BMS_WAIT, // wait for BMS, send CTS+CML receive BRO(00), next BRO(AA)
|
||||
GBT_S8_INIT_CHARGER,// starting power modules, send CRO(00)
|
||||
GBT_S9_WAIT_BCL, // waiting for BCL (requested voltage), send CRO(00)
|
||||
GBT_S10_CHARGING, // charging, contactor ON, send CCS, receiving BCL+BCS+BSM
|
||||
GBT_STOP, // stop
|
||||
//TODO: after stop send BSD state
|
||||
GBT_DISABLED = 0x10,
|
||||
// GBT_S0_UNCONNECTED = 0x10, //СС1 12V/6V СС2 12V
|
||||
// GBT_S1_CONNECTED = 0x11, //СС1 4V СС2 4V (6V)
|
||||
// GBT_S2_LOCKED = 0x12, //
|
||||
GBT_S3_STARTED = 0x13, // 12V AUX
|
||||
GBT_S4_ISOTEST = 0x14, // testing isolation, send CHM receive BHM
|
||||
GBT_S5_BAT_INFO = 0x15, // identifying BMS, send CRM receive BRM (long)
|
||||
GBT_S6_BAT_STAT = 0x16, // send CRM(AA), receive BCP (long)
|
||||
GBT_S7_BMS_WAIT = 0x17, // wait for BMS, send CTS+CML receive BRO(00), next BRO(AA)
|
||||
GBT_S8_INIT_CHARGER = 0x18,// starting power modules, send CRO(00)
|
||||
GBT_S9_WAIT_BCL = 0x19, // waiting for BCL (requested voltage), send CRO(00)
|
||||
GBT_S10_CHARGING = 0x20, // charging, contactor ON, send CCS, receiving BCL+BCS+BSM
|
||||
GBT_STOP = 0x21, // normal stop
|
||||
GBT_STOP_CSD = 0x22, // normal stop
|
||||
GBT_ERROR = 0x23, // Error
|
||||
GBT_COMPLETE = 0x24,
|
||||
|
||||
}gbtState_t;
|
||||
|
||||
@@ -46,7 +63,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint8_t bmsIdentified;
|
||||
char chargerNumber[4];
|
||||
uint32_t chargerNumber;
|
||||
char chargerLocation[3];
|
||||
}GBT_CRM_t;
|
||||
|
||||
@@ -124,6 +141,12 @@ typedef struct {
|
||||
|
||||
}GBT_CCS_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t chargingTime;
|
||||
uint16_t outputEnergy;
|
||||
uint32_t chargerNumber;
|
||||
}GBT_CSD_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t enablePSU;
|
||||
@@ -135,6 +158,9 @@ typedef struct {
|
||||
uint16_t chargingElapsedTimeMin; //
|
||||
uint8_t chargingElapsedTimeSec; //
|
||||
|
||||
CONN_State_t connectorState;
|
||||
|
||||
|
||||
}GBT_EDCAN_Output_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -142,9 +168,11 @@ typedef struct {
|
||||
uint16_t measuredVoltage; // 0.1V/bit
|
||||
uint16_t measuredCurrent; // 0.1A/bit
|
||||
|
||||
CONN_Control_t chargeControl;
|
||||
|
||||
}GBT_EDCAN_Input_t;
|
||||
|
||||
|
||||
/* 500 - Power Supply
|
||||
TX
|
||||
* PSU_ENABLE
|
||||
@@ -170,6 +198,8 @@ RX
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
extern gbtState_t GBT_State;
|
||||
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
|
||||
extern GBT_BRM_t GBT_EVInfo;
|
||||
@@ -180,30 +210,38 @@ extern GBT_CML_t GBT_MaxLoad;
|
||||
extern GBT_CCS_t GBT_ChargerCurrentStatus;
|
||||
extern GBT_CRM_t GBT_ChargerInfo;
|
||||
extern GBT_BSM_t GBT_BatteryStatus;
|
||||
extern GBT_CSD_t GBT_ChargerStop;
|
||||
|
||||
extern uint8_t GBT_BRO;
|
||||
|
||||
extern uint8_t GBT_Charger_Enable;
|
||||
|
||||
void GBT_Init();
|
||||
void GBT_Start();
|
||||
void GBT_Stop();
|
||||
void GBT_Stop1();
|
||||
void GBT_Reset();
|
||||
void GBT_Stop(uint32_t causecode);
|
||||
void GBT_ForceStop();
|
||||
void GBT_ChargerTask();
|
||||
float GBT_CC_GetAdc();
|
||||
void ADC_Select_Channel(uint32_t ch);
|
||||
uint8_t GBT_CC_GetState();
|
||||
void GBT_Error(uint32_t errorcode);
|
||||
|
||||
//float GBT_CC_GetAdc();
|
||||
|
||||
//uint8_t GBT_CC_GetState();
|
||||
|
||||
void GBT_SwitchState(gbtState_t state);
|
||||
void GBT_Delay(uint32_t delay);
|
||||
uint32_t GBT_StateTick();
|
||||
void J_SendPacket(uint32_t PGN, uint8_t pri, uint8_t DLC, uint8_t *data);
|
||||
|
||||
void GBT_SendCCS();
|
||||
void GBT_SendCST();
|
||||
void GBT_SendCST(uint32_t Cause);
|
||||
void GBT_SendCRO(uint8_t state);
|
||||
void GBT_SendCML();
|
||||
void GBT_SendCTS();
|
||||
void GBT_SendCHM();
|
||||
void GBT_SendCRM(uint8_t state);
|
||||
|
||||
void GBT_SendCSD();
|
||||
void GBT_SendCEM(uint32_t ErrorCode);
|
||||
|
||||
|
||||
#endif /* INC_CHARGER_GBT_H_ */
|
||||
|
||||
49
Core/Inc/connector.h
Normal file
49
Core/Inc/connector.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* connector.h
|
||||
*
|
||||
* Created on: Jul 31, 2024
|
||||
* Author: colorbass
|
||||
*/
|
||||
|
||||
#ifndef INC_CONNECTOR_H_
|
||||
#define INC_CONNECTOR_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
||||
// Статус
|
||||
// статус подключения к автомобилю
|
||||
|
||||
typedef enum __attribute__((packed)) {
|
||||
CONN_Initializing = 1,
|
||||
CONN_Error = 2,
|
||||
CONN_Available = 3,
|
||||
CONN_Occupied_waiting = 4,// to charge
|
||||
CONN_Occupied_charging = 5,
|
||||
CONN_Occupied_complete = 6,//, waiting to disconnect
|
||||
|
||||
} CONN_State_t;
|
||||
|
||||
// Управление
|
||||
// Разрешение на зарядку
|
||||
|
||||
typedef enum __attribute__((packed)) {
|
||||
CHARGING_NOT_ALLOWED = 1,
|
||||
CHARGING_ALLOWED = 2,
|
||||
FORCE_UNLOCK = 3,
|
||||
|
||||
} CONN_Control_t;
|
||||
#include "charger_gbt.h"
|
||||
|
||||
|
||||
extern CONN_State_t connectorState;
|
||||
|
||||
void CONN_Init();
|
||||
void CONN_Task();
|
||||
void CONN_SetState(CONN_State_t state);
|
||||
uint8_t CONN_CC_GetStateRaw();
|
||||
uint8_t CONN_CC_GetState();
|
||||
float CONN_CC_GetAdc();
|
||||
|
||||
#endif /* INC_CONNECTOR_H_ */
|
||||
@@ -10,4 +10,8 @@
|
||||
//#define ED_CAN1
|
||||
#define ED_CAN2
|
||||
|
||||
extern CAN_HandleTypeDef hcan2;
|
||||
#define ED_CAN_INSTANCE hcan2
|
||||
|
||||
|
||||
#endif //EDCAN_CONFIG_H
|
||||
|
||||
@@ -35,5 +35,6 @@ void J_SendACK(j_receive_t rx);
|
||||
|
||||
|
||||
void GBT_CAN_ReInit();
|
||||
void GBT_CAN_FilterInit();
|
||||
|
||||
#endif /* INC_J1939_H_ */
|
||||
|
||||
28
Core/Inc/lock.h
Normal file
28
Core/Inc/lock.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* lock.h
|
||||
*
|
||||
* Created on: Jul 31, 2024
|
||||
* Author: colorbass
|
||||
*/
|
||||
|
||||
#ifndef INC_LOCK_H_
|
||||
#define INC_LOCK_H_
|
||||
|
||||
#include "main.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
|
||||
void GBT_Lock(uint8_t state);
|
||||
void GBT_ManageLock();
|
||||
uint8_t GBT_LockGetState();
|
||||
void GBT_ForceLock(uint8_t state);
|
||||
|
||||
typedef struct {
|
||||
// uint8_t state;
|
||||
uint8_t demand;
|
||||
uint8_t error;
|
||||
} GBT_LockState_t;
|
||||
|
||||
extern GBT_LockState_t GBT_LockState;
|
||||
|
||||
#endif /* INC_LOCK_H_ */
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#include <stdio.h>
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
52
Core/Inc/rtc.h
Normal file
52
Core/Inc/rtc.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtc.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the rtc.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 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 __RTC_H__
|
||||
#define __RTC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_RTC_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RTC_H__ */
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
/*#define HAL_HCD_MODULE_ENABLED */
|
||||
/*#define HAL_PWR_MODULE_ENABLED */
|
||||
/*#define HAL_RCC_MODULE_ENABLED */
|
||||
/*#define HAL_RTC_MODULE_ENABLED */
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
/*#define HAL_SD_MODULE_ENABLED */
|
||||
/*#define HAL_MMC_MODULE_ENABLED */
|
||||
/*#define HAL_SDRAM_MODULE_ENABLED */
|
||||
|
||||
Reference in New Issue
Block a user