Moved firmware to subfoler firmware
This commit is contained in:
88
firmware/Core/Inc/DPC_Timeout.h
Normal file
88
firmware/Core/Inc/DPC_Timeout.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @file Timeout.h
|
||||
* @author Smart Power - SRA CL
|
||||
* @version V1.0.0
|
||||
* @date 18-Dec-2019
|
||||
* @brief .
|
||||
* @details
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* THIS SOURCE CODE IS PROTECTED BY A LICENSE.
|
||||
* FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED
|
||||
* IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2019 STMicroelectronics</center></h2>
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMEOUT_H
|
||||
#define __TIMEOUT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
|
||||
|
||||
/** @defgroup Exported_Tyoedef Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
typedef enum{
|
||||
TO_OFF = 0,
|
||||
TO_RUN,
|
||||
TO_TOOK
|
||||
} TO_STATE;
|
||||
|
||||
typedef struct{
|
||||
uint32_t Count;
|
||||
TO_STATE State;
|
||||
} TimeoutDataStr_T;
|
||||
|
||||
|
||||
|
||||
typedef enum{
|
||||
TO_OUT_ERR = 0,
|
||||
TO_OUT_OK,
|
||||
TO_OUT_TOOK
|
||||
} TO_RET_STATE;
|
||||
|
||||
#define TO_MAX_NUMBER 10
|
||||
|
||||
#define TO_LED 0
|
||||
#define TO_COM 1
|
||||
#define TO_UART 2
|
||||
#define TO_AT_TIMEOUT 3
|
||||
#define TO_SIM_TIMEOUT 4
|
||||
#define TO_HTTP_PARAM 5
|
||||
#define TO_SD_Card 6
|
||||
#define TO_SD_Filename 7
|
||||
|
||||
#define TEL_TIMEOUT_VAL 200
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
void DPC_TO_Init(void);
|
||||
TO_RET_STATE DPC_TO_Set(uint8_t TO_Num, uint32_t Val);
|
||||
TO_RET_STATE DPC_TO_Check(uint8_t TO_Num);
|
||||
void TimeoutMng(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif //TELEMETRY
|
||||
|
||||
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/
|
||||
385
firmware/Core/Inc/GSM.h
Normal file
385
firmware/Core/Inc/GSM.h
Normal file
@@ -0,0 +1,385 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file GSM.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the GSM.c file
|
||||
******************************************************************************
|
||||
*1. define SIM800_Global_Struct
|
||||
*2. start init functions
|
||||
SIM800_Var_Init(&SIM800_Struct);
|
||||
HTTP_Data_Init(&SIM800_Struct);
|
||||
*3. DPC_TO_Init();
|
||||
*4.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef __GSMMODULE_H
|
||||
#define __GSMMODULE_H
|
||||
|
||||
#include "main.h"
|
||||
#include "modconfig.h"
|
||||
|
||||
//#include "string.h"
|
||||
//#include "stdlib.h"
|
||||
|
||||
#define SIM_RESET_TIMEOUT 120000 //ms
|
||||
#define SIM_NETWORK_CHECK_TIMEOUT 120000
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t SIM_RX_Flag;
|
||||
char SIM_answer[1024];
|
||||
char* SIM_command;
|
||||
uint8_t Size;
|
||||
}SIM_Answer_Struct;
|
||||
|
||||
typedef struct {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t timezone;
|
||||
}Time_Struct;
|
||||
|
||||
typedef struct{
|
||||
char* Serial_Number;
|
||||
char* Battery_Condition_ID;
|
||||
char* Event_time;
|
||||
char* Started_At_Time;
|
||||
char* Ended_At_Time;
|
||||
char* Status_Indication;
|
||||
char* Energy_Sum;
|
||||
char* Battery_Level_At_Start;
|
||||
char* Battery_Level_At_End;
|
||||
char* Battery_Voltage_At_Start;
|
||||
char* Battery_Voltage_At_End;
|
||||
char* Battery_Temperature_At_End;
|
||||
char* Latitude;
|
||||
char* Longitude;
|
||||
char* Maximum_Load_Current;
|
||||
char* Maximum_Charge_Current;
|
||||
char* Internal_Resistance;
|
||||
char* Moderated;
|
||||
char* Current_time;
|
||||
|
||||
char Serial_Number_var[10];
|
||||
char Battery_Condition_ID_var[10];
|
||||
char Event_time_var[30];
|
||||
char Started_At_Time_var[30];
|
||||
char Ended_At_Time_var[30];
|
||||
char Status_Indication_var[10];
|
||||
char Energy_Sum_var[10];
|
||||
char Battery_Level_At_Start_var[10];
|
||||
char Battery_Level_At_End_var[10];
|
||||
char Battery_Voltage_At_Start_var[10];
|
||||
char Battery_Voltage_At_End_var[10];
|
||||
char Battery_Temperature_At_End_var[10];
|
||||
char Latitude_var[10];
|
||||
char Longitude_var[10];
|
||||
char Maximum_Load_Current_var[10];
|
||||
char Maximum_Charge_Current_var[10];
|
||||
char Internal_Resistance_var[15];
|
||||
char Moderated_var[15];
|
||||
char Current_time_var[30];
|
||||
|
||||
}HTTP_DATA_Struct;
|
||||
|
||||
typedef enum{
|
||||
AT,
|
||||
ATE,
|
||||
ATV,
|
||||
ATW,
|
||||
ATCCLK,
|
||||
ATCMEE2,
|
||||
ATCLTS,
|
||||
ATCNMI,
|
||||
ATCREG,
|
||||
ATCCID,
|
||||
ATCSQ,
|
||||
ATCOPS,
|
||||
ATCOPS_Manual,
|
||||
ATHTTPSTATUS,
|
||||
|
||||
ATCGATT_check,
|
||||
ATCGATT_disconnect,
|
||||
ATCGATT_connect,
|
||||
ATSAPBR0,
|
||||
ATSAPBR1,
|
||||
ATSAPBR2,
|
||||
ATSAPBR3_1_CONTYPE,
|
||||
ATSAPBR3_1_APN,
|
||||
ATSAPBR3_1_USER,
|
||||
ATSAPBR3_1_PWD,
|
||||
ATSAPBR4_1,
|
||||
|
||||
|
||||
ATHTTP,
|
||||
ATHTTPPARA_CID,
|
||||
ATHTTPPARA_URL,
|
||||
ATHTTPPARA_URL_EVENT,
|
||||
ATHTTPPARA_CONTENT,
|
||||
ATHTTPPARA_USERDATA,
|
||||
ATHTTPPARA_PARAM,
|
||||
ATHTTPDATA,
|
||||
ATHTTPP_ACTION_POST,
|
||||
ATHTTPP_ACTION_GET,
|
||||
DATA0,
|
||||
DATA1,
|
||||
DATA2,
|
||||
ATHTTPREAD,
|
||||
ATHTTPREAD_REQ,
|
||||
ATHTTPHEAD,
|
||||
ATHTTPTERM,
|
||||
ATHTTPSSL,
|
||||
ATHTTPSSLREQUEST,
|
||||
ATCGMR,
|
||||
ATCDNSCFG,
|
||||
ATCDNSCFG_REQ,
|
||||
ATCIFSR,
|
||||
ATCIPSTATUS,
|
||||
ATCSTT,
|
||||
ATCIICR,
|
||||
ATCIPSHUT,
|
||||
ATCIPMUX,
|
||||
ATCIPGSMLOC,
|
||||
|
||||
REQUEST_START,
|
||||
REQUEST_FINISHED,
|
||||
READY_TO_OPERATE,
|
||||
NETWORK_CHECK,
|
||||
|
||||
GPS_Req,
|
||||
GET_ACTUAL_TIME,
|
||||
GPS_LBS_Change
|
||||
} Sim_Stages;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Init_Complete;
|
||||
uint8_t GPRS_Established;
|
||||
uint8_t Permission_to_Send;
|
||||
}SIM800_States;
|
||||
|
||||
//PUT DATA STRUCT
|
||||
typedef struct{
|
||||
uint64_t Serial;
|
||||
uint8_t Battery_cond_ID;
|
||||
Time_Struct Event_time;
|
||||
Time_Struct Started_At_Time;
|
||||
Time_Struct Ended_At_Time;
|
||||
uint8_t Status_Indication;
|
||||
uint16_t Energy_Sum;
|
||||
uint16_t Battery_Level_At_Start;
|
||||
uint16_t Battery_Level_At_End;
|
||||
float Battery_Voltage_At_Start;
|
||||
float Battery_Voltage_At_End;
|
||||
uint16_t Battery_Temperature_At_End;
|
||||
uint16_t Maximum_Load_Current;
|
||||
uint16_t Maximum_Charge_Current;
|
||||
float Internal_Resistance;
|
||||
uint8_t Moderated;
|
||||
}Battery_Data_Struct;
|
||||
|
||||
typedef enum{
|
||||
INITIALISATION,
|
||||
READY,
|
||||
BUSY,
|
||||
SIM_ERROR,
|
||||
COMMAND_SET,
|
||||
COMMAND_NOT_SET
|
||||
}SIM800_Op_States;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* AT ; // "AT\r\n";
|
||||
char* ATV ;// "ATV1\r\n"; //echo turn off
|
||||
char* ATE ;// "ATE0\r\n"; //answer without echo
|
||||
char* ATW ;// "AT&W\r\n"; //save presets to mem
|
||||
char* ATCFUN0;//"AT+CFUN;//0\r\n"; //reboot
|
||||
char* ATCFUN1;//"AT+CFUN;//1\r\n"; //reboot
|
||||
char* ATCMEE2;//"AT+CMEE;//2\r\n"; //return error code
|
||||
char* ATCGREG;//"AT+CGREG?\r\n"; //gprs availability
|
||||
char* ATCOPS;//"AT+COPS?\r\n";
|
||||
char* ATCPAS;//"AT+CPAS\r\n";
|
||||
char* ATCSQ;//"AT+CSQ\r\n";
|
||||
|
||||
//sms
|
||||
char* ATCMGF1;//"AT+CMGF;//1\r\n";
|
||||
char* ATCSMP;//"AT+CSMP;//17,167,0,0\r\n";
|
||||
char* ATCMGFnum;//"AT+CMGS;//\"+79253801217\"\r\n";
|
||||
char* ATCMGFtext;//"Hello\32\r\n";
|
||||
char* ATD;//"ATD+79253801217\r\n";
|
||||
char* ATCSCSUCS2;//"AT+CSCS;//\"UCS2\"\r\n";
|
||||
|
||||
//TIME
|
||||
char* ATCLTS ;// "AT+CLTS;//1\r\n";
|
||||
char* ATCCLK ;// "AT+CCLK?\r\n";
|
||||
//GPS
|
||||
char* ATCLBS;
|
||||
char* ATCLBSCFG;
|
||||
|
||||
//GPRS
|
||||
char* ATCGATT_check;//"AT+CGATT?\r\n";
|
||||
char* ATCGATT_disconnect;
|
||||
char* ATCGATT_connect;//"AT+CGATT;//1\r\n";
|
||||
char* ATSAPBR1;//"AT+SAPBR;//1,1\r\n"; //Set connection
|
||||
char* ATSAPBR2;//"AT+SAPBR;//2,1\r\n"; //get info and IP
|
||||
char* ATSAPBR3_1_CONTYPE;//"AT+SAPBR;//3,1,\"CONTYPE\",\"GPRS\"\r\n"; //CONTYPE gprs connection types
|
||||
char* ATSAPBR3_1_APN;//"AT+SAPBR;//3,1,\"APN\",\"internet.beeline.ru\"\r\n"; //APN connection¤
|
||||
char* ATSAPBR3_1_USER;//"AT+SAPBR;//3,1,\"USER\",\"Beeline\"\r\n"; //
|
||||
char* ATSAPBR3_1_PWD;//"AT+SAPBR;//3,1,\"PWD\",\"Beeline\"\r\n"; //
|
||||
char* ATSAPBR4_1;//"AT+SAPBR;//4,1\r\n"; //current settings
|
||||
char* ATCSTT;
|
||||
char* ATCIICR;
|
||||
char* ATCIPSHUT;
|
||||
char* ATCIPGSMLOC;
|
||||
|
||||
|
||||
//HTTP
|
||||
char* ATHTTP;//"AT+HTTPINIT\r\n"; //init http
|
||||
char* ATHTTPPARA_CID;
|
||||
char* ATHTTPSTATUS;
|
||||
char* ATHTTPPARA_PARAM;
|
||||
char* ATHTTPPARA_URL;
|
||||
char* ATHTTPP_ACTION_POST;
|
||||
char* ATHTTPP_ACTION_GET;
|
||||
|
||||
char* ATHTTPPARA_USERDATA;
|
||||
|
||||
char* ATHTTPPARA_CONTENT; //set the Content-Type field in HTTP header
|
||||
char* ATHTTPPARA_KEY;
|
||||
//after this should return DOWNLOAD - we ready to transmit
|
||||
|
||||
char* DATA2;
|
||||
|
||||
char* ATHTTPACTION; //0-GET 1-POST 2-HEAD
|
||||
char* ATHTTPREAD; //should return 200
|
||||
char* ATHTTPTERM; //close
|
||||
char* ATSAPBR0; //close
|
||||
char* AT_CSCS_GSM;
|
||||
char* ATCUSD102;
|
||||
char* ATCNMI;
|
||||
char* ATCMGL;
|
||||
char* ATCCID;
|
||||
char* ATCREG;
|
||||
char* ATHTTPSSLREQUEST;
|
||||
char* ATHTTPSSL;
|
||||
char* ATCGMR;
|
||||
char* ATCOPS_Manual;
|
||||
char* ATCDNSCFG_REQ;
|
||||
char* ATCDNSCFG;
|
||||
char* ATCIFSR;
|
||||
char* ATCIPSTATUS;
|
||||
char* ATCIPMUX;
|
||||
char* ATHTTPREAD_REQ;
|
||||
char* ATHTTPHEAD;
|
||||
char* ATHTTPPARA_URL_EVENT;
|
||||
char* ATHTTPPARA_URL_EVENT_TEST;
|
||||
char* ATHTTPPARA_URL_TEST;
|
||||
|
||||
char* SE_HTTPDATA;
|
||||
|
||||
char* SE_ENDOFSTRING;
|
||||
char* SE_DATATO;
|
||||
|
||||
|
||||
char* DATA0;
|
||||
char* DATA1; //data to transmit
|
||||
char* ATHTTPDATA0;
|
||||
char* ATHTTPDATA1;
|
||||
char* SE_Length1;
|
||||
char* SE_Length2;
|
||||
|
||||
char DATA0_ch[500];
|
||||
char DATA1_ch[300];
|
||||
char ATHTTPDATA0_ch[100];
|
||||
char ATHTTPDATA1_ch[100];
|
||||
char SE_Length1_ch[100];
|
||||
char SE_Length2_ch[100];
|
||||
char Domain_URL[250];
|
||||
char Domain_URL_Event[250];
|
||||
char GSM_APN[50];
|
||||
char GSM_USER[50];
|
||||
char GSM_PWD[50];
|
||||
|
||||
} AT_Commands_Struct;
|
||||
|
||||
typedef enum{
|
||||
DONOTHING,
|
||||
HTTP_EVENT_POST,
|
||||
HTTP_PARAMETERS_POST,
|
||||
GET_GPS_COORDINATES,
|
||||
GET_TIME,
|
||||
HTTP_PARAMETERS_POST_TEST,
|
||||
HTTP_EVENT_POST_TEST,
|
||||
CHECK_NETWORK_AWAILABILITY
|
||||
}SIM800_Op_Commands;
|
||||
|
||||
typedef struct{
|
||||
Battery_Data_Struct BATTERY_DATA;
|
||||
SIM_Answer_Struct Sim_Answer;
|
||||
Time_Struct Sim_Time;
|
||||
HTTP_DATA_Struct Sim_HTTP_Data;
|
||||
Sim_Stages Sim_Stages_List;
|
||||
SIM800_Op_States Sim_States_to_return;
|
||||
SIM800_States Sim_Main_States;
|
||||
AT_Commands_Struct Sim_At_Commands;
|
||||
uint8_t SIM_RESET_Switch;
|
||||
uint8_t SIM_RESET_Set;
|
||||
uint32_t REQUEST_Timeout;
|
||||
uint8_t REQUEST_Timeout_Active;
|
||||
uint32_t INIT_Timeout;
|
||||
uint8_t INIT_Timeout_Active;
|
||||
uint32_t NORMAL_Timeout;
|
||||
uint8_t NORMAL_Timeout_Active;
|
||||
SIM800_Op_Commands Sim_Active_Command;
|
||||
char* Default_Longitude;
|
||||
char* Default_Latitude;
|
||||
char Raw_var[100];
|
||||
uint8_t Network_Check_Flag;
|
||||
}SIM800_Global_Struct;
|
||||
|
||||
|
||||
|
||||
|
||||
void SIM800_Var_Init(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Send_Command(char* command);
|
||||
void SIM800_Send_Command_Long(char* command);
|
||||
void SIM800_RESET(SIM800_Global_Struct* Sim_Struct);
|
||||
uint8_t SIM800_Received_LOOKFOR(SIM_Answer_Struct* answ, char* LOOKFOR );
|
||||
void SIM800_get_time(SIM_Answer_Struct* answ, Time_Struct* time);
|
||||
void SIM800_Time_To_String(Time_Struct* Time, char* DST);
|
||||
void SIM800_import_time_to_struct(SIM800_Global_Struct* Sim_Struct, Time_Struct* DST);
|
||||
void Battery_Data_Event_Processing(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Parameters_Processing(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Length_Calculating(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Time_Processing(SIM800_Global_Struct* Sim_Struct/*HTTP_DATA_Struct* HTTP_DATA,Time_Struct* time*/);
|
||||
void HTTP_Data_Init(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Get_Coordinates(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Interrupt_Handler(SIM800_Global_Struct* Sim_Struct, uint8_t* UART_Buffer, uint16_t Size);
|
||||
void SIM800_Processing(SIM800_Global_Struct* Sim_Struct, uint8_t* UART_Buf);
|
||||
SIM800_Op_States SIM800_Init(SIM800_Global_Struct* Sim_Struct/*SIM800_States* State, Sim_Stages* CMD_Type, AT_Commands_Struct* AT_CMD ,SIM_Answer_Struct* Answer_Struct, Time_Struct* Time*/);
|
||||
SIM800_Op_States SIM800_Active_Mode(SIM800_Global_Struct* Sim_Struct);
|
||||
SIM800_Op_States SIM800_Set_Command(SIM800_Global_Struct* Sim_Struct, SIM800_Op_Commands CMD, uint32_t Timeout);
|
||||
void Battery_Data_to_String_Converter(SIM800_Global_Struct* Sim_Struct);
|
||||
|
||||
void SetParametersFromConfig(SIM800_Global_Struct* Sim_Struct, modConfigGeneralConfigStructTypedef *Config);
|
||||
|
||||
|
||||
#endif
|
||||
119
firmware/Core/Inc/SD_Card.h
Normal file
119
firmware/Core/Inc/SD_Card.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* SD_Card.h
|
||||
*
|
||||
* Created on: 24 дек. 2021 г.
|
||||
* Author: Николай
|
||||
*/
|
||||
|
||||
#ifndef INC_SD_CARD_H_
|
||||
#define INC_SD_CARD_H_
|
||||
|
||||
#include "GSM.h"
|
||||
#include "fatfs.h"
|
||||
//FATFS
|
||||
|
||||
#define __MIN_FREE_SPACE_REQUIRED 500*1000*1000 //bytes
|
||||
|
||||
FATFS FatFs; //Fatfs handle
|
||||
FIL fil; //File handle
|
||||
FRESULT fres; //Result after operations
|
||||
DIR dir;
|
||||
|
||||
FILINFO flinf;
|
||||
DWORD free_clusters, free_sectors, total_sectors;
|
||||
uint32_t free_space;
|
||||
FATFS* getFreeFs;
|
||||
UINT nRead;
|
||||
char readbuff[1024];
|
||||
uint32_t sizeWritten;
|
||||
unsigned int BytesWr;
|
||||
|
||||
typedef enum{
|
||||
SD_OP_DONOTHING,
|
||||
SD_OP_WRITE_STATUS,
|
||||
SD_OP_WRITE_PARAM,
|
||||
SD_OP_WRITE_HEADER,
|
||||
SD_OP_DELETEOLD,
|
||||
SD_OP_MOUNT,
|
||||
SD_OP_UMOUNT
|
||||
}SD_Op_Commands;
|
||||
|
||||
typedef enum{
|
||||
SD_READY,
|
||||
SD_BUSY,
|
||||
SD_ERROR,
|
||||
SD_COMMAND_SET,
|
||||
SD_COMMAND_NOT_SET
|
||||
}SD_Card_states;
|
||||
|
||||
typedef enum{
|
||||
SD_IDLE,
|
||||
SD_MOUNT,
|
||||
SD_OPEN_DIR,
|
||||
SD_OPEN_FILE,
|
||||
SD_WRITE,
|
||||
SD_WRITE_HEADER,
|
||||
SD_READ,
|
||||
SD_CLOSE,
|
||||
SD_UMOUNT,
|
||||
SD_DELETE_OLD_FILES,
|
||||
SD_CHECK_FREE_SPACE
|
||||
|
||||
} SD_Stages;
|
||||
|
||||
typedef struct{
|
||||
uint64_t Battery_Serial;
|
||||
HTTP_DATA_Struct CSV_DATA;
|
||||
Battery_Data_Struct BATTERY_DATA;
|
||||
char Raw_var[100];
|
||||
SD_Op_Commands SD_Active_Command;
|
||||
SD_Card_states SD_State_to_return;
|
||||
SD_Stages SD_Stages_list;
|
||||
|
||||
uint8_t SD_CARD_ChipDetect;
|
||||
char* DATA0;
|
||||
char DATA0_ch[1000];
|
||||
|
||||
char* Header;
|
||||
char* FileName;
|
||||
char* Path;
|
||||
char Path_ch[100];
|
||||
char Filename_ch[20];
|
||||
uint8_t Mount_Flag;
|
||||
uint8_t Mount_CMD_SET;
|
||||
|
||||
uint8_t Filename_Check_Done;
|
||||
|
||||
FRESULT Fat_result;
|
||||
}SD_CARD_Global_Struct;
|
||||
|
||||
typedef struct{
|
||||
char isDir;
|
||||
|
||||
char fullpath_ch[100];
|
||||
char* fullpath;
|
||||
char filename_ch[13];
|
||||
char* filename;
|
||||
uint32_t value;
|
||||
|
||||
uint32_t FN_Value;
|
||||
uint8_t Lastfound_FN_Month;
|
||||
uint8_t Lastfound_FN_Year;
|
||||
uint8_t Oldest_FN_Month;
|
||||
uint8_t Oldest_FN_Year;
|
||||
uint32_t Oldest_FN_Value;
|
||||
|
||||
}ff_search_struct;
|
||||
|
||||
|
||||
void Battery_Data_to_CSV_Converter(SD_CARD_Global_Struct* Sd_Struct, HTTP_DATA_Struct* DST);
|
||||
void CSV_Status_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct);
|
||||
void CSV_Param_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct);
|
||||
SD_Card_states SD_Set_Command(SD_CARD_Global_Struct* SD_Struct, SD_Op_Commands CMD, uint32_t Timeout);
|
||||
void SD_Card_Processing(SD_CARD_Global_Struct* SD_Struct);
|
||||
uint64_t Filename_to_Value(char* FN);
|
||||
uint8_t Configure_Path_to_delete(char* path, uint32_t Value);
|
||||
void Search_for_Oldest(volatile ff_search_struct* sourceStruct,char* Path, uint64_t ActualSerial);
|
||||
void SD_Update_Path(SD_CARD_Global_Struct* source);
|
||||
|
||||
#endif /* INC_SD_CARD_H_ */
|
||||
56
firmware/Core/Inc/can.h
Normal file
56
firmware/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
|
||||
56
firmware/Core/Inc/dataHelper.h
Normal file
56
firmware/Core/Inc/dataHelper.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t Val;
|
||||
uint8_t v[2];
|
||||
struct
|
||||
{
|
||||
uint8_t LB;
|
||||
uint8_t HB;
|
||||
} byte;
|
||||
} UINT16_VAL;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t Val;
|
||||
uint16_t w[2];
|
||||
uint8_t v[4];
|
||||
struct
|
||||
{
|
||||
uint16_t LW;
|
||||
uint16_t HW;
|
||||
} word;
|
||||
struct
|
||||
{
|
||||
uint8_t LB;
|
||||
uint8_t HB;
|
||||
uint8_t UB;
|
||||
uint8_t MB;
|
||||
} byte;
|
||||
struct
|
||||
{
|
||||
UINT16_VAL low;
|
||||
UINT16_VAL high;
|
||||
}wordUnion;
|
||||
} UINT32_VAL;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint64_t Val;
|
||||
uint32_t d[2];
|
||||
uint16_t w[4];
|
||||
uint8_t v[8];
|
||||
struct
|
||||
{
|
||||
uint32_t LD;
|
||||
uint32_t HD;
|
||||
} dword;
|
||||
struct
|
||||
{
|
||||
uint16_t LW;
|
||||
uint16_t HW;
|
||||
uint16_t UW;
|
||||
uint16_t MW;
|
||||
} word;
|
||||
} UINT64_VAL;
|
||||
2
firmware/Core/Inc/desktop.ini
Normal file
2
firmware/Core/Inc/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
334
firmware/Core/Inc/driverHWEEPROM.h
Normal file
334
firmware/Core/Inc/driverHWEEPROM.h
Normal file
@@ -0,0 +1,334 @@
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DRIVERHWEEPROM_H
|
||||
#define __DRIVERHWEEPROM_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdlib.h"
|
||||
#include "modFlash.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* EEPROM emulation firmware error codes */
|
||||
#define EE_OK (uint32_t)HAL_OK
|
||||
#define EE_ERROR (uint32_t)HAL_ERROR
|
||||
#define EE_BUSY (uint32_t)HAL_BUSY
|
||||
#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
|
||||
|
||||
/* Base address of the Flash sectors */
|
||||
|
||||
//#define ADDR_FLASH_PAGE_0 ((uint32_t)0x0807D000) /* Base @ of Page 250, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_1 ((uint32_t)0x0807D800) /* Base @ of Page 251, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_2 ((uint32_t)0x0807E000) /* Base @ of Page 252, 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 */
|
||||
|
||||
|
||||
//#define ADDR_FLASH_PAGE_253 ((uint32_t)0x0807E800) /* Base @ of Page 253, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_254 ((uint32_t)0x0807F000) /* Base @ of Page 254, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_255 ((uint32_t)0x0807F800) /* Base @ of Page 255, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */ // Startup Code
|
||||
//#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */ // Page0
|
||||
//#define ADDR_FLASH_PAGE_2 ((uint32_t)0x08001000) /* Base @ of Page 2, 2 Kbytes */ // Page1
|
||||
//#define ADDR_FLASH_PAGE_3 ((uint32_t)0x08001800) /* Base @ of Page 3, 2 Kbytes */ // Remainder of code from here
|
||||
//#define ADDR_FLASH_PAGE_4 ((uint32_t)0x08002000) /* Base @ of Page 4, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_5 ((uint32_t)0x08002800) /* Base @ of Page 5, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_6 ((uint32_t)0x08003000) /* Base @ of Page 6, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_7 ((uint32_t)0x08003800) /* Base @ of Page 7, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_8 ((uint32_t)0x08004000) /* Base @ of Page 8, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_9 ((uint32_t)0x08004800) /* Base @ of Page 9, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_10 ((uint32_t)0x08005000) /* Base @ of Page 10, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_11 ((uint32_t)0x08005800) /* Base @ of Page 11, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_12 ((uint32_t)0x08006000) /* Base @ of Page 12, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_13 ((uint32_t)0x08006800) /* Base @ of Page 13, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_14 ((uint32_t)0x08007000) /* Base @ of Page 14, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_15 ((uint32_t)0x08007800) /* Base @ of Page 15, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_16 ((uint32_t)0x08008000) /* Base @ of Page 16, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_17 ((uint32_t)0x08008800) /* Base @ of Page 17, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_18 ((uint32_t)0x08009000) /* Base @ of Page 18, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_19 ((uint32_t)0x08009800) /* Base @ of Page 19, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_20 ((uint32_t)0x0800A000) /* Base @ of Page 20, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_21 ((uint32_t)0x0800A800) /* Base @ of Page 21, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_22 ((uint32_t)0x0800B000) /* Base @ of Page 22, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_23 ((uint32_t)0x0800B800) /* Base @ of Page 23, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_24 ((uint32_t)0x0800C000) /* Base @ of Page 24, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_25 ((uint32_t)0x0800C800) /* Base @ of Page 25, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_26 ((uint32_t)0x0800D000) /* Base @ of Page 26, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_27 ((uint32_t)0x0800D800) /* Base @ of Page 27, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_28 ((uint32_t)0x0800E000) /* Base @ of Page 28, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_29 ((uint32_t)0x0800E800) /* Base @ of Page 29, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_30 ((uint32_t)0x0800F000) /* Base @ of Page 30, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_31 ((uint32_t)0x0800F800) /* Base @ of Page 31, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_32 ((uint32_t)0x08010000) /* Base @ of Page 32, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_33 ((uint32_t)0x08010800) /* Base @ of Page 33, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_34 ((uint32_t)0x08011000) /* Base @ of Page 34, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_35 ((uint32_t)0x08011800) /* Base @ of Page 35, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_36 ((uint32_t)0x08012000) /* Base @ of Page 36, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_37 ((uint32_t)0x08012800) /* Base @ of Page 37, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_38 ((uint32_t)0x08013000) /* Base @ of Page 38, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_39 ((uint32_t)0x08013800) /* Base @ of Page 39, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_40 ((uint32_t)0x08014000) /* Base @ of Page 40, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_41 ((uint32_t)0x08014800) /* Base @ of Page 41, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_42 ((uint32_t)0x08015000) /* Base @ of Page 42, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_43 ((uint32_t)0x08015800) /* Base @ of Page 43, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_44 ((uint32_t)0x08016000) /* Base @ of Page 44, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_45 ((uint32_t)0x08016800) /* Base @ of Page 45, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_46 ((uint32_t)0x08017000) /* Base @ of Page 46, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_47 ((uint32_t)0x08017800) /* Base @ of Page 47, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_48 ((uint32_t)0x08018000) /* Base @ of Page 48, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_49 ((uint32_t)0x08018800) /* Base @ of Page 49, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_50 ((uint32_t)0x08019000) /* Base @ of Page 50, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_51 ((uint32_t)0x08019800) /* Base @ of Page 51, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_52 ((uint32_t)0x0801A000) /* Base @ of Page 52, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_53 ((uint32_t)0x0801A800) /* Base @ of Page 53, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_54 ((uint32_t)0x0801B000) /* Base @ of Page 54, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_55 ((uint32_t)0x0801B800) /* Base @ of Page 55, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_56 ((uint32_t)0x0801C000) /* Base @ of Page 56, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_57 ((uint32_t)0x0801C800) /* Base @ of Page 57, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_58 ((uint32_t)0x0801D000) /* Base @ of Page 58, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_59 ((uint32_t)0x0801D800) /* Base @ of Page 59, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_60 ((uint32_t)0x0801E000) /* Base @ of Page 60, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_61 ((uint32_t)0x0801E800) /* Base @ of Page 61, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_62 ((uint32_t)0x0801F000) /* Base @ of Page 62, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_63 ((uint32_t)0x0801F800) /* Base @ of Page 63, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_64 ((uint32_t)0x08020000) /* Base @ of Page 64, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_65 ((uint32_t)0x08020800) /* Base @ of Page 65, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_66 ((uint32_t)0x08021000) /* Base @ of Page 66, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_67 ((uint32_t)0x08021800) /* Base @ of Page 67, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_68 ((uint32_t)0x08022000) /* Base @ of Page 68, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_69 ((uint32_t)0x08022800) /* Base @ of Page 69, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_70 ((uint32_t)0x08023000) /* Base @ of Page 70, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_71 ((uint32_t)0x08023800) /* Base @ of Page 71, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_72 ((uint32_t)0x08024000) /* Base @ of Page 72, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_73 ((uint32_t)0x08024800) /* Base @ of Page 73, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_74 ((uint32_t)0x08025000) /* Base @ of Page 74, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_75 ((uint32_t)0x08025800) /* Base @ of Page 75, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_76 ((uint32_t)0x08026000) /* Base @ of Page 76, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_77 ((uint32_t)0x08026800) /* Base @ of Page 77, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_78 ((uint32_t)0x08027000) /* Base @ of Page 78, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_79 ((uint32_t)0x08027800) /* Base @ of Page 79, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_80 ((uint32_t)0x08028000) /* Base @ of Page 80, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_81 ((uint32_t)0x08028800) /* Base @ of Page 81, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_82 ((uint32_t)0x08029000) /* Base @ of Page 82, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_83 ((uint32_t)0x08029800) /* Base @ of Page 83, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_84 ((uint32_t)0x0802A000) /* Base @ of Page 84, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_85 ((uint32_t)0x0802A800) /* Base @ of Page 85, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_86 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_87 ((uint32_t)0x0802B800) /* Base @ of Page 87, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_88 ((uint32_t)0x0802C000) /* Base @ of Page 88, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_89 ((uint32_t)0x0802C800) /* Base @ of Page 89, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_90 ((uint32_t)0x0802D000) /* Base @ of Page 90, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_91 ((uint32_t)0x0802D800) /* Base @ of Page 91, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_92 ((uint32_t)0x0802E000) /* Base @ of Page 92, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_93 ((uint32_t)0x0802E800) /* Base @ of Page 93, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_94 ((uint32_t)0x0802F000) /* Base @ of Page 94, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_95 ((uint32_t)0x0802F800) /* Base @ of Page 95, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_96 ((uint32_t)0x08030000) /* Base @ of Page 96, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_97 ((uint32_t)0x08030800) /* Base @ of Page 97, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_98 ((uint32_t)0x08031000) /* Base @ of Page 98, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_99 ((uint32_t)0x08031800) /* Base @ of Page 99, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_100 ((uint32_t)0x08032000) /* Base @ of Page 100, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_101 ((uint32_t)0x08032800) /* Base @ of Page 101, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_102 ((uint32_t)0x08033000) /* Base @ of Page 102, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_103 ((uint32_t)0x08033800) /* Base @ of Page 103, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_104 ((uint32_t)0x08034000) /* Base @ of Page 104, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_105 ((uint32_t)0x08034800) /* Base @ of Page 105, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_106 ((uint32_t)0x08035000) /* Base @ of Page 106, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_107 ((uint32_t)0x08035800) /* Base @ of Page 107, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_108 ((uint32_t)0x08036000) /* Base @ of Page 108, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_109 ((uint32_t)0x08036800) /* Base @ of Page 109, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_110 ((uint32_t)0x08037000) /* Base @ of Page 110, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_111 ((uint32_t)0x08037800) /* Base @ of Page 111, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_112 ((uint32_t)0x08038000) /* Base @ of Page 112, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_113 ((uint32_t)0x08038800) /* Base @ of Page 113, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_114 ((uint32_t)0x08039000) /* Base @ of Page 114, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_115 ((uint32_t)0x08039800) /* Base @ of Page 115, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_116 ((uint32_t)0x0803A000) /* Base @ of Page 116, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_117 ((uint32_t)0x0803A800) /* Base @ of Page 117, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_118 ((uint32_t)0x0803B000) /* Base @ of Page 118, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_119 ((uint32_t)0x0803B800) /* Base @ of Page 119, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_120 ((uint32_t)0x0803C000) /* Base @ of Page 120, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_121 ((uint32_t)0x0803C800) /* Base @ of Page 121, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_122 ((uint32_t)0x0803D000) /* Base @ of Page 122, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_123 ((uint32_t)0x0803D800) /* Base @ of Page 123, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_124 ((uint32_t)0x0803E000) /* Base @ of Page 124, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_125 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_126 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_127 ((uint32_t)0x0803F800) /* Base @ of Page 127, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_128 ((uint32_t)0x08040000) /* Base @ of Page 128, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_129 ((uint32_t)0x08040800) /* Base @ of Page 129, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_130 ((uint32_t)0x08041000) /* Base @ of Page 130, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_131 ((uint32_t)0x08041800) /* Base @ of Page 131, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_132 ((uint32_t)0x08042000) /* Base @ of Page 132, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_133 ((uint32_t)0x08042800) /* Base @ of Page 133, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_134 ((uint32_t)0x08043000) /* Base @ of Page 134, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_135 ((uint32_t)0x08043800) /* Base @ of Page 135, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_136 ((uint32_t)0x08044000) /* Base @ of Page 136, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_137 ((uint32_t)0x08044800) /* Base @ of Page 137, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_138 ((uint32_t)0x08045000) /* Base @ of Page 138, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_139 ((uint32_t)0x08045800) /* Base @ of Page 139, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_140 ((uint32_t)0x08046000) /* Base @ of Page 140, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_141 ((uint32_t)0x08046800) /* Base @ of Page 141, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_142 ((uint32_t)0x08047000) /* Base @ of Page 142, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_143 ((uint32_t)0x08047800) /* Base @ of Page 143, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_144 ((uint32_t)0x08048000) /* Base @ of Page 144, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_145 ((uint32_t)0x08048800) /* Base @ of Page 145, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_146 ((uint32_t)0x08049000) /* Base @ of Page 146, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_147 ((uint32_t)0x08049800) /* Base @ of Page 147, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_148 ((uint32_t)0x0804A000) /* Base @ of Page 148, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_149 ((uint32_t)0x0804A800) /* Base @ of Page 149, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_150 ((uint32_t)0x0804B000) /* Base @ of Page 150, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_151 ((uint32_t)0x0804B800) /* Base @ of Page 151, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_152 ((uint32_t)0x0804C000) /* Base @ of Page 152, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_153 ((uint32_t)0x0804C800) /* Base @ of Page 153, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_154 ((uint32_t)0x0804D000) /* Base @ of Page 154, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_155 ((uint32_t)0x0804D800) /* Base @ of Page 155, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_156 ((uint32_t)0x0804E000) /* Base @ of Page 156, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_157 ((uint32_t)0x0804E800) /* Base @ of Page 157, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_158 ((uint32_t)0x0804F000) /* Base @ of Page 158, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_159 ((uint32_t)0x0804F800) /* Base @ of Page 159, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_160 ((uint32_t)0x08050000) /* Base @ of Page 160, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_161 ((uint32_t)0x08050800) /* Base @ of Page 161, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_162 ((uint32_t)0x08051000) /* Base @ of Page 162, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_163 ((uint32_t)0x08051800) /* Base @ of Page 163, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_164 ((uint32_t)0x08052000) /* Base @ of Page 164, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_165 ((uint32_t)0x08052800) /* Base @ of Page 165, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_166 ((uint32_t)0x08053000) /* Base @ of Page 166, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_167 ((uint32_t)0x08053800) /* Base @ of Page 167, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_168 ((uint32_t)0x08054000) /* Base @ of Page 168, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_169 ((uint32_t)0x08054800) /* Base @ of Page 169, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_170 ((uint32_t)0x08055000) /* Base @ of Page 170, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_171 ((uint32_t)0x08055800) /* Base @ of Page 171, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_172 ((uint32_t)0x08056000) /* Base @ of Page 172, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_173 ((uint32_t)0x08056800) /* Base @ of Page 173, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_174 ((uint32_t)0x08057000) /* Base @ of Page 174, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_175 ((uint32_t)0x08057800) /* Base @ of Page 175, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_176 ((uint32_t)0x08058000) /* Base @ of Page 176, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_177 ((uint32_t)0x08058800) /* Base @ of Page 177, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_178 ((uint32_t)0x08059000) /* Base @ of Page 178, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_179 ((uint32_t)0x08059800) /* Base @ of Page 179, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_180 ((uint32_t)0x0805A000) /* Base @ of Page 180, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_181 ((uint32_t)0x0805A800) /* Base @ of Page 181, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_182 ((uint32_t)0x0805B000) /* Base @ of Page 182, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_183 ((uint32_t)0x0805B800) /* Base @ of Page 183, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_184 ((uint32_t)0x0805C000) /* Base @ of Page 184, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_185 ((uint32_t)0x0805C800) /* Base @ of Page 185, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_186 ((uint32_t)0x0805D000) /* Base @ of Page 186, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_187 ((uint32_t)0x0805D800) /* Base @ of Page 187, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_188 ((uint32_t)0x0805E000) /* Base @ of Page 188, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_189 ((uint32_t)0x0805E800) /* Base @ of Page 189, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_190 ((uint32_t)0x0805F000) /* Base @ of Page 190, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_191 ((uint32_t)0x0805F800) /* Base @ of Page 191, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_192 ((uint32_t)0x08060000) /* Base @ of Page 192, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_193 ((uint32_t)0x08060800) /* Base @ of Page 193, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_194 ((uint32_t)0x08061000) /* Base @ of Page 194, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_195 ((uint32_t)0x08061800) /* Base @ of Page 195, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_196 ((uint32_t)0x08062000) /* Base @ of Page 196, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_197 ((uint32_t)0x08062800) /* Base @ of Page 197, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_198 ((uint32_t)0x08063000) /* Base @ of Page 198, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_199 ((uint32_t)0x08063800) /* Base @ of Page 199, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_200 ((uint32_t)0x08064000) /* Base @ of Page 200, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_201 ((uint32_t)0x08064800) /* Base @ of Page 201, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_202 ((uint32_t)0x08065000) /* Base @ of Page 202, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_203 ((uint32_t)0x08065800) /* Base @ of Page 203, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_204 ((uint32_t)0x08066000) /* Base @ of Page 204, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_205 ((uint32_t)0x08066800) /* Base @ of Page 205, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_206 ((uint32_t)0x08067000) /* Base @ of Page 206, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_207 ((uint32_t)0x08067800) /* Base @ of Page 207, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_208 ((uint32_t)0x08068000) /* Base @ of Page 208, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_209 ((uint32_t)0x08068800) /* Base @ of Page 209, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_210 ((uint32_t)0x08069000) /* Base @ of Page 210, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_211 ((uint32_t)0x08069800) /* Base @ of Page 211, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_212 ((uint32_t)0x0806A000) /* Base @ of Page 212, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_213 ((uint32_t)0x0806A800) /* Base @ of Page 213, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_214 ((uint32_t)0x0806B000) /* Base @ of Page 214, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_215 ((uint32_t)0x0806B800) /* Base @ of Page 215, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_216 ((uint32_t)0x0806C000) /* Base @ of Page 216, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_217 ((uint32_t)0x0806C800) /* Base @ of Page 217, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_218 ((uint32_t)0x0806D000) /* Base @ of Page 218, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_219 ((uint32_t)0x0806D800) /* Base @ of Page 219, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_220 ((uint32_t)0x0806E000) /* Base @ of Page 220, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_221 ((uint32_t)0x0806E800) /* Base @ of Page 221, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_222 ((uint32_t)0x0806F000) /* Base @ of Page 222, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_223 ((uint32_t)0x0806F800) /* Base @ of Page 223, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_224 ((uint32_t)0x08070000) /* Base @ of Page 224, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_225 ((uint32_t)0x08070800) /* Base @ of Page 225, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_226 ((uint32_t)0x08071000) /* Base @ of Page 226, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_227 ((uint32_t)0x08071800) /* Base @ of Page 227, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_228 ((uint32_t)0x08072000) /* Base @ of Page 228, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_229 ((uint32_t)0x08072800) /* Base @ of Page 229, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_230 ((uint32_t)0x08073000) /* Base @ of Page 230, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_231 ((uint32_t)0x08073800) /* Base @ of Page 231, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_232 ((uint32_t)0x08074000) /* Base @ of Page 232, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_233 ((uint32_t)0x08074800) /* Base @ of Page 233, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_234 ((uint32_t)0x08075000) /* Base @ of Page 234, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_235 ((uint32_t)0x08075800) /* Base @ of Page 235, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_236 ((uint32_t)0x08076000) /* Base @ of Page 236, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_237 ((uint32_t)0x08076800) /* Base @ of Page 237, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_238 ((uint32_t)0x08077000) /* Base @ of Page 238, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_239 ((uint32_t)0x08077800) /* Base @ of Page 239, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_240 ((uint32_t)0x08078000) /* Base @ of Page 240, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_241 ((uint32_t)0x08078800) /* Base @ of Page 241, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_242 ((uint32_t)0x08079000) /* Base @ of Page 242, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_243 ((uint32_t)0x08079800) /* Base @ of Page 243, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_244 ((uint32_t)0x0807A000) /* Base @ of Page 244, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_245 ((uint32_t)0x0807A800) /* Base @ of Page 245, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_246 ((uint32_t)0x0807B000) /* Base @ of Page 246, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_247 ((uint32_t)0x0807B800) /* Base @ of Page 247, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_248 ((uint32_t)0x0807C000) /* Base @ of Page 248, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_249 ((uint32_t)0x0807C800) /* Base @ of Page 249, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_250 ((uint32_t)0x0807D000) /* Base @ of Page 250, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_251 ((uint32_t)0x0807D800) /* Base @ of Page 251, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_252 ((uint32_t)0x0807E000) /* Base @ of Page 252, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_253 ((uint32_t)0x0807E800) /* Base @ of Page 253, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_254 ((uint32_t)0x0807F000) /* Base @ of Page 254, 2 Kbytes */
|
||||
//#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 * 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 */
|
||||
|
||||
/* Pages 0 and 1 base and end addresses */
|
||||
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
|
||||
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
|
||||
|
||||
#define PAGE1_BASE_ADDRESS ((uint32_t)(ADDR_EEPROM_PAGE_1))
|
||||
#define PAGE1_END_ADDRESS ((uint32_t)(ADDR_EEPROM_PAGE_1 + PAGE_SIZE - 1))
|
||||
|
||||
/* Used Flash pages for EEPROM emulation */
|
||||
#define PAGE0 ((uint16_t)0x0000)
|
||||
#define PAGE1 ((uint16_t)1) /* Page numbers between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
|
||||
/* No valid page define */
|
||||
#define NO_VALID_PAGE ((uint16_t)0x00AB)
|
||||
|
||||
/* Page status definitions */
|
||||
#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
|
||||
|
||||
/* Valid pages in read and write defines */
|
||||
#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
|
||||
#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
|
||||
|
||||
/* Page full define */
|
||||
#define PAGE_FULL ((uint8_t)0x80)
|
||||
|
||||
/* Variables' number */
|
||||
//#define NB_OF_VAR ((uint8_t)0x03)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
uint16_t driverHWEEPROMInit(uint16_t numberOfVars);
|
||||
uint16_t driverHWEEPROMEraseFlash(void);
|
||||
uint16_t driverHWEEPROMReadVariable(uint16_t VirtAddress, uint16_t* Data);
|
||||
uint16_t driverHWEEPROMWriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
|
||||
#endif /* __EEPROM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
35
firmware/Core/Inc/driverHWPowerState.h
Normal file
35
firmware/Core/Inc/driverHWPowerState.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __DRIVERHWPOWERSTATE_H
|
||||
#define __DRIVERHWPOWERSTATE_H
|
||||
|
||||
#include "generalDefines.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
#define NoOfPowersSTATs 3
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* Port;
|
||||
uint32_t ClkRegister;
|
||||
uint32_t Pin;
|
||||
uint32_t Mode;
|
||||
uint32_t Pull;
|
||||
} PowerStatePortStruct;
|
||||
|
||||
extern const PowerStatePortStruct driverHWPorts[NoOfPowersSTATs];
|
||||
|
||||
typedef enum {
|
||||
P_STAT_POWER_ENABLE = 0,
|
||||
P_STAT_BUTTON_INPUT,
|
||||
P_STAT_CHARGE_DETECT
|
||||
} PowerStateIDTypedef;
|
||||
|
||||
typedef enum {
|
||||
P_STAT_RESET = 0,
|
||||
P_STAT_SET
|
||||
} PowerStateStateTypedef;
|
||||
|
||||
void driverHWPowerStateInit(void);
|
||||
void driverHWPowerStateSetOutput(PowerStateIDTypedef inputPort, PowerStateStateTypedef newState);
|
||||
bool driverHWPowerStateReadInput(PowerStateIDTypedef inputPort);
|
||||
|
||||
#endif
|
||||
10
firmware/Core/Inc/driverHWSPI1.h
Normal file
10
firmware/Core/Inc/driverHWSPI1.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
#define driverHWSPI1DefaultTimeout 100
|
||||
|
||||
void driverHWSPI1Init(GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
bool driverHWSPI1Write(uint8_t *writeBuffer, uint8_t noOfBytesToWrite,GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
bool driverHWSPI1WriteRead(uint8_t *writeBuffer, uint8_t noOfBytesToWrite, uint8_t *readBuffer, uint8_t noOfBytesToRead,GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
71
firmware/Core/Inc/driverHWSwitches.h
Normal file
71
firmware/Core/Inc/driverHWSwitches.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "generalDefines.h"
|
||||
|
||||
#define NoOfSwitches 6 //7
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* Port;
|
||||
uint32_t ClkRegister;
|
||||
uint32_t Pin;
|
||||
uint32_t Mode;
|
||||
uint32_t Pull;
|
||||
} driverHWSwitchesPortStruct;
|
||||
|
||||
extern const driverHWSwitchesPortStruct driverHWSwitchesPorts[NoOfSwitches];
|
||||
|
||||
typedef enum {
|
||||
#if ENNOID_SS
|
||||
SWITCH_CHARGE_BYPASS = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_DISCHARGE,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#elif ENNOID_SS_LITE
|
||||
SWITCH_DISCHARGE = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_CHARGE_BYPASS,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#else
|
||||
SWITCH_COOLING = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_DISCHARGE,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#endif
|
||||
|
||||
} driverHWSwitchesIDTypedef;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_RESET = 0,
|
||||
SWITCH_SET,
|
||||
} driverHWSwitchesStateTypedef;
|
||||
|
||||
void driverHWSwitchesInit(void);
|
||||
void driverHWSwitchesSetSwitchState(driverHWSwitchesIDTypedef switchID, driverHWSwitchesStateTypedef newState);
|
||||
void driverHWSwitchesDisableAll(void);
|
||||
bool driverHWSwitchesGetSwitchState(driverHWSwitchesIDTypedef switchID);
|
||||
14
firmware/Core/Inc/driverHWUART2.h
Normal file
14
firmware/Core/Inc/driverHWUART2.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "string.h"
|
||||
|
||||
#define RX_UART_BUFFER_SIZE 1024//2048 //1024
|
||||
|
||||
void driverHWUART2Init(uint32_t baudRate);
|
||||
void driverHWUART2SendChar(uint8_t character);
|
||||
bool driverHWUART2GetChar(char *character);
|
||||
|
||||
extern uint8_t driverHWUART2ReceiveBuffer[RX_UART_BUFFER_SIZE];
|
||||
extern uint8_t driverHWUART2ReceiveBuffer_usb[RX_UART_BUFFER_SIZE];
|
||||
extern uint32_t driverHWUART2Receive_CNDTR;
|
||||
extern uint8_t driverHWUART2Receive_CNDTR_resetFlag;
|
||||
258
firmware/Core/Inc/driverSWLTC6804.h
Normal file
258
firmware/Core/Inc/driverSWLTC6804.h
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driverHWSPI1.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
#include "mainDataTypes.h"
|
||||
#include "modDelay.h"
|
||||
//#include "driverSWLTC6804.h"
|
||||
|
||||
|
||||
/*
|
||||
Pre computed crc15 table used for the LTC6804 PEC calculation
|
||||
|
||||
The code used to generate the crc15 table is:
|
||||
|
||||
void generate_crc15_table()
|
||||
{
|
||||
int remainder;
|
||||
for(int i = 0; i<256;i++)
|
||||
{
|
||||
remainder = i<< 7;
|
||||
for (int bit = 8; bit > 0; --bit)
|
||||
{
|
||||
|
||||
if ((remainder & 0x4000) > 0)//equivalent to remainder & 2^14 simply check for MSB
|
||||
{
|
||||
remainder = ((remainder << 1)) ;
|
||||
remainder = (remainder ^ 0x4599);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = ((remainder << 1));
|
||||
}
|
||||
}
|
||||
|
||||
crc15Table[i] = remainder&0xFFFF;
|
||||
}
|
||||
}
|
||||
*/
|
||||
static const unsigned int crc15Table[256] = {
|
||||
0x0000, 0xc599, 0xceab, 0x0b32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac, //!<precomputed CRC15 Table
|
||||
0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
|
||||
0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
|
||||
0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
|
||||
0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
|
||||
0x2544, 0x02be, 0xc727, 0xcc15, 0x098c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
|
||||
0x3d6e, 0xf8f7, 0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x07c2, 0xc25b, 0xc969, 0x0cf0, 0xdf0d,
|
||||
0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
|
||||
0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
|
||||
0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
|
||||
0x4a88, 0x8f11, 0x057c, 0xc0e5, 0xcbd7, 0x0e4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
|
||||
0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
|
||||
0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
|
||||
0x85e9, 0x0f84, 0xca1d, 0xc12f, 0x04b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a,
|
||||
0x3528, 0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2,
|
||||
0xe46b, 0xef59, 0x2ac0, 0x0d3a, 0xc8a3, 0xc391, 0x0608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7,
|
||||
0x54aa, 0x9133, 0x9a01, 0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06,
|
||||
0xab9f, 0x7862, 0xbdfb, 0xb6c9, 0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80,
|
||||
0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a, 0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41,
|
||||
0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25, 0x2fbc, 0x0846, 0xcddf, 0xc6ed, 0x0374,
|
||||
0xd089, 0x1510, 0x1e22, 0xdbbb, 0x0af8, 0xcf61, 0xc453, 0x01ca, 0xd237, 0x17ae, 0x1c9c,
|
||||
0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b, 0x2d02, 0xa76f, 0x62f6,
|
||||
0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3, 0x585a, 0x8ba7,
|
||||
0x4e3e, 0x450c, 0x8095
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
|MD| Dec | ADC Conversion Model|
|
||||
|--|------|---------------------|
|
||||
|01| 1 | Fast |
|
||||
|10| 2 | Normal |
|
||||
|11| 3 | Filtered |
|
||||
*/
|
||||
#define MD_FAST 1
|
||||
#define MD_NORMAL 2
|
||||
#define MD_FILTERED 3
|
||||
|
||||
|
||||
/*!
|
||||
|CH | Dec | Channels to convert |
|
||||
|---|------|---------------------|
|
||||
|000| 0 | All Cells |
|
||||
|001| 1 | Cell 1 and Cell 7 |
|
||||
|010| 2 | Cell 2 and Cell 8 |
|
||||
|011| 3 | Cell 3 and Cell 9 |
|
||||
|100| 4 | Cell 4 and Cell 10 |
|
||||
|101| 5 | Cell 5 and Cell 11 |
|
||||
|110| 6 | Cell 6 and Cell 12 |
|
||||
*/
|
||||
|
||||
#define CELL_CH_ALL 0
|
||||
#define CELL_CH_1and7 1
|
||||
#define CELL_CH_2and8 2
|
||||
#define CELL_CH_3and9 3
|
||||
#define CELL_CH_4and10 4
|
||||
#define CELL_CH_5and11 5
|
||||
#define CELL_CH_6and12 6
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|CHG | Dec |Channels to convert |
|
||||
|----|------|----------------------|
|
||||
|000 | 0 | All GPIOS and 2nd Ref|
|
||||
|001 | 1 | GPIO 1 |
|
||||
|010 | 2 | GPIO 2 |
|
||||
|011 | 3 | GPIO 3 |
|
||||
|100 | 4 | GPIO 4 |
|
||||
|101 | 5 | GPIO 5 |
|
||||
|110 | 6 | Vref2 |
|
||||
*/
|
||||
|
||||
#define AUX_CH_ALL 0
|
||||
#define AUX_CH_GPIO1 1
|
||||
#define AUX_CH_GPIO2 2
|
||||
#define AUX_CH_GPIO3 3
|
||||
#define AUX_CH_GPIO4 4
|
||||
#define AUX_CH_GPIO5 5
|
||||
#define AUX_CH_VREF2 6
|
||||
|
||||
//uint8_t CHG = 0; //!< aux channels to be converted
|
||||
/*!****************************************************
|
||||
\brief Controls if Discharging transitors are enabled
|
||||
or disabled during Cell conversions.
|
||||
|
||||
|DCP | Discharge Permitted During conversion |
|
||||
|----|----------------------------------------|
|
||||
|0 | No - discharge is not permitted |
|
||||
|1 | Yes - discharge is permitted |
|
||||
|
||||
********************************************************/
|
||||
#define DCP_DISABLED 0
|
||||
#define DCP_ENABLED 1
|
||||
|
||||
typedef enum {
|
||||
LTC6804WriteConfigRegA = 0x0001, // WRCFG
|
||||
LTC6804WriteConfigRegB = 0x0024, // WRCFG
|
||||
LTC6804ReadConfigRegA = 0x0002, // RDCFG
|
||||
LTC6804ReadConfigRegB = 0x0026, // RDCFG
|
||||
LTC6804ReadCellVoltageGroupA = 0x0004, // RDVCA
|
||||
LTC6804ReadCellVoltageGroupB = 0x0006, // RDVCB
|
||||
LTC6804ReadCellVoltageGroupC = 0x0008, // RDVCC
|
||||
LTC6804ReadCellVoltageGroupD = 0x000A, // RDVCD
|
||||
LTC6804ReadAuxGroupA = 0x000C, // RDAUXA
|
||||
LTC6804ReadAuxGroupB = 0x000E, // RDAUXB
|
||||
LTC6804ReadStatusRegisterGroupA = 0x0010, // RDSTATA
|
||||
LTC6804ReadStatusRegisterGroupB = 0x0012, // RDSTATB
|
||||
LTC6804StartCellVoltageADConversion = 0x0260, // ADCV
|
||||
LTC6804StartCellOpenWireVoltageADConversion = 0x0228, // ADOW
|
||||
LTC6804StartCellSelfTestVoltageConversion = 0x0207, // CVST
|
||||
LTC6804StartGPIOADConversion = 0x0460, // ADAX
|
||||
LTC6804SelfTestGPIOConversion = 0x0407, // AXST
|
||||
LTC6804StartStatusGroupConversion = 0x0468, // ADSTAT
|
||||
LTC6804StartSelfTestStatusGroup = 0x040F, // STATST
|
||||
LTC6804StartCombinedADConversion = 0x046F, // ADCVAX
|
||||
LTC6804ClearCellVoltageGroup = 0x0711, // CLRCELL
|
||||
LTC6804ClearAuxVoltageGroup = 0x0712, // CLRAUX
|
||||
LTC6804ClearStatusRegisterGroup = 0x0713, // CLRSTAT
|
||||
LTC6804PollADConversion = 0x0714, // PLADC
|
||||
LTC6804DiagnoseMUX = 0x0715, // DIAGN
|
||||
LTC6804CommunicationWriteRegisterGroup = 0x0721, // WRCOMM
|
||||
LTC6804CommunucationReadRegisterGroup = 0x0722, // RDCOMM
|
||||
LTC6804CommuncationStart = 0x0723 // STCOMM
|
||||
} driverSWLTC6804RegistersBase;
|
||||
|
||||
typedef struct {
|
||||
bool GPIO1; // Read/Write opendrain GPIO1
|
||||
bool GPIO2; // Read/Write opendrain GPIO2
|
||||
bool GPIO3; // Read/Write opendrain GPIO3
|
||||
bool GPIO4; // Read/Write opendrain GPIO4
|
||||
bool GPIO5; // Read/Write opendrain GPIO5
|
||||
bool GPIO6; // Read/Write opendrain GPIO6
|
||||
bool GPIO7; // Read/Write opendrain GPIO7
|
||||
bool GPIO8; // Read/Write opendrain GPIO8
|
||||
bool GPIO9; // Read/Write opendrain GPIO9
|
||||
bool ReferenceON; // Reference ON
|
||||
bool SoftwareTimerFlag; // Read software timer pin
|
||||
bool ADCOption; // ADC Option register for configuration of over sampling ratio
|
||||
uint8_t noOfCells; // Number of cells to monitor (that can cause interrupt)
|
||||
uint32_t DisChargeEnableMask; // Set enable state of discharge, 1=EnableDischarge, 0=DisableDischarge
|
||||
uint8_t DischargeTimout; // Discharge timout value / limit
|
||||
double CellUnderVoltageLimit; // Undervoltage level, cell voltages under this limit will cause interrupt
|
||||
double CellOverVoltageLimit; // Over voltage limit, cell voltages over this limit will cause interrupt
|
||||
} driverLTC6804ConfigStructTypedef;
|
||||
|
||||
typedef struct {
|
||||
float sumOfCells;
|
||||
float dieTemperature;
|
||||
float voltageAnalogSupply;
|
||||
float voltageDigitalSupply;
|
||||
uint16_t overVoltage;
|
||||
uint16_t underVoltage;
|
||||
bool muxFail;
|
||||
} driverSWLTC6804StatusStructTypedef;
|
||||
|
||||
//Init
|
||||
void driverSWLTC6804Init(driverLTC6804ConfigStructTypedef configStruct, uint8_t totalNumberOfLTCs, uint8_t maxNoOfCellPerModule, uint8_t maxNoOfTempSensorPerModule, uint8_t cellMonitorType);
|
||||
|
||||
//Write/read config registers
|
||||
void driverSWLTC6804WriteConfigRegister(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray);
|
||||
void driverSWLTC6804WriteConfigRegisterB(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray);
|
||||
int8_t driverSWLTC6804ReadConfigRegister(uint8_t nIC, uint8_t r_config[][8]);
|
||||
|
||||
//Balance resistor
|
||||
void driverSWLTC6804EnableBalanceResistors(uint32_t enableMask, uint8_t cellMonitorType); // Used only for single slave test with "testbms" command
|
||||
void driverSWLTC6804EnableBalanceResistorsArray(uint32_t *enableMask, uint8_t cellMonitorType);
|
||||
|
||||
//Cell voltage
|
||||
void driverSWLTC6804StartCellAndAuxVoltageConversion(uint8_t MD,uint8_t DCP);
|
||||
void driverSWLTC6804StartCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH);
|
||||
void driverSWLTC6804StartLoadedCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH,uint8_t PUP);
|
||||
|
||||
bool driverSWLTC6804ReadCellVoltagesArray(float cellVoltagesArray[][18]);
|
||||
uint8_t driverSWLTC6804ReadCellVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t cell_codes[][18]);
|
||||
void driverSWLTC6804ReadCellVoltageGroups(uint8_t reg, uint8_t total_ic, uint8_t *data);
|
||||
|
||||
// Aux sensors
|
||||
void driverSWLTC6804StartAuxVoltageConversion(uint8_t MD, uint8_t CHG);
|
||||
float driverSWLTC6804ConvertTemperatureExt(uint16_t inputValue,uint32_t ntcNominal,uint32_t ntcSeriesResistance,uint16_t ntcBetaFactor, float ntcNominalTemp);
|
||||
|
||||
bool driverSWLTC6804ReadAuxVoltagesArray(float auxVoltagesArray[][12],uint32_t ntcNominal,uint32_t ntcSeriesResistance, uint16_t ntcBetaFactor,float ntcNominalTemp);
|
||||
int8_t driverSWLTC6804ReadAuxVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t aux_codes[][12]);
|
||||
void driverSWLTC6804ReadAuxGroups(uint8_t reg, uint8_t total_ic,uint8_t *data);
|
||||
|
||||
//Status & flags
|
||||
bool driverSWLTC6804ReadVoltageFlags(uint32_t *underVoltageFlags, uint32_t *overVoltageFlags, uint32_t lastICMask, uint8_t noOfParallelModules, uint32_t dieTemperature[]);
|
||||
uint8_t driverSWLTC6804ReadStatusValues(uint8_t total_ic, driverSWLTC6804StatusStructTypedef statusArray[]);
|
||||
void driverSWLTC6804ReadStatusGroups(uint8_t reg, uint8_t total_ic, uint8_t *data );
|
||||
|
||||
//Utilities
|
||||
void driverSWLTC6804ResetCellVoltageRegisters(void);
|
||||
void driverSWLTC6804ResetAuxRegisters(void);
|
||||
void driverSWLTC6804ResetStatusRegisters(void);
|
||||
void driverSWLTC6804DelayMS(uint32_t delayMS);
|
||||
void driverSWLTC6804Write(uint8_t *writeBytes, uint8_t writeLength);
|
||||
void driverSWLTC6804WriteRead(uint8_t *writeBytes, uint8_t writeLength, uint8_t *readBytes, uint8_t readLength);
|
||||
void driverSWLTC6804WakeIC(void);
|
||||
uint16_t driverSWLTC6804CalcPEC15(uint8_t len, uint8_t *data);
|
||||
25
firmware/Core/Inc/driverSWStorageManager.h
Normal file
25
firmware/Core/Inc/driverSWStorageManager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __DRIVERSWSTORAGEMANAGER_H
|
||||
#define __DRIVERSWSTORAGEMANAGER_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "driverHWEEPROM.h"
|
||||
|
||||
extern bool driverSWStorageManagerConfigEmpty;
|
||||
extern bool driverSWStorageManagerStateOfChargeEmpty;
|
||||
extern uint16_t driverSWStorageManagerConfigStructSize;
|
||||
extern uint16_t driverSWStorageManagerStateOfChargeStructSize;
|
||||
|
||||
typedef enum {
|
||||
STORAGE_CONFIG = 0,
|
||||
STORAGE_STATEOFCHARGE,
|
||||
} StorageLocationTypedef;
|
||||
|
||||
void driverSWStorageManagerInit(void);
|
||||
bool driverSWStorageManagerEraseData(void);
|
||||
bool driverSWStorageManagerStoreStruct(void *configStruct, StorageLocationTypedef storageLocation);
|
||||
bool driverSWStorageManagerGetStruct(void *configStruct, StorageLocationTypedef storageLocation);
|
||||
uint16_t driverSWStorageManagerGetOffsetFromLocation(StorageLocationTypedef storageLocation);
|
||||
uint16_t driverSWStorageManagerGetStructSize(StorageLocationTypedef storageLocation);
|
||||
|
||||
#endif
|
||||
12
firmware/Core/Inc/driverSWUART2.h
Normal file
12
firmware/Core/Inc/driverSWUART2.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "driverHWUART2.h"
|
||||
#include "libRingBuffer.h"
|
||||
|
||||
#define RINGBUFFERSIZE 1024
|
||||
|
||||
void driverSWUART2Init(uint32_t baudRate);
|
||||
char driverSWUART2PutCharInOutputBuffer(char character, FILE *stream);
|
||||
bool driverSWUART2Task(void);
|
||||
49
firmware/Core/Inc/fatfs.h
Normal file
49
firmware/Core/Inc/fatfs.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file fatfs.h
|
||||
* @brief Header for fatfs applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __fatfs_H
|
||||
#define __fatfs_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ff.h"
|
||||
#include "ff_gen_drv.h"
|
||||
#include "user_diskio.h" /* defines USER_Driver as external */
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern uint8_t retUSER; /* Return value for USER */
|
||||
extern char USERPath[4]; /* USER logical drive path */
|
||||
extern FATFS USERFatFS; /* File system object for USER logical drive */
|
||||
extern FIL USERFile; /* File object for USER */
|
||||
|
||||
void MX_FATFS_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
void MX_FATFS_DeInit(void);
|
||||
/* USER CODE END Prototypes */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__fatfs_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
275
firmware/Core/Inc/ffconf.h
Normal file
275
firmware/Core/Inc/ffconf.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 32020 /* Revision ID */
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Additional user header to be used
|
||||
/-----------------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
#define _USE_STRFUNC 2 /* 0:Disable or 1-2:Enable */
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read feature and related functions,
|
||||
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_FASTSEEK 1
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 850
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
/ 1250 - Central Europe (Windows)
|
||||
/ 1251 - Cyrillic (Windows)
|
||||
/ 1252 - Latin 1 (Windows)
|
||||
/ 1253 - Greek (Windows)
|
||||
/ 1254 - Turkish (Windows)
|
||||
/ 1255 - Hebrew (Windows)
|
||||
/ 1256 - Arabic (Windows)
|
||||
/ 1257 - Baltic (Windows)
|
||||
/ 1258 - Vietnam (OEM, Windows)
|
||||
/ 437 - U.S. (OEM)
|
||||
/ 720 - Arabic (OEM)
|
||||
/ 737 - Greek (OEM)
|
||||
/ 775 - Baltic (OEM)
|
||||
/ 850 - Multilingual Latin 1 (OEM)
|
||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
||||
/ 852 - Latin 2 (OEM)
|
||||
/ 855 - Cyrillic (OEM)
|
||||
/ 866 - Russian (OEM)
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII (No extended character. Valid for only non-LFN configuration.) */
|
||||
|
||||
#define _USE_LFN 0 /* 0 to 3 */
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
#define _FS_RPATH 0 /* 0 to 2 */
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
/* USER CODE BEGIN Volumes */
|
||||
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
/* USER CODE END Volumes */
|
||||
|
||||
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Multiple partition */
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
|
||||
|
||||
#define _MIN_SS 512 /* 512, 1024, 2048 or 4096 */
|
||||
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
#define _FS_NOFSINFO 0 /* 0,1,2 or 3 */
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_NORTC 0
|
||||
#define _NORTC_MON 6
|
||||
#define _NORTC_MDAY 4
|
||||
#define _NORTC_YEAR 2015
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
#define _FS_LOCK 2 /* 0:Disable or >=1:Enable */
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _SYNC_t NULL
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
#define _WORD_ACCESS 0 /* 0 or 1 */
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
#endif /* _FFCONF */
|
||||
61
firmware/Core/Inc/generalDefines.h
Normal file
61
firmware/Core/Inc/generalDefines.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// Define the hardware version here:
|
||||
#ifndef ENNOID_SS_LITE
|
||||
#define ENNOID_SS_LITE 0
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_SS
|
||||
#define ENNOID_SS 0
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_LV
|
||||
#define ENNOID_LV 1
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_HV
|
||||
#define ENNOID_HV 0
|
||||
#endif
|
||||
|
||||
// Firmware version
|
||||
//#define FW_VERSION_MAJOR 1
|
||||
//#define FW_VERSION_MINOR 3
|
||||
//#define FW_REAL_VERSION "V1.3"
|
||||
|
||||
#define FW_VERSION_MAJOR 1
|
||||
#define FW_VERSION_MINOR 4
|
||||
#define FW_REAL_VERSION "V1.4"
|
||||
|
||||
// UUID
|
||||
#define STM32_UUID ((uint32_t*)0x1FFFF7E8)
|
||||
#define STM32_UUID_8 ((uint8_t*)0x1FFFF7E8)
|
||||
|
||||
// Hardware names and limits
|
||||
#if ENNOID_LV
|
||||
#define HW_NAME "ENNOID-LV"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 18
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_HV
|
||||
#define HW_NAME "ENNOID-HV"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 18
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_SS
|
||||
#define HW_NAME "ENNOID-SS"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 1
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_SS_LITE
|
||||
#define HW_NAME "ENNOID-SS-LITE"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 1
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
51
firmware/Core/Inc/libBuffer.h
Normal file
51
firmware/Core/Inc/libBuffer.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BUFFER_H_
|
||||
#define BUFFER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void libBufferAppend_int8(uint8_t* buffer, int8_t number, int32_t *index);
|
||||
void libBufferAppend_uint8(uint8_t* buffer, uint8_t number, int32_t *index);
|
||||
void libBufferAppend_int16(uint8_t* buffer, int16_t number, int32_t *index);
|
||||
void libBufferAppend_uint16(uint8_t* buffer, uint16_t number, int32_t *index);
|
||||
void libBufferAppend_int32(uint8_t* buffer, int32_t number, int32_t *index);
|
||||
void libBufferAppend_uint32(uint8_t* buffer, uint32_t number, int32_t *index);
|
||||
void libBufferAppend_uint64(uint8_t* buffer, uint64_t number, int32_t *index);
|
||||
|
||||
void libBufferAppend_int16_LSBFirst(uint8_t* buffer, int16_t number, int32_t *index);
|
||||
void libBufferAppend_uint16_LSBFirst(uint8_t* buffer, uint16_t number, int32_t *index);
|
||||
void libBufferAppend_int32_LSBFirst(uint8_t* buffer, int32_t number, int32_t *index);
|
||||
void libBufferAppend_uint32_LSBFirst(uint8_t* buffer, uint32_t number, int32_t *index);
|
||||
|
||||
void libBufferAppend_float16(uint8_t* buffer, float number, float scale, int32_t *index);
|
||||
void libBufferAppend_float32(uint8_t* buffer, float number, float scale, int32_t *index);
|
||||
void libBufferAppend_float32_auto(uint8_t* buffer, float number, int32_t *index);
|
||||
int8_t libBufferGet_int8(const uint8_t *buffer, int32_t *index);
|
||||
uint8_t libBufferGet_uint8(const uint8_t *buffer, int32_t *index);
|
||||
int16_t libBufferGet_int16(const uint8_t *buffer, int32_t *index);
|
||||
uint16_t libBufferGet_uint16(const uint8_t *buffer, int32_t *index);
|
||||
int32_t libBufferGet_int32(const uint8_t *buffer, int32_t *index);
|
||||
uint32_t libBufferGet_uint32(const uint8_t *buffer, int32_t *index);
|
||||
float libBufferGet_float16(const uint8_t *buffer, float scale, int32_t *index);
|
||||
float libBufferGet_float32(const uint8_t *buffer, float scale, int32_t *index);
|
||||
float libBufferGet_float32_auto(const uint8_t *buffer, int32_t *index);
|
||||
|
||||
#endif /* BUFFER_H_ */
|
||||
28
firmware/Core/Inc/libCRC.h
Normal file
28
firmware/Core/Inc/libCRC.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CRC_H_
|
||||
#define CRC_H_
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
unsigned short libCRCCalcCRC16(unsigned char *buf, unsigned int len);
|
||||
|
||||
#endif /* CRC_H_ */
|
||||
36
firmware/Core/Inc/libPacket.h
Normal file
36
firmware/Core/Inc/libPacket.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PACKET_H_
|
||||
#define PACKET_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Settings
|
||||
#define PACKET_RX_TIMEOUT 10
|
||||
#define PACKET_HANDLERS 1
|
||||
#define PACKET_MAX_PL_LEN 1024
|
||||
|
||||
// Functions
|
||||
void libPacketInit(void (*s_func)(unsigned char *data, unsigned int len), void (*p_func)(unsigned char *data, unsigned int len), int handler_num);
|
||||
void libPacketProcessByte(uint8_t rx_data, int handler_num);
|
||||
void libPacketTimerFunc(void);
|
||||
void libPacketSendPacket(unsigned char *data, unsigned int len, int handler_num);
|
||||
|
||||
#endif /* PACKET_H_ */
|
||||
55
firmware/Core/Inc/libRingbuffer.h
Normal file
55
firmware/Core/Inc/libRingbuffer.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef RingBuf_h
|
||||
#define RingBuf_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//https://github.com/wizard97/ArduinoRingBuffer
|
||||
|
||||
typedef struct libRingBufferTypedef libRingBufferTypedef;
|
||||
|
||||
typedef struct libRingBufferTypedef {
|
||||
// Invariant: end and start is always in bounds
|
||||
unsigned char *buf;
|
||||
unsigned int len, size, start, end, elements;
|
||||
|
||||
// Private:
|
||||
int (*next_end_index) (libRingBufferTypedef*);
|
||||
int (*incr_end_index) (libRingBufferTypedef*);
|
||||
|
||||
int (*incr_start_index) (libRingBufferTypedef*);
|
||||
|
||||
//public:
|
||||
// Returns true if full
|
||||
bool (*isFull) (libRingBufferTypedef*);
|
||||
// Returns true if empty
|
||||
bool (*isEmpty) (libRingBufferTypedef*);
|
||||
// Returns number of elemnts in buffer
|
||||
unsigned int (*numElements)(libRingBufferTypedef*);
|
||||
// Add Event, Returns index where added in buffer, -1 on full buffer
|
||||
int (*add) (libRingBufferTypedef*, const void*);
|
||||
// Returns pointer to nth element, NULL when nth element is empty
|
||||
void *(*peek) (libRingBufferTypedef*, unsigned int);
|
||||
// Removes element and copies it to location pointed to by void *
|
||||
// Returns pointer passed in, NULL on empty buffer
|
||||
void *(*pull) (libRingBufferTypedef*, void *);
|
||||
|
||||
} libRingBufferTypedef;
|
||||
|
||||
libRingBufferTypedef *libRingBufferNew(int size, int len);
|
||||
int libRingBufferInit(libRingBufferTypedef *self, int size, int len);
|
||||
int libRingBufferDelete(libRingBufferTypedef *self);
|
||||
int libRingBufferNextEndIndex(libRingBufferTypedef *self);
|
||||
int libRingBufferIncrEnd(libRingBufferTypedef *self);
|
||||
int libRingBufferIncrStart(libRingBufferTypedef *self);
|
||||
int libRingBufferAdd(libRingBufferTypedef *self, const void *object);
|
||||
void *libRingBufferPeek(libRingBufferTypedef *self, unsigned int num);
|
||||
void *libRingBufferPull(libRingBufferTypedef *self, void *object);
|
||||
bool libRingBufferIsFull(libRingBufferTypedef *self);
|
||||
bool libRingBufferIsEmpty(libRingBufferTypedef *self);
|
||||
unsigned int libRingBufferNumElements(libRingBufferTypedef *self);
|
||||
|
||||
#endif
|
||||
143
firmware/Core/Inc/main.h
Normal file
143
firmware/Core/Inc/main.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.h
|
||||
* @brief : Header for main.c file.
|
||||
* This file contains the common defines of the application.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
extern void usbTIM(uint8_t OnOff);
|
||||
|
||||
extern uint16_t load_current;
|
||||
extern uint16_t charge_current;
|
||||
extern float float_current;
|
||||
extern uint8_t load_switch_state;
|
||||
extern uint8_t charge_switch_state;
|
||||
|
||||
extern uint16_t export_adc_average_res;
|
||||
|
||||
extern float export_real_capacity;
|
||||
|
||||
extern float cellVoltageHigh_Maximum;
|
||||
extern float cellVoltageHigh_Maximum_Hyst;
|
||||
extern float maxChargeCurrent;
|
||||
extern float maxLoadCurrent;
|
||||
extern float cellVoltageLow_Minimum;
|
||||
extern float cellVoltageLow_Minimum_Hyst;
|
||||
extern float currentZero_config;
|
||||
|
||||
extern float Brush_Minimum_SoC;
|
||||
extern uint8_t Brush_Default_State;
|
||||
|
||||
extern float maxTemperature;
|
||||
extern float maxTemperature_Hyst;
|
||||
|
||||
|
||||
extern uint8_t Pilot_Status;
|
||||
extern uint8_t Maximum_Charge_Current_Status;
|
||||
extern uint8_t Maximum_Voltage_Status;
|
||||
extern uint8_t Maximum_Temp_Status;
|
||||
extern uint8_t Maximum_Load_Current_Status;
|
||||
extern uint8_t Minimum_Voltage_Status;
|
||||
extern uint8_t Deep_Discharge_Status;
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* 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);
|
||||
|
||||
void UpdateGSMParamsFromConfig();
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define Output_2_Pin GPIO_PIN_2
|
||||
#define Output_2_GPIO_Port GPIOE
|
||||
#define Output_3_Pin GPIO_PIN_3
|
||||
#define Output_3_GPIO_Port GPIOE
|
||||
#define Output_4_Pin GPIO_PIN_4
|
||||
#define Output_4_GPIO_Port GPIOE
|
||||
#define Output_5_Pin GPIO_PIN_5
|
||||
#define Output_5_GPIO_Port GPIOE
|
||||
#define SD_CD_Pin GPIO_PIN_10
|
||||
#define SD_CD_GPIO_Port GPIOA
|
||||
#define SPI3_CS_Pin GPIO_PIN_3
|
||||
#define SPI3_CS_GPIO_Port GPIOC
|
||||
#define Input_1_Pin GPIO_PIN_7
|
||||
#define Input_1_GPIO_Port GPIOE
|
||||
#define Input_2_Pin GPIO_PIN_8
|
||||
#define Input_2_GPIO_Port GPIOE
|
||||
#define Input_3_Pin GPIO_PIN_9
|
||||
#define Input_3_GPIO_Port GPIOE
|
||||
#define GSM_RST_Pin GPIO_PIN_10
|
||||
#define GSM_RST_GPIO_Port GPIOE
|
||||
#define HL5_Pin GPIO_PIN_12
|
||||
#define HL5_GPIO_Port GPIOE
|
||||
#define HL4_Pin GPIO_PIN_13
|
||||
#define HL4_GPIO_Port GPIOE
|
||||
#define HL3_Pin GPIO_PIN_14
|
||||
#define HL3_GPIO_Port GPIOE
|
||||
#define HL2_Pin GPIO_PIN_15
|
||||
#define HL2_GPIO_Port GPIOE
|
||||
#define SD_CS_Pin GPIO_PIN_8
|
||||
#define SD_CS_GPIO_Port GPIOA
|
||||
#define Charging_Pin GPIO_PIN_2
|
||||
#define Charging_GPIO_Port GPIOD
|
||||
#define Output_0_Pin GPIO_PIN_0
|
||||
#define Output_0_GPIO_Port GPIOE
|
||||
#define Output_1_Pin GPIO_PIN_1
|
||||
#define Output_1_GPIO_Port GPIOE
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#define SD_SPI_HANDLE hspi1
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
785
firmware/Core/Inc/mainDataTypes.h
Normal file
785
firmware/Core/Inc/mainDataTypes.h
Normal file
@@ -0,0 +1,785 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DATATYPES_H_
|
||||
#define DATATYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dataHelper.h"
|
||||
|
||||
#define systime_t uint32_t // was not here
|
||||
|
||||
typedef enum {
|
||||
BALANCE_MODE_DISABLED = 0,
|
||||
BALANCE_MODE_CHARGING_ONLY,
|
||||
BALANCE_MODE_DURING_AND_AFTER_CHARGING,
|
||||
BALANCE_MODE_ALWAYS
|
||||
} BMS_BALANCE_MODE;
|
||||
|
||||
typedef enum {
|
||||
HW_TYPE_VESC = 0,
|
||||
HW_TYPE_VESC_BMS,
|
||||
HW_TYPE_CUSTOM_MODULE,
|
||||
HW_TYPE_EBMS
|
||||
} HW_TYPE;
|
||||
|
||||
typedef enum {
|
||||
I_MEASURE_MODE_BMS = 0,
|
||||
I_MEASURE_MODE_VESC
|
||||
} I_MEASURE_MODE;
|
||||
|
||||
// Data types
|
||||
typedef enum {
|
||||
MC_STATE_OFF = 0,
|
||||
MC_STATE_DETECTING,
|
||||
MC_STATE_RUNNING,
|
||||
MC_STATE_FULL_BRAKE,
|
||||
} mc_state;
|
||||
|
||||
typedef enum {
|
||||
PWM_MODE_NONSYNCHRONOUS_HISW = 0, // This mode is not recommended
|
||||
PWM_MODE_SYNCHRONOUS, // The recommended and most tested mode
|
||||
PWM_MODE_BIPOLAR // Some glitches occasionally, can kill MOSFETs
|
||||
} mc_pwm_mode;
|
||||
|
||||
typedef enum {
|
||||
COMM_MODE_INTEGRATE = 0,
|
||||
COMM_MODE_DELAY
|
||||
} mc_comm_mode;
|
||||
|
||||
typedef enum {
|
||||
SENSOR_MODE_SENSORLESS = 0,
|
||||
SENSOR_MODE_SENSORED,
|
||||
SENSOR_MODE_HYBRID
|
||||
} mc_sensor_mode;
|
||||
|
||||
typedef enum {
|
||||
FOC_SENSOR_MODE_SENSORLESS = 0,
|
||||
FOC_SENSOR_MODE_ENCODER,
|
||||
FOC_SENSOR_MODE_HALL
|
||||
} mc_foc_sensor_mode;
|
||||
|
||||
typedef enum {
|
||||
MOTOR_TYPE_BLDC = 0,
|
||||
MOTOR_TYPE_DC,
|
||||
MOTOR_TYPE_FOC
|
||||
} mc_motor_type;
|
||||
|
||||
typedef enum {
|
||||
FAULT_CODE_NONE = 0,
|
||||
FAULT_CODE_PACK_OVER_VOLTAGE,
|
||||
FAULT_CODE_PACK_UNDER_VOLTAGE,
|
||||
FAULT_CODE_LOAD_OVER_VOLTAGE,
|
||||
FAULT_CODE_LOAD_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CHARGER_OVER_VOLTAGE,
|
||||
FAULT_CODE_CHARGER_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CELL_HARD_OVER_VOLTAGE,
|
||||
FAULT_CODE_CELL_HARD_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CELL_SOFT_OVER_VOLTAGE,
|
||||
FAULT_CODE_CELL_SOFT_UNDER_VOLTAGE,
|
||||
FAULT_CODE_MAX_UVP_OVP_ERRORS,
|
||||
FAULT_CODE_MAX_UVT_OVT_ERRORS,
|
||||
FAULT_CODE_OVER_CURRENT,
|
||||
FAULT_CODE_OVER_TEMP_BMS,
|
||||
FAULT_CODE_UNDER_TEMP_BMS,
|
||||
FAULT_CODE_DISCHARGE_OVER_TEMP_CELLS,
|
||||
FAULT_CODE_DISCHARGE_UNDER_TEMP_CELLS,
|
||||
FAULT_CODE_CHARGE_OVER_TEMP_CELLS,
|
||||
FAULT_CODE_CHARGE_UNDER_TEMP_CELLS,
|
||||
FAULT_CODE_PRECHARGE_TIMEOUT,
|
||||
FAULT_CODE_DISCHARGE_RETRY,
|
||||
FAULT_CODE_CHARGE_RETRY,
|
||||
FAULT_CODE_CAN_DELAYED_POWER_DOWN,
|
||||
FAULT_CODE_NOT_USED_TIMEOUT,
|
||||
FAULT_CODE_CHARGER_DISCONNECT
|
||||
} bms_fault_state;
|
||||
|
||||
typedef enum {
|
||||
CONTROL_MODE_DUTY = 0,
|
||||
CONTROL_MODE_SPEED,
|
||||
CONTROL_MODE_CURRENT,
|
||||
CONTROL_MODE_CURRENT_BRAKE,
|
||||
CONTROL_MODE_POS,
|
||||
CONTROL_MODE_HANDBRAKE,
|
||||
CONTROL_MODE_OPENLOOP,
|
||||
CONTROL_MODE_NONE
|
||||
} mc_control_mode;
|
||||
|
||||
typedef enum {
|
||||
DISP_POS_MODE_NONE = 0,
|
||||
DISP_POS_MODE_INDUCTANCE,
|
||||
DISP_POS_MODE_OBSERVER,
|
||||
DISP_POS_MODE_ENCODER,
|
||||
DISP_POS_MODE_PID_POS,
|
||||
DISP_POS_MODE_PID_POS_ERROR,
|
||||
DISP_POS_MODE_ENCODER_OBSERVER_ERROR
|
||||
} disp_pos_mode;
|
||||
|
||||
typedef enum {
|
||||
SENSOR_PORT_MODE_HALL = 0,
|
||||
SENSOR_PORT_MODE_ABI,
|
||||
SENSOR_PORT_MODE_AS5047_SPI
|
||||
} sensor_port_mode;
|
||||
|
||||
typedef struct {
|
||||
float cycle_int_limit;
|
||||
float cycle_int_limit_running;
|
||||
float cycle_int_limit_max;
|
||||
float comm_time_sum;
|
||||
float comm_time_sum_min_rpm;
|
||||
int32_t comms;
|
||||
uint32_t time_at_comm;
|
||||
} mc_rpm_dep_struct;
|
||||
|
||||
typedef enum {
|
||||
DRV8301_OC_LIMIT = 0,
|
||||
DRV8301_OC_LATCH_SHUTDOWN,
|
||||
DRV8301_OC_REPORT_ONLY,
|
||||
DRV8301_OC_DISABLED
|
||||
} drv8301_oc_mode;
|
||||
|
||||
typedef enum {
|
||||
DEBUG_SAMPLING_OFF = 0,
|
||||
DEBUG_SAMPLING_NOW,
|
||||
DEBUG_SAMPLING_START,
|
||||
DEBUG_SAMPLING_TRIGGER_START,
|
||||
DEBUG_SAMPLING_TRIGGER_FAULT,
|
||||
DEBUG_SAMPLING_TRIGGER_START_NOSEND,
|
||||
DEBUG_SAMPLING_TRIGGER_FAULT_NOSEND,
|
||||
DEBUG_SAMPLING_SEND_LAST_SAMPLES
|
||||
} debug_sampling_mode;
|
||||
|
||||
typedef struct {
|
||||
// Switching and drive
|
||||
mc_pwm_mode pwm_mode;
|
||||
mc_comm_mode comm_mode;
|
||||
mc_motor_type motor_type;
|
||||
mc_sensor_mode sensor_mode;
|
||||
// Limits
|
||||
float l_current_max;
|
||||
float l_current_min;
|
||||
float l_in_current_max;
|
||||
float l_in_current_min;
|
||||
float l_abs_current_max;
|
||||
float l_min_erpm;
|
||||
float l_max_erpm;
|
||||
float l_erpm_start;
|
||||
float l_max_erpm_fbrake;
|
||||
float l_max_erpm_fbrake_cc;
|
||||
float l_min_vin;
|
||||
float l_max_vin;
|
||||
float l_battery_cut_start;
|
||||
float l_battery_cut_end;
|
||||
bool l_slow_abs_current;
|
||||
float l_temp_fet_start;
|
||||
float l_temp_fet_end;
|
||||
float l_temp_motor_start;
|
||||
float l_temp_motor_end;
|
||||
float l_min_duty;
|
||||
float l_max_duty;
|
||||
float l_watt_max;
|
||||
float l_watt_min;
|
||||
// Overridden limits (Computed during runtime)
|
||||
float lo_current_max;
|
||||
float lo_current_min;
|
||||
float lo_in_current_max;
|
||||
float lo_in_current_min;
|
||||
float lo_current_motor_max_now;
|
||||
float lo_current_motor_min_now;
|
||||
// Sensorless (bldc)
|
||||
float sl_min_erpm;
|
||||
float sl_min_erpm_cycle_int_limit;
|
||||
float sl_max_fullbreak_current_dir_change;
|
||||
float sl_cycle_int_limit;
|
||||
float sl_phase_advance_at_br;
|
||||
float sl_cycle_int_rpm_br;
|
||||
float sl_bemf_coupling_k;
|
||||
// Hall sensor
|
||||
int8_t hall_table[8];
|
||||
float hall_sl_erpm;
|
||||
// FOC
|
||||
float foc_current_kp;
|
||||
float foc_current_ki;
|
||||
float foc_f_sw;
|
||||
float foc_dt_us;
|
||||
float foc_encoder_offset;
|
||||
bool foc_encoder_inverted;
|
||||
float foc_encoder_ratio;
|
||||
float foc_motor_l;
|
||||
float foc_motor_r;
|
||||
float foc_motor_flux_linkage;
|
||||
float foc_observer_gain;
|
||||
float foc_observer_gain_slow;
|
||||
float foc_pll_kp;
|
||||
float foc_pll_ki;
|
||||
float foc_duty_dowmramp_kp;
|
||||
float foc_duty_dowmramp_ki;
|
||||
float foc_openloop_rpm;
|
||||
float foc_sl_openloop_hyst;
|
||||
float foc_sl_openloop_time;
|
||||
float foc_sl_d_current_duty;
|
||||
float foc_sl_d_current_factor;
|
||||
mc_foc_sensor_mode foc_sensor_mode;
|
||||
uint8_t foc_hall_table[8];
|
||||
float foc_sl_erpm;
|
||||
bool foc_sample_v0_v7;
|
||||
bool foc_sample_high_current;
|
||||
float foc_sat_comp;
|
||||
bool foc_temp_comp;
|
||||
float foc_temp_comp_base_temp;
|
||||
// Speed PID
|
||||
float s_pid_kp;
|
||||
float s_pid_ki;
|
||||
float s_pid_kd;
|
||||
float s_pid_min_erpm;
|
||||
bool s_pid_allow_braking;
|
||||
// Pos PID
|
||||
float p_pid_kp;
|
||||
float p_pid_ki;
|
||||
float p_pid_kd;
|
||||
float p_pid_ang_div;
|
||||
// Current controller
|
||||
float cc_startup_boost_duty;
|
||||
float cc_min_current;
|
||||
float cc_gain;
|
||||
float cc_ramp_step_max;
|
||||
// Misc
|
||||
int32_t m_fault_stop_time_ms;
|
||||
float m_duty_ramp_step;
|
||||
float m_current_backoff_gain;
|
||||
uint32_t m_encoder_counts;
|
||||
sensor_port_mode m_sensor_port_mode;
|
||||
bool m_invert_direction;
|
||||
drv8301_oc_mode m_drv8301_oc_mode;
|
||||
int m_drv8301_oc_adj;
|
||||
float m_bldc_f_sw_min;
|
||||
float m_bldc_f_sw_max;
|
||||
float m_dc_f_sw;
|
||||
} mc_configuration;
|
||||
|
||||
// Applications to use
|
||||
typedef enum {
|
||||
APP_NONE = 0,
|
||||
APP_PPM,
|
||||
APP_ADC,
|
||||
APP_UART,
|
||||
APP_PPM_UART,
|
||||
APP_ADC_UART,
|
||||
APP_NUNCHUK,
|
||||
APP_NRF,
|
||||
APP_CUSTOM
|
||||
} app_use;
|
||||
|
||||
// Throttle curve mode
|
||||
typedef enum {
|
||||
THR_EXP_EXPO = 0,
|
||||
THR_EXP_NATURAL,
|
||||
THR_EXP_POLY
|
||||
} thr_exp_mode;
|
||||
|
||||
// PPM control types
|
||||
typedef enum {
|
||||
PPM_CTRL_TYPE_NONE = 0,
|
||||
PPM_CTRL_TYPE_CURRENT,
|
||||
PPM_CTRL_TYPE_CURRENT_NOREV,
|
||||
PPM_CTRL_TYPE_CURRENT_NOREV_BRAKE,
|
||||
PPM_CTRL_TYPE_DUTY,
|
||||
PPM_CTRL_TYPE_DUTY_NOREV,
|
||||
PPM_CTRL_TYPE_PID,
|
||||
PPM_CTRL_TYPE_PID_NOREV
|
||||
} ppm_control_type;
|
||||
|
||||
typedef struct {
|
||||
ppm_control_type ctrl_type;
|
||||
float pid_max_erpm;
|
||||
float hyst;
|
||||
float pulse_start;
|
||||
float pulse_end;
|
||||
float pulse_center;
|
||||
bool median_filter;
|
||||
bool safe_start;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
} ppm_config;
|
||||
|
||||
// ADC control types
|
||||
typedef enum {
|
||||
ADC_CTRL_TYPE_NONE = 0,
|
||||
ADC_CTRL_TYPE_CURRENT,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_CENTER,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_BUTTON,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_BUTTON_BRAKE_ADC,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_BUTTON,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_ADC,
|
||||
ADC_CTRL_TYPE_DUTY,
|
||||
ADC_CTRL_TYPE_DUTY_REV_CENTER,
|
||||
ADC_CTRL_TYPE_DUTY_REV_BUTTON
|
||||
} adc_control_type;
|
||||
|
||||
typedef struct {
|
||||
adc_control_type ctrl_type;
|
||||
float hyst;
|
||||
float voltage_start;
|
||||
float voltage_end;
|
||||
float voltage_center;
|
||||
float voltage2_start;
|
||||
float voltage2_end;
|
||||
bool use_filter;
|
||||
bool safe_start;
|
||||
bool cc_button_inverted;
|
||||
bool rev_button_inverted;
|
||||
bool voltage_inverted;
|
||||
bool voltage2_inverted;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
uint32_t update_rate_hz;
|
||||
} adc_config;
|
||||
|
||||
// Nunchuk control types
|
||||
typedef enum {
|
||||
CHUK_CTRL_TYPE_NONE = 0,
|
||||
CHUK_CTRL_TYPE_CURRENT,
|
||||
CHUK_CTRL_TYPE_CURRENT_NOREV
|
||||
} chuk_control_type;
|
||||
|
||||
typedef struct {
|
||||
chuk_control_type ctrl_type;
|
||||
float hyst;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
float stick_erpm_per_s_in_cc;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
} chuk_config;
|
||||
|
||||
// NRF Datatypes
|
||||
typedef enum {
|
||||
NRF_SPEED_250K = 0,
|
||||
NRF_SPEED_1M,
|
||||
NRF_SPEED_2M
|
||||
} NRF_SPEED;
|
||||
|
||||
typedef enum {
|
||||
NRF_POWER_M18DBM = 0,
|
||||
NRF_POWER_M12DBM,
|
||||
NRF_POWER_M6DBM,
|
||||
NRF_POWER_0DBM
|
||||
} NRF_POWER;
|
||||
|
||||
typedef enum {
|
||||
NRF_AW_3 = 0,
|
||||
NRF_AW_4,
|
||||
NRF_AW_5
|
||||
} NRF_AW;
|
||||
|
||||
typedef enum {
|
||||
NRF_CRC_DISABLED = 0,
|
||||
NRF_CRC_1B,
|
||||
NRF_CRC_2B
|
||||
} NRF_CRC;
|
||||
|
||||
typedef enum {
|
||||
NRF_RETR_DELAY_250US = 0,
|
||||
NRF_RETR_DELAY_500US,
|
||||
NRF_RETR_DELAY_750US,
|
||||
NRF_RETR_DELAY_1000US,
|
||||
NRF_RETR_DELAY_1250US,
|
||||
NRF_RETR_DELAY_1500US,
|
||||
NRF_RETR_DELAY_1750US,
|
||||
NRF_RETR_DELAY_2000US,
|
||||
NRF_RETR_DELAY_2250US,
|
||||
NRF_RETR_DELAY_2500US,
|
||||
NRF_RETR_DELAY_2750US,
|
||||
NRF_RETR_DELAY_3000US,
|
||||
NRF_RETR_DELAY_3250US,
|
||||
NRF_RETR_DELAY_3500US,
|
||||
NRF_RETR_DELAY_3750US,
|
||||
NRF_RETR_DELAY_4000US
|
||||
} NRF_RETR_DELAY;
|
||||
|
||||
typedef struct {
|
||||
NRF_SPEED speed;
|
||||
NRF_POWER power;
|
||||
NRF_CRC crc_type;
|
||||
NRF_RETR_DELAY retry_delay;
|
||||
unsigned char retries;
|
||||
unsigned char channel;
|
||||
unsigned char address[3];
|
||||
bool send_crc_ack;
|
||||
} nrf_config;
|
||||
|
||||
typedef struct {
|
||||
// Settings
|
||||
uint8_t controller_id;
|
||||
uint32_t timeout_msec;
|
||||
float timeout_brake_current;
|
||||
bool send_can_status;
|
||||
uint32_t send_can_status_rate_hz;
|
||||
|
||||
// Application to use
|
||||
app_use app_to_use;
|
||||
|
||||
// PPM application settings
|
||||
ppm_config app_ppm_conf;
|
||||
|
||||
// ADC application settings
|
||||
adc_config app_adc_conf;
|
||||
|
||||
// UART application settings
|
||||
uint32_t app_uart_baudrate;
|
||||
|
||||
// Nunchuk application settings
|
||||
chuk_config app_chuk_conf;
|
||||
|
||||
// NRF application settings
|
||||
nrf_config app_nrf_conf;
|
||||
} app_configuration;
|
||||
|
||||
// Communication commands
|
||||
typedef enum {
|
||||
COMM_FW_VERSION = 0,
|
||||
COMM_JUMP_TO_BOOTLOADER,
|
||||
COMM_ERASE_NEW_APP,
|
||||
COMM_WRITE_NEW_APP_DATA,
|
||||
COMM_GET_VALUES,
|
||||
COMM_SET_DUTY,
|
||||
COMM_SET_CURRENT,
|
||||
COMM_SET_CURRENT_BRAKE,
|
||||
COMM_SET_RPM,
|
||||
COMM_SET_POS,
|
||||
COMM_SET_HANDBRAKE,
|
||||
COMM_SET_DETECT,
|
||||
COMM_SET_SERVO_POS,
|
||||
COMM_SET_MCCONF,
|
||||
COMM_GET_MCCONF,
|
||||
COMM_GET_MCCONF_DEFAULT,
|
||||
|
||||
|
||||
|
||||
COMM_SET_APPCONF,
|
||||
COMM_GET_APPCONF,
|
||||
COMM_GET_APPCONF_DEFAULT,
|
||||
COMM_SAMPLE_PRINT,
|
||||
COMM_TERMINAL_CMD,
|
||||
COMM_PRINT,
|
||||
COMM_ROTOR_POSITION,
|
||||
COMM_EXPERIMENT_SAMPLE,
|
||||
COMM_DETECT_MOTOR_PARAM,
|
||||
COMM_DETECT_MOTOR_R_L,
|
||||
COMM_DETECT_MOTOR_FLUX_LINKAGE,
|
||||
COMM_DETECT_ENCODER,
|
||||
COMM_DETECT_HALL_FOC,
|
||||
COMM_REBOOT,
|
||||
COMM_ALIVE,
|
||||
COMM_GET_DECODED_PPM,
|
||||
COMM_GET_DECODED_ADC,
|
||||
COMM_GET_DECODED_CHUK,
|
||||
COMM_FORWARD_CAN,
|
||||
COMM_SET_CHUCK_DATA,
|
||||
COMM_CUSTOM_APP_DATA,
|
||||
COMM_NRF_START_PAIRING,
|
||||
COMM_GPD_SET_FSW,
|
||||
COMM_GPD_BUFFER_NOTIFY,
|
||||
COMM_GPD_BUFFER_SIZE_LEFT,
|
||||
COMM_GPD_FILL_BUFFER,
|
||||
COMM_GPD_OUTPUT_SAMPLE,
|
||||
COMM_GPD_SET_MODE,
|
||||
COMM_GPD_FILL_BUFFER_INT8,
|
||||
COMM_GPD_FILL_BUFFER_INT16,
|
||||
COMM_GPD_SET_BUFFER_INT_SCALE,
|
||||
COMM_GET_VALUES_SETUP,
|
||||
COMM_SET_MCCONF_TEMP,
|
||||
COMM_SET_MCCONF_TEMP_SETUP,
|
||||
COMM_GET_VALUES_SELECTIVE,
|
||||
COMM_GET_VALUES_SETUP_SELECTIVE,
|
||||
COMM_EXT_NRF_PRESENT,
|
||||
COMM_EXT_NRF_ESB_SET_CH_ADDR,
|
||||
COMM_EXT_NRF_ESB_SEND_DATA,
|
||||
COMM_EXT_NRF_ESB_RX_DATA,
|
||||
COMM_EXT_NRF_SET_ENABLED,
|
||||
COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP,
|
||||
COMM_DETECT_APPLY_ALL_FOC,
|
||||
COMM_JUMP_TO_BOOTLOADER_ALL_CAN,
|
||||
COMM_ERASE_NEW_APP_ALL_CAN,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN,
|
||||
COMM_PING_CAN,
|
||||
COMM_APP_DISABLE_OUTPUT,
|
||||
COMM_TERMINAL_CMD_SYNC,
|
||||
COMM_GET_IMU_DATA,
|
||||
COMM_BM_CONNECT,
|
||||
COMM_BM_ERASE_FLASH_ALL,
|
||||
COMM_BM_WRITE_FLASH,
|
||||
COMM_BM_REBOOT,
|
||||
COMM_BM_DISCONNECT,
|
||||
COMM_BM_MAP_PINS_DEFAULT,
|
||||
COMM_BM_MAP_PINS_NRF5X,
|
||||
COMM_ERASE_BOOTLOADER,
|
||||
COMM_ERASE_BOOTLOADER_ALL_CAN,
|
||||
COMM_PLOT_INIT,
|
||||
COMM_PLOT_DATA,
|
||||
COMM_PLOT_ADD_GRAPH,
|
||||
COMM_PLOT_SET_GRAPH,
|
||||
COMM_GET_DECODED_BALANCE,
|
||||
COMM_BM_MEM_READ,
|
||||
COMM_WRITE_NEW_APP_DATA_LZO,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
|
||||
COMM_BM_WRITE_FLASH_LZO,
|
||||
COMM_SET_CURRENT_REL,
|
||||
COMM_CAN_FWD_FRAME,
|
||||
COMM_SET_BATTERY_CUT,
|
||||
COMM_SET_BLE_NAME,
|
||||
COMM_SET_BLE_PIN,
|
||||
COMM_SET_CAN_MODE,
|
||||
COMM_GET_IMU_CALIBRATION,
|
||||
COMM_GET_MCCONF_TEMP,
|
||||
|
||||
// Custom configuration for hardware
|
||||
COMM_GET_CUSTOM_CONFIG_XML,
|
||||
COMM_GET_CUSTOM_CONFIG,
|
||||
COMM_GET_CUSTOM_CONFIG_DEFAULT,
|
||||
COMM_SET_CUSTOM_CONFIG,
|
||||
|
||||
// BMS commands
|
||||
COMM_BMS_GET_VALUES,
|
||||
COMM_BMS_SET_CHARGE_ALLOWED,
|
||||
COMM_BMS_SET_BALANCE_OVERRIDE,
|
||||
COMM_BMS_RESET_COUNTERS,
|
||||
COMM_BMS_FORCE_BALANCE,
|
||||
COMM_BMS_ZERO_CURRENT_OFFSET,
|
||||
|
||||
// FW updates commands for different HW types
|
||||
COMM_JUMP_TO_BOOTLOADER_HW,
|
||||
COMM_ERASE_NEW_APP_HW,
|
||||
COMM_WRITE_NEW_APP_DATA_HW,
|
||||
COMM_ERASE_BOOTLOADER_HW,
|
||||
COMM_JUMP_TO_BOOTLOADER_ALL_CAN_HW,
|
||||
COMM_ERASE_NEW_APP_ALL_CAN_HW,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN_HW,
|
||||
COMM_ERASE_BOOTLOADER_ALL_CAN_HW,
|
||||
|
||||
COMM_SET_ODOMETER,
|
||||
|
||||
// ENNOID-BMS specific
|
||||
COMM_STORE_BMS_CONF = 150,
|
||||
COMM_GET_BMS_CELLS,
|
||||
COMM_GET_BMS_AUX,
|
||||
COMM_GET_BMS_EXP_TEMP,
|
||||
COMM_GET_GSM_DATA,
|
||||
COMM_GET_GSM_DEFAULT_DATA,
|
||||
COMM_SET_GSM_DATA,
|
||||
COMM_GET_FAULT_STATE,
|
||||
} COMM_PACKET_ID;
|
||||
|
||||
typedef enum {
|
||||
CANIDStyleVESC = 0,
|
||||
CANIDStyleFoiler
|
||||
} CAN_ID_STYLE;
|
||||
|
||||
typedef enum {
|
||||
OP_STATE_INIT = 0, // 0
|
||||
OP_STATE_CHARGING, // 1
|
||||
OP_STATE_PRE_CHARGE, // 2
|
||||
OP_STATE_LOAD_ENABLED, // 3
|
||||
OP_STATE_BATTERY_DEAD, // 4
|
||||
OP_STATE_POWER_DOWN, // 5
|
||||
OP_STATE_EXTERNAL, // 6
|
||||
OP_STATE_ERROR, // 7
|
||||
OP_STATE_ERROR_PRECHARGE, // 8
|
||||
OP_STATE_BALANCING, // 9
|
||||
OP_STATE_CHARGED, // 10
|
||||
OP_STATE_FORCEON, // 11
|
||||
} OperationalStateTypedef;
|
||||
|
||||
typedef enum {
|
||||
opInit = 0,
|
||||
opChargerReset,
|
||||
opChargerSet,
|
||||
opCharging
|
||||
} ChargerStateTypedef;
|
||||
|
||||
// CAN commands
|
||||
typedef enum {
|
||||
CAN_PACKET_ESC_SET_DUTY = 0,
|
||||
CAN_PACKET_ESC_SET_CURRENT,
|
||||
CAN_PACKET_ESC_SET_CURRENT_BRAKE,
|
||||
CAN_PACKET_ESC_SET_RPM,
|
||||
CAN_PACKET_ESC_SET_POS,
|
||||
CAN_PACKET_FILL_RX_BUFFER,
|
||||
CAN_PACKET_FILL_RX_BUFFER_LONG,
|
||||
CAN_PACKET_PROCESS_RX_BUFFER,
|
||||
CAN_PACKET_PROCESS_SHORT_BUFFER,
|
||||
CAN_PACKET_ESC_STATUS,
|
||||
CAN_PACKET_ESC_SET_CURRENT_REL,
|
||||
CAN_PACKET_ESC_SET_CURRENT_BRAKE_REL,
|
||||
CAN_PACKET_BMS_STATUS_MAIN_IV = 30,
|
||||
CAN_PACKET_BMS_STATUS_CELLVOLTAGE,
|
||||
CAN_PACKET_BMS_STATUS_THROTTLE_CH_DISCH_BOOL,
|
||||
CAN_PACKET_BMS_STATUS_TEMPERATURES,
|
||||
CAN_PACKET_BMS_STATUS_AUX_IV_SAFETY_WATCHDOG,
|
||||
CAN_PACKET_BMS_KEEP_ALIVE_SAFETY,
|
||||
CAN_PACKET_BMS_STATUS_TEMP_INDIVIDUAL,
|
||||
CAN_PACKET_SLS_STATUS_CURRENT_RPM = 40,
|
||||
CAN_PACKET_SLS_STATUS_TEMPERATURE,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_V_TEMP = 60,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_LOAD0,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_LOAD1
|
||||
} CAN_PACKET_ID;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
systime_t rx_time;
|
||||
float rpm;
|
||||
float current;
|
||||
float duty;
|
||||
} can_status_msg;
|
||||
|
||||
typedef enum {
|
||||
MOTE_PACKET_BATT_LEVEL = 0,
|
||||
MOTE_PACKET_BUTTONS,
|
||||
MOTE_PACKET_ALIVE,
|
||||
MOTE_PACKET_FILL_RX_BUFFER,
|
||||
MOTE_PACKET_FILL_RX_BUFFER_LONG,
|
||||
MOTE_PACKET_PROCESS_RX_BUFFER,
|
||||
MOTE_PACKET_PROCESS_SHORT_BUFFER,
|
||||
MOTE_PACKET_PAIRING_INFO
|
||||
} MOTE_PACKET;
|
||||
|
||||
typedef enum {
|
||||
NRF_PAIR_STARTED = 0,
|
||||
NRF_PAIR_OK,
|
||||
NRF_PAIR_FAIL
|
||||
} NRF_PAIR_RES;
|
||||
|
||||
typedef enum {
|
||||
CELL_MON_NONE = 0,
|
||||
CELL_MON_LTC6811_1,
|
||||
CELL_MON_LTC6812_1,
|
||||
CELL_MON_LTC6813_1
|
||||
} configCellMonitorICTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
opStateExternal = 0,
|
||||
opStateExtNormal
|
||||
} configExtEnableStateTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
opStateChargingModeCharging = 0,
|
||||
opStateChargingModeNormal
|
||||
} configChargerEnableStateTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
canSpeedBaud125k = 0,
|
||||
canSpeedBaud250k,
|
||||
canSpeedBaud500k
|
||||
} configCANSpeedTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
sourcePackVoltageNone = 0,
|
||||
sourcePackVoltageISL28022_2_BatteryIn,
|
||||
sourcePackVoltageSumOfIndividualCellVoltages,
|
||||
sourcePackVoltageCANDieBieShunt,
|
||||
sourcePackVoltageCANIsabellenhutte
|
||||
} configPackVoltageDataSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
sourcePackCurrentNone = 0,
|
||||
sourcePackCurrentLowCurrentShunt,
|
||||
sourcePackCurrentCANDieBieShunt,
|
||||
sourcePackCurrentCANIsaBellenHuette
|
||||
} configPackCurrentDataSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
socNone = 0,
|
||||
socCoulomb,
|
||||
socCoulombAndCellVoltage
|
||||
} configStateOfChargeMethodEnum;
|
||||
|
||||
typedef enum {
|
||||
basic = 0,
|
||||
advanced
|
||||
} displayStyle;
|
||||
|
||||
typedef enum {
|
||||
buzzerSourceOff = 0,
|
||||
buzzerSourceOn,
|
||||
buzzerSourceAll,
|
||||
buzzerSourceLC,
|
||||
buzzerSourceSOA
|
||||
} buzzerSignalSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
canEmitProtocolNone = 0,
|
||||
canEmitProtocolDieBieEngineering,
|
||||
canEmitProtocolMGElectronics
|
||||
} canEmitProtocol;
|
||||
|
||||
typedef struct {
|
||||
float cellVoltage;
|
||||
uint8_t cellNumber;
|
||||
bool cellBleedActive;
|
||||
} cellMonitorCellsTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float auxVoltage;
|
||||
uint8_t auxNumber;
|
||||
} auxMonitorTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float expVoltage;
|
||||
uint8_t expNumber;
|
||||
} expMonitorTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float voltages[12];
|
||||
uint16_t balanceMask;
|
||||
float temperatures[8];
|
||||
float humidity;
|
||||
} cellMonitorModuleTypeDef;
|
||||
|
||||
typedef enum {
|
||||
disabled = 0,
|
||||
enabled,
|
||||
forced // For specific hardware with negative main contactor as precharge circuit
|
||||
} switchState;
|
||||
|
||||
typedef enum {
|
||||
none = 0,
|
||||
si7020,
|
||||
htc1080
|
||||
} humidityICTypeEnum;
|
||||
|
||||
#endif /* DATATYPES_H_ */
|
||||
45
firmware/Core/Inc/modCommands.h
Normal file
45
firmware/Core/Inc/modCommands.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMANDS_H_
|
||||
#define COMMANDS_H_
|
||||
|
||||
#include "mainDataTypes.h"
|
||||
#include "libPacket.h"
|
||||
#include "generalDefines.h"
|
||||
#include "libBuffer.h"
|
||||
#include "modTerminal.h"
|
||||
//#include "modCAN.h"
|
||||
#include "modFlash.h"
|
||||
#include "modConfig.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Functions
|
||||
void modCommandsInit(modPowerElectronicsPackStateTypedef *generalState,modConfigGeneralConfigStructTypedef *configPointer);
|
||||
void modCommandsSetSendFunction(void(*func)(unsigned char *data, unsigned int len));
|
||||
void modCommandsSendPacket(unsigned char *data, unsigned int len);
|
||||
void modCommandsProcessPacket(unsigned char *data, unsigned int len);
|
||||
void modCommandsPrintf(const char* format, ...);
|
||||
void modCommandsJumpToMainApplication(void);
|
||||
|
||||
#endif /* COMMANDS_H_ */
|
||||
172
firmware/Core/Inc/modConfig.h
Normal file
172
firmware/Core/Inc/modConfig.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MODCONFIG_H
|
||||
#define __MODCONFIG_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdbool.h"
|
||||
#include "mainDataTypes.h"
|
||||
#include "driverSWStorageManager.h"
|
||||
#include "generalDefines.h"
|
||||
|
||||
#define modConfigNoOfNTCTypes 5
|
||||
#define modConfigNTCGroupLTCExt 2
|
||||
#define modConfigNTCGroupMasterPCB 3
|
||||
#define modConfigNTCGroupExp 4
|
||||
|
||||
#define __DEFAULT_BATTERY_SERIAL 20000007
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Master BMS
|
||||
//uint32_t serialNumber;
|
||||
uint8_t noOfCellsSeries; // Total number of cells in series in the battery pack
|
||||
uint8_t noOfCellsParallel; // Number of cells in parallel group
|
||||
uint8_t noOfCellsPerModule; // Number of cell levels monitored per LTC68XX
|
||||
uint8_t noOfParallelModules; // Number of parallel modules
|
||||
float batteryCapacity; // Battery capacity in Ah
|
||||
float cellHardUnderVoltage; // If the lowest cell is under this voltage -> Error situation, turn all off and power down
|
||||
float cellHardOverVoltage; // If the upper cell is above this voltage -> Error situation, turn all off and power down
|
||||
float cellLCSoftUnderVoltage; // If the lowest cell is under this voltage -> disable low current load
|
||||
float cellSoftOverVoltage; // If the upper cell is above this voltage -> disable charging, but keep bms enabled
|
||||
float cellBalanceDifferenceThreshold; // If the upper cell is more than this voltage away from the average -> start discharging this cell
|
||||
float cellBalanceStart; // If an upper cell is above this voltage and higher than the cellBalanceDifferenceThreshold voltage then average, start discharging
|
||||
bool cellBalanceAllTime; // Enable balancing under all opstate
|
||||
float cellThrottleUpperStart; // Charge throttle range
|
||||
float cellThrottleLowerStart; // Discharge throttle rande
|
||||
float cellThrottleUpperMargin; // Margin from the upper cell voltage extremes
|
||||
float cellThrottleLowerMargin; // Margin from the lower cell voltage extremes
|
||||
uint8_t packVoltageDataSource; // Enum value of pack voltage data source (what source to derive the voltage information from different ADC options)
|
||||
uint8_t packCurrentDataSource; // Enum value of pack current data source (what source to derive the current information from LC/HC/LC+HC/CAN)
|
||||
uint8_t buzzerSignalSource; // - Stores what source shoud be taken to trigger
|
||||
uint8_t buzzerSignalPersistant; // - Stores whether the buzzer should stay on after triggering
|
||||
float shuntLCFactor; // Shunt multiplication factor Low current
|
||||
float voltageLCFactor; // Battery Voltage multiplication factor Low current
|
||||
int16_t voltageLCOffset; // Battery Voltage low current offset
|
||||
float loadVoltageFactor; // Load Voltage multiplication factor
|
||||
float loadVoltageOffset; // Load Voltage offset
|
||||
float chargerVoltageFactor; // Charger Voltage multiplication factor
|
||||
float chargerVoltageOffset; // Charger Voltage offset
|
||||
uint8_t throttleChargeIncreaseRate; // The rate of charge throttle percentage increase per 100ms
|
||||
uint8_t throttleDisChargeIncreaseRate; // The rate of discharge throttle percentage instrease per 100ms
|
||||
uint32_t cellBalanceUpdateInterval; // Amount of time that the balance resistor enable mask is kept
|
||||
uint8_t maxSimultaneousDischargingCells; // Set the maximum amount of discharging cells. This is to limit dissepated power (and thus board temperature)
|
||||
uint32_t timeoutDischargeRetry; // If soft lower threshold limit was tripped wait this amount of time to re-enable load if cell is within threshold
|
||||
float hysteresisDischarge; // If the lowest cell voltage rises this amount of mV re enable output
|
||||
uint32_t timeoutChargeRetry; // If soft higher threshold limit was tripped and cell is within acceptable limits wait this amount of time before re-enabling charge input
|
||||
float hysteresisCharge; // If the highest cell voltage loweres this amount of mW re enable charge input
|
||||
uint32_t timeoutChargeCompleted; // If tricklecharging > this threshold timer declare the pack charged but keep balancing if nessesary
|
||||
uint32_t timeoutChargingCompletedMinimalMismatch; // If charger is disabled and cellvoltagemismatch is under threshold determin charged after this timeout time
|
||||
float maxMismatchThreshold; // If the mismatch is below this threshold the battery SoC is set to 100%
|
||||
float chargerEnabledThreshold; // Minimal current to stay in charge mode
|
||||
uint32_t timeoutChargerDisconnected; // Timeout for charger disconnect detection
|
||||
float minimalPrechargePercentage; // Output voltage threshold for precharging
|
||||
uint32_t timeoutLCPreCharge; // If threshold is not reached within this time in ms goto error state
|
||||
float maxAllowedCurrent; // Max allowed current passing trough BMS, if limit is exceded disable output
|
||||
float allowedTempBattDischargingMax; // Max battery temperature where discharging is still allowed
|
||||
float allowedTempBattDischargingMin; // Min battery temperature where discharging is still allowed
|
||||
float allowedTempBattChargingMax; // Max battery temperature where charging is still allowed
|
||||
float allowedTempBattChargingMin; // Min battery temperature where heating is activated
|
||||
float allowedTempBattCoolingMax; // Max battery temperature where cooling is activated
|
||||
float allowedTempBattCoolingMin; // Min battery temperature where charging is still allowed
|
||||
float allowedTempBMSMax; // Max BMS operational temperature
|
||||
float allowedTempBMSMin; // Min BMS operational temperature
|
||||
uint32_t displayTimeoutBatteryDead; // Duration of displaying battery dead symbol
|
||||
uint32_t displayTimeoutBatteryError; // Duration of displaying error symbol
|
||||
uint32_t displayTimeoutBatteryErrorPreCharge; // Duration of displaying error symbol
|
||||
uint32_t displayTimeoutSplashScreen; // Duration of displaying splash screen + First few samples of ADC's
|
||||
uint8_t displayStyle; // Enum value for the SSD1306 display style option used
|
||||
uint8_t maxUnderAndOverVoltageErrorCount; // Threshold that defines max amount of hard over / under voltage errors
|
||||
uint8_t maxUnderAndOverTemperatureErrorCount; // Threshold that defines max amount of hard over / under temperature errors
|
||||
float notUsedCurrentThreshold; // Threshold that defines whether or not pack is in use.
|
||||
uint32_t notUsedTimeout; // Delay time that defines max amount of no operation on-time. When absolute battery curren < notUsedCurrentThreshold for longer than this amount of time -> the system is disabled
|
||||
uint32_t stateOfChargeStoreInterval; // Interval to store state of charge information.
|
||||
uint8_t stateOfChargeMethod; // Stores the desired type of state of charge algorithm
|
||||
uint8_t CANID; // Stores the CAN ID of the device.
|
||||
uint8_t CANIDStyle; // Store the ID style used to communicate over CAN
|
||||
uint8_t emitStatusOverCAN; // Enable or disable sending of status over CAN
|
||||
uint8_t emitStatusProtocol; // The protocol type / format to send the status data
|
||||
uint32_t tempEnableMaskBMS; // Stores the mask to select what temperature sensor is enabled for the BMS.
|
||||
uint32_t tempEnableMaskBattery; // Stores the mask to select what temperature sensor is enabled for the battery.
|
||||
uint32_t tempEnableMaskExpansion; // Stores the mask to select what temperature sensor is enabled for the battery.
|
||||
uint8_t noOfTempSensorPerModule; // Number of temperature sensor monitored per LTC68XX
|
||||
uint8_t noOfExpansionBoard; // Number of expansion board
|
||||
uint8_t noOfTempSensorPerExpansionBoard; // Number of temperature sensor monitored per expansion board
|
||||
uint8_t LCUseDischarge; // Enable or disable switch output.
|
||||
uint8_t LCUsePrecharge; // choice whether to precharge or not.
|
||||
uint8_t allowChargingDuringDischarge; // Allow charging during discharge.
|
||||
uint8_t allowForceOn; // Enable or disable the option to be forced on.
|
||||
uint8_t pulseToggleButton; // Pulse or Toggle power button.
|
||||
uint8_t togglePowerModeDirectHCDelay; // Toggle switch controls onstate directly or controls HC output with delayed turn off.
|
||||
uint8_t useCANSafetyInput; // Use the safe input state received from the CAN bus.
|
||||
uint8_t useCANDelayedPowerDown; // Config that holds the preference whethet to used delayes power down
|
||||
uint8_t cellMonitorType; // The cell monitor IC type
|
||||
uint8_t cellMonitorICCount; // The amount of cell monitor IC's connected
|
||||
uint8_t lastICNoOfCells; // Store number of cells in the last module (Used for odd number of cells in series only)
|
||||
uint32_t lastICMask; // Stores the mask to select what cell should be monitored when last IC is not equal to other ones (Used for odd number of cells in series only)
|
||||
uint8_t externalEnableOperationalState; // The state to enter when externally enabled
|
||||
uint32_t powerDownDelay; // The delay time between going to power down and turning off
|
||||
uint8_t canBusSpeed; // CAN bus baudrate
|
||||
uint8_t chargeEnableOperationalState; // State to enter when BMS is turned on due to charger
|
||||
uint32_t NTCTopResistor[modConfigNoOfNTCTypes]; // NTC Pullup resistor value
|
||||
uint32_t NTC25DegResistance[modConfigNoOfNTCTypes]; // NTC resistance at 25 degree
|
||||
uint16_t NTCBetaFactor[modConfigNoOfNTCTypes]; // NTC Beta factor
|
||||
uint8_t humidityICType; // Humidity sensor IC type
|
||||
|
||||
char Domain_URL[250];
|
||||
char Domain_URL_Event[250];
|
||||
char GSM_APN[50];
|
||||
char GSM_USER[50];
|
||||
char GSM_PWD[50];
|
||||
|
||||
uint64_t serialNumber;
|
||||
uint64_t PC_Time;
|
||||
|
||||
bool chargeBatteryOutputChecked;
|
||||
bool brushOrShuntOutputChecked;
|
||||
bool brushOrShuntMode; // shunt -> false, brush -> true
|
||||
uint16_t brushUsageSocThreshold;
|
||||
uint16_t shuntChargingContactorDelay;
|
||||
bool coolingOutputChecked;
|
||||
int16_t coolingStartThreshold;
|
||||
int16_t coolingStopThreshold;
|
||||
bool heatingOutputChecked;
|
||||
int16_t heatingStartThreshold;
|
||||
int16_t heatingStopThreshold;
|
||||
|
||||
float floatCurrentK1; // First factor of current calculation
|
||||
float floatCurrentK2; // Second factor of current calculation
|
||||
|
||||
float externalChargeCurrentTable[9][11];
|
||||
bool externalChargeUnitTable[9][11];
|
||||
// uint8_t dummy;
|
||||
} modConfigGeneralConfigStructTypedef;
|
||||
|
||||
modConfigGeneralConfigStructTypedef* modConfigInit(void);
|
||||
bool modConfigStoreAndLoadDefaultConfig(void);
|
||||
bool modConfigStoreConfig(void);
|
||||
bool modConfigLoadConfig(void);
|
||||
bool modConfigStoreDefaultConfig(void);
|
||||
void modConfigLoadDefaultConfig(modConfigGeneralConfigStructTypedef *configLocation);
|
||||
void modconfigHardwareLimitsApply(modConfigGeneralConfigStructTypedef *configLocation);
|
||||
|
||||
#endif
|
||||
28
firmware/Core/Inc/modDelay.h
Normal file
28
firmware/Core/Inc/modDelay.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
void modDelayInit(void);
|
||||
uint8_t modDelayTick1ms(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick100ms(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick1msNoRST(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick100msNoRST(uint32_t *last, uint32_t ticks);
|
||||
161
firmware/Core/Inc/modFlash.h
Normal file
161
firmware/Core/Inc/modFlash.h
Normal file
@@ -0,0 +1,161 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
#ifndef MODFLASH_H__
|
||||
#define MODFLASH_H__
|
||||
|
||||
#define FLASH_PAGES 128
|
||||
#define BOOTLOADER_BASE 104
|
||||
#define MAIN_APP_BASE 0
|
||||
#define NEW_APP_BASE 52
|
||||
#define NEW_APP_SECTORS 52
|
||||
#define NEW_APP_MAX_SIZE (NEW_APP_SECTORS * (1 << 11))
|
||||
|
||||
/* Base address of the Flash sectors */
|
||||
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */ // Startup Code - Main application
|
||||
#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_2 ((uint32_t)0x08001000) /* Base @ of Page 2, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_3 ((uint32_t)0x08001800) /* Base @ of Page 3, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_4 ((uint32_t)0x08002000) /* Base @ of Page 4, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_5 ((uint32_t)0x08002800) /* Base @ of Page 5, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_6 ((uint32_t)0x08003000) /* Base @ of Page 6, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_7 ((uint32_t)0x08003800) /* Base @ of Page 7, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_8 ((uint32_t)0x08004000) /* Base @ of Page 8, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_9 ((uint32_t)0x08004800) /* Base @ of Page 9, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_10 ((uint32_t)0x08005000) /* Base @ of Page 10, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_11 ((uint32_t)0x08005800) /* Base @ of Page 11, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_12 ((uint32_t)0x08006000) /* Base @ of Page 12, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_13 ((uint32_t)0x08006800) /* Base @ of Page 13, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_14 ((uint32_t)0x08007000) /* Base @ of Page 14, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_15 ((uint32_t)0x08007800) /* Base @ of Page 15, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_16 ((uint32_t)0x08008000) /* Base @ of Page 16, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_17 ((uint32_t)0x08008800) /* Base @ of Page 17, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_18 ((uint32_t)0x08009000) /* Base @ of Page 18, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_19 ((uint32_t)0x08009800) /* Base @ of Page 19, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_20 ((uint32_t)0x0800A000) /* Base @ of Page 20, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_21 ((uint32_t)0x0800A800) /* Base @ of Page 21, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_22 ((uint32_t)0x0800B000) /* Base @ of Page 22, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_23 ((uint32_t)0x0800B800) /* Base @ of Page 23, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_24 ((uint32_t)0x0800C000) /* Base @ of Page 24, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_25 ((uint32_t)0x0800C800) /* Base @ of Page 25, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_26 ((uint32_t)0x0800D000) /* Base @ of Page 26, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_27 ((uint32_t)0x0800D800) /* Base @ of Page 27, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_28 ((uint32_t)0x0800E000) /* Base @ of Page 28, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_29 ((uint32_t)0x0800E800) /* Base @ of Page 29, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_30 ((uint32_t)0x0800F000) /* Base @ of Page 30, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_31 ((uint32_t)0x0800F800) /* Base @ of Page 31, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_32 ((uint32_t)0x08010000) /* Base @ of Page 32, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_33 ((uint32_t)0x08010800) /* Base @ of Page 33, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_34 ((uint32_t)0x08011000) /* Base @ of Page 34, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_35 ((uint32_t)0x08011800) /* Base @ of Page 35, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_36 ((uint32_t)0x08012000) /* Base @ of Page 36, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_37 ((uint32_t)0x08012800) /* Base @ of Page 37, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_38 ((uint32_t)0x08013000) /* Base @ of Page 38, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_39 ((uint32_t)0x08013800) /* Base @ of Page 39, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_40 ((uint32_t)0x08014000) /* Base @ of Page 40, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_41 ((uint32_t)0x08014800) /* Base @ of Page 41, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_42 ((uint32_t)0x08015000) /* Base @ of Page 42, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_43 ((uint32_t)0x08015800) /* Base @ of Page 43, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_44 ((uint32_t)0x08016000) /* Base @ of Page 44, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_45 ((uint32_t)0x08016800) /* Base @ of Page 45, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_46 ((uint32_t)0x08017000) /* Base @ of Page 46, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_47 ((uint32_t)0x08017800) /* Base @ of Page 47, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_48 ((uint32_t)0x08018000) /* Base @ of Page 48, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_49 ((uint32_t)0x08018800) /* Base @ of Page 49, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_50 ((uint32_t)0x08019000) /* Base @ of Page 50, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_51 ((uint32_t)0x08019800) /* Base @ of Page 51, 2 Kbytes *///Main ends here
|
||||
#define ADDR_FLASH_PAGE_52 ((uint32_t)0x0801A000) /* Base @ of Page 52, 2 Kbytes *///NEW app start
|
||||
#define ADDR_FLASH_PAGE_53 ((uint32_t)0x0801A800) /* Base @ of Page 53, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_54 ((uint32_t)0x0801B000) /* Base @ of Page 54, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_55 ((uint32_t)0x0801B800) /* Base @ of Page 55, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_56 ((uint32_t)0x0801C000) /* Base @ of Page 56, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_57 ((uint32_t)0x0801C800) /* Base @ of Page 57, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_58 ((uint32_t)0x0801D000) /* Base @ of Page 58, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_59 ((uint32_t)0x0801D800) /* Base @ of Page 59, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_60 ((uint32_t)0x0801E000) /* Base @ of Page 60, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_61 ((uint32_t)0x0801E800) /* Base @ of Page 61, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_62 ((uint32_t)0x0801F000) /* Base @ of Page 62, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_63 ((uint32_t)0x0801F800) /* Base @ of Page 63, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_64 ((uint32_t)0x08020000) /* Base @ of Page 64, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_65 ((uint32_t)0x08020800) /* Base @ of Page 65, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_66 ((uint32_t)0x08021000) /* Base @ of Page 66, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_67 ((uint32_t)0x08021800) /* Base @ of Page 67, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_68 ((uint32_t)0x08022000) /* Base @ of Page 68, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_69 ((uint32_t)0x08022800) /* Base @ of Page 69, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_70 ((uint32_t)0x08023000) /* Base @ of Page 70, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_71 ((uint32_t)0x08023800) /* Base @ of Page 71, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_72 ((uint32_t)0x08024000) /* Base @ of Page 72, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_73 ((uint32_t)0x08024800) /* Base @ of Page 73, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_74 ((uint32_t)0x08025000) /* Base @ of Page 74, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_75 ((uint32_t)0x08025800) /* Base @ of Page 75, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_76 ((uint32_t)0x08026000) /* Base @ of Page 76, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_77 ((uint32_t)0x08026800) /* Base @ of Page 77, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_78 ((uint32_t)0x08027000) /* Base @ of Page 78, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_79 ((uint32_t)0x08027800) /* Base @ of Page 79, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_80 ((uint32_t)0x08028000) /* Base @ of Page 80, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_81 ((uint32_t)0x08028800) /* Base @ of Page 81, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_82 ((uint32_t)0x08029000) /* Base @ of Page 82, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_83 ((uint32_t)0x08029800) /* Base @ of Page 83, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_84 ((uint32_t)0x0802A000) /* Base @ of Page 84, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_85 ((uint32_t)0x0802A800) /* Base @ of Page 85, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_86 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_87 ((uint32_t)0x0802B800) /* Base @ of Page 87, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_88 ((uint32_t)0x0802C000) /* Base @ of Page 88, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_89 ((uint32_t)0x0802C800) /* Base @ of Page 89, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_90 ((uint32_t)0x0802D000) /* Base @ of Page 90, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_91 ((uint32_t)0x0802D800) /* Base @ of Page 91, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_92 ((uint32_t)0x0802E000) /* Base @ of Page 92, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_93 ((uint32_t)0x0802E800) /* Base @ of Page 93, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_94 ((uint32_t)0x0802F000) /* Base @ of Page 94, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_95 ((uint32_t)0x0802F800) /* Base @ of Page 95, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_96 ((uint32_t)0x08030000) /* Base @ of Page 96, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_97 ((uint32_t)0x08030800) /* Base @ of Page 97, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_98 ((uint32_t)0x08031000) /* Base @ of Page 98, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_99 ((uint32_t)0x08031800) /* Base @ of Page 99, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_100 ((uint32_t)0x08032000) /* Base @ of Page 100, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_101 ((uint32_t)0x08032800) /* Base @ of Page 101, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_102 ((uint32_t)0x08033000) /* Base @ of Page 102, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_103 ((uint32_t)0x08033800) /* Base @ of Page 103, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_104 ((uint32_t)0x08034000) /* Base @ of Page 104, 2 Kbytes *///bootloader
|
||||
#define ADDR_FLASH_PAGE_105 ((uint32_t)0x08034800) /* Base @ of Page 105, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_106 ((uint32_t)0x08035000) /* Base @ of Page 106, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_107 ((uint32_t)0x08035800) /* Base @ of Page 107, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_108 ((uint32_t)0x08036000) /* Base @ of Page 108, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_109 ((uint32_t)0x08036800) /* Base @ of Page 109, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_110 ((uint32_t)0x08037000) /* Base @ of Page 110, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_111 ((uint32_t)0x08037800) /* Base @ of Page 111, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_112 ((uint32_t)0x08038000) /* Base @ of Page 112, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_113 ((uint32_t)0x08038800) /* Base @ of Page 113, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_114 ((uint32_t)0x08039000) /* Base @ of Page 114, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_115 ((uint32_t)0x08039800) /* Base @ of Page 115, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_116 ((uint32_t)0x0803A000) /* Base @ of Page 116, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_117 ((uint32_t)0x0803A800) /* Base @ of Page 117, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_118 ((uint32_t)0x0803B000) /* Base @ of Page 118, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_119 ((uint32_t)0x0803B800) /* Base @ of Page 119, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_120 ((uint32_t)0x0803C000) /* Base @ of Page 120, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_121 ((uint32_t)0x0803C800) /* Base @ of Page 121, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_122 ((uint32_t)0x0803D000) /* Base @ of Page 122, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_123 ((uint32_t)0x0803D800) /* Base @ of Page 123, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_124 ((uint32_t)0x0803E000) /* Base @ of Page 124, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_125 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_126 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */ //EEprom page1
|
||||
#define ADDR_FLASH_PAGE_127 ((uint32_t)0x0803F800) /* Base @ of Page 127, 2 Kbytes */ //EEprom page2
|
||||
// flash ends here
|
||||
|
||||
|
||||
typedef void (application_t)(void);
|
||||
|
||||
typedef struct{
|
||||
uint32_t stack_addr;
|
||||
application_t* func_p;
|
||||
} JumpStruct;
|
||||
|
||||
uint16_t modFlashEraseNewAppData(uint32_t new_app_size);
|
||||
uint16_t modFlashEraseMainAppData(uint32_t new_app_size);
|
||||
uint16_t modFlashWriteNewAppData(uint32_t offset, uint8_t *data, uint32_t len);
|
||||
uint16_t modFlashCopyNewAppToMainApp(uint32_t offset, uint8_t *data, uint32_t len);
|
||||
void modFlashJumpToBootloader(void);
|
||||
void modFlashJumpToMainApplication(void);
|
||||
void jumpToBootLoader(void);
|
||||
|
||||
#endif
|
||||
50
firmware/Core/Inc/modOperationalState.h
Normal file
50
firmware/Core/Inc/modOperationalState.h
Normal file
@@ -0,0 +1,50 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "stdbool.h"
|
||||
//#include "mainDataTypes.h"
|
||||
//#include "modDelay.h"
|
||||
//#include "modPowerState.h"
|
||||
////#include "modEffect.h"
|
||||
//#include "modPowerElectronics.h"
|
||||
////#include "modDisplay.h"
|
||||
//#include "modConfig.h"
|
||||
//#include "modStateOfCharge.h"
|
||||
//#include "math.h"
|
||||
//
|
||||
//#ifndef MODOPERATIONALSTATE_H_
|
||||
//#define MODOPERATIONALSTATE_H_
|
||||
//
|
||||
//void modOperationalStateInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer,modStateOfChargeStructTypeDef *generalStateOfCharge);
|
||||
//void modOperationalStateTask(void);
|
||||
//void modOperationalStateUpdateStates(void);
|
||||
//void modOperationalStateSetAllStates(OperationalStateTypedef newState);
|
||||
//void modOperationalStateSetNewState(OperationalStateTypedef newState);
|
||||
//
|
||||
//void modOperationalStateUpdateFaultStates(void);
|
||||
//void modOperationalStateSetAllFaultStates(bms_fault_state newFaultState);
|
||||
//void modOperationalStateSetNewFaultState(bms_fault_state newFaultState);
|
||||
//
|
||||
//void modOperationalStateHandleChargerDisconnect(OperationalStateTypedef newState);
|
||||
//void modOperationalStateTerminateOperation(void);
|
||||
//bool modOperationalStateDelayedDisable(bool delayedPowerDownDesired);
|
||||
//bool modOperationalStatePowerDownDelayCheck(void);
|
||||
//
|
||||
//#endif
|
||||
193
firmware/Core/Inc/modPowerElectronics.h
Normal file
193
firmware/Core/Inc/modPowerElectronics.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MODPOWERELECTRONICS_H
|
||||
#define __MODPOWERELECTRONICS_H
|
||||
|
||||
//#include "driverSWISL28022.h"
|
||||
//#include "driverHWADC.h"
|
||||
#include "driverSWLTC6804.h"
|
||||
//#include "driverSWADC128D818.h"
|
||||
//#include "driverHWSwitches.h"
|
||||
//#include "driverSWEMC2305.h"
|
||||
#include "modDelay.h"
|
||||
#include "modConfig.h"
|
||||
#//include "modPowerState.h"
|
||||
#include "stdbool.h"
|
||||
#include "math.h"
|
||||
//#include "driverSWSHT21.h"
|
||||
//#include "driverSWHTC1080.h"
|
||||
|
||||
|
||||
#define NoOfCellsPossibleOnBMS 180
|
||||
#define NoOfCellMonitorsPossibleOnBMS 19
|
||||
|
||||
#define NoOfAuxPossibleOnBMS 120
|
||||
|
||||
#define NoOfExpPossibleOnBMS 72
|
||||
#define NoOfExpMonitorPossibleOnBMS 9
|
||||
|
||||
#define NoOfTempSensors 16
|
||||
#define VinErrorThreshold 10
|
||||
|
||||
typedef enum {
|
||||
TEMP_EXT_LTC_NTC0 = 0, // EXT on master BMS on LTC
|
||||
TEMP_EXT_LTC_NTC1, // EXT on master BMS on LTC
|
||||
TEMP_INT_LTC_CHIP, // Int on master BMS inside LTC Chip
|
||||
TEMP_INT_STM_NTC, // Int on master BMS outside STM Chip
|
||||
TEMP_EXT_ADC_NTC0, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC1, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC2, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC3, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC4, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC5, // Ext on slave BMS OR water detect
|
||||
TEMP_INT_ADC_NTC6, // Int on slave BMS
|
||||
TEMP_INT_ADC_NTC7, // Int on slave BMS
|
||||
TEMP_INT_SHT, // Int on slave BMS
|
||||
TEMP_INT_ADC_NTCAUX // Ext on the CAN connector
|
||||
} modPowerElectronicsTemperatureSensorMapping;
|
||||
|
||||
typedef enum {
|
||||
PACK_STATE_ERROR_HARD_CELLVOLTAGE = 0,
|
||||
PACK_STATE_ERROR_SOFT_CELLVOLTAGE,
|
||||
PACK_STATE_ERROR_OVER_CURRENT,
|
||||
PACK_STATE_NORMAL,
|
||||
PACK_STATE_ERROR_TEMPERATURE,
|
||||
} modPowerElectronicsPackOperationalCellStatesTypedef;
|
||||
|
||||
typedef struct {
|
||||
// Master BMS
|
||||
|
||||
uint64_t serial_number;
|
||||
|
||||
uint16_t throttleDutyGeneralTemperatureBMS;
|
||||
uint16_t throttleDutyChargeVoltage;
|
||||
uint16_t throttleDutyChargeTemperatureBattery;
|
||||
uint16_t throttleDutyCharge;
|
||||
uint16_t throttleDutyDischargeVoltage;
|
||||
uint16_t throttleDutyDischargeTemperatureBattery;
|
||||
uint16_t throttleDutyDischarge;
|
||||
float SoC;
|
||||
float SoCCapacityAh;
|
||||
OperationalStateTypedef operationalState;
|
||||
bms_fault_state faultState;
|
||||
float packVoltage;
|
||||
float packCurrent;
|
||||
float packPower;
|
||||
float loCurrentLoadCurrent;
|
||||
float loCurrentLoadVoltage;
|
||||
float chargerVoltage;
|
||||
float cellVoltageHigh;
|
||||
float cellVoltageLow;
|
||||
float cellVoltageAverage;
|
||||
float cellVoltageMisMatch;
|
||||
uint16_t cellBalanceResistorEnableMask;
|
||||
float temperatures[NoOfTempSensors];
|
||||
float tempBatteryHigh;
|
||||
float tempBatteryLow;
|
||||
float tempBatteryAverage;
|
||||
float tempBMSHigh;
|
||||
float tempBMSLow;
|
||||
float tempBMSAverage;
|
||||
float humidity;
|
||||
uint8_t preChargeDesired;
|
||||
uint8_t disChargeDesired;
|
||||
uint8_t disChargeLCAllowed;
|
||||
bool disChargeOverMaxTemperature;
|
||||
bool disChargeOverMinTemperature;
|
||||
uint8_t chargeDesired;
|
||||
uint8_t chargePFETDesired;
|
||||
uint8_t chargeAllowed;
|
||||
bool chargeOverMaxTemperature;
|
||||
bool chargeOverMinTemperature;
|
||||
uint8_t coolingDesired;
|
||||
uint8_t coolingAllowed;
|
||||
uint8_t safetyOverCANHCSafeNSafe;
|
||||
uint8_t chargeCurrentDetected;
|
||||
uint8_t chargeBalanceActive;
|
||||
uint8_t balanceActive;
|
||||
uint8_t powerButtonActuated;
|
||||
uint8_t packInSOADischarge;
|
||||
uint8_t packInSOACharge;
|
||||
uint8_t powerDownDesired;
|
||||
uint8_t powerOnLongButtonPress;
|
||||
uint8_t buzzerOn;
|
||||
uint8_t watchDogTime;
|
||||
cellMonitorCellsTypeDef cellVoltagesIndividual[NoOfCellsPossibleOnBMS];
|
||||
auxMonitorTypeDef auxVoltagesIndividual[NoOfAuxPossibleOnBMS];
|
||||
expMonitorTypeDef expVoltagesIndividual[NoOfExpPossibleOnBMS];
|
||||
|
||||
modPowerElectronicsPackOperationalCellStatesTypedef packOperationalCellState;
|
||||
|
||||
// Slave modules -> TODO move into struct.
|
||||
float cellModuleVoltages[NoOfCellMonitorsPossibleOnBMS][18];
|
||||
float auxModuleVoltages[NoOfCellMonitorsPossibleOnBMS][12];
|
||||
float expModuleVoltages[NoOfExpMonitorPossibleOnBMS][8];
|
||||
uint32_t cellModuleBalanceResistorEnableMask[NoOfCellMonitorsPossibleOnBMS];
|
||||
uint32_t dieTemperature[NoOfCellMonitorsPossibleOnBMS];
|
||||
|
||||
} modPowerElectronicsPackStateTypedef;
|
||||
|
||||
void modPowerElectronicsInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfig);
|
||||
bool modPowerElectronicsTask(void);
|
||||
void modPowerElectronicsAllowForcedOn(bool allowedState);
|
||||
void modPowerElectronicsSetPreCharge(bool newState);
|
||||
bool modPowerElectronicsSetDisCharge(bool newState);
|
||||
void modPowerElectronicsSetCharge(bool newState);
|
||||
void modPowerElectronicsSetChargePFET(bool newState);
|
||||
void modPowerElectronicsSetCooling(bool newState);
|
||||
void modPowerElectronicsDisableAll(void);
|
||||
void modPowerElectronicsCalculateCellStats(void);
|
||||
void modPowerElectronicsSubTaskBalancing(void);
|
||||
void modPowerElectronicsCallMonitorsCalcBalanceResistorArray(void);
|
||||
void modPowerElectronicsSubTaskVoltageWatch(void);
|
||||
void modPowerElectronicsSubTaskCurrentWatch(void);
|
||||
void modPowerElectronicsUpdateSwitches(void);
|
||||
void modPowerElectronicsSortCells(cellMonitorCellsTypeDef *cells, uint8_t cellCount);
|
||||
void modPowerElectronicsCalcTempStats(void);
|
||||
void modPowerElectronicsCalcThrottle(void);
|
||||
int32_t modPowerElectronicsMapVariableInt(int32_t inputVariable, int32_t inputLowerLimit, int32_t inputUpperLimit, int32_t outputLowerLimit, int32_t outputUpperLimit);
|
||||
float modPowerElectronicsMapVariableFloat(float inputVariable, float inputLowerLimit, float inputUpperLimit, float outputLowerLimit, float outputUpperLimit);
|
||||
void modPowerElectronicsInitISL(void);
|
||||
void modPowerElectronicsSubTaskBuzzer(void);
|
||||
bool modPowerElectronicsHCSafetyCANAndPowerButtonCheck(void);
|
||||
void modPowerElectronicsResetBalanceModeActiveTimeout(void);
|
||||
void modPowerElectronicsCellMonitorsInit(void);
|
||||
void modPowerElectronicsCellMonitorsCheckConfigAndReadAnalogData(void);
|
||||
void modPowerElectronicsCellMonitorsStartCellConversion(void);
|
||||
void modPowerElectronicsCellMonitorsStartLoadedCellConversion(bool PUP);
|
||||
void modPowerElectronicsCellMonitorsStartTemperatureConversion(void);
|
||||
void modPowerElectronicsCellMonitorsEnableBalanceResistors(uint32_t);
|
||||
void modPowerElectronicsCellMonitorsEnableBalanceResistorsArray(void);
|
||||
void modPowerElectronicsCellMonitorsReadVoltageFlags(uint32_t *underVoltageFlags, uint32_t *overVoltageFlags);
|
||||
void modPowerElectronicsCellMonitorsCheckAndSolveInitState(void);
|
||||
void modPowerElectronicsCellMonitorsArrayTranslate(void);
|
||||
void modPowerElectronicsAuxMonitorsArrayTranslate(void);
|
||||
void modPowerElectronicsExpMonitorsArrayTranslate(void);
|
||||
float modPowerElectronicsCalcPackCurrent(void);
|
||||
void modPowerElectronicsTerminalCellConnectionTest(int argc, const char **argv);
|
||||
void modPowerElectronicsCheckPackSOA(void);
|
||||
void modPowerElectronicsSamplePackAndLCData(void);
|
||||
void modPowerElectronicsSamplePackVoltage(float *voltagePointer);
|
||||
void modPowerElectronicsLCSenseSample(void);
|
||||
void modPowerElectronicsLCSenseInit(void);
|
||||
uint16_t modPowerElectronicsLowestInThree(uint16_t num1,uint16_t num2,uint16_t num3);
|
||||
|
||||
#endif
|
||||
38
firmware/Core/Inc/modPowerState.h
Normal file
38
firmware/Core/Inc/modPowerState.h
Normal file
@@ -0,0 +1,38 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "modDelay.h"
|
||||
//#include "driverHWPowerState.h"
|
||||
//#include "modconfig.h"
|
||||
//
|
||||
//#define POWERBUTTON_POWERDOWN_THRESHOLD_TIME 1000
|
||||
//#define POWERBUTTON_FORCEON_THRESHOLD_TIME 5000
|
||||
//#define POWERBUTTON_DEBOUNCE_TIME 600
|
||||
//
|
||||
//void modPowerStateInit(PowerStateStateTypedef desiredPowerState);
|
||||
//void modPowerStateSetConfigHandle(modConfigGeneralConfigStructTypedef *generalConfigPointer);
|
||||
//void modPowerStateTask(void);
|
||||
//bool modPowerStateGetButtonPressedState(void);
|
||||
//bool modPowerStateChargerDetected(void);
|
||||
//bool modPowerStatePowerdownRequest(void);
|
||||
//bool modPowerStateForceOnRequest(void);
|
||||
//void modPowerStateSetState(PowerStateStateTypedef newState);
|
||||
//bool modPowerStateButtonPressedOnTurnon(void);
|
||||
//bool modPowerStateGetLongButtonPressState(void);
|
||||
38
firmware/Core/Inc/modStateOfCharge.h
Normal file
38
firmware/Core/Inc/modStateOfCharge.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef __MODSTATEOFCHARGE_H
|
||||
#define __MODSTATEOFCHARGE_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include "modConfig.h"
|
||||
|
||||
typedef struct {
|
||||
float generalStateOfCharge;
|
||||
float generalStateOfHealth;
|
||||
float remainingCapacityAh;
|
||||
float remainingCapacityWh;
|
||||
} modStateOfChargeStructTypeDef;
|
||||
|
||||
|
||||
extern float real_capacity;
|
||||
extern float previous_capacity;
|
||||
extern float previous_SoC;
|
||||
//static float current_SoC = 0;
|
||||
extern float soc_diff;
|
||||
extern float capacity_diff;
|
||||
extern uint8_t SoC_Save_Flag;
|
||||
|
||||
typedef enum {
|
||||
EVENT_FULL = 0,
|
||||
EVENT_EMPTY,
|
||||
} modStateOfChargeVoltageEventTypeDef;
|
||||
|
||||
modStateOfChargeStructTypeDef* modStateOfChargeInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer);
|
||||
void modStateOfChargeProcess(void);
|
||||
bool modStateOfChargeStoreAndLoadDefaultStateOfCharge(void);
|
||||
bool modStateOfChargeStoreStateOfCharge(void);
|
||||
bool modStateOfChargeLoadStateOfCharge(void);
|
||||
bool modStateOfChargePowerDownSave(void);
|
||||
void modStateOfChargeVoltageEvent(modStateOfChargeVoltageEventTypeDef eventType);
|
||||
|
||||
#endif
|
||||
50
firmware/Core/Inc/modTerminal.h
Normal file
50
firmware/Core/Inc/modTerminal.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the VESC/DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TERMINAL_H_
|
||||
#define TERMINAL_H_
|
||||
|
||||
#include "mainDataTypes.h"
|
||||
#include "modCommands.h"
|
||||
#include "generalDefines.h"
|
||||
#include "modStateOfCharge.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include "modOperationalState.h"
|
||||
#include "modConfig.h"
|
||||
#include "GSM.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
// Settings
|
||||
#define FAULT_VEC_LEN 25
|
||||
#define CALLBACK_LEN 25
|
||||
|
||||
// Functions
|
||||
void modTerminalProcessString(char *str);
|
||||
void modTerminalRegisterCommandCallBack(
|
||||
const char* command,
|
||||
const char *help,
|
||||
const char *arg_names,
|
||||
void(*cbf)(int argc, const char **argv));
|
||||
|
||||
#endif /* TERMINAL_H_ */
|
||||
28
firmware/Core/Inc/modUART.h
Normal file
28
firmware/Core/Inc/modUART.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef __MODMESSAGE_H
|
||||
#define __MODMESSAGE_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "driverSWUART2.h"
|
||||
#include "modDelay.h"
|
||||
#include "modConfig.h"
|
||||
#include "modPowerElectronics.h"
|
||||
|
||||
#include "libPacket.h"
|
||||
#include "modCommands.h"
|
||||
|
||||
#define PACKET_HANDLER_UART 0
|
||||
|
||||
typedef enum {
|
||||
MESSAGE_DEBUG = 0,
|
||||
MESSAGE_ERROR,
|
||||
MESSAGE_NORMAL,
|
||||
} modMessageMessageTypeDef;
|
||||
|
||||
void modUARTInit(void);
|
||||
void modUARTTask(void);
|
||||
void modUARTSendPacketWrapper(unsigned char *data, unsigned int len);
|
||||
void modUARTProcessPacket(unsigned char *data, unsigned int len);
|
||||
void modUARTSendPacket(unsigned char *data, unsigned int len);
|
||||
|
||||
#endif
|
||||
58
firmware/Core/Inc/rtc.h
Normal file
58
firmware/Core/Inc/rtc.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtc.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the rtc.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __RTC_H__
|
||||
#define __RTC_H__
|
||||
|
||||
#ifndef __GSMMODULE_H
|
||||
#include "GSM.h"
|
||||
#endif
|
||||
|
||||
|
||||
#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 */
|
||||
void RTC_Get_Values(Time_Struct* Time_to_Get);
|
||||
void RTC_Set_Values(Time_Struct* Time_to_Get);
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RTC_H__ */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
391
firmware/Core/Inc/stm32f1xx_hal_conf.h
Normal file
391
firmware/Core/Inc/stm32f1xx_hal_conf.h
Normal file
@@ -0,0 +1,391 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_conf.h
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F1xx_HAL_CONF_H
|
||||
#define __STM32F1xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||
#define HAL_CAN_MODULE_ENABLED
|
||||
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
/*#define HAL_CEC_MODULE_ENABLED */
|
||||
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
#define HAL_DAC_MODULE_ENABLED
|
||||
/*#define HAL_DMA_MODULE_ENABLED */
|
||||
/*#define HAL_ETH_MODULE_ENABLED */
|
||||
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
/*#define HAL_I2C_MODULE_ENABLED */
|
||||
/*#define HAL_I2S_MODULE_ENABLED */
|
||||
/*#define HAL_IRDA_MODULE_ENABLED */
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
/*#define HAL_NOR_MODULE_ENABLED */
|
||||
/*#define HAL_NAND_MODULE_ENABLED */
|
||||
/*#define HAL_PCCARD_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/*#define HAL_HCD_MODULE_ENABLED */
|
||||
/*#define HAL_PWR_MODULE_ENABLED */
|
||||
/*#define HAL_RCC_MODULE_ENABLED */
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
/*#define HAL_SD_MODULE_ENABLED */
|
||||
/*#define HAL_MMC_MODULE_ENABLED */
|
||||
/*#define HAL_SDRAM_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/*#define HAL_USART_MODULE_ENABLED */
|
||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
|
||||
/* ########################## Oscillator Values adaptation ####################*/
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
|
||||
/**
|
||||
* @brief External Low Speed oscillator (LSE) value.
|
||||
* This value is used by the UART, RTC HAL module to compute the system frequency
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority (lowest by default) */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 1U
|
||||
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
|
||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
|
||||
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
|
||||
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
|
||||
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
|
||||
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
|
||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
|
||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
|
||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
/* ################## Ethernet peripheral configuration ##################### */
|
||||
|
||||
/* Section 1 : Ethernet peripheral configuration */
|
||||
|
||||
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||
#define MAC_ADDR0 2U
|
||||
#define MAC_ADDR1 0U
|
||||
#define MAC_ADDR2 0U
|
||||
#define MAC_ADDR3 0U
|
||||
#define MAC_ADDR4 0U
|
||||
#define MAC_ADDR5 0U
|
||||
|
||||
/* Definition of the Ethernet driver buffers size and count */
|
||||
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||
#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||
|
||||
/* Section 2: PHY configuration section */
|
||||
|
||||
/* DP83848_PHY_ADDRESS Address*/
|
||||
#define DP83848_PHY_ADDRESS 0x01U
|
||||
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||
#define PHY_RESET_DELAY 0x000000FFU
|
||||
/* PHY Configuration delay */
|
||||
#define PHY_CONFIG_DELAY 0x00000FFFU
|
||||
|
||||
#define PHY_READ_TO 0x0000FFFFU
|
||||
#define PHY_WRITE_TO 0x0000FFFFU
|
||||
|
||||
/* Section 3: Common PHY Registers */
|
||||
|
||||
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
|
||||
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
|
||||
|
||||
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
|
||||
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
|
||||
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
|
||||
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
|
||||
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
|
||||
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
|
||||
|
||||
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
|
||||
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
|
||||
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
|
||||
|
||||
/* Section 4: Extended PHY Registers */
|
||||
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
|
||||
|
||||
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
|
||||
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
|
||||
|
||||
/* ################## SPI peripheral configuration ########################## */
|
||||
|
||||
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
|
||||
* Activated: CRC code is present inside driver
|
||||
* Deactivated: CRC code cleaned from driver
|
||||
*/
|
||||
|
||||
#define USE_SPI_CRC 0U
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ETH_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_eth.h"
|
||||
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_can.h"
|
||||
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||
#include "Legacy/stm32f1xx_hal_can_legacy.h"
|
||||
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CEC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_cec.h"
|
||||
#endif /* HAL_CEC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_adc.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_dac.h"
|
||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_sram.h"
|
||||
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NOR_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_nor.h"
|
||||
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2S_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_i2s.h"
|
||||
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pccard.h"
|
||||
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_sd.h"
|
||||
#endif /* HAL_SD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NAND_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_nand.h"
|
||||
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_irda.h"
|
||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_smartcard.h"
|
||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pcd.h"
|
||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HCD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_hcd.h"
|
||||
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_MMC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_mmc.h"
|
||||
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F1xx_HAL_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
72
firmware/Core/Inc/stm32f1xx_it.h
Normal file
72
firmware/Core/Inc/stm32f1xx_it.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_it.h
|
||||
* @brief This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F1xx_IT_H
|
||||
#define __STM32F1xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* 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 NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void OTG_FS_IRQHandler(void);
|
||||
void CAN1_RX0_IRQHandler(void);
|
||||
void CAN2_RX1_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F1xx_IT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user