add first rev of eeprom

and ref voltage in varhandler
This commit is contained in:
2022-12-13 14:30:40 +01:00
parent bf7cde9730
commit 7cadcdbc28
47 changed files with 30486 additions and 1377 deletions

View File

@ -57,7 +57,7 @@
//=================================================================================================
/* Software Version */
#define SW_VERSION 1
#define SW_VERSION 2
#define MSG_QUEUE_SIZE 8
@ -74,7 +74,8 @@
#define COMMAND_ALARM 4
#define COMMAND_CLEAR_ERROR 5
#define COMMAND_GET_SW_VERSION 6
#define COMMAND_SET_REF_VOLTAGE 7
#define COMMAND_SAVE_VARIABLES 7
#define COMMAND_LOAD_VARIABLES 8
#define COMMAND_REBOOT 255
@ -199,7 +200,7 @@ LOCAL CONST osTimerAttr_t stWatchdogTimerAttribute =
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL MAIN_boInitializeModule( VOID )
BOOL MAIN_boInitializeModule( VOID )
{
BOOL boOK = TRUE;
@ -274,7 +275,6 @@ PRIVATE VOID vTask( PVOID arg )
case COMMAND_ON:
PECO_Enable( TRUE );
break;
case COMMAND_OFF:
PECO_Enable( FALSE );
break;
@ -293,11 +293,13 @@ PRIVATE VOID vTask( PVOID arg )
au8Buffer[1] = SW_VERSION;
CAND_boSendMessage( au8Buffer, 2, stMessage.boIsPrivate, stMessage.u8Type );
break;
case COMMAND_SET_REF_VOLTAGE:
VARH_UVariable uData;
UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4);
ANPI_vSetRefVoltage(uData.flVal);
ANPO_boSetVoltage(uData.flVal);
case COMMAND_SAVE_VARIABLES:
au8Buffer[0] = COMMAND_SAVE_VARIABLES;
au8Buffer[1] = VARH_vSaveVariablestoFlash() ? 0xFF : 0x00;
CAND_boSendMessage( au8Buffer, 2, stMessage.boIsPrivate, stMessage.u8Type );
break;
case COMMAND_LOAD_VARIABLES:
VARH_vLoadVariablesfromFlash();
break;
default:
break;

View File

@ -30,6 +30,8 @@
#include "VARH_VariableHandler.h"
#include "USFL_UserFlash.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"
@ -69,6 +71,11 @@ LOCAL osMutexId_t m_pstMutexID = NULL;
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
/*
If you set the VARH_FLAGINFO_FLASH, don't forget to update the Number of variables saved into Flash!!!
Middlewares\ST\EEPROM_Emul\Core\eeprom_emul_conf.h
*/
LOCAL CONST VARH_StVarInfo m_astVarInfo[VARH_eNumberOfVariables] =
{
{ VARH_FLAGINFO_NONE, (VARH_UVariable)(U32)1, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)1}, // VARH_eMode
@ -97,6 +104,7 @@ LOCAL CONST VARH_StVarInfo m_astVarInfo[VARH_eNumberOfVariables] =
{ VARH_FLAGINFO_READONLY, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)1 }, // VARH_ePowerState
{ VARH_FLAGINFO_READONLY, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0xFFFFFFFF }, // VARH_eError
{ VARH_FLAGINFO_FLASH | VARH_FLAGINFO_FLOAT, (VARH_UVariable)3.3f, (VARH_UVariable)(U32)2.0f, (VARH_UVariable)4.0f }, // VARH_eRef_U
};
LOCAL CONST osMutexAttr_t m_stMutexAttr =
@ -353,6 +361,56 @@ VOID VARH_vSetAllVariablesToInitData( VOID )
}
}
//-------------------------------------------------------------------------------------------------
// Function: VARH_vSaveVariablestoFlash
// Description: Saves all Variables with Flag VARH_FLAGINFO_FLASH to Flash
// Parameters: None
// Returns: TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL VARH_vSaveVariablestoFlash( VOID )
{
BOOL boOK = TRUE;
USFL_vUnlock();
for( U8 u8Var = 0; u8Var < VARH_eNumberOfVariables; u8Var++ )
{
if( (m_astVarInfo[u8Var].u8Flags & VARH_FLAGINFO_FLASH) == VARH_FLAGINFO_FLASH ){
boOK &= USFL_boSetVariable(u8Var, VARH_u32GetVariableData(u8Var));
}
}
USFL_vLock();
return boOK;
}
//-------------------------------------------------------------------------------------------------
// Function: VARH_vSaveVariablestoFlash
// Description: Saves all Variables with Flag VARH_FLAGINFO_FLASH to Flash
// Parameters: None
// Returns: None
//-------------------------------------------------------------------------------------------------
VOID VARH_vLoadVariablesfromFlash( VOID )
{
BOOL boOK = TRUE;
for( U8 u8Var = 0; u8Var < VARH_eNumberOfVariables; u8Var++ )
{
if( (m_astVarInfo[u8Var].u8Flags & VARH_FLAGINFO_FLASH) == VARH_FLAGINFO_FLASH ){
U32 u32Data;
boOK &= USFL_boGetVariable(u8Var, &u32Data);
if( boOK ) VARH_vSetVariableDataFromSystemU32(u8Var, u32Data);
}
}
if( !boOK ){
for( U8 u8Var = 0; u8Var < VARH_eNumberOfVariables; u8Var++ )
{
if( (m_astVarInfo[u8Var].u8Flags & VARH_FLAGINFO_FLASH) == VARH_FLAGINFO_FLASH ){
VARH_vSetVariableToInitData( u8Var );
}
}
}
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.

View File

@ -91,6 +91,7 @@ typedef enum
VARH_ePowerState,
VARH_eError,
VARH_eRef_U,
VARH_eNumberOfVariables, // Must be last entry
} VARH_EnVariables;
@ -167,6 +168,9 @@ U8 VARH_uGetVariableFlags( U8 u8Variable );
VOID VARH_vSetVariableToInitData( U8 u8Variable );
VOID VARH_vSetAllVariablesToInitData( VOID );
BOOL VARH_vSaveVariablestoFlash( VOID );
VOID VARH_vLoadVariablesfromFlash( VOID );
#ifdef __cplusplus
}
#endif

View File

@ -52,8 +52,6 @@
#define ADC_RES (4096) // ADC resolution: 12 bits
#define NR_OF_ADCS ANPI_eInNumberOfInputs // number of internal adc channels
#define INT_ADC_REF (3.3f)// int. reference voltage for conversion
#define BUFFER_SIZE NR_OF_ADCS * 2
#define BUFFER_HALF_SIZE NR_OF_ADCS
@ -95,8 +93,6 @@ LOCAL osThreadId_t m_pstThreadID = NULL;
LOCAL osEventFlagsId_t m_pstEventID = NULL;
LOCAL osMutexId_t m_pstMutexID = NULL;
LOCAL FLOAT flRefVoltage = INT_ADC_REF;
//=================================================================================================
// Section: LOCAL CONSTANTS
// Description: Definition of local constants (visible by this module only).
@ -200,17 +196,6 @@ BOOL ANPI_boInitializeModule( VOID )
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: ANPI_vSetRefVoltage
// Description: Sets the Reference Voltage for calculating the Voltage
// Parameters: FLOAT flVoltage -> The Ref Voltage measured with an DMM for example
// Returns: None
//-------------------------------------------------------------------------------------------------
VOID ANPI_vSetRefVoltage( FLOAT flVoltage )
{
flRefVoltage = flVoltage;
}
//-------------------------------------------------------------------------------------------------
// Function: ANPI_vTask
// Description: ANPI_vTask
@ -244,6 +229,8 @@ VOID vTask( PVOID arg )
for( U16 u16Cnt = 0; u16Cnt < BUFFER_HALF_SIZE; u16Cnt++ )
au32ADCRawData[ u16Cnt ] = m_au16ADCDataBuffer[u16Cnt + u16Offset];
FLOAT flRefVoltage = VARH_flGetVariableData(VARH_eRef_U);
// multiply conversion factor and add the offset
for( U16 u16Cnt = 0; u16Cnt < ANPI_eInNumberOfInputs; u16Cnt++ )
{

View File

@ -94,7 +94,6 @@ typedef enum
//=================================================================================================
BOOL ANPI_boInitializeModule( VOID );
VOID ANPI_vSetRefVoltage( FLOAT flVoltage );
#ifdef __cplusplus
}

View File

@ -32,6 +32,8 @@
#include "ANPO_AnalogPortsOut.h"
#include "VARH_VariableHandler.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"
@ -45,7 +47,7 @@
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
#define INT_DAC_REF (3.3f)// int. reference voltage for conversion
//=================================================================================================
// Section: MACROS
@ -61,7 +63,6 @@
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of local Structures (visible by this module only).
@ -69,13 +70,12 @@
//=================================================================================================
// Section: LOCAL VARIABLES
// Description: Definition of local variables (visible by this module only).
//=================================================================================================
LOCAL FLOAT flRefVoltage = INT_DAC_REF;
//=================================================================================================
// Section: LOCAL CONSTANTS
@ -125,17 +125,6 @@ BOOL ANPO_boInitializeModule( VOID )
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: ANPO_vSetRefVoltage
// Description: Sets the Reference Voltage for calculating the Voltage
// Parameters: FLOAT flVoltage -> The Ref Voltage measured with an DMM for example
// Returns: None
//-------------------------------------------------------------------------------------------------
VOID ANPO_vSetRefVoltage( FLOAT flVoltage )
{
flRefVoltage = flVoltage;
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
@ -166,7 +155,7 @@ BOOL ANPO_boSetVoltage( FLOAT flVoltage ){
U32 u32ConvertVoltagetoRaw( FLOAT flVoltage ){
U32 RawData;
RawData = flVoltage * 4095 / flRefVoltage;
RawData = flVoltage * 4095 / VARH_flGetVariableData(VARH_eRef_U);
return RawData;
}

View File

@ -88,7 +88,6 @@ typedef enum
BOOL ANPO_boInitializeModule( VOID );
BOOL ANPO_boSetVoltage( FLOAT flVoltage );
VOID ANPO_vSetRefVoltage( FLOAT flVoltage );
#ifdef __cplusplus
}

View File

@ -19,23 +19,11 @@
//
//-------------------------------------------------------------------------------------------------
//
// Description: This source file contains all functions dealing with internal flash for User Settings
// Description: This source file contains all functions dealing with the virtual eeprom
//
// STM32L432KBUX_FLASH.ld
// More info in the AN4894 or this link:
// https://www.st.com/en/embedded-software/x-cube-eeprom.html
//
// DATA (rwx) : ORIGIN = 0x801F800, LENGTH = 2K
//
// /* Sections */
// SECTIONS
// {
// /* NOLOAD is required for not ereasing this block */
// .user_data (NOLOAD) :
// {
// . = ALIGN(4);
// *(.user_data)
// . = ALIGN(4);
// } > DATA*/
// ...
//=================================================================================================
@ -47,26 +35,18 @@
#include "USFL_UserFlash.h"
// Toolbox
#include "../Application/VARH_VariableHandler.h"
// include STM32 drivers
#include "stm32l4xx_hal.h"
#include "cmsis_os2.h"
#include "eeprom_emul.h"
//=================================================================================================
// Section: DEFINITIONS
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
#define USERFLASHSIZE (2000/4) // Bytes -> 64 Bits
#define USERFLASHPAGE (63)
#define VARDEF 0xABCDEF
#define STARTDEF (((U64)0xAA01F055 << 32) + (VARDEF << 2))
//=================================================================================================
@ -88,12 +68,6 @@
// Description: Definition of local Structures (visible by this module only).
//=================================================================================================
FLASH_EraseInitTypeDef stEreaseInit = {
FLASH_TYPEERASE_PAGES,
FLASH_BANK_1,
USERFLASHPAGE,
1
};
//=================================================================================================
@ -101,24 +75,29 @@ FLASH_EraseInitTypeDef stEreaseInit = {
// Description: Definition of local variables (visible by this module only).
//=================================================================================================
U32 u32VarPointer = 0;
__IO uint32_t ErasingOnGoing = 0;
LOCAL osMutexId_t m_pstMutexID = NULL;
//=================================================================================================
// Section: LOCAL CONSTANTS
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
__attribute__((__section__(".user_data"))) const U64 UserFlash[USERFLASHSIZE];
LOCAL CONST osMutexAttr_t m_stMutexAttr =
{
"USFL_Mutex", // human readable mutex name
osMutexRecursive | osMutexPrioInherit, // attr_bits
NULL, // memory for control block
0U // size for control block
};
//=================================================================================================
// Section: LOCAL FUNCTIONS (PROTOTYPES)
// Description: Definition of local functions (visible by this module only).
//=================================================================================================
BOOL vEreaseUserFlash( void );
U32 vFindNextFreePointer( void );
U32 u32FindLastPointer( void );
U8 u8ConvertWordsToDoubleWords( U8 u8Words );
//=================================================================================================
// Section: GLOBAL FUNCTIONS
@ -131,28 +110,87 @@ U8 u8ConvertWordsToDoubleWords( U8 u8Words );
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL USFL_boInitializeModule( VOID )
{
BOOL boOK = TRUE;
if( UserFlash[0] != STARTDEF ){
boOK &= vEreaseUserFlash();
}
boOK &= ( ( m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE;
boOK &= EE_Init(EE_FORCED_ERASE) == EE_OK ? TRUE : FALSE;
return( boOK );
}
VARH_UVariable USFL_uGetVariable ( void ){
//-------------------------------------------------------------------------------------------------
// Function: USFL_boGetVariable
// Description: Gets a variable out of the virtual eeprom
// Parameters: U8 u8Variable -> virtual adress of variable
// U32 * u32Variable -> pointer to data
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL USFL_boGetVariable ( U8 u8Variable, U32 * u32Variable ){
BOOL boOK = TRUE;
if( u32VarPointer == 0 ) u32VarPointer = u32FindLastPointer();
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
boOK &= EE_ReadVariable32bits( (U16) u8Variable, u32Variable ) == EE_OK ? TRUE : FALSE;
osMutexRelease( m_pstMutexID ); // release mutex
return boOK;
}
//-------------------------------------------------------------------------------------------------
// Function: USFL_boSetVariable
// Description: Writes a variable into the virtual eeprom
// Parameters: U8 u8Variable -> virtual adress of variable
// U32 u32Variable -> data to write
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL USFL_boSetVariable ( U8 u8Variable, U32 u32Variable ){
BOOL boOK = TRUE;
EE_Status ee_status = EE_OK;
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
boOK &= (ee_status = EE_WriteVariable32bits( (U16) u8Variable, u32Variable )) == EE_OK ? TRUE : FALSE;
/* Start cleanup IT mode, if cleanup is needed */
if ((ee_status & EE_STATUSMASK_CLEANUP) == EE_STATUSMASK_CLEANUP) {
ErasingOnGoing = 1;
boOK &= (ee_status |= EE_CleanUp()) == EE_OK ? TRUE : FALSE;
}
if ((ee_status & EE_STATUSMASK_ERROR) == EE_STATUSMASK_ERROR) {boOK &= FALSE;}
osMutexRelease( m_pstMutexID ); // release mutex
return boOK;
}
//-------------------------------------------------------------------------------------------------
// Function: USFL_vLock
// Description: Locks the Flash, no more clearing and programming possible
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL USFL_vLock( VOID ){
BOOL boOK = TRUE;
boOK &= HAL_FLASH_Lock() == HAL_OK ? TRUE : FALSE;
return boOK;
}
//-------------------------------------------------------------------------------------------------
// Function: USFL_vUnlock
// Description: Unlocks the Flash, clearing and programming possible
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL USFL_vUnlock( VOID ){
BOOL boOK = TRUE;
boOK &= HAL_FLASH_Unlock() == HAL_OK ? TRUE : FALSE;
return boOK;
}
//=================================================================================================
@ -160,116 +198,3 @@ VARH_UVariable USFL_uGetVariable ( void ){
// Descriptionn: Definition (implementation) of local functions.
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: u32FindNextFreePointer
// Description: Finds the next free sector in the flash for saving variables
// Parameters: None
// Returns: U32 next free pointer
//-------------------------------------------------------------------------------------------------
U32 u32FindNextFreePointer( void ){
BOOL boFound = FALSE;
U32 u32Pointer = u32VarPointer;
while(!boFound){
if( ( ( UserFlash[u32Pointer] >> 8 ) & 0xFFFFFF ) == VARDEF ){
U8 u8Size = UserFlash[u32Pointer] & 0xFF;
if( u8Size == 0 ){
boFound = TRUE;
} else {
u32Pointer += u8ConvertWordsToDoubleWords(u8Size);
}
} else {
u32Pointer += 1;
}
if( u32Pointer >= USERFLASHSIZE ){
u32Pointer = 1;
break;
}
}
return u32Pointer;
}
//-------------------------------------------------------------------------------------------------
// Function: u32FindLastPointer
// Description: Finds the next free sector in the flash for saving variables
// Parameters: None
// Returns: U32 next free pointer
//-------------------------------------------------------------------------------------------------
U32 u32FindLastPointer( void ){
BOOL boFound = FALSE;
U32 u32Pointer = 0;
U8 u8LastSize = 0;
while(!boFound){
if( ( UserFlash[u32Pointer] >> 40) == VARDEF ){
U8 u8Size = UserFlash[u32Pointer] & 0xFF;
if( u8Size == 0 ){
boFound = TRUE;
u32Pointer -= u8ConvertWordsToDoubleWords(u8LastSize);
} else {
u32Pointer += u8ConvertWordsToDoubleWords(u8Size);
u8LastSize = u8Size;
}
} else {
u32Pointer += 1;
}
if( u32Pointer >= USERFLASHSIZE ){
u32Pointer = 1;
break;
}
}
return u32Pointer;
}
//-------------------------------------------------------------------------------------------------
// Function: u8ConvertWordsToDoubleWords
// Description: Converts 32Bit Word size to 64 Bit Double Word size for saving Vars
// Parameters: U8 u8Words
// Returns: U8 Double Words
//-------------------------------------------------------------------------------------------------
U8 u8ConvertWordsToDoubleWords( U8 u8Words ) {
U8 u8DWords;
u8Words += 1; // + VARDEF
u8DWords = u8Words / 2;
u8DWords += u8Words % 2;
return u8DWords;
}
//-------------------------------------------------------------------------------------------------
// Function: vEreaseUserFlash
// Description: Ereases the User Flash Sector
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL vEreaseUserFlash( void ){
uint32_t u32PageError = 0;
BOOL boOK = TRUE;
HAL_FLASH_Unlock();
boOK &= HAL_FLASHEx_Erase(&stEreaseInit, &u32PageError) == HAL_OK ? TRUE : FALSE;
if( !boOK ){
return FALSE;
}
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, (U32) &UserFlash[0], STARTDEF);
HAL_FLASH_Lock();
return TRUE;
}

View File

@ -87,6 +87,11 @@ extern "C" {
//=================================================================================================
BOOL USFL_boInitializeModule( VOID );
BOOL USFL_boGetVariable ( U8 u8Variable, U32 * u32Variable );
BOOL USFL_boSetVariable ( U8 u8Variable, U32 u32Variable );
BOOL USFL_vLock( VOID );
BOOL USFL_vUnlock( VOID );
#ifdef __cplusplus
}

View File

@ -40,7 +40,7 @@
/*#define HAL_CRYP_MODULE_ENABLED */
#define HAL_CAN_MODULE_ENABLED
/*#define HAL_COMP_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */
#define HAL_CRC_MODULE_ENABLED
/*#define HAL_CRYP_MODULE_ENABLED */
#define HAL_DAC_MODULE_ENABLED
/*#define HAL_DCMI_MODULE_ENABLED */

View File

@ -52,6 +52,8 @@ DMA_HandleTypeDef hdma_adc1;
CAN_HandleTypeDef hcan1;
CRC_HandleTypeDef hcrc;
DAC_HandleTypeDef hdac1;
I2C_HandleTypeDef hi2c1;
@ -83,6 +85,7 @@ static void MX_DAC1_Init(void);
static void MX_SPI1_Init(void);
static void MX_I2C1_Init(void);
static void MX_IWDG_Init(void);
static void MX_CRC_Init(void);
void vDefaultTask(void *argument);
/* USER CODE BEGIN PFP */
@ -146,6 +149,7 @@ int main(void)
MX_SPI1_Init();
MX_I2C1_Init();
MX_IWDG_Init();
MX_CRC_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -211,6 +215,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
@ -228,6 +233,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
@ -260,6 +266,7 @@ static void MX_ADC1_Init(void)
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
@ -285,6 +292,7 @@ static void MX_ADC1_Init(void)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_6;
@ -297,6 +305,7 @@ static void MX_ADC1_Init(void)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_16;
@ -305,6 +314,7 @@ static void MX_ADC1_Init(void)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_7;
@ -313,6 +323,7 @@ static void MX_ADC1_Init(void)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_15;
@ -366,6 +377,37 @@ static void MX_CAN1_Init(void)
}
/**
* @brief CRC Initialization Function
* @param None
* @retval None
*/
static void MX_CRC_Init(void)
{
/* USER CODE BEGIN CRC_Init 0 */
/* USER CODE END CRC_Init 0 */
/* USER CODE BEGIN CRC_Init 1 */
/* USER CODE END CRC_Init 1 */
hcrc.Instance = CRC;
hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;
hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;
hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;
hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;
hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
if (HAL_CRC_Init(&hcrc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CRC_Init 2 */
/* USER CODE END CRC_Init 2 */
}
/**
* @brief DAC1 Initialization Function
* @param None
@ -383,6 +425,7 @@ static void MX_DAC1_Init(void)
/* USER CODE BEGIN DAC1_Init 1 */
/* USER CODE END DAC1_Init 1 */
/** DAC Initialization
*/
hdac1.Instance = DAC1;
@ -390,6 +433,7 @@ static void MX_DAC1_Init(void)
{
Error_Handler();
}
/** DAC channel OUT1 config
*/
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
@ -440,12 +484,14 @@ static void MX_I2C1_Init(void)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
@ -665,4 +711,3 @@ void assert_failed(uint8_t *file, uint32_t line)
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

View File

@ -99,6 +99,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
@ -274,6 +275,50 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
}
/**
* @brief CRC MSP Initialization
* This function configures the hardware resources used in this example
* @param hcrc: CRC handle pointer
* @retval None
*/
void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
/* USER CODE BEGIN CRC_MspInit 0 */
/* USER CODE END CRC_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_CRC_CLK_ENABLE();
/* USER CODE BEGIN CRC_MspInit 1 */
/* USER CODE END CRC_MspInit 1 */
}
}
/**
* @brief CRC MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hcrc: CRC handle pointer
* @retval None
*/
void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
{
if(hcrc->Instance==CRC)
{
/* USER CODE BEGIN CRC_MspDeInit 0 */
/* USER CODE END CRC_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_CRC_CLK_DISABLE();
/* USER CODE BEGIN CRC_MspDeInit 1 */
/* USER CODE END CRC_MspDeInit 1 */
}
}
/**
* @brief DAC MSP Initialization
* This function configures the hardware resources used in this example
@ -350,6 +395,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
/* USER CODE BEGIN I2C1_MspInit 0 */
/* USER CODE END I2C1_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
@ -525,4 +571,3 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@ -317,4 +317,3 @@ void DMA2_Channel3_IRQHandler(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */