create new branch for 23 charger testing
This commit is contained in:
43
Software/Core/Inc/b_cccv_algo.h
Normal file
43
Software/Core/Inc/b_cccv_algo.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* b_cccv_algo.h
|
||||
*
|
||||
* Created on: 16.06.2023
|
||||
* Author: max
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#ifndef INC_B_CCCV_ALGO_H_
|
||||
#define INC_B_CCCV_ALGO_H_
|
||||
|
||||
#define I_GAIN 4
|
||||
#define P_GAIN 10
|
||||
#define CHARGE_CURRENT_LIMIT 10.0
|
||||
#define SIMULINKTEST
|
||||
#undef SIMULINKTEST
|
||||
|
||||
|
||||
typedef enum{
|
||||
NO_CHARGING,
|
||||
CHARGING_IN_PROGRESS,
|
||||
CHARGING_COMPLETED
|
||||
} CCCV_CONTROL_STATE;
|
||||
|
||||
#ifdef SIMULINKTEST
|
||||
CCCV_CONTROL_STATE cccvloop(float maxcellvoltage, float voltagesetpoint, float maxcurrent, float*ccurrent);
|
||||
#else
|
||||
|
||||
CCCV_CONTROL_STATE cccvloop(float maxcellvoltage, float voltagesetpoint, float maxcurrent);
|
||||
void setchargecurrent(float chargecurrent);
|
||||
void setchargevoltage(uint8_t numberofcells,float maximumcellvoltage);
|
||||
float getMaximumCellVoltage();
|
||||
void chargingloop(float maximumcellvoltage);
|
||||
void startcharging(float endvoltage);
|
||||
void initChargerAlgo(uint8_t numberofcells, float maximumcellvoltage);
|
||||
void setchargevoltage(uint8_t numberofcells,float maximumcellvoltage);
|
||||
void stopcharging();
|
||||
#endif
|
||||
|
||||
float matlabvalidationwrapper(float maxcellvoltage, float voltagesetpoint, float maxcurrent);
|
||||
|
||||
#endif /* INC_B_CCCV_ALGO_H_ */
|
||||
62
Software/Core/Inc/can-halal.h
Normal file
62
Software/Core/Inc/can-halal.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef CAN_HALAL_H
|
||||
#define CAN_HALAL_H
|
||||
|
||||
// Define family macros if none are defined and we recognize a chip macro
|
||||
#if !defined(STM32F3) && !defined(STM32H7)
|
||||
#if defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xB) || \
|
||||
defined(STM32F302xC)
|
||||
#define STM32F3
|
||||
#endif
|
||||
#if defined(STM32H7A3xx)
|
||||
#define STM32H7
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(STM32F3)
|
||||
#include "stm32f3xx_hal.h"
|
||||
#define FTCAN_IS_BXCAN
|
||||
#define FTCAN_NUM_FILTERS 13
|
||||
#elif defined(STM32H7)
|
||||
#include "stm32h7xx_hal.h"
|
||||
#define FTCAN_IS_FDCAN
|
||||
#define FTCAN_NUM_FILTERS 13
|
||||
#else
|
||||
#error "Couldn't detect STM family"
|
||||
#endif
|
||||
|
||||
#if defined(FTCAN_IS_BXCAN)
|
||||
HAL_StatusTypeDef ftcan_init(CAN_HandleTypeDef *handle);
|
||||
#elif defined(FTCAN_IS_FDCAN)
|
||||
HAL_StatusTypeDef ftcan_init(FDCAN_HandleTypeDef *handle);
|
||||
#else
|
||||
#error "Unknown CAN peripheral"
|
||||
#endif
|
||||
|
||||
HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
||||
size_t datalen);
|
||||
|
||||
HAL_StatusTypeDef ftcan_add_filter(uint16_t id, uint16_t mask);
|
||||
|
||||
/**
|
||||
* Define this function to be notified of incoming CAN messages
|
||||
*/
|
||||
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* Read num_bytes bytes from a message (unmarshalled network byte order). The
|
||||
* msg pointer is advanced by the corresponding number of bytes.
|
||||
*
|
||||
* Both methods return a 64-bit integer, but you can safely cast it to a smaller
|
||||
* integer type.
|
||||
*/
|
||||
uint64_t ftcan_unmarshal_unsigned(const uint8_t **data, size_t num_bytes);
|
||||
int64_t ftcan_unmarshal_signed(const uint8_t **data, size_t num_bytes);
|
||||
|
||||
/**
|
||||
* Write num_bytes to a message (marshalled in network byte order). The pointer
|
||||
* is advanced by the corresponding number of bytes and returned.
|
||||
*/
|
||||
uint8_t *ftcan_marshal_unsigned(uint8_t *data, uint64_t val, size_t num_bytes);
|
||||
uint8_t *ftcan_marshal_signed(uint8_t *data, int64_t val, size_t num_bytes);
|
||||
|
||||
#endif // CAN_HALAL_H
|
||||
22
Software/Core/Inc/can.h
Normal file
22
Software/Core/Inc/can.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* can.h
|
||||
*
|
||||
* Created on: 21.06.2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
#ifndef INC_CAN_H_
|
||||
#define INC_CAN_H_
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#define CAN_ID_AMS_STATUS 0x00A
|
||||
#define CAN_ID_AMS_IN 0x00B
|
||||
#define CAN_ID_SLAVE_STATUS_BASE 0x080
|
||||
#define CAN_ID_CHARGER_ACTIVE 0x200
|
||||
|
||||
|
||||
|
||||
void initCan(FDCAN_HandleTypeDef *hcan);
|
||||
|
||||
#endif /* INC_CAN_H_ */
|
||||
17
Software/Core/Inc/charge_ctrl_test_shell.h
Normal file
17
Software/Core/Inc/charge_ctrl_test_shell.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* charge_ctrl_test_shell.h
|
||||
*
|
||||
* Created on: May 21, 2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
#ifndef INC_CHARGE_CTRL_TEST_SHELL_H_
|
||||
#define INC_CHARGE_CTRL_TEST_SHELL_H_
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
void charge_shell_init(UART_HandleTypeDef *huart);
|
||||
void charge_shell_loop();
|
||||
|
||||
|
||||
#endif /* INC_CHARGE_CTRL_TEST_SHELL_H_ */
|
||||
39
Software/Core/Inc/charger_control.h
Normal file
39
Software/Core/Inc/charger_control.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* charger_control.h
|
||||
*
|
||||
* Created on: May 21, 2023
|
||||
* Author: MaxMax
|
||||
*/
|
||||
|
||||
#ifndef INC_CHARGER_CONTROL_H_
|
||||
#define INC_CHARGER_CONTROL_H_
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#define CURRENT_DAC_ADR 0x58
|
||||
#define VOLTAGE_DAC_ADR 0x5E
|
||||
#define CHARGER_ADC_ADR 0x90
|
||||
|
||||
typedef struct{
|
||||
uint8_t acfail;
|
||||
uint8_t dcfail;
|
||||
uint8_t cc_status;
|
||||
uint8_t ot_status;
|
||||
uint8_t lim_status;
|
||||
uint16_t voltage;
|
||||
uint16_t current;
|
||||
}ChargerStatusHandleTypeDef;
|
||||
|
||||
void charger_control_init(I2C_HandleTypeDef* hi2c);
|
||||
|
||||
ChargerStatusHandleTypeDef charger_control_get_state();
|
||||
void charger_control_set_current(uint32_t current);
|
||||
void charger_control_set_voltage(uint32_t voltage);
|
||||
void charger_control_enable_charger_relay();
|
||||
void charger_control_disable_charger_relay();
|
||||
void charger_control_enable_remote();
|
||||
void charger_control_disable_remote();
|
||||
void charger_control_setup_DACs();
|
||||
|
||||
|
||||
#endif /* INC_CHARGER_CONTROL_H_ */
|
||||
@ -7,12 +7,13 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@ -57,6 +58,32 @@ void Error_Handler(void);
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define STATUS_LED_1_Pin GPIO_PIN_6
|
||||
#define STATUS_LED_1_GPIO_Port GPIOF
|
||||
#define STATUS_LED_2_Pin GPIO_PIN_7
|
||||
#define STATUS_LED_2_GPIO_Port GPIOF
|
||||
#define Display_Reset_Pin GPIO_PIN_8
|
||||
#define Display_Reset_GPIO_Port GPIOC
|
||||
#define Display_Standby_Pin GPIO_PIN_10
|
||||
#define Display_Standby_GPIO_Port GPIOC
|
||||
#define Display_Left_Right_Pin GPIO_PIN_11
|
||||
#define Display_Left_Right_GPIO_Port GPIOC
|
||||
#define Display_Up_Down_Pin GPIO_PIN_12
|
||||
#define Display_Up_Down_GPIO_Port GPIOC
|
||||
#define Charger_CC_Status_Pin GPIO_PIN_9
|
||||
#define Charger_CC_Status_GPIO_Port GPIOG
|
||||
#define Charger_OT_Pin GPIO_PIN_11
|
||||
#define Charger_OT_GPIO_Port GPIOG
|
||||
#define Charger_LIM_Pin GPIO_PIN_12
|
||||
#define Charger_LIM_GPIO_Port GPIOG
|
||||
#define Charger_DC_FAIL_Pin GPIO_PIN_13
|
||||
#define Charger_DC_FAIL_GPIO_Port GPIOG
|
||||
#define Charger_Relay_Pin GPIO_PIN_14
|
||||
#define Charger_Relay_GPIO_Port GPIOG
|
||||
#define Charger_AC_Fail_Pin GPIO_PIN_4
|
||||
#define Charger_AC_Fail_GPIO_Port GPIOB
|
||||
#define Charger_Remote_Shutdown_Pin GPIO_PIN_5
|
||||
#define Charger_Remote_Shutdown_GPIO_Port GPIOB
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
|
||||
46
Software/Core/Inc/slave_handler.h
Normal file
46
Software/Core/Inc/slave_handler.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* slave_handler.h
|
||||
*
|
||||
* Created on: Jun 21, 2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
#ifndef INC_SLAVE_HANDLER_H_
|
||||
#define INC_SLAVE_HANDLER_H_
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#define N_SLAVES 6
|
||||
|
||||
typedef enum {
|
||||
SLAVE_ERR_NONE,
|
||||
SLAVE_ERR_TIMEOUT,
|
||||
SLAVE_ERR_OT,
|
||||
SLAVE_ERR_UT,
|
||||
SLAVE_ERR_OV,
|
||||
SLAVE_ERR_UV,
|
||||
SLAVE_ERR_UNKNOWN,
|
||||
} SlaveErrorKind;
|
||||
|
||||
typedef struct {
|
||||
SlaveErrorKind kind;
|
||||
uint32_t data; // Cell/temperature ID etc
|
||||
} SlaveError;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
SlaveError error;
|
||||
uint8_t soc;
|
||||
uint16_t min_voltage;
|
||||
uint16_t max_voltage;
|
||||
int16_t max_temp;
|
||||
uint32_t last_message;
|
||||
} SlaveHandle;
|
||||
|
||||
extern SlaveHandle slaves[N_SLAVES];
|
||||
|
||||
float slaves_get_maximum_voltage();
|
||||
void slaves_handle_status(const uint8_t *data);
|
||||
void slave_handler_init();
|
||||
|
||||
#endif /* INC_SLAVE_HANDLER_H_ */
|
||||
@ -45,13 +45,12 @@
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
/* #define HAL_ETH_LEGACY_MODULE_ENABLED */
|
||||
/* #define HAL_ETH_MODULE_ENABLED */
|
||||
/* #define HAL_NAND_MODULE_ENABLED */
|
||||
/* #define HAL_NOR_MODULE_ENABLED */
|
||||
/* #define HAL_OTFDEC_MODULE_ENABLED */
|
||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
#define HAL_SDRAM_MODULE_ENABLED
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
/* #define HAL_HRTIM_MODULE_ENABLED */
|
||||
/* #define HAL_HSEM_MODULE_ENABLED */
|
||||
@ -59,29 +58,29 @@
|
||||
/* #define HAL_JPEG_MODULE_ENABLED */
|
||||
/* #define HAL_OPAMP_MODULE_ENABLED */
|
||||
/* #define HAL_OSPI_MODULE_ENABLED */
|
||||
/* #define HAL_XSPI_MODULE_ENABLED */
|
||||
/* #define HAL_OSPI_MODULE_ENABLED */
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_SMBUS_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LPTIM_MODULE_ENABLED */
|
||||
#define HAL_LTDC_MODULE_ENABLED
|
||||
/* #define HAL_XSPI_MODULE_ENABLED */
|
||||
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||
/* #define HAL_RAMECC_MODULE_ENABLED */
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
/* #define HAL_RTC_MODULE_ENABLED */
|
||||
/* #define HAL_SAI_MODULE_ENABLED */
|
||||
/* #define HAL_SD_MODULE_ENABLED */
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
/* #define HAL_MMC_MODULE_ENABLED */
|
||||
/* #define HAL_SPDIFRX_MODULE_ENABLED */
|
||||
/* #define HAL_SPI_MODULE_ENABLED */
|
||||
/* #define HAL_SWPMI_MODULE_ENABLED */
|
||||
/* #define HAL_TIM_MODULE_ENABLED */
|
||||
/* #define HAL_UART_MODULE_ENABLED */
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/* #define HAL_USART_MODULE_ENABLED */
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||
/* #define HAL_PCD_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/* #define HAL_HCD_MODULE_ENABLED */
|
||||
/* #define HAL_DFSDM_MODULE_ENABLED */
|
||||
/* #define HAL_DSI_MODULE_ENABLED */
|
||||
@ -107,7 +106,7 @@
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE (25000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
|
||||
#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
@ -166,7 +165,7 @@
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority */
|
||||
#define TICK_INT_PRIORITY (0UL) /*!< tick interrupt priority */
|
||||
#define USE_RTOS 0
|
||||
#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */
|
||||
#define USE_SPI_CRC 0U /*!< use CRC in SPI */
|
||||
@ -221,8 +220,8 @@
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* ########################### Ethernet Configuration ######################### */
|
||||
#define ETH_TX_DESC_CNT 4U /* number of Ethernet Tx DMA descriptors */
|
||||
#define ETH_RX_DESC_CNT 4U /* number of Ethernet Rx DMA descriptors */
|
||||
#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
|
||||
#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
|
||||
|
||||
#define ETH_MAC_ADDR0 (0x02UL)
|
||||
#define ETH_MAC_ADDR1 (0x00UL)
|
||||
@ -287,10 +286,6 @@
|
||||
#include "stm32h7xx_hal_eth.h"
|
||||
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ETH_LEGACY_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_eth_legacy.h"
|
||||
#endif /* HAL_ETH_LEGACY_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
@ -6,12 +6,13 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@ -55,6 +56,12 @@ void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void FDCAN1_IT0_IRQHandler(void);
|
||||
void FDCAN1_IT1_IRQHandler(void);
|
||||
void FMC_IRQHandler(void);
|
||||
void FDCAN_CAL_IRQHandler(void);
|
||||
void LTDC_IRQHandler(void);
|
||||
void LTDC_ER_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
205
Software/Core/Src/b_cccv_algo.c
Normal file
205
Software/Core/Src/b_cccv_algo.c
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* b_cccv_algo.c
|
||||
*
|
||||
* Created on: 16.06.2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
#include "b_cccv_algo.h"
|
||||
#include "charger_control.h"
|
||||
#include "main.h"
|
||||
|
||||
static uint32_t dt;
|
||||
static uint32_t lasttick;
|
||||
static float errorintegration = 0;
|
||||
static float finalvoltage = 4.15;
|
||||
static float chargevoltage = 430;
|
||||
static float chargecurrentlimit = CHARGE_CURRENT_LIMIT;
|
||||
|
||||
static float resistancelut[1024];
|
||||
static float voltageresistancelut[1024];
|
||||
|
||||
#define CURRENT_R 2.2
|
||||
#define VOLTAGE_R 18
|
||||
|
||||
CCCV_CONTROL_STATE chargerstate = NO_CHARGING;
|
||||
|
||||
#ifdef SIMULINKTEST
|
||||
CCCV_CONTROL_STATE cccvloop(float maxcellvoltage, float voltagesetpoint, float maxcurrent, float*ccurrent)
|
||||
#else
|
||||
CCCV_CONTROL_STATE cccvloop(float maxcellvoltage, float voltagesetpoint, float maxcurrent)
|
||||
#endif
|
||||
|
||||
{
|
||||
#ifdef SIMULINKTEST
|
||||
dt = 1000;
|
||||
#else
|
||||
dt = HAL_GetTick() - lasttick;
|
||||
lasttick = HAL_GetTick();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float chargecurrent = 0;
|
||||
|
||||
//Calculate Voltage Error and I and P Factors
|
||||
float voltageerror = voltagesetpoint-maxcellvoltage;
|
||||
|
||||
float errorproportional = P_GAIN * voltageerror;
|
||||
errorintegration += I_GAIN*voltageerror * ((float)dt)/1000;
|
||||
|
||||
|
||||
//Limit I and P Factors to maximum charge current
|
||||
|
||||
if(errorintegration > maxcurrent)
|
||||
errorintegration = maxcurrent;
|
||||
|
||||
if(errorproportional > maxcurrent)
|
||||
errorproportional = maxcurrent;
|
||||
|
||||
if(errorproportional <= -maxcurrent)
|
||||
errorproportional = -maxcurrent;
|
||||
|
||||
if(errorintegration <= -maxcurrent)
|
||||
errorintegration = -maxcurrent;
|
||||
|
||||
float errorintegrationout = errorintegration;
|
||||
chargecurrent = (errorproportional + errorintegrationout);
|
||||
|
||||
if(chargecurrent > maxcurrent)
|
||||
chargecurrent = maxcurrent;
|
||||
|
||||
if(chargecurrent <= 0)
|
||||
chargecurrent = 0;
|
||||
|
||||
if(chargecurrent < 0.01) //If Charge Current ist below minimum threshold, stop charging
|
||||
return CHARGING_COMPLETED;
|
||||
#ifdef SIMULINKTEST
|
||||
*ccurrent = chargecurrent;
|
||||
#else
|
||||
setchargevoltage(103,finalvoltage+0.05);
|
||||
setchargecurrent(chargecurrent);
|
||||
#endif
|
||||
|
||||
|
||||
return CHARGING_IN_PROGRESS;
|
||||
}
|
||||
|
||||
#ifndef SIMULINKTEST
|
||||
|
||||
void initChargerAlgo(uint8_t numberofcells, float maximumcellvoltage)
|
||||
{
|
||||
chargerstate = NO_CHARGING;
|
||||
chargevoltage = numberofcells * maximumcellvoltage;
|
||||
|
||||
for(uint32_t i = 0; i < 1024; i++)
|
||||
{
|
||||
resistancelut[i] = 10*CURRENT_R/(CURRENT_R+(20*((float)i)/1024));
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < 1024; i++)
|
||||
{
|
||||
voltageresistancelut[i] = (600*VOLTAGE_R)/(VOLTAGE_R+(20*((float)i)/1024));
|
||||
}
|
||||
}
|
||||
|
||||
void setchargecurrent(float chargecurrent)
|
||||
{
|
||||
float targetresistance;
|
||||
if(chargecurrent != 0)
|
||||
{
|
||||
for(uint32_t setpoint = 0; setpoint < 1024; setpoint++)
|
||||
{
|
||||
if(resistancelut[setpoint] <= chargecurrent)
|
||||
{
|
||||
targetresistance = (20000*((float)setpoint)/1024);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetresistance = 20000;
|
||||
}
|
||||
|
||||
float wiperpos = targetresistance/20000 * (1023);
|
||||
charger_control_set_current((uint32_t) wiperpos);
|
||||
}
|
||||
|
||||
void setchargevoltage(uint8_t numberofcells,float maximumcellvoltage)
|
||||
{
|
||||
|
||||
float chargevoltage = numberofcells * maximumcellvoltage;
|
||||
float targetresistance;
|
||||
|
||||
if(chargevoltage != 0)
|
||||
{
|
||||
for(uint32_t setpoint = 0; setpoint < 1024; setpoint++)
|
||||
{
|
||||
if(voltageresistancelut[setpoint] <= chargevoltage)
|
||||
{
|
||||
targetresistance = (20000*((float)setpoint)/1024);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetresistance = 20000;
|
||||
}
|
||||
|
||||
float wiperpos = targetresistance/20000 * (1023);
|
||||
charger_control_set_voltage((uint32_t) wiperpos);
|
||||
//@TODO Call Function to set Resistance for Voltage
|
||||
}
|
||||
|
||||
void chargingloop(float maximumcellvoltage)
|
||||
{
|
||||
switch(chargerstate)
|
||||
{
|
||||
case NO_CHARGING: //Do Nothing IDLE Loop
|
||||
chargerstate = NO_CHARGING;
|
||||
charger_control_disable_remote();
|
||||
errorintegration = 0;
|
||||
break;
|
||||
case CHARGING_IN_PROGRESS: //Run charging algo periodically
|
||||
charger_control_enable_remote();
|
||||
chargerstate = cccvloop(maximumcellvoltage, finalvoltage, chargecurrentlimit);
|
||||
break;
|
||||
case CHARGING_COMPLETED: //Signal Completion of Charging here
|
||||
chargerstate = NO_CHARGING;
|
||||
charger_control_disable_remote();
|
||||
errorintegration = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void startcharging(float endvoltage)
|
||||
{
|
||||
chargerstate = CHARGING_IN_PROGRESS;
|
||||
finalvoltage = endvoltage;
|
||||
}
|
||||
|
||||
void stopcharging()
|
||||
{
|
||||
chargerstate = NO_CHARGING;
|
||||
charger_control_disable_remote();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SIMULINKTEST
|
||||
|
||||
float matlabvalidationwrapper(float maxcellvoltage, float voltagesetpoint, float maxcurrent)
|
||||
{
|
||||
float chargecurrent = 0;
|
||||
(void*) cccvloop(maxcellvoltage,voltagesetpoint,maxcurrent, &chargecurrent);
|
||||
return chargecurrent;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
273
Software/Core/Src/can-halal.c
Normal file
273
Software/Core/Src/can-halal.c
Normal file
@ -0,0 +1,273 @@
|
||||
#include "can-halal.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(FTCAN_IS_BXCAN)
|
||||
static CAN_HandleTypeDef *hcan;
|
||||
|
||||
HAL_StatusTypeDef ftcan_init(CAN_HandleTypeDef *handle) {
|
||||
hcan = handle;
|
||||
|
||||
HAL_StatusTypeDef status =
|
||||
HAL_CAN_ActivateNotification(hcan, CAN_IT_RX_FIFO0_MSG_PENDING);
|
||||
if (status != HAL_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return HAL_CAN_Start(hcan);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
||||
size_t datalen) {
|
||||
static CAN_TxHeaderTypeDef header;
|
||||
header.StdId = id;
|
||||
header.IDE = CAN_ID_STD;
|
||||
header.RTR = CAN_RTR_DATA;
|
||||
header.DLC = datalen;
|
||||
uint32_t mailbox;
|
||||
return HAL_CAN_AddTxMessage(hcan, &header, data, &mailbox);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_add_filter(uint16_t id, uint16_t mask) {
|
||||
static uint32_t next_filter_no = 0;
|
||||
static CAN_FilterTypeDef filter;
|
||||
if (next_filter_no % 2 == 0) {
|
||||
filter.FilterIdHigh = id << 5;
|
||||
filter.FilterMaskIdHigh = mask << 5;
|
||||
filter.FilterIdLow = id << 5;
|
||||
filter.FilterMaskIdLow = mask << 5;
|
||||
} else {
|
||||
// Leave high filter untouched from the last configuration
|
||||
filter.FilterIdLow = id << 5;
|
||||
filter.FilterMaskIdLow = mask << 5;
|
||||
}
|
||||
filter.FilterFIFOAssignment = CAN_FILTER_FIFO0;
|
||||
filter.FilterBank = next_filter_no / 2;
|
||||
if (filter.FilterBank > FTCAN_NUM_FILTERS + 1) {
|
||||
return HAL_ERROR;
|
||||
}
|
||||
filter.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||
filter.FilterScale = CAN_FILTERSCALE_16BIT;
|
||||
filter.FilterActivation = CAN_FILTER_ENABLE;
|
||||
|
||||
// Disable slave filters
|
||||
// TODO: Some STM32 have multiple CAN peripherals, and one uses the slave
|
||||
// filter bank
|
||||
filter.SlaveStartFilterBank = FTCAN_NUM_FILTERS;
|
||||
|
||||
HAL_StatusTypeDef status = HAL_CAN_ConfigFilter(hcan, &filter);
|
||||
if (status == HAL_OK) {
|
||||
next_filter_no++;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *handle) {
|
||||
if (handle != hcan) {
|
||||
return;
|
||||
}
|
||||
CAN_RxHeaderTypeDef header;
|
||||
uint8_t data[8];
|
||||
if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &header, data) != HAL_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (header.IDE != CAN_ID_STD) {
|
||||
return;
|
||||
}
|
||||
|
||||
ftcan_msg_received_cb(header.StdId, header.DLC, data);
|
||||
}
|
||||
#elif defined(FTCAN_IS_FDCAN)
|
||||
static FDCAN_HandleTypeDef *hcan;
|
||||
|
||||
HAL_StatusTypeDef ftcan_init(FDCAN_HandleTypeDef *handle) {
|
||||
hcan = handle;
|
||||
|
||||
HAL_StatusTypeDef status =
|
||||
HAL_FDCAN_ActivateNotification(hcan, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);
|
||||
if (status != HAL_OK) {
|
||||
return status;
|
||||
}
|
||||
// Reject non-matching messages
|
||||
status =
|
||||
HAL_FDCAN_ConfigGlobalFilter(hcan, FDCAN_REJECT, FDCAN_REJECT,
|
||||
FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);
|
||||
if (status != HAL_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return HAL_FDCAN_Start(hcan);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
||||
size_t datalen) {
|
||||
static FDCAN_TxHeaderTypeDef header;
|
||||
header.Identifier = id;
|
||||
header.IdType = FDCAN_STANDARD_ID;
|
||||
header.TxFrameType = FDCAN_DATA_FRAME;
|
||||
switch (datalen) {
|
||||
case 0:
|
||||
header.DataLength = FDCAN_DLC_BYTES_0;
|
||||
break;
|
||||
case 1:
|
||||
header.DataLength = FDCAN_DLC_BYTES_1;
|
||||
break;
|
||||
case 2:
|
||||
header.DataLength = FDCAN_DLC_BYTES_2;
|
||||
break;
|
||||
case 3:
|
||||
header.DataLength = FDCAN_DLC_BYTES_3;
|
||||
break;
|
||||
case 4:
|
||||
header.DataLength = FDCAN_DLC_BYTES_4;
|
||||
break;
|
||||
case 5:
|
||||
header.DataLength = FDCAN_DLC_BYTES_5;
|
||||
break;
|
||||
case 6:
|
||||
header.DataLength = FDCAN_DLC_BYTES_6;
|
||||
break;
|
||||
case 7:
|
||||
header.DataLength = FDCAN_DLC_BYTES_7;
|
||||
break;
|
||||
case 8:
|
||||
default:
|
||||
header.DataLength = FDCAN_DLC_BYTES_8;
|
||||
break;
|
||||
}
|
||||
header.ErrorStateIndicator = FDCAN_ESI_PASSIVE;
|
||||
header.BitRateSwitch = FDCAN_BRS_OFF;
|
||||
header.FDFormat = FDCAN_CLASSIC_CAN;
|
||||
header.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
|
||||
|
||||
// HAL_FDCAN_AddMessageToTxFifoQ doesn't modify the data, but it's not marked
|
||||
// as const for some reason.
|
||||
uint8_t *data_nonconst = (uint8_t *)data;
|
||||
return HAL_FDCAN_AddMessageToTxFifoQ(hcan, &header, data_nonconst);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_add_filter(uint16_t id, uint16_t mask) {
|
||||
static uint32_t next_filter_no = 0;
|
||||
static FDCAN_FilterTypeDef filter;
|
||||
filter.IdType = FDCAN_STANDARD_ID;
|
||||
filter.FilterIndex = next_filter_no;
|
||||
if (filter.FilterIndex > FTCAN_NUM_FILTERS + 1) {
|
||||
return HAL_ERROR;
|
||||
}
|
||||
filter.FilterType = FDCAN_FILTER_MASK;
|
||||
filter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
|
||||
filter.FilterID1 = id;
|
||||
filter.FilterID2 = mask;
|
||||
|
||||
HAL_StatusTypeDef status = HAL_FDCAN_ConfigFilter(hcan, &filter);
|
||||
if (status == HAL_OK) {
|
||||
next_filter_no++;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *handle,
|
||||
uint32_t RxFifo0ITs) {
|
||||
if (handle != hcan || (RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) == RESET) {
|
||||
return;
|
||||
}
|
||||
|
||||
static FDCAN_RxHeaderTypeDef header;
|
||||
static uint8_t data[8];
|
||||
if (HAL_FDCAN_GetRxMessage(hcan, FDCAN_RX_FIFO0, &header, data) != HAL_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (header.FDFormat != FDCAN_CLASSIC_CAN ||
|
||||
header.RxFrameType != FDCAN_DATA_FRAME ||
|
||||
header.IdType != FDCAN_STANDARD_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t datalen;
|
||||
switch (header.DataLength) {
|
||||
case FDCAN_DLC_BYTES_0:
|
||||
datalen = 0;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_1:
|
||||
datalen = 1;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_2:
|
||||
datalen = 2;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_3:
|
||||
datalen = 3;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_4:
|
||||
datalen = 4;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_5:
|
||||
datalen = 5;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_6:
|
||||
datalen = 6;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_7:
|
||||
datalen = 7;
|
||||
break;
|
||||
case FDCAN_DLC_BYTES_8:
|
||||
datalen = 8;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
ftcan_msg_received_cb(header.Identifier, datalen, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
__weak void ftcan_msg_received_cb(uint16_t id, size_t datalen,
|
||||
const uint8_t *data) {}
|
||||
|
||||
uint64_t ftcan_unmarshal_unsigned(const uint8_t **data_ptr, size_t num_bytes) {
|
||||
if (num_bytes > 8) {
|
||||
num_bytes = 8;
|
||||
}
|
||||
|
||||
const uint8_t *data = *data_ptr;
|
||||
uint64_t result = 0;
|
||||
for (size_t i = 0; i < num_bytes; i++) {
|
||||
result <<= 8;
|
||||
result |= data[i];
|
||||
}
|
||||
*data_ptr += num_bytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t ftcan_unmarshal_signed(const uint8_t **data_ptr, size_t num_bytes) {
|
||||
if (num_bytes > 8) {
|
||||
num_bytes = 8;
|
||||
}
|
||||
|
||||
uint64_t result_unsigned = ftcan_unmarshal_unsigned(data_ptr, num_bytes);
|
||||
// Sign extend by shifting left, then copying to a signed int and shifting
|
||||
// back to the right
|
||||
size_t diff_to_64 = 64 - num_bytes * 8;
|
||||
result_unsigned <<= diff_to_64;
|
||||
int64_t result;
|
||||
memcpy(&result, &result_unsigned, 8);
|
||||
return result >> diff_to_64;
|
||||
}
|
||||
|
||||
uint8_t *ftcan_marshal_unsigned(uint8_t *data, uint64_t val, size_t num_bytes) {
|
||||
if (num_bytes > 8) {
|
||||
num_bytes = 8;
|
||||
}
|
||||
|
||||
for (int i = num_bytes - 1; i >= 0; i--) {
|
||||
data[i] = val & 0xFF;
|
||||
val >>= 8;
|
||||
}
|
||||
|
||||
return data + num_bytes;
|
||||
}
|
||||
|
||||
uint8_t *ftcan_marshal_signed(uint8_t *data, int64_t val, size_t num_bytes) {
|
||||
return ftcan_marshal_unsigned(data, val, num_bytes);
|
||||
}
|
||||
57
Software/Core/Src/can.c
Normal file
57
Software/Core/Src/can.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* can.c
|
||||
*
|
||||
* Created on: 21.06.2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
|
||||
#include "can.h"
|
||||
#include "can-halal.h"
|
||||
#include "slave_handler.h"
|
||||
#include "b_cccv_algo.h"
|
||||
#include "charger_control.h"
|
||||
|
||||
|
||||
void initCan(FDCAN_HandleTypeDef *hcan)
|
||||
{
|
||||
ftcan_init(hcan);
|
||||
ftcan_add_filter(0, 0);
|
||||
}
|
||||
|
||||
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data)
|
||||
{
|
||||
if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) {
|
||||
// slaves_handle_status(data);
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (id == CAN_ID_CHARGER_ACTIVE)
|
||||
{
|
||||
if(data[0] == 1)
|
||||
{
|
||||
uint8_t* ptr = &data[1];
|
||||
startcharging(((float) ftcan_unmarshal_unsigned(&ptr, 2))/10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
stopcharging();
|
||||
}
|
||||
return;
|
||||
}*/
|
||||
switch (id) {
|
||||
case CAN_ID_AMS_STATUS: {
|
||||
int sdc_closed = data[0] >> 7;
|
||||
if (sdc_closed == 0) {
|
||||
charger_control_disable_remote();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CAN_ID_AMS_IN: {
|
||||
int active = data[0] & 0x01;
|
||||
if (active) {
|
||||
charger_control_enable_remote();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Software/Core/Src/charge_ctrl_test_shell.c
Normal file
69
Software/Core/Src/charge_ctrl_test_shell.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* charge_ctrl_test_shell.c
|
||||
*
|
||||
* Created on: May 21, 2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
|
||||
#include "charge_ctrl_test_shell.h"
|
||||
#include "charger_control.h"
|
||||
|
||||
UART_HandleTypeDef *suart;
|
||||
|
||||
void charge_shell_init(UART_HandleTypeDef *huart)
|
||||
{
|
||||
suart = huart;
|
||||
}
|
||||
|
||||
void charge_shell_loop()
|
||||
{
|
||||
uint8_t command[3];
|
||||
HAL_StatusTypeDef status = HAL_UART_Receive(suart, command, 3, 100);
|
||||
if(status == HAL_OK)
|
||||
{
|
||||
switch(command[0])
|
||||
{
|
||||
case 'r':
|
||||
if(command[1] == 'c') //enable remote control
|
||||
{
|
||||
charger_control_enable_remote();
|
||||
}
|
||||
else if(command[1] == 'o') //disable remote control
|
||||
{
|
||||
charger_control_disable_remote();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
if(command[1] == 'c')
|
||||
{
|
||||
charger_control_enable_charger_relay();
|
||||
}
|
||||
else if(command[1] == 'o')
|
||||
{
|
||||
charger_control_disable_charger_relay();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
;uint16_t voltage = (command[1]<<8) | command[2];
|
||||
charger_control_set_voltage(voltage);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
;uint16_t current = (command[1]<<8 | command[2]);
|
||||
charger_control_set_current(current);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
;ChargerStatusHandleTypeDef charg = charger_control_get_state();
|
||||
uint8_t txbuffer[9] = {charg.acfail, charg.dcfail, charg.cc_status,
|
||||
charg.lim_status, charg.ot_status, (uint8_t)(charg.current>>8),
|
||||
(uint8_t)charg.current&0xFF,(uint8_t)(charg.voltage>>8),
|
||||
(uint8_t)charg.voltage&0xFF
|
||||
};
|
||||
HAL_UART_Transmit(suart, txbuffer, 9, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
168
Software/Core/Src/charger_control.c
Normal file
168
Software/Core/Src/charger_control.c
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* charger_control.c
|
||||
*
|
||||
* Created on: May 21, 2023
|
||||
* Author: MaxMax
|
||||
*/
|
||||
|
||||
#include "charger_control.h"
|
||||
#include "main.h"
|
||||
|
||||
I2C_HandleTypeDef* charger_i2c;
|
||||
|
||||
|
||||
/*** @brief Start ADC Conversion on Charger Current Channel and returns the result
|
||||
* @note The ADC has a PGA leading to an input range of +-6.144 in twos complement. With single ended measurements, the range is 15 bit and
|
||||
* Voltage = 6.144/(2^(15)-1)
|
||||
* @note The charger maps a voltage range of 0-5V to the output current of 0-10A
|
||||
* @retval ADC Conversion register value
|
||||
*/
|
||||
uint16_t readADCCurrent()
|
||||
{
|
||||
uint8_t writeconfigreg[3] = {0x01, 0xC1, 0xE3};
|
||||
uint8_t readconfigreg[1] = {0x01};
|
||||
uint8_t readconversionreg[1] = {0x00};
|
||||
uint8_t configreg[2];
|
||||
uint8_t conversionreg[2];
|
||||
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, writeconfigreg, 3, 1000); //Set Config Register and Start conversion
|
||||
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, readconfigreg, 1, 1000); //Read Back Config Reg to check for conversion completion
|
||||
HAL_I2C_Master_Receive(charger_i2c, CHARGER_ADC_ADR, configreg, 2, 1000);
|
||||
HAL_Delay(1);//@TODO Remove if ADC Works
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, readconversionreg, 1, 1000); //Read Result from conversion register
|
||||
HAL_I2C_Master_Receive(charger_i2c, CHARGER_ADC_ADR, conversionreg, 2, 1000);
|
||||
|
||||
return (uint16_t)(conversionreg[0]<<8 | conversionreg[1]);
|
||||
|
||||
}
|
||||
|
||||
/*** @brief Start ADC Conversion on Charger Voltage Channel and returns the result
|
||||
* @note The ADC has a PGA leading to an input range of +-6.144 in twos complement. With single ended measurements, the range is 15 bit and
|
||||
* Voltage = 6.144/(2^(15)-1)
|
||||
* @note The charger maps a voltage range of 0-5V to the output voltage range of 0-600V
|
||||
* @retval ADC Conversion register value
|
||||
*/
|
||||
|
||||
uint16_t readADCVoltage()
|
||||
{
|
||||
uint8_t writeconfigreg[3] = {0x01, 0xC1, 0xE3};
|
||||
uint8_t readconfigreg[1] = {0x01};
|
||||
uint8_t readconversionreg[1] = {0x00};
|
||||
uint8_t configreg[2];
|
||||
uint8_t conversionreg[2];
|
||||
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, writeconfigreg, 3, 1000); //Set Config Register and Start conversion
|
||||
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, readconfigreg, 1, 1000); //Read Back Config Reg to check for conversion completion
|
||||
HAL_I2C_Master_Receive(charger_i2c, CHARGER_ADC_ADR, configreg, 2, 1000);
|
||||
HAL_Delay(1);//@TODO Remove if ADC Works
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CHARGER_ADC_ADR, readconversionreg, 1, 1000); //Read Result from conversion register
|
||||
HAL_I2C_Master_Receive(charger_i2c, CHARGER_ADC_ADR, conversionreg, 2, 1000);
|
||||
|
||||
return (uint16_t)(conversionreg[0]<<8 | conversionreg[1]);
|
||||
}
|
||||
|
||||
/*** @brief Initilization Routine of the charger
|
||||
* @note initially all outputs are set to 0, remote control and charger relay are deactivated
|
||||
* @param hi2c Handler to I2C struct for ADC and DAC communication
|
||||
*/
|
||||
void charger_control_init(I2C_HandleTypeDef* hi2c)
|
||||
{
|
||||
charger_i2c = hi2c;
|
||||
|
||||
charger_control_disable_remote();
|
||||
charger_control_disable_charger_relay();
|
||||
charger_control_setup_DACs();
|
||||
charger_control_set_current(0);
|
||||
charger_control_set_voltage(0);
|
||||
}
|
||||
|
||||
/*** @brief Get State of voltage, current and error flags of the charger
|
||||
* @retval Struct Containing charger information
|
||||
*/
|
||||
|
||||
ChargerStatusHandleTypeDef charger_control_get_state()
|
||||
{
|
||||
ChargerStatusHandleTypeDef chargerstate;
|
||||
chargerstate.voltage = readADCVoltage();
|
||||
chargerstate.current = readADCCurrent();
|
||||
chargerstate.acfail = HAL_GPIO_ReadPin(Charger_AC_Fail_GPIO_Port, Charger_AC_Fail_Pin);
|
||||
chargerstate.dcfail = HAL_GPIO_ReadPin(Charger_DC_FAIL_GPIO_Port, Charger_DC_FAIL_Pin);
|
||||
chargerstate.cc_status = HAL_GPIO_ReadPin(Charger_CC_Status_GPIO_Port, Charger_CC_Status_Pin);
|
||||
chargerstate.lim_status = HAL_GPIO_ReadPin(Charger_LIM_GPIO_Port, Charger_LIM_Pin);
|
||||
chargerstate.ot_status = HAL_GPIO_ReadPin(Charger_OT_GPIO_Port, Charger_OT_Pin);
|
||||
return chargerstate;
|
||||
}
|
||||
|
||||
void charger_control_setup_DACs()
|
||||
{
|
||||
uint8_t enabledacs[2] = {0x1C, 0x02};
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CURRENT_DAC_ADR, enabledacs, 2, 1000);
|
||||
HAL_I2C_Master_Transmit(charger_i2c, VOLTAGE_DAC_ADR, enabledacs, 2, 1000);
|
||||
}
|
||||
|
||||
/*** @brief set current channel using the DAC
|
||||
* @param current value in 10 bit => 0-5V are equal to 0-10A so 1 bit is approx 49mA
|
||||
*
|
||||
*/
|
||||
|
||||
void charger_control_set_current(uint32_t current)
|
||||
{
|
||||
uint8_t currentlow = current & 0xFF;
|
||||
uint8_t currenthigh = ((current>>8) & 0x03) | 0x04;
|
||||
uint8_t current_dac_data[2] = {currenthigh,currentlow};
|
||||
HAL_I2C_Master_Transmit(charger_i2c, CURRENT_DAC_ADR, current_dac_data, 2, 1000);
|
||||
}
|
||||
|
||||
/** @brief set voltage channel using the DAC
|
||||
* @param voltage value in 10 bit => 0-5V are equal to 0-600V so 1 bit is approx. 2.93V
|
||||
*
|
||||
*/
|
||||
|
||||
void charger_control_set_voltage(uint32_t voltage)
|
||||
{
|
||||
uint8_t voltagelow = voltage & 0xFF;
|
||||
uint8_t voltagehigh = ((voltage>>8) & 0x03) | 0x04;
|
||||
uint8_t voltage_dac_data[2] = {voltagehigh,voltagelow};
|
||||
HAL_I2C_Master_Transmit(charger_i2c, VOLTAGE_DAC_ADR, voltage_dac_data, 2, 1000);
|
||||
}
|
||||
|
||||
/** @brief Closes the main charger Relay
|
||||
* @note The relay is also dependend on the Shutdown Circuit
|
||||
*/
|
||||
|
||||
void charger_control_enable_charger_relay()
|
||||
{
|
||||
HAL_GPIO_WritePin(Charger_Relay_GPIO_Port, Charger_Relay_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/** @brief opens the main charger Relay
|
||||
* @note The relay is also dependend on the Shutdown Circuit
|
||||
*/
|
||||
|
||||
void charger_control_disable_charger_relay()
|
||||
{
|
||||
HAL_GPIO_WritePin(Charger_Relay_GPIO_Port, Charger_Relay_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
/** @brief enables remote control of the charger
|
||||
* @note The relay is also dependend on the Shutdown Circuit
|
||||
*/
|
||||
|
||||
void charger_control_enable_remote()
|
||||
{
|
||||
HAL_GPIO_WritePin(Charger_Remote_Shutdown_GPIO_Port, Charger_Remote_Shutdown_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
|
||||
/** @brief disable remote control of the charger
|
||||
* @note The relay is also dependend on the Shutdown Circuit
|
||||
*/
|
||||
|
||||
void charger_control_disable_remote()
|
||||
{
|
||||
HAL_GPIO_WritePin(Charger_Remote_Shutdown_GPIO_Port, Charger_Remote_Shutdown_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
|
||||
@ -6,22 +6,26 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "string.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "charger_control.h"
|
||||
#include "slave_handler.h"
|
||||
#include "can.h"
|
||||
#include "b_cccv_algo.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@ -32,7 +36,6 @@
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
@ -41,49 +44,50 @@
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma location=0x30000000
|
||||
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
|
||||
#pragma location=0x30000200
|
||||
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
|
||||
|
||||
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
|
||||
|
||||
__attribute__((at(0x30000000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
|
||||
__attribute__((at(0x30000200))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
|
||||
|
||||
#elif defined ( __GNUC__ ) /* GNU Compiler */
|
||||
|
||||
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
|
||||
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */
|
||||
#endif
|
||||
|
||||
ETH_TxPacketConfig TxConfig;
|
||||
|
||||
ETH_HandleTypeDef heth;
|
||||
|
||||
FDCAN_HandleTypeDef hfdcan1;
|
||||
|
||||
I2C_HandleTypeDef hi2c4;
|
||||
|
||||
LTDC_HandleTypeDef hltdc;
|
||||
|
||||
SD_HandleTypeDef hsd2;
|
||||
|
||||
UART_HandleTypeDef huart5;
|
||||
UART_HandleTypeDef huart10;
|
||||
|
||||
PCD_HandleTypeDef hpcd_USB_OTG_HS;
|
||||
|
||||
SDRAM_HandleTypeDef hsdram1;
|
||||
|
||||
uint16_t setpoint = 0;
|
||||
float currentsetpoint = 0.0;
|
||||
float voltagesetpoint = 3.8;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void SystemClock_Config(void);
|
||||
static void MPU_Config(void);
|
||||
void PeriphCommonClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_LTDC_Init(void);
|
||||
static void MX_ETH_Init(void);
|
||||
static void MX_FDCAN1_Init(void);
|
||||
static void MX_FMC_Init(void);
|
||||
static void MX_I2C4_Init(void);
|
||||
static void MX_SDMMC2_SD_Init(void);
|
||||
static void MX_USART10_UART_Init(void);
|
||||
static void MX_USB_OTG_HS_PCD_Init(void);
|
||||
static void MX_UART5_Init(void);
|
||||
static void MX_LTDC_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
uint32_t MemoryCheck(UART_HandleTypeDef *uart_console, SDRAM_HandleTypeDef *sram);
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
#define RAM_TEST_BLOCKSIZE 4096
|
||||
__attribute__((section(".ahb_sec"))) uint32_t testarray[RAM_TEST_BLOCKSIZE];
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -92,14 +96,10 @@ static void MX_FDCAN1_Init(void);
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MPU Configuration--------------------------------------------------------*/
|
||||
MPU_Config();
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||
@ -112,26 +112,56 @@ int main(void)
|
||||
/* Configure the system clock */
|
||||
SystemClock_Config();
|
||||
|
||||
/* Configure the peripherals common clocks */
|
||||
PeriphCommonClock_Config();
|
||||
|
||||
/* USER CODE BEGIN SysInit */
|
||||
|
||||
/* USER CODE END SysInit */
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_LTDC_Init();
|
||||
MX_ETH_Init();
|
||||
MX_FDCAN1_Init();
|
||||
//MX_FMC_Init();
|
||||
MX_I2C4_Init();
|
||||
//MX_SDMMC2_SD_Init();
|
||||
MX_USART10_UART_Init();
|
||||
MX_USB_OTG_HS_PCD_Init();
|
||||
MX_UART5_Init();
|
||||
//MX_LTDC_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
//uint32_t sdramcheck = MemoryCheck(&huart5, &hsdram1);
|
||||
//MX_LTDC_Init();
|
||||
slave_handler_init();
|
||||
initCan(&hfdcan1);
|
||||
charger_control_init(&hi2c4);
|
||||
initChargerAlgo(102, 4.15);
|
||||
setchargecurrent(0.0);
|
||||
setchargevoltage(102, 0);
|
||||
charger_control_disable_remote();
|
||||
//HAL_LTDC_Reload(&hltdc, LTDC_RELOAD_IMMEDIATE);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
uint32_t lasttick = HAL_GetTick();
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
||||
|
||||
if((HAL_GetTick() - lasttick) > 1000)
|
||||
{
|
||||
// float maxvoltage = slaves_get_maximum_voltage();
|
||||
// lasttick = HAL_GetTick();
|
||||
// chargingloop(slaves_get_maximum_voltage());
|
||||
HAL_GPIO_TogglePin(STATUS_LED_2_GPIO_Port, STATUS_LED_2_Pin);
|
||||
}
|
||||
|
||||
// HAL_Delay(500);
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
@ -145,32 +175,39 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/*AXI clock gating */
|
||||
RCC->CKGAENR = 0xFFFFFFFF;
|
||||
|
||||
/** Supply configuration update enable
|
||||
*/
|
||||
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
|
||||
|
||||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||||
|
||||
/** Macro to configure the PLL clock source
|
||||
*/
|
||||
__HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 9;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 20;
|
||||
RCC_OscInitStruct.PLL.PLLP = 2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 3;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||
RCC_OscInitStruct.PLL.PLLR = 2;
|
||||
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
|
||||
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
|
||||
RCC_OscInitStruct.PLL.PLLFRACN = 3072;
|
||||
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
|
||||
RCC_OscInitStruct.PLL.PLLFRACN = 0;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
@ -181,67 +218,45 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
|
||||
|RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV1;
|
||||
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1;
|
||||
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
|
||||
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ETH Initialization Function
|
||||
* @param None
|
||||
* @brief Peripherals Common Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_ETH_Init(void)
|
||||
void PeriphCommonClock_Config(void)
|
||||
{
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
||||
|
||||
/* USER CODE BEGIN ETH_Init 0 */
|
||||
|
||||
/* USER CODE END ETH_Init 0 */
|
||||
|
||||
static uint8_t MACAddr[6];
|
||||
|
||||
/* USER CODE BEGIN ETH_Init 1 */
|
||||
|
||||
/* USER CODE END ETH_Init 1 */
|
||||
heth.Instance = ETH;
|
||||
MACAddr[0] = 0x00;
|
||||
MACAddr[1] = 0x80;
|
||||
MACAddr[2] = 0xE1;
|
||||
MACAddr[3] = 0x00;
|
||||
MACAddr[4] = 0x00;
|
||||
MACAddr[5] = 0x00;
|
||||
heth.Init.MACAddr = &MACAddr[0];
|
||||
heth.Init.MediaInterface = HAL_ETH_MII_MODE;
|
||||
heth.Init.TxDesc = DMATxDscrTab;
|
||||
heth.Init.RxDesc = DMARxDscrTab;
|
||||
heth.Init.RxBuffLen = 1524;
|
||||
|
||||
/* USER CODE BEGIN MACADDRESS */
|
||||
|
||||
/* USER CODE END MACADDRESS */
|
||||
|
||||
if (HAL_ETH_Init(&heth) != HAL_OK)
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC|RCC_PERIPHCLK_SDMMC;
|
||||
PeriphClkInitStruct.PLL2.PLL2M = 1;
|
||||
PeriphClkInitStruct.PLL2.PLL2N = 20;
|
||||
PeriphClkInitStruct.PLL2.PLL2P = 2;
|
||||
PeriphClkInitStruct.PLL2.PLL2Q = 4;
|
||||
PeriphClkInitStruct.PLL2.PLL2R = 2;
|
||||
PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
|
||||
PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
|
||||
PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
|
||||
PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2;
|
||||
PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL2;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig));
|
||||
TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD;
|
||||
TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
|
||||
TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;
|
||||
/* USER CODE BEGIN ETH_Init 2 */
|
||||
|
||||
/* USER CODE END ETH_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,18 +280,18 @@ static void MX_FDCAN1_Init(void)
|
||||
hfdcan1.Init.AutoRetransmission = DISABLE;
|
||||
hfdcan1.Init.TransmitPause = DISABLE;
|
||||
hfdcan1.Init.ProtocolException = DISABLE;
|
||||
hfdcan1.Init.NominalPrescaler = 16;
|
||||
hfdcan1.Init.NominalPrescaler = 2;
|
||||
hfdcan1.Init.NominalSyncJumpWidth = 1;
|
||||
hfdcan1.Init.NominalTimeSeg1 = 2;
|
||||
hfdcan1.Init.NominalTimeSeg2 = 2;
|
||||
hfdcan1.Init.NominalTimeSeg1 = 63;
|
||||
hfdcan1.Init.NominalTimeSeg2 = 16;
|
||||
hfdcan1.Init.DataPrescaler = 1;
|
||||
hfdcan1.Init.DataSyncJumpWidth = 1;
|
||||
hfdcan1.Init.DataTimeSeg1 = 1;
|
||||
hfdcan1.Init.DataTimeSeg2 = 1;
|
||||
hfdcan1.Init.MessageRAMOffset = 0;
|
||||
hfdcan1.Init.StdFiltersNbr = 0;
|
||||
hfdcan1.Init.StdFiltersNbr = 32;
|
||||
hfdcan1.Init.ExtFiltersNbr = 0;
|
||||
hfdcan1.Init.RxFifo0ElmtsNbr = 0;
|
||||
hfdcan1.Init.RxFifo0ElmtsNbr = 16;
|
||||
hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
|
||||
hfdcan1.Init.RxFifo1ElmtsNbr = 0;
|
||||
hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
|
||||
@ -284,7 +299,7 @@ static void MX_FDCAN1_Init(void)
|
||||
hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
|
||||
hfdcan1.Init.TxEventsNbr = 0;
|
||||
hfdcan1.Init.TxBuffersNbr = 0;
|
||||
hfdcan1.Init.TxFifoQueueElmtsNbr = 0;
|
||||
hfdcan1.Init.TxFifoQueueElmtsNbr = 1;
|
||||
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
|
||||
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
|
||||
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
|
||||
@ -297,6 +312,54 @@ static void MX_FDCAN1_Init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C4 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2C4_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2C4_Init 0 */
|
||||
|
||||
/* USER CODE END I2C4_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN I2C4_Init 1 */
|
||||
|
||||
/* USER CODE END I2C4_Init 1 */
|
||||
hi2c4.Instance = I2C4;
|
||||
hi2c4.Init.Timing = 0x10909CEC;
|
||||
hi2c4.Init.OwnAddress1 = 0;
|
||||
hi2c4.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
hi2c4.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
hi2c4.Init.OwnAddress2 = 0;
|
||||
hi2c4.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
||||
hi2c4.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c4.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Analogue filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c4, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Digital filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c4, 0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C4_Init 2 */
|
||||
|
||||
/* USER CODE END I2C4_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LTDC Initialization Function
|
||||
* @param None
|
||||
@ -310,7 +373,6 @@ static void MX_LTDC_Init(void)
|
||||
/* USER CODE END LTDC_Init 0 */
|
||||
|
||||
LTDC_LayerCfgTypeDef pLayerCfg = {0};
|
||||
LTDC_LayerCfgTypeDef pLayerCfg1 = {0};
|
||||
|
||||
/* USER CODE BEGIN LTDC_Init 1 */
|
||||
|
||||
@ -320,14 +382,14 @@ static void MX_LTDC_Init(void)
|
||||
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
||||
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
||||
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
|
||||
hltdc.Init.HorizontalSync = 7;
|
||||
hltdc.Init.VerticalSync = 3;
|
||||
hltdc.Init.AccumulatedHBP = 14;
|
||||
hltdc.Init.AccumulatedVBP = 5;
|
||||
hltdc.Init.AccumulatedActiveW = 654;
|
||||
hltdc.Init.AccumulatedActiveH = 485;
|
||||
hltdc.Init.TotalWidth = 660;
|
||||
hltdc.Init.TotalHeigh = 487;
|
||||
hltdc.Init.HorizontalSync = 19;
|
||||
hltdc.Init.VerticalSync = 2;
|
||||
hltdc.Init.AccumulatedHBP = 159;
|
||||
hltdc.Init.AccumulatedVBP = 22;
|
||||
hltdc.Init.AccumulatedActiveW = 1183;
|
||||
hltdc.Init.AccumulatedActiveH = 622;
|
||||
hltdc.Init.TotalWidth = 1343;
|
||||
hltdc.Init.TotalHeigh = 634;
|
||||
hltdc.Init.Backcolor.Blue = 0;
|
||||
hltdc.Init.Backcolor.Green = 0;
|
||||
hltdc.Init.Backcolor.Red = 0;
|
||||
@ -339,46 +401,263 @@ static void MX_LTDC_Init(void)
|
||||
pLayerCfg.WindowX1 = 0;
|
||||
pLayerCfg.WindowY0 = 0;
|
||||
pLayerCfg.WindowY1 = 0;
|
||||
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
||||
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB888;
|
||||
pLayerCfg.Alpha = 0;
|
||||
pLayerCfg.Alpha0 = 0;
|
||||
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
||||
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
||||
pLayerCfg.FBStartAdress = 0;
|
||||
pLayerCfg.ImageWidth = 0;
|
||||
pLayerCfg.ImageHeight = 0;
|
||||
pLayerCfg.Backcolor.Blue = 0;
|
||||
pLayerCfg.FBStartAdress = 201326592;
|
||||
pLayerCfg.ImageWidth = 1024;
|
||||
pLayerCfg.ImageHeight = 600;
|
||||
pLayerCfg.Backcolor.Blue = 100;
|
||||
pLayerCfg.Backcolor.Green = 0;
|
||||
pLayerCfg.Backcolor.Red = 0;
|
||||
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
pLayerCfg1.WindowX0 = 0;
|
||||
pLayerCfg1.WindowX1 = 0;
|
||||
pLayerCfg1.WindowY0 = 0;
|
||||
pLayerCfg1.WindowY1 = 0;
|
||||
pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
||||
pLayerCfg1.Alpha = 0;
|
||||
pLayerCfg1.Alpha0 = 0;
|
||||
pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
||||
pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
||||
pLayerCfg1.FBStartAdress = 0;
|
||||
pLayerCfg1.ImageWidth = 0;
|
||||
pLayerCfg1.ImageHeight = 0;
|
||||
pLayerCfg1.Backcolor.Blue = 0;
|
||||
pLayerCfg1.Backcolor.Green = 0;
|
||||
pLayerCfg1.Backcolor.Red = 0;
|
||||
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK)
|
||||
/* USER CODE BEGIN LTDC_Init 2 */
|
||||
__HAL_LTDC_ENABLE(&hltdc);
|
||||
__HAL_LTDC_LAYER_ENABLE(&hltdc,1);
|
||||
/* USER CODE END LTDC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SDMMC2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SDMMC2_SD_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SDMMC2_Init 0 */
|
||||
|
||||
/* USER CODE END SDMMC2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SDMMC2_Init 1 */
|
||||
|
||||
/* USER CODE END SDMMC2_Init 1 */
|
||||
hsd2.Instance = SDMMC2;
|
||||
hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
|
||||
hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
|
||||
hsd2.Init.BusWide = SDMMC_BUS_WIDE_1B;
|
||||
hsd2.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||
hsd2.Init.ClockDiv = 0;
|
||||
if (HAL_SD_Init(&hsd2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN LTDC_Init 2 */
|
||||
/* USER CODE BEGIN SDMMC2_Init 2 */
|
||||
|
||||
/* USER CODE END LTDC_Init 2 */
|
||||
/* USER CODE END SDMMC2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART5 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_UART5_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN UART5_Init 0 */
|
||||
|
||||
/* USER CODE END UART5_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN UART5_Init 1 */
|
||||
|
||||
/* USER CODE END UART5_Init 1 */
|
||||
huart5.Instance = UART5;
|
||||
huart5.Init.BaudRate = 115200;
|
||||
huart5.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart5.Init.StopBits = UART_STOPBITS_1;
|
||||
huart5.Init.Parity = UART_PARITY_NONE;
|
||||
huart5.Init.Mode = UART_MODE_TX_RX;
|
||||
huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart5.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
huart5.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
huart5.Init.ClockPrescaler = UART_PRESCALER_DIV1;
|
||||
huart5.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
if (HAL_UART_Init(&huart5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetTxFifoThreshold(&huart5, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetRxFifoThreshold(&huart5, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_DisableFifoMode(&huart5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN UART5_Init 2 */
|
||||
|
||||
/* USER CODE END UART5_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USART10 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_USART10_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART10_Init 0 */
|
||||
|
||||
/* USER CODE END USART10_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN USART10_Init 1 */
|
||||
|
||||
/* USER CODE END USART10_Init 1 */
|
||||
huart10.Instance = USART10;
|
||||
huart10.Init.BaudRate = 115200;
|
||||
huart10.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart10.Init.StopBits = UART_STOPBITS_1;
|
||||
huart10.Init.Parity = UART_PARITY_NONE;
|
||||
huart10.Init.Mode = UART_MODE_TX_RX;
|
||||
huart10.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart10.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
huart10.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
huart10.Init.ClockPrescaler = UART_PRESCALER_DIV1;
|
||||
huart10.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
if (HAL_UART_Init(&huart10) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetTxFifoThreshold(&huart10, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_SetRxFifoThreshold(&huart10, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UARTEx_DisableFifoMode(&huart10) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART10_Init 2 */
|
||||
|
||||
/* USER CODE END USART10_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB_OTG_HS Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_USB_OTG_HS_PCD_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_HS_Init 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_HS_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_HS_Init 1 */
|
||||
|
||||
/* USER CODE END USB_OTG_HS_Init 1 */
|
||||
hpcd_USB_OTG_HS.Instance = USB_OTG_HS;
|
||||
hpcd_USB_OTG_HS.Init.dev_endpoints = 9;
|
||||
hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL;
|
||||
hpcd_USB_OTG_HS.Init.dma_enable = DISABLE;
|
||||
hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY;
|
||||
hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE;
|
||||
hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE;
|
||||
hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE;
|
||||
hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE;
|
||||
hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE;
|
||||
hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE;
|
||||
if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USB_OTG_HS_Init 2 */
|
||||
|
||||
/* USER CODE END USB_OTG_HS_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/* FMC initialization function */
|
||||
static void MX_FMC_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN FMC_Init 0 */
|
||||
|
||||
/* USER CODE END FMC_Init 0 */
|
||||
|
||||
FMC_SDRAM_TimingTypeDef SdramTiming = {0};
|
||||
|
||||
/* USER CODE BEGIN FMC_Init 1 */
|
||||
|
||||
/* USER CODE END FMC_Init 1 */
|
||||
|
||||
/** Perform the SDRAM1 memory initialization sequence
|
||||
*/
|
||||
hsdram1.Instance = FMC_SDRAM_DEVICE;
|
||||
/* hsdram1.Init */
|
||||
hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
|
||||
hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;
|
||||
hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;
|
||||
hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
|
||||
hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
|
||||
hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
|
||||
hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
|
||||
hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
|
||||
hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE;
|
||||
hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;
|
||||
/* SdramTiming */
|
||||
SdramTiming.LoadToActiveDelay = 2;
|
||||
SdramTiming.ExitSelfRefreshDelay = 5;
|
||||
SdramTiming.SelfRefreshTime = 3;
|
||||
SdramTiming.RowCycleDelay = 4;
|
||||
SdramTiming.WriteRecoveryTime = 3;
|
||||
SdramTiming.RPDelay = 3;
|
||||
SdramTiming.RCDDelay = 2;
|
||||
|
||||
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
|
||||
{
|
||||
Error_Handler( );
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN FMC_Init 2 */
|
||||
FMC_SDRAM_CommandTypeDef command;
|
||||
HAL_StatusTypeDef status;
|
||||
command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
|
||||
command.AutoRefreshNumber = 1;
|
||||
command.ModeRegisterDefinition = 0;
|
||||
status = HAL_SDRAM_SendCommand(&hsdram1, &command, 1000);
|
||||
HAL_Delay(1);
|
||||
|
||||
|
||||
command.CommandMode = FMC_SDRAM_CMD_PALL;
|
||||
command.AutoRefreshNumber = 8;
|
||||
command.ModeRegisterDefinition = 0;
|
||||
status = HAL_SDRAM_SendCommand(&hsdram1, &command, 1000);
|
||||
|
||||
command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
|
||||
command.AutoRefreshNumber = 1;
|
||||
command.ModeRegisterDefinition = 0x130;
|
||||
status = HAL_SDRAM_SendCommand(&hsdram1, &command, 1000);
|
||||
|
||||
command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
|
||||
command.AutoRefreshNumber = 8;
|
||||
command.ModeRegisterDefinition = 0;
|
||||
status = HAL_SDRAM_SendCommand(&hsdram1, &command, 1000);
|
||||
|
||||
status = HAL_SDRAM_ProgramRefreshRate(&hsdram1, 0x0595);
|
||||
/* USER CODE END FMC_Init 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO Initialization Function
|
||||
* @param None
|
||||
@ -386,56 +665,118 @@ static void MX_LTDC_Init(void)
|
||||
*/
|
||||
static void MX_GPIO_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
||||
/* USER CODE END MX_GPIO_Init_1 */
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOI_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOF, STATUS_LED_1_Pin|STATUS_LED_2_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, Display_Reset_Pin|Display_Standby_Pin|Display_Left_Right_Pin|Display_Up_Down_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(Charger_Relay_GPIO_Port, Charger_Relay_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(Charger_Remote_Shutdown_GPIO_Port, Charger_Remote_Shutdown_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : STATUS_LED_1_Pin STATUS_LED_2_Pin */
|
||||
GPIO_InitStruct.Pin = STATUS_LED_1_Pin|STATUS_LED_2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : Display_Reset_Pin Display_Standby_Pin Display_Left_Right_Pin Display_Up_Down_Pin */
|
||||
GPIO_InitStruct.Pin = Display_Reset_Pin|Display_Standby_Pin|Display_Left_Right_Pin|Display_Up_Down_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : Charger_CC_Status_Pin Charger_OT_Pin Charger_LIM_Pin Charger_DC_FAIL_Pin */
|
||||
GPIO_InitStruct.Pin = Charger_CC_Status_Pin|Charger_OT_Pin|Charger_LIM_Pin|Charger_DC_FAIL_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : Charger_Relay_Pin */
|
||||
GPIO_InitStruct.Pin = Charger_Relay_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(Charger_Relay_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : Charger_AC_Fail_Pin */
|
||||
GPIO_InitStruct.Pin = Charger_AC_Fail_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(Charger_AC_Fail_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : Charger_Remote_Shutdown_Pin */
|
||||
GPIO_InitStruct.Pin = Charger_Remote_Shutdown_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(Charger_Remote_Shutdown_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||
/* USER CODE END MX_GPIO_Init_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/* MPU Configuration */
|
||||
|
||||
void MPU_Config(void)
|
||||
/** @brief run a Memory Check over the complete SDRAM Area
|
||||
*
|
||||
*/
|
||||
uint32_t MemoryCheck(UART_HandleTypeDef *uart_console, SDRAM_HandleTypeDef *sram)
|
||||
{
|
||||
MPU_Region_InitTypeDef MPU_InitStruct = {0};
|
||||
uint32_t totalerrors = 0;
|
||||
uint32_t numberofsectors = 400;
|
||||
|
||||
/* Disables the MPU */
|
||||
HAL_MPU_Disable();
|
||||
uint32_t testadr = 0xC0000000;
|
||||
|
||||
/** Initializes and configures the Region and the memory to be protected
|
||||
*/
|
||||
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
|
||||
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
|
||||
MPU_InitStruct.BaseAddress = 0x0;
|
||||
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
|
||||
MPU_InitStruct.SubRegionDisable = 0x87;
|
||||
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
|
||||
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
|
||||
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
|
||||
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
|
||||
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
|
||||
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
|
||||
|
||||
HAL_MPU_ConfigRegion(&MPU_InitStruct);
|
||||
/* Enables the MPU */
|
||||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
|
||||
//*testpointer = 1;
|
||||
|
||||
for(uint32_t startaddress = 0; startaddress < numberofsectors*RAM_TEST_BLOCKSIZE; startaddress += RAM_TEST_BLOCKSIZE)
|
||||
{
|
||||
|
||||
for(uint32_t i = 0; i < RAM_TEST_BLOCKSIZE; i++)
|
||||
{
|
||||
testarray[i] = 0xFFFF00FF;
|
||||
}
|
||||
//*testadr = (uint32_t*) ;
|
||||
HAL_StatusTypeDef status = HAL_SDRAM_Write_32b(sram, (uint32_t*)(testadr+startaddress), testarray, RAM_TEST_BLOCKSIZE);
|
||||
//testadr = (uint32_t*) (startaddress + 0xC0000000);
|
||||
for(uint32_t i = 0; i < RAM_TEST_BLOCKSIZE; i++)
|
||||
{
|
||||
testarray[i] = 0;
|
||||
}
|
||||
status = HAL_SDRAM_Read_32b(sram,(uint32_t*)(testadr+startaddress), testarray, RAM_TEST_BLOCKSIZE);
|
||||
|
||||
uint32_t errorcounter = 0;
|
||||
for(uint32_t i = 0; i <RAM_TEST_BLOCKSIZE;i++)
|
||||
{
|
||||
if(testarray[i] != (i+3000))
|
||||
{
|
||||
errorcounter++;
|
||||
}
|
||||
}
|
||||
totalerrors += errorcounter;
|
||||
}
|
||||
|
||||
return totalerrors;
|
||||
|
||||
}
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
|
||||
70
Software/Core/Src/slave_handler.c
Normal file
70
Software/Core/Src/slave_handler.c
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* slave_handler.c
|
||||
*
|
||||
* Created on: Jun 21, 2023
|
||||
* Author: max
|
||||
*/
|
||||
|
||||
#include "slave_handler.h"
|
||||
#include "can.h"
|
||||
#include "can-halal.h"
|
||||
|
||||
static uint8_t slave_id_to_index[128] = {0xFF};
|
||||
|
||||
|
||||
void slave_handler_init()
|
||||
{
|
||||
memset(slave_id_to_index,0xFF,128);
|
||||
}
|
||||
|
||||
SlaveHandle slaves[N_SLAVES];
|
||||
static size_t get_slave_index(uint8_t);
|
||||
|
||||
void slaves_handle_status(const uint8_t *data) {
|
||||
uint8_t slave_id = data[0] & 0x7F;
|
||||
uint8_t idx = get_slave_index(slave_id);
|
||||
int error = data[0] & 0x80;
|
||||
if (error) {
|
||||
if (slaves[idx].error.kind == SLAVE_ERR_NONE) {
|
||||
slaves[idx].error.kind = SLAVE_ERR_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
slaves[idx].error.kind = SLAVE_ERR_NONE;
|
||||
}
|
||||
slaves[idx].soc = data[1];
|
||||
const uint8_t *ptr = &data[2];
|
||||
slaves[idx].min_voltage = ftcan_unmarshal_unsigned(&ptr, 2);
|
||||
slaves[idx].max_voltage = ftcan_unmarshal_unsigned(&ptr, 2);
|
||||
slaves[idx].max_temp = ftcan_unmarshal_unsigned(&ptr, 2);
|
||||
slaves[idx].last_message = HAL_GetTick();
|
||||
}
|
||||
|
||||
float slaves_get_maximum_voltage()
|
||||
{
|
||||
float maxvoltage = 0;
|
||||
for(uint8_t i = 0; i < N_SLAVES; i++)
|
||||
{
|
||||
if(maxvoltage < slaves[i].max_voltage)
|
||||
maxvoltage = slaves[i].max_voltage;
|
||||
}
|
||||
return ((float)maxvoltage)/10000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t get_slave_index(uint8_t slave_id) {
|
||||
// Slave IDs are 7-bit, so we can use a 128-element array to map them to
|
||||
// indices. 0xFF is used to mark unseen slave IDs, since the highest index we
|
||||
// could need is N_SLAVES - 1 (i.e. 5).
|
||||
static size_t next_slave_index = 0;
|
||||
if (slave_id_to_index[slave_id] == 0xFF) {
|
||||
if (next_slave_index >= N_SLAVES) {
|
||||
// We've seen more than N_SLAVES slave IDs, this shouldn't happen.
|
||||
Error_Handler();
|
||||
}
|
||||
slave_id_to_index[slave_id] = next_slave_index;
|
||||
slaves[next_slave_index].id = slave_id;
|
||||
next_slave_index++;
|
||||
}
|
||||
return slave_id_to_index[slave_id];
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,13 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@ -55,7 +56,9 @@
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
extern FDCAN_HandleTypeDef hfdcan1;
|
||||
extern SDRAM_HandleTypeDef hsdram1;
|
||||
extern LTDC_HandleTypeDef hltdc;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
@ -72,7 +75,7 @@ void NMI_Handler(void)
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
while (1)
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
@ -198,6 +201,90 @@ void SysTick_Handler(void)
|
||||
/* please refer to the startup file (startup_stm32h7xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles FDCAN1 interrupt 0.
|
||||
*/
|
||||
void FDCAN1_IT0_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN FDCAN1_IT0_IRQn 0 */
|
||||
|
||||
/* USER CODE END FDCAN1_IT0_IRQn 0 */
|
||||
HAL_FDCAN_IRQHandler(&hfdcan1);
|
||||
/* USER CODE BEGIN FDCAN1_IT0_IRQn 1 */
|
||||
|
||||
/* USER CODE END FDCAN1_IT0_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles FDCAN1 interrupt 1.
|
||||
*/
|
||||
void FDCAN1_IT1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN FDCAN1_IT1_IRQn 0 */
|
||||
|
||||
/* USER CODE END FDCAN1_IT1_IRQn 0 */
|
||||
HAL_FDCAN_IRQHandler(&hfdcan1);
|
||||
/* USER CODE BEGIN FDCAN1_IT1_IRQn 1 */
|
||||
|
||||
/* USER CODE END FDCAN1_IT1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles FMC global interrupt.
|
||||
*/
|
||||
void FMC_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN FMC_IRQn 0 */
|
||||
|
||||
/* USER CODE END FMC_IRQn 0 */
|
||||
HAL_SDRAM_IRQHandler(&hsdram1);
|
||||
/* USER CODE BEGIN FMC_IRQn 1 */
|
||||
|
||||
/* USER CODE END FMC_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles FDCAN calibration unit interrupt.
|
||||
*/
|
||||
void FDCAN_CAL_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN FDCAN_CAL_IRQn 0 */
|
||||
|
||||
/* USER CODE END FDCAN_CAL_IRQn 0 */
|
||||
HAL_FDCAN_IRQHandler(&hfdcan1);
|
||||
/* USER CODE BEGIN FDCAN_CAL_IRQn 1 */
|
||||
|
||||
/* USER CODE END FDCAN_CAL_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles LTDC global interrupt.
|
||||
*/
|
||||
void LTDC_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN LTDC_IRQn 0 */
|
||||
|
||||
/* USER CODE END LTDC_IRQn 0 */
|
||||
HAL_LTDC_IRQHandler(&hltdc);
|
||||
/* USER CODE BEGIN LTDC_IRQn 1 */
|
||||
|
||||
/* USER CODE END LTDC_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles LTDC Error global Interrupt.
|
||||
*/
|
||||
void LTDC_ER_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN LTDC_ER_IRQn 0 */
|
||||
|
||||
/* USER CODE END LTDC_ER_IRQn 0 */
|
||||
HAL_LTDC_IRQHandler(&hltdc);
|
||||
/* USER CODE BEGIN LTDC_ER_IRQn 1 */
|
||||
|
||||
/* USER CODE END LTDC_ER_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file syscalls.c
|
||||
* @author Auto-generated by STM32CubeMX
|
||||
* @brief Minimal System calls file
|
||||
* @author Auto-generated by STM32CubeIDE
|
||||
* @brief STM32CubeIDE Minimal System calls file
|
||||
*
|
||||
* For more information about which c-functions
|
||||
* need which of these lowlevel functions
|
||||
@ -10,12 +10,13 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020-2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@ -47,130 +48,109 @@ void initialise_monitor_handles()
|
||||
|
||||
int _getpid(void)
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _kill(int pid, int sig)
|
||||
{
|
||||
(void)pid;
|
||||
(void)sig;
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _exit (int status)
|
||||
{
|
||||
_kill(status, -1);
|
||||
while (1) {} /* Make sure we hang here */
|
||||
_kill(status, -1);
|
||||
while (1) {} /* Make sure we hang here */
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||
{
|
||||
(void)file;
|
||||
int DataIdx;
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
*ptr++ = __io_getchar();
|
||||
}
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
*ptr++ = __io_getchar();
|
||||
}
|
||||
|
||||
return len;
|
||||
return len;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||
{
|
||||
(void)file;
|
||||
int DataIdx;
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
__io_putchar(*ptr++);
|
||||
}
|
||||
return len;
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
__io_putchar(*ptr++);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int _close(int file)
|
||||
{
|
||||
(void)file;
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int _fstat(int file, struct stat *st)
|
||||
{
|
||||
(void)file;
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isatty(int file)
|
||||
{
|
||||
(void)file;
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _lseek(int file, int ptr, int dir)
|
||||
{
|
||||
(void)file;
|
||||
(void)ptr;
|
||||
(void)dir;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _open(char *path, int flags, ...)
|
||||
{
|
||||
(void)path;
|
||||
(void)flags;
|
||||
/* Pretend like we always fail */
|
||||
return -1;
|
||||
/* Pretend like we always fail */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _wait(int *status)
|
||||
{
|
||||
(void)status;
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _unlink(char *name)
|
||||
{
|
||||
(void)name;
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _times(struct tms *buf)
|
||||
{
|
||||
(void)buf;
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _stat(char *file, struct stat *st)
|
||||
{
|
||||
(void)file;
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _link(char *old, char *new)
|
||||
{
|
||||
(void)old;
|
||||
(void)new;
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _fork(void)
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _execve(char *name, char **argv, char **env)
|
||||
{
|
||||
(void)name;
|
||||
(void)argv;
|
||||
(void)env;
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sysmem.c
|
||||
* @author Generated by STM32CubeMX
|
||||
* @brief System Memory calls file
|
||||
* @author Generated by STM32CubeIDE
|
||||
* @brief STM32CubeIDE System Memory calls file
|
||||
*
|
||||
* For more information about which C functions
|
||||
* need which of these lowlevel functions
|
||||
@ -10,12 +10,13 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
|
||||
#include "stm32h7xx.h"
|
||||
#include <math.h>
|
||||
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
@ -94,14 +93,14 @@
|
||||
/* #define VECT_TAB_SRAM */
|
||||
#if defined(VECT_TAB_SRAM)
|
||||
#define VECT_TAB_BASE_ADDRESS D2_AXISRAM_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#else
|
||||
#define VECT_TAB_BASE_ADDRESS FLASH_BANK2_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#endif /* VECT_TAB_SRAM */
|
||||
#else
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table
|
||||
@ -109,14 +108,14 @@
|
||||
/* #define VECT_TAB_SRAM */
|
||||
#if defined(VECT_TAB_SRAM)
|
||||
#define VECT_TAB_BASE_ADDRESS D1_AXISRAM_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#else
|
||||
#define VECT_TAB_BASE_ADDRESS FLASH_BANK1_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x400. */
|
||||
This value must be a multiple of 0x200. */
|
||||
#endif /* VECT_TAB_SRAM */
|
||||
#endif /* DUAL_CORE && CORE_CM4 */
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
@ -188,7 +187,7 @@ void SystemInit (void)
|
||||
if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
|
||||
{
|
||||
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
|
||||
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
|
||||
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
|
||||
}
|
||||
|
||||
/* Set HSION bit */
|
||||
@ -199,12 +198,12 @@ void SystemInit (void)
|
||||
|
||||
/* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
|
||||
RCC->CR &= 0xEAF6ED7FU;
|
||||
|
||||
|
||||
/* Decreasing the number of wait states because of lower CPU frequency */
|
||||
if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
|
||||
{
|
||||
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
|
||||
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
|
||||
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
|
||||
}
|
||||
|
||||
#if defined(D3_SRAM_BASE)
|
||||
@ -262,10 +261,10 @@ void SystemInit (void)
|
||||
/* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
|
||||
*((__IO uint32_t*)0x51008108) = 0x000000001U;
|
||||
}
|
||||
#endif /* STM32H7_DEV_ID */
|
||||
#endif
|
||||
|
||||
#if defined(DATA_IN_D2_SRAM)
|
||||
/* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */
|
||||
#if defined (DATA_IN_D2_SRAM)
|
||||
/* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock (AHB SRAM clock) */
|
||||
#if defined(RCC_AHB2ENR_D2SRAM3EN)
|
||||
RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);
|
||||
#elif defined(RCC_AHB2ENR_D2SRAM2EN)
|
||||
@ -285,6 +284,7 @@ void SystemInit (void)
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Disable the FMC bank1 (enabled after reset).
|
||||
* This, prevents CPU speculation access on this bank which blocks the use of FMC during
|
||||
@ -298,6 +298,7 @@ void SystemInit (void)
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
|
||||
#endif /*DUAL_CORE && CORE_CM4*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
742
Software/Core/Startup/startup_stm32h7a3zitx.s
Normal file
742
Software/Core/Startup/startup_stm32h7a3zitx.s
Normal file
@ -0,0 +1,742 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32h7a3xx.s
|
||||
* @author MCD Application Team
|
||||
* @brief STM32H7B3xx Devices vector table for GCC based toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m7
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
/* stack used for SystemInit_ExtMemCtl; always internal RAM used */
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
ldr sp, =_estack /* set stack pointer */
|
||||
|
||||
/* Call the clock system initialization function.*/
|
||||
bl SystemInit
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
ldr r0, =_sdata
|
||||
ldr r1, =_edata
|
||||
ldr r2, =_sidata
|
||||
movs r3, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r4, [r2, r3]
|
||||
str r4, [r0, r3]
|
||||
adds r3, r3, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
adds r4, r0, r3
|
||||
cmp r4, r1
|
||||
bcc CopyDataInit
|
||||
/* Zero fill the bss segment. */
|
||||
ldr r2, =_sbss
|
||||
ldr r4, =_ebss
|
||||
movs r3, #0
|
||||
b LoopFillZerobss
|
||||
|
||||
FillZerobss:
|
||||
str r3, [r2]
|
||||
adds r2, r2, #4
|
||||
|
||||
LoopFillZerobss:
|
||||
cmp r2, r4
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call static constructors */
|
||||
bl __libc_init_array
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
/******************************************************************************
|
||||
*
|
||||
* The minimal vector table for a Cortex M. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.word WWDG_IRQHandler /* Window WatchDog */
|
||||
.word PVD_PVM_IRQHandler /* PVD/PVM through EXTI Line detection */
|
||||
.word RTC_TAMP_STAMP_CSS_LSE_IRQHandler /* Tamper and TimeStamps through the EXTI line */
|
||||
.word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
|
||||
.word FLASH_IRQHandler /* FLASH */
|
||||
.word RCC_IRQHandler /* RCC */
|
||||
.word EXTI0_IRQHandler /* EXTI Line0 */
|
||||
.word EXTI1_IRQHandler /* EXTI Line1 */
|
||||
.word EXTI2_IRQHandler /* EXTI Line2 */
|
||||
.word EXTI3_IRQHandler /* EXTI Line3 */
|
||||
.word EXTI4_IRQHandler /* EXTI Line4 */
|
||||
.word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
|
||||
.word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
|
||||
.word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
|
||||
.word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
|
||||
.word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
|
||||
.word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
|
||||
.word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
|
||||
.word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
|
||||
.word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */
|
||||
.word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */
|
||||
.word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */
|
||||
.word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */
|
||||
.word EXTI9_5_IRQHandler /* External Line[9:5]s */
|
||||
.word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */
|
||||
.word TIM1_UP_IRQHandler /* TIM1 Update interrupt */
|
||||
.word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */
|
||||
.word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
|
||||
.word TIM2_IRQHandler /* TIM2 */
|
||||
.word TIM3_IRQHandler /* TIM3 */
|
||||
.word TIM4_IRQHandler /* TIM4 */
|
||||
.word I2C1_EV_IRQHandler /* I2C1 Event */
|
||||
.word I2C1_ER_IRQHandler /* I2C1 Error */
|
||||
.word I2C2_EV_IRQHandler /* I2C2 Event */
|
||||
.word I2C2_ER_IRQHandler /* I2C2 Error */
|
||||
.word SPI1_IRQHandler /* SPI1 */
|
||||
.word SPI2_IRQHandler /* SPI2 */
|
||||
.word USART1_IRQHandler /* USART1 */
|
||||
.word USART2_IRQHandler /* USART2 */
|
||||
.word USART3_IRQHandler /* USART3 */
|
||||
.word EXTI15_10_IRQHandler /* External Line[15:10]s */
|
||||
.word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
|
||||
.word DFSDM2_IRQHandler /* DFSDM2 Interrupt */
|
||||
.word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */
|
||||
.word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */
|
||||
.word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
|
||||
.word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
|
||||
.word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
|
||||
.word FMC_IRQHandler /* FMC */
|
||||
.word SDMMC1_IRQHandler /* SDMMC1 */
|
||||
.word TIM5_IRQHandler /* TIM5 */
|
||||
.word SPI3_IRQHandler /* SPI3 */
|
||||
.word UART4_IRQHandler /* UART4 */
|
||||
.word UART5_IRQHandler /* UART5 */
|
||||
.word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */
|
||||
.word TIM7_IRQHandler /* TIM7 */
|
||||
.word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
|
||||
.word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
|
||||
.word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
|
||||
.word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
|
||||
.word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/
|
||||
.word DFSDM1_FLT4_IRQHandler /* DFSDM Filter4 Interrupt */
|
||||
.word DFSDM1_FLT5_IRQHandler /* DFSDM Filter5 Interrupt */
|
||||
.word DFSDM1_FLT6_IRQHandler /* DFSDM Filter6 Interrupt */
|
||||
.word DFSDM1_FLT7_IRQHandler /* DFSDM Filter7 Interrupt */
|
||||
.word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
|
||||
.word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
|
||||
.word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
|
||||
.word USART6_IRQHandler /* USART6 */
|
||||
.word I2C3_EV_IRQHandler /* I2C3 event */
|
||||
.word I2C3_ER_IRQHandler /* I2C3 error */
|
||||
.word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */
|
||||
.word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */
|
||||
.word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */
|
||||
.word OTG_HS_IRQHandler /* USB OTG HS */
|
||||
.word DCMI_PSSI_IRQHandler /* DCMI, PSSI */
|
||||
.word 0 /* Reserved */
|
||||
.word RNG_IRQHandler /* RNG */
|
||||
.word FPU_IRQHandler /* FPU */
|
||||
.word UART7_IRQHandler /* UART7 */
|
||||
.word UART8_IRQHandler /* UART8 */
|
||||
.word SPI4_IRQHandler /* SPI4 */
|
||||
.word SPI5_IRQHandler /* SPI5 */
|
||||
.word SPI6_IRQHandler /* SPI6 */
|
||||
.word SAI1_IRQHandler /* SAI1 */
|
||||
.word LTDC_IRQHandler /* LTDC */
|
||||
.word LTDC_ER_IRQHandler /* LTDC error */
|
||||
.word DMA2D_IRQHandler /* DMA2D */
|
||||
.word SAI2_IRQHandler /* SAI2 */
|
||||
.word OCTOSPI1_IRQHandler /* OCTOSPI1 */
|
||||
.word LPTIM1_IRQHandler /* LPTIM1 */
|
||||
.word CEC_IRQHandler /* HDMI_CEC */
|
||||
.word I2C4_EV_IRQHandler /* I2C4 Event */
|
||||
.word I2C4_ER_IRQHandler /* I2C4 Error */
|
||||
.word SPDIF_RX_IRQHandler /* SPDIF_RX */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */
|
||||
.word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */
|
||||
.word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */
|
||||
.word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */
|
||||
.word TIM15_IRQHandler /* TIM15 global Interrupt */
|
||||
.word TIM16_IRQHandler /* TIM16 global Interrupt */
|
||||
.word TIM17_IRQHandler /* TIM17 global Interrupt */
|
||||
.word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */
|
||||
.word MDIOS_IRQHandler /* MDIOS global Interrupt */
|
||||
.word JPEG_IRQHandler /* JPEG global Interrupt */
|
||||
.word MDMA_IRQHandler /* MDMA global Interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */
|
||||
.word HSEM1_IRQHandler /* HSEM1 global Interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word DAC2_IRQHandler /* DAC2 global Interrupt */
|
||||
.word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */
|
||||
.word BDMA2_Channel0_IRQHandler /* BDMA2 Channel 0 global Interrupt */
|
||||
.word BDMA2_Channel1_IRQHandler /* BDMA2 Channel 1 global Interrupt */
|
||||
.word BDMA2_Channel2_IRQHandler /* BDMA2 Channel 2 global Interrupt */
|
||||
.word BDMA2_Channel3_IRQHandler /* BDMA2 Channel 3 global Interrupt */
|
||||
.word BDMA2_Channel4_IRQHandler /* BDMA2 Channel 4 global Interrupt */
|
||||
.word BDMA2_Channel5_IRQHandler /* BDMA2 Channel 5 global Interrupt */
|
||||
.word BDMA2_Channel6_IRQHandler /* BDMA2 Channel 6 global Interrupt */
|
||||
.word BDMA2_Channel7_IRQHandler /* BDMA2 Channel 7 global Interrupt */
|
||||
.word COMP_IRQHandler /* COMP global Interrupt */
|
||||
.word LPTIM2_IRQHandler /* LP TIM2 global interrupt */
|
||||
.word LPTIM3_IRQHandler /* LP TIM3 global interrupt */
|
||||
.word UART9_IRQHandler /* UART9 global interrupt */
|
||||
.word USART10_IRQHandler /* USART10 global interrupt */
|
||||
.word LPUART1_IRQHandler /* LP UART1 interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word CRS_IRQHandler /* Clock Recovery Global Interrupt */
|
||||
.word ECC_IRQHandler /* ECC diagnostic Global Interrupt */
|
||||
.word 0 /* Reserved */
|
||||
.word DTS_IRQHandler /* DTS */
|
||||
.word 0 /* Reserved */
|
||||
.word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */
|
||||
.word OCTOSPI2_IRQHandler /* OCTOSPI2 */
|
||||
.word 0 /* Reserved */
|
||||
.word 0 /* Reserved */
|
||||
.word GFXMMU_IRQHandler /* GFXMMU */
|
||||
.word BDMA1_IRQHandler /* BDMA1 */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_PVM_IRQHandler
|
||||
.thumb_set PVD_PVM_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_TAMP_STAMP_CSS_LSE_IRQHandler
|
||||
.thumb_set RTC_TAMP_STAMP_CSS_LSE_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream0_IRQHandler
|
||||
.thumb_set DMA1_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream1_IRQHandler
|
||||
.thumb_set DMA1_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream2_IRQHandler
|
||||
.thumb_set DMA1_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream3_IRQHandler
|
||||
.thumb_set DMA1_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream4_IRQHandler
|
||||
.thumb_set DMA1_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream5_IRQHandler
|
||||
.thumb_set DMA1_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream6_IRQHandler
|
||||
.thumb_set DMA1_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC_IRQHandler
|
||||
.thumb_set ADC_IRQHandler,Default_Handler
|
||||
|
||||
.weak FDCAN1_IT0_IRQHandler
|
||||
.thumb_set FDCAN1_IT0_IRQHandler,Default_Handler
|
||||
|
||||
.weak FDCAN2_IT0_IRQHandler
|
||||
.thumb_set FDCAN2_IT0_IRQHandler,Default_Handler
|
||||
|
||||
.weak FDCAN1_IT1_IRQHandler
|
||||
.thumb_set FDCAN1_IT1_IRQHandler,Default_Handler
|
||||
|
||||
.weak FDCAN2_IT1_IRQHandler
|
||||
.thumb_set FDCAN2_IT1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_BRK_IRQHandler
|
||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_UP_IRQHandler
|
||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_TRG_COM_IRQHandler
|
||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM1_CC_IRQHandler
|
||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM3_IRQHandler
|
||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM4_IRQHandler
|
||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART3_IRQHandler
|
||||
.thumb_set USART3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM2_IRQHandler
|
||||
.thumb_set DFSDM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_BRK_TIM12_IRQHandler
|
||||
.thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_UP_TIM13_IRQHandler
|
||||
.thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_TRG_COM_TIM14_IRQHandler
|
||||
.thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM8_CC_IRQHandler
|
||||
.thumb_set TIM8_CC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Stream7_IRQHandler
|
||||
.thumb_set DMA1_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak FMC_IRQHandler
|
||||
.thumb_set FMC_IRQHandler,Default_Handler
|
||||
|
||||
.weak SDMMC1_IRQHandler
|
||||
.thumb_set SDMMC1_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM5_IRQHandler
|
||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI3_IRQHandler
|
||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART4_IRQHandler
|
||||
.thumb_set UART4_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART5_IRQHandler
|
||||
.thumb_set UART5_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM6_DAC_IRQHandler
|
||||
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM7_IRQHandler
|
||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream0_IRQHandler
|
||||
.thumb_set DMA2_Stream0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream1_IRQHandler
|
||||
.thumb_set DMA2_Stream1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream2_IRQHandler
|
||||
.thumb_set DMA2_Stream2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream3_IRQHandler
|
||||
.thumb_set DMA2_Stream3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream4_IRQHandler
|
||||
.thumb_set DMA2_Stream4_IRQHandler,Default_Handler
|
||||
|
||||
.weak FDCAN_CAL_IRQHandler
|
||||
.thumb_set FDCAN_CAL_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT4_IRQHandler
|
||||
.thumb_set DFSDM1_FLT4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT5_IRQHandler
|
||||
.thumb_set DFSDM1_FLT5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT6_IRQHandler
|
||||
.thumb_set DFSDM1_FLT6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT7_IRQHandler
|
||||
.thumb_set DFSDM1_FLT7_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream5_IRQHandler
|
||||
.thumb_set DMA2_Stream5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream6_IRQHandler
|
||||
.thumb_set DMA2_Stream6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Stream7_IRQHandler
|
||||
.thumb_set DMA2_Stream7_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART6_IRQHandler
|
||||
.thumb_set USART6_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_EV_IRQHandler
|
||||
.thumb_set I2C3_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C3_ER_IRQHandler
|
||||
.thumb_set I2C3_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_OUT_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_EP1_IN_IRQHandler
|
||||
.thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_WKUP_IRQHandler
|
||||
.thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak OTG_HS_IRQHandler
|
||||
.thumb_set OTG_HS_IRQHandler,Default_Handler
|
||||
|
||||
.weak DCMI_PSSI_IRQHandler
|
||||
.thumb_set DCMI_PSSI_IRQHandler,Default_Handler
|
||||
|
||||
.weak RNG_IRQHandler
|
||||
.thumb_set RNG_IRQHandler,Default_Handler
|
||||
|
||||
.weak FPU_IRQHandler
|
||||
.thumb_set FPU_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART7_IRQHandler
|
||||
.thumb_set UART7_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART8_IRQHandler
|
||||
.thumb_set UART8_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI4_IRQHandler
|
||||
.thumb_set SPI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI5_IRQHandler
|
||||
.thumb_set SPI5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI6_IRQHandler
|
||||
.thumb_set SPI6_IRQHandler,Default_Handler
|
||||
|
||||
.weak SAI1_IRQHandler
|
||||
.thumb_set SAI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LTDC_IRQHandler
|
||||
.thumb_set LTDC_IRQHandler,Default_Handler
|
||||
|
||||
.weak LTDC_ER_IRQHandler
|
||||
.thumb_set LTDC_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2D_IRQHandler
|
||||
.thumb_set DMA2D_IRQHandler,Default_Handler
|
||||
|
||||
.weak SAI2_IRQHandler
|
||||
.thumb_set SAI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak OCTOSPI1_IRQHandler
|
||||
.thumb_set OCTOSPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM1_IRQHandler
|
||||
.thumb_set LPTIM1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CEC_IRQHandler
|
||||
.thumb_set CEC_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C4_EV_IRQHandler
|
||||
.thumb_set I2C4_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C4_ER_IRQHandler
|
||||
.thumb_set I2C4_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPDIF_RX_IRQHandler
|
||||
.thumb_set SPDIF_RX_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMAMUX1_OVR_IRQHandler
|
||||
.thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT0_IRQHandler
|
||||
.thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT1_IRQHandler
|
||||
.thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT2_IRQHandler
|
||||
.thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DFSDM1_FLT3_IRQHandler
|
||||
.thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler
|
||||
|
||||
.weak SWPMI1_IRQHandler
|
||||
.thumb_set SWPMI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM15_IRQHandler
|
||||
.thumb_set TIM15_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM16_IRQHandler
|
||||
.thumb_set TIM16_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM17_IRQHandler
|
||||
.thumb_set TIM17_IRQHandler,Default_Handler
|
||||
|
||||
.weak MDIOS_WKUP_IRQHandler
|
||||
.thumb_set MDIOS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak MDIOS_IRQHandler
|
||||
.thumb_set MDIOS_IRQHandler,Default_Handler
|
||||
|
||||
.weak JPEG_IRQHandler
|
||||
.thumb_set JPEG_IRQHandler,Default_Handler
|
||||
|
||||
.weak MDMA_IRQHandler
|
||||
.thumb_set MDMA_IRQHandler,Default_Handler
|
||||
|
||||
.weak SDMMC2_IRQHandler
|
||||
.thumb_set SDMMC2_IRQHandler,Default_Handler
|
||||
|
||||
.weak HSEM1_IRQHandler
|
||||
.thumb_set HSEM1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DAC2_IRQHandler
|
||||
.thumb_set DAC2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMAMUX2_OVR_IRQHandler
|
||||
.thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel0_IRQHandler
|
||||
.thumb_set BDMA2_Channel0_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel1_IRQHandler
|
||||
.thumb_set BDMA2_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel2_IRQHandler
|
||||
.thumb_set BDMA2_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel3_IRQHandler
|
||||
.thumb_set BDMA2_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel4_IRQHandler
|
||||
.thumb_set BDMA2_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel5_IRQHandler
|
||||
.thumb_set BDMA2_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel6_IRQHandler
|
||||
.thumb_set BDMA2_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA2_Channel7_IRQHandler
|
||||
.thumb_set BDMA2_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak COMP_IRQHandler
|
||||
.thumb_set COMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM2_IRQHandler
|
||||
.thumb_set LPTIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM3_IRQHandler
|
||||
.thumb_set LPTIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM4_IRQHandler
|
||||
.thumb_set LPTIM4_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPTIM5_IRQHandler
|
||||
.thumb_set LPTIM5_IRQHandler,Default_Handler
|
||||
|
||||
.weak UART9_IRQHandler
|
||||
.thumb_set UART9_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART10_IRQHandler
|
||||
.thumb_set USART10_IRQHandler,Default_Handler
|
||||
|
||||
.weak LPUART1_IRQHandler
|
||||
.thumb_set LPUART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak CRS_IRQHandler
|
||||
.thumb_set CRS_IRQHandler,Default_Handler
|
||||
|
||||
.weak ECC_IRQHandler
|
||||
.thumb_set ECC_IRQHandler,Default_Handler
|
||||
|
||||
.weak DTS_IRQHandler
|
||||
.thumb_set DTS_IRQHandler,Default_Handler
|
||||
|
||||
.weak WAKEUP_PIN_IRQHandler
|
||||
.thumb_set WAKEUP_PIN_IRQHandler,Default_Handler
|
||||
|
||||
.weak OCTOSPI2_IRQHandler
|
||||
.thumb_set OCTOSPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak GFXMMU_IRQHandler
|
||||
.thumb_set GFXMMU_IRQHandler,Default_Handler
|
||||
|
||||
.weak BDMA1_IRQHandler
|
||||
.thumb_set BDMA1_IRQHandler,Default_Handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user