add first rev of eeprom
and ref voltage in varhandler
This commit is contained in:
File diff suppressed because one or more lines are too long
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@ -12,6 +12,8 @@
|
|||||||
"Drivers/CMSIS/Include",
|
"Drivers/CMSIS/Include",
|
||||||
"Drivers/STM32L4xx_HAL_Driver/Inc",
|
"Drivers/STM32L4xx_HAL_Driver/Inc",
|
||||||
"Drivers/STM32L4xx_HAL_Driver/Inc/Legacy",
|
"Drivers/STM32L4xx_HAL_Driver/Inc/Legacy",
|
||||||
|
"Middlewares/ST/EEPROM_Emul/Core",
|
||||||
|
"Middlewares/ST/EEPROM_Emul/Porting/STM32L4",
|
||||||
"Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2",
|
"Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2",
|
||||||
"Middlewares/Third_Party/FreeRTOS/Source/include",
|
"Middlewares/Third_Party/FreeRTOS/Source/include",
|
||||||
"Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"
|
"Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -3,7 +3,8 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"peco_peltiercontroller.h": "c",
|
"peco_peltiercontroller.h": "c",
|
||||||
"cmsis_os2.h": "c",
|
"cmsis_os2.h": "c",
|
||||||
"varh_variablehandler.h": "c"
|
"varh_variablehandler.h": "c",
|
||||||
|
"eeprom_emul.h": "c"
|
||||||
},
|
},
|
||||||
"cortex-debug.armToolchainPath": "c:\\Users\\pique_n\\AppData\\Roaming\\Code\\User\\globalStorage\\bmd.stm32-for-vscode\\@xpack-dev-tools\\arm-none-eabi-gcc\\11.3.1-1.1.2\\.content\\bin",
|
"cortex-debug.armToolchainPath": "c:\\Users\\pique_n\\AppData\\Roaming\\Code\\User\\globalStorage\\bmd.stm32-for-vscode\\@xpack-dev-tools\\arm-none-eabi-gcc\\11.3.1-1.1.2\\.content\\bin",
|
||||||
"cortex-debug.openocdPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\OPENOCD\\0.11.0-5.1\\.CONTENT\\BIN\\OPENOCD.EXE",
|
"cortex-debug.openocdPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\OPENOCD\\0.11.0-5.1\\.CONTENT\\BIN\\OPENOCD.EXE",
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
/* Software Version */
|
/* Software Version */
|
||||||
#define SW_VERSION 1
|
#define SW_VERSION 2
|
||||||
|
|
||||||
#define MSG_QUEUE_SIZE 8
|
#define MSG_QUEUE_SIZE 8
|
||||||
|
|
||||||
@ -74,7 +74,8 @@
|
|||||||
#define COMMAND_ALARM 4
|
#define COMMAND_ALARM 4
|
||||||
#define COMMAND_CLEAR_ERROR 5
|
#define COMMAND_CLEAR_ERROR 5
|
||||||
#define COMMAND_GET_SW_VERSION 6
|
#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
|
#define COMMAND_REBOOT 255
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ LOCAL CONST osTimerAttr_t stWatchdogTimerAttribute =
|
|||||||
// Returns: Boolean TRUE if successful
|
// Returns: Boolean TRUE if successful
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BOOL MAIN_boInitializeModule( VOID )
|
BOOL MAIN_boInitializeModule( VOID )
|
||||||
{
|
{
|
||||||
BOOL boOK = TRUE;
|
BOOL boOK = TRUE;
|
||||||
|
|
||||||
@ -274,7 +275,6 @@ PRIVATE VOID vTask( PVOID arg )
|
|||||||
case COMMAND_ON:
|
case COMMAND_ON:
|
||||||
PECO_Enable( TRUE );
|
PECO_Enable( TRUE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMMAND_OFF:
|
case COMMAND_OFF:
|
||||||
PECO_Enable( FALSE );
|
PECO_Enable( FALSE );
|
||||||
break;
|
break;
|
||||||
@ -293,11 +293,13 @@ PRIVATE VOID vTask( PVOID arg )
|
|||||||
au8Buffer[1] = SW_VERSION;
|
au8Buffer[1] = SW_VERSION;
|
||||||
CAND_boSendMessage( au8Buffer, 2, stMessage.boIsPrivate, stMessage.u8Type );
|
CAND_boSendMessage( au8Buffer, 2, stMessage.boIsPrivate, stMessage.u8Type );
|
||||||
break;
|
break;
|
||||||
case COMMAND_SET_REF_VOLTAGE:
|
case COMMAND_SAVE_VARIABLES:
|
||||||
VARH_UVariable uData;
|
au8Buffer[0] = COMMAND_SAVE_VARIABLES;
|
||||||
UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4);
|
au8Buffer[1] = VARH_vSaveVariablestoFlash() ? 0xFF : 0x00;
|
||||||
ANPI_vSetRefVoltage(uData.flVal);
|
CAND_boSendMessage( au8Buffer, 2, stMessage.boIsPrivate, stMessage.u8Type );
|
||||||
ANPO_boSetVoltage(uData.flVal);
|
break;
|
||||||
|
case COMMAND_LOAD_VARIABLES:
|
||||||
|
VARH_vLoadVariablesfromFlash();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include "VARH_VariableHandler.h"
|
#include "VARH_VariableHandler.h"
|
||||||
|
|
||||||
|
#include "USFL_UserFlash.h"
|
||||||
|
|
||||||
// Toolbox
|
// Toolbox
|
||||||
#include "../Toolbox/UTIL_Utility.h"
|
#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).
|
// 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] =
|
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
|
{ 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)1 }, // VARH_ePowerState
|
||||||
{ VARH_FLAGINFO_READONLY, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0xFFFFFFFF }, // VARH_eError
|
{ 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 =
|
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
|
// Section: LOCAL FUNCTIONS
|
||||||
// Descriptionn: Definition (implementation) of local functions.
|
// Descriptionn: Definition (implementation) of local functions.
|
||||||
|
@ -91,6 +91,7 @@ typedef enum
|
|||||||
|
|
||||||
VARH_ePowerState,
|
VARH_ePowerState,
|
||||||
VARH_eError,
|
VARH_eError,
|
||||||
|
VARH_eRef_U,
|
||||||
|
|
||||||
VARH_eNumberOfVariables, // Must be last entry
|
VARH_eNumberOfVariables, // Must be last entry
|
||||||
} VARH_EnVariables;
|
} VARH_EnVariables;
|
||||||
@ -167,6 +168,9 @@ U8 VARH_uGetVariableFlags( U8 u8Variable );
|
|||||||
VOID VARH_vSetVariableToInitData( U8 u8Variable );
|
VOID VARH_vSetVariableToInitData( U8 u8Variable );
|
||||||
VOID VARH_vSetAllVariablesToInitData( VOID );
|
VOID VARH_vSetAllVariablesToInitData( VOID );
|
||||||
|
|
||||||
|
BOOL VARH_vSaveVariablestoFlash( VOID );
|
||||||
|
VOID VARH_vLoadVariablesfromFlash( VOID );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,8 +52,6 @@
|
|||||||
#define ADC_RES (4096) // ADC resolution: 12 bits
|
#define ADC_RES (4096) // ADC resolution: 12 bits
|
||||||
#define NR_OF_ADCS ANPI_eInNumberOfInputs // number of internal adc channels
|
#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_SIZE NR_OF_ADCS * 2
|
||||||
#define BUFFER_HALF_SIZE NR_OF_ADCS
|
#define BUFFER_HALF_SIZE NR_OF_ADCS
|
||||||
|
|
||||||
@ -95,8 +93,6 @@ LOCAL osThreadId_t m_pstThreadID = NULL;
|
|||||||
LOCAL osEventFlagsId_t m_pstEventID = NULL;
|
LOCAL osEventFlagsId_t m_pstEventID = NULL;
|
||||||
LOCAL osMutexId_t m_pstMutexID = NULL;
|
LOCAL osMutexId_t m_pstMutexID = NULL;
|
||||||
|
|
||||||
LOCAL FLOAT flRefVoltage = INT_ADC_REF;
|
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: LOCAL CONSTANTS
|
// Section: LOCAL CONSTANTS
|
||||||
// Description: Definition of local constants (visible by this module only).
|
// Description: Definition of local constants (visible by this module only).
|
||||||
@ -200,17 +196,6 @@ BOOL ANPI_boInitializeModule( VOID )
|
|||||||
return( boOK );
|
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
|
// Function: ANPI_vTask
|
||||||
// Description: ANPI_vTask
|
// Description: ANPI_vTask
|
||||||
@ -244,6 +229,8 @@ VOID vTask( PVOID arg )
|
|||||||
for( U16 u16Cnt = 0; u16Cnt < BUFFER_HALF_SIZE; u16Cnt++ )
|
for( U16 u16Cnt = 0; u16Cnt < BUFFER_HALF_SIZE; u16Cnt++ )
|
||||||
au32ADCRawData[ u16Cnt ] = m_au16ADCDataBuffer[u16Cnt + u16Offset];
|
au32ADCRawData[ u16Cnt ] = m_au16ADCDataBuffer[u16Cnt + u16Offset];
|
||||||
|
|
||||||
|
FLOAT flRefVoltage = VARH_flGetVariableData(VARH_eRef_U);
|
||||||
|
|
||||||
// multiply conversion factor and add the offset
|
// multiply conversion factor and add the offset
|
||||||
for( U16 u16Cnt = 0; u16Cnt < ANPI_eInNumberOfInputs; u16Cnt++ )
|
for( U16 u16Cnt = 0; u16Cnt < ANPI_eInNumberOfInputs; u16Cnt++ )
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,6 @@ typedef enum
|
|||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
BOOL ANPI_boInitializeModule( VOID );
|
BOOL ANPI_boInitializeModule( VOID );
|
||||||
VOID ANPI_vSetRefVoltage( FLOAT flVoltage );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include "ANPO_AnalogPortsOut.h"
|
#include "ANPO_AnalogPortsOut.h"
|
||||||
|
|
||||||
|
#include "VARH_VariableHandler.h"
|
||||||
|
|
||||||
// Toolbox
|
// Toolbox
|
||||||
#include "../Toolbox/UTIL_Utility.h"
|
#include "../Toolbox/UTIL_Utility.h"
|
||||||
|
|
||||||
@ -45,7 +47,7 @@
|
|||||||
// Description: Definition of local constants (visible by this module only).
|
// Description: Definition of local constants (visible by this module only).
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
#define INT_DAC_REF (3.3f)// int. reference voltage for conversion
|
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: MACROS
|
// Section: MACROS
|
||||||
@ -61,7 +63,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: STRUCTURES
|
// Section: STRUCTURES
|
||||||
// Description: Definition of local Structures (visible by this module only).
|
// Description: Definition of local Structures (visible by this module only).
|
||||||
@ -69,13 +70,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: LOCAL VARIABLES
|
// Section: LOCAL VARIABLES
|
||||||
// Description: Definition of local variables (visible by this module only).
|
// Description: Definition of local variables (visible by this module only).
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
LOCAL FLOAT flRefVoltage = INT_DAC_REF;
|
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: LOCAL CONSTANTS
|
// Section: LOCAL CONSTANTS
|
||||||
@ -125,17 +125,6 @@ BOOL ANPO_boInitializeModule( VOID )
|
|||||||
return( boOK );
|
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
|
// Section: LOCAL FUNCTIONS
|
||||||
// Descriptionn: Definition (implementation) of local functions.
|
// Descriptionn: Definition (implementation) of local functions.
|
||||||
@ -166,7 +155,7 @@ BOOL ANPO_boSetVoltage( FLOAT flVoltage ){
|
|||||||
U32 u32ConvertVoltagetoRaw( FLOAT flVoltage ){
|
U32 u32ConvertVoltagetoRaw( FLOAT flVoltage ){
|
||||||
U32 RawData;
|
U32 RawData;
|
||||||
|
|
||||||
RawData = flVoltage * 4095 / flRefVoltage;
|
RawData = flVoltage * 4095 / VARH_flGetVariableData(VARH_eRef_U);
|
||||||
|
|
||||||
return RawData;
|
return RawData;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,6 @@ typedef enum
|
|||||||
|
|
||||||
BOOL ANPO_boInitializeModule( VOID );
|
BOOL ANPO_boInitializeModule( VOID );
|
||||||
BOOL ANPO_boSetVoltage( FLOAT flVoltage );
|
BOOL ANPO_boSetVoltage( FLOAT flVoltage );
|
||||||
VOID ANPO_vSetRefVoltage( FLOAT flVoltage );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -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"
|
#include "USFL_UserFlash.h"
|
||||||
|
|
||||||
// Toolbox
|
|
||||||
#include "../Application/VARH_VariableHandler.h"
|
|
||||||
|
|
||||||
// include STM32 drivers
|
// include STM32 drivers
|
||||||
#include "stm32l4xx_hal.h"
|
#include "stm32l4xx_hal.h"
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
|
#include "eeprom_emul.h"
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
// Section: DEFINITIONS
|
// Section: DEFINITIONS
|
||||||
// Description: Definition of local constants (visible by this module only).
|
// 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).
|
// 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).
|
// 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
|
// Section: LOCAL CONSTANTS
|
||||||
// Description: Definition of local constants (visible by this module only).
|
// 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)
|
// Section: LOCAL FUNCTIONS (PROTOTYPES)
|
||||||
// Description: Definition of local functions (visible by this module only).
|
// 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
|
// Section: GLOBAL FUNCTIONS
|
||||||
@ -131,28 +110,87 @@ U8 u8ConvertWordsToDoubleWords( U8 u8Words );
|
|||||||
// Parameters: None
|
// Parameters: None
|
||||||
// Returns: Boolean TRUE if successful
|
// Returns: Boolean TRUE if successful
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BOOL USFL_boInitializeModule( VOID )
|
BOOL USFL_boInitializeModule( VOID )
|
||||||
{
|
{
|
||||||
BOOL boOK = TRUE;
|
BOOL boOK = TRUE;
|
||||||
|
|
||||||
if( UserFlash[0] != STARTDEF ){
|
boOK &= ( ( m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE;
|
||||||
boOK &= vEreaseUserFlash();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
boOK &= EE_Init(EE_FORCED_ERASE) == EE_OK ? TRUE : FALSE;
|
||||||
|
|
||||||
return( boOK );
|
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.
|
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,6 +87,11 @@ extern "C" {
|
|||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
BOOL USFL_boInitializeModule( VOID );
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||||
#define HAL_CAN_MODULE_ENABLED
|
#define HAL_CAN_MODULE_ENABLED
|
||||||
/*#define HAL_COMP_MODULE_ENABLED */
|
/*#define HAL_COMP_MODULE_ENABLED */
|
||||||
/*#define HAL_CRC_MODULE_ENABLED */
|
#define HAL_CRC_MODULE_ENABLED
|
||||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||||
#define HAL_DAC_MODULE_ENABLED
|
#define HAL_DAC_MODULE_ENABLED
|
||||||
/*#define HAL_DCMI_MODULE_ENABLED */
|
/*#define HAL_DCMI_MODULE_ENABLED */
|
||||||
|
@ -52,6 +52,8 @@ DMA_HandleTypeDef hdma_adc1;
|
|||||||
|
|
||||||
CAN_HandleTypeDef hcan1;
|
CAN_HandleTypeDef hcan1;
|
||||||
|
|
||||||
|
CRC_HandleTypeDef hcrc;
|
||||||
|
|
||||||
DAC_HandleTypeDef hdac1;
|
DAC_HandleTypeDef hdac1;
|
||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
I2C_HandleTypeDef hi2c1;
|
||||||
@ -83,6 +85,7 @@ static void MX_DAC1_Init(void);
|
|||||||
static void MX_SPI1_Init(void);
|
static void MX_SPI1_Init(void);
|
||||||
static void MX_I2C1_Init(void);
|
static void MX_I2C1_Init(void);
|
||||||
static void MX_IWDG_Init(void);
|
static void MX_IWDG_Init(void);
|
||||||
|
static void MX_CRC_Init(void);
|
||||||
void vDefaultTask(void *argument);
|
void vDefaultTask(void *argument);
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
@ -146,6 +149,7 @@ int main(void)
|
|||||||
MX_SPI1_Init();
|
MX_SPI1_Init();
|
||||||
MX_I2C1_Init();
|
MX_I2C1_Init();
|
||||||
MX_IWDG_Init();
|
MX_IWDG_Init();
|
||||||
|
MX_CRC_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
@ -211,6 +215,7 @@ void SystemClock_Config(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
* in the RCC_OscInitTypeDef structure.
|
* in the RCC_OscInitTypeDef structure.
|
||||||
*/
|
*/
|
||||||
@ -228,6 +233,7 @@ void SystemClock_Config(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
*/
|
*/
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
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 BEGIN ADC1_Init 1 */
|
||||||
|
|
||||||
/* USER CODE END ADC1_Init 1 */
|
/* USER CODE END ADC1_Init 1 */
|
||||||
|
|
||||||
/** Common config
|
/** Common config
|
||||||
*/
|
*/
|
||||||
hadc1.Instance = ADC1;
|
hadc1.Instance = ADC1;
|
||||||
@ -285,6 +292,7 @@ static void MX_ADC1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Regular Channel
|
/** Configure Regular Channel
|
||||||
*/
|
*/
|
||||||
sConfig.Channel = ADC_CHANNEL_6;
|
sConfig.Channel = ADC_CHANNEL_6;
|
||||||
@ -297,6 +305,7 @@ static void MX_ADC1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Regular Channel
|
/** Configure Regular Channel
|
||||||
*/
|
*/
|
||||||
sConfig.Channel = ADC_CHANNEL_16;
|
sConfig.Channel = ADC_CHANNEL_16;
|
||||||
@ -305,6 +314,7 @@ static void MX_ADC1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Regular Channel
|
/** Configure Regular Channel
|
||||||
*/
|
*/
|
||||||
sConfig.Channel = ADC_CHANNEL_7;
|
sConfig.Channel = ADC_CHANNEL_7;
|
||||||
@ -313,6 +323,7 @@ static void MX_ADC1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Regular Channel
|
/** Configure Regular Channel
|
||||||
*/
|
*/
|
||||||
sConfig.Channel = ADC_CHANNEL_15;
|
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
|
* @brief DAC1 Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
@ -383,6 +425,7 @@ static void MX_DAC1_Init(void)
|
|||||||
/* USER CODE BEGIN DAC1_Init 1 */
|
/* USER CODE BEGIN DAC1_Init 1 */
|
||||||
|
|
||||||
/* USER CODE END DAC1_Init 1 */
|
/* USER CODE END DAC1_Init 1 */
|
||||||
|
|
||||||
/** DAC Initialization
|
/** DAC Initialization
|
||||||
*/
|
*/
|
||||||
hdac1.Instance = DAC1;
|
hdac1.Instance = DAC1;
|
||||||
@ -390,6 +433,7 @@ static void MX_DAC1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** DAC channel OUT1 config
|
/** DAC channel OUT1 config
|
||||||
*/
|
*/
|
||||||
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
|
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
|
||||||
@ -440,12 +484,14 @@ static void MX_I2C1_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Analogue filter
|
/** Configure Analogue filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Digital filter
|
/** Configure Digital filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
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 */
|
/* USER CODE END 6 */
|
||||||
}
|
}
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
|||||||
/* USER CODE BEGIN ADC1_MspInit 0 */
|
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END ADC1_MspInit 0 */
|
/* USER CODE END ADC1_MspInit 0 */
|
||||||
|
|
||||||
/** Initializes the peripherals clock
|
/** Initializes the peripherals clock
|
||||||
*/
|
*/
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
|
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
|
* @brief DAC MSP Initialization
|
||||||
* This function configures the hardware resources used in this example
|
* 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 BEGIN I2C1_MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END I2C1_MspInit 0 */
|
/* USER CODE END I2C1_MspInit 0 */
|
||||||
|
|
||||||
/** Initializes the peripherals clock
|
/** Initializes the peripherals clock
|
||||||
*/
|
*/
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
|
||||||
@ -525,4 +571,3 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
|||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
@ -317,4 +317,3 @@ void DMA2_Channel3_IRQHandler(void)
|
|||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
342
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h
Normal file
342
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_hal_crc.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of CRC HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_HAL_CRC_H
|
||||||
|
#define STM32L4xx_HAL_CRC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CRC
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Exported_Types CRC Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CRC HAL State Structure definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */
|
||||||
|
HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */
|
||||||
|
HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */
|
||||||
|
HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */
|
||||||
|
HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */
|
||||||
|
} HAL_CRC_StateTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CRC Init Structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t DefaultPolynomialUse; /*!< This parameter is a value of @ref CRC_Default_Polynomial and indicates if default polynomial is used.
|
||||||
|
If set to DEFAULT_POLYNOMIAL_ENABLE, resort to default
|
||||||
|
X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 +
|
||||||
|
X^4 + X^2+ X +1.
|
||||||
|
In that case, there is no need to set GeneratingPolynomial field.
|
||||||
|
If otherwise set to DEFAULT_POLYNOMIAL_DISABLE, GeneratingPolynomial and
|
||||||
|
CRCLength fields must be set. */
|
||||||
|
|
||||||
|
uint8_t DefaultInitValueUse; /*!< This parameter is a value of @ref CRC_Default_InitValue_Use and indicates if default init value is used.
|
||||||
|
If set to DEFAULT_INIT_VALUE_ENABLE, resort to default
|
||||||
|
0xFFFFFFFF value. In that case, there is no need to set InitValue field. If
|
||||||
|
otherwise set to DEFAULT_INIT_VALUE_DISABLE, InitValue field must be set. */
|
||||||
|
|
||||||
|
uint32_t GeneratingPolynomial; /*!< Set CRC generating polynomial as a 7, 8, 16 or 32-bit long value for a polynomial degree
|
||||||
|
respectively equal to 7, 8, 16 or 32. This field is written in normal,
|
||||||
|
representation e.g., for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1
|
||||||
|
is written 0x65. No need to specify it if DefaultPolynomialUse is set to
|
||||||
|
DEFAULT_POLYNOMIAL_ENABLE. */
|
||||||
|
|
||||||
|
uint32_t CRCLength; /*!< This parameter is a value of @ref CRC_Polynomial_Sizes and indicates CRC length.
|
||||||
|
Value can be either one of
|
||||||
|
@arg @ref CRC_POLYLENGTH_32B (32-bit CRC),
|
||||||
|
@arg @ref CRC_POLYLENGTH_16B (16-bit CRC),
|
||||||
|
@arg @ref CRC_POLYLENGTH_8B (8-bit CRC),
|
||||||
|
@arg @ref CRC_POLYLENGTH_7B (7-bit CRC). */
|
||||||
|
|
||||||
|
uint32_t InitValue; /*!< Init value to initiate CRC computation. No need to specify it if DefaultInitValueUse
|
||||||
|
is set to DEFAULT_INIT_VALUE_ENABLE. */
|
||||||
|
|
||||||
|
uint32_t InputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Input_Data_Inversion and specifies input data inversion mode.
|
||||||
|
Can be either one of the following values
|
||||||
|
@arg @ref CRC_INPUTDATA_INVERSION_NONE no input data inversion
|
||||||
|
@arg @ref CRC_INPUTDATA_INVERSION_BYTE byte-wise inversion, 0x1A2B3C4D
|
||||||
|
becomes 0x58D43CB2
|
||||||
|
@arg @ref CRC_INPUTDATA_INVERSION_HALFWORD halfword-wise inversion,
|
||||||
|
0x1A2B3C4D becomes 0xD458B23C
|
||||||
|
@arg @ref CRC_INPUTDATA_INVERSION_WORD word-wise inversion, 0x1A2B3C4D
|
||||||
|
becomes 0xB23CD458 */
|
||||||
|
|
||||||
|
uint32_t OutputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Output_Data_Inversion and specifies output data (i.e. CRC) inversion mode.
|
||||||
|
Can be either
|
||||||
|
@arg @ref CRC_OUTPUTDATA_INVERSION_DISABLE no CRC inversion,
|
||||||
|
@arg @ref CRC_OUTPUTDATA_INVERSION_ENABLE CRC 0x11223344 is converted
|
||||||
|
into 0x22CC4488 */
|
||||||
|
} CRC_InitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CRC Handle Structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CRC_TypeDef *Instance; /*!< Register base address */
|
||||||
|
|
||||||
|
CRC_InitTypeDef Init; /*!< CRC configuration parameters */
|
||||||
|
|
||||||
|
HAL_LockTypeDef Lock; /*!< CRC Locking object */
|
||||||
|
|
||||||
|
__IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */
|
||||||
|
|
||||||
|
uint32_t InputDataFormat; /*!< This parameter is a value of @ref CRC_Input_Buffer_Format and specifies input data format.
|
||||||
|
Can be either
|
||||||
|
@arg @ref CRC_INPUTDATA_FORMAT_BYTES input data is a stream of bytes
|
||||||
|
(8-bit data)
|
||||||
|
@arg @ref CRC_INPUTDATA_FORMAT_HALFWORDS input data is a stream of
|
||||||
|
half-words (16-bit data)
|
||||||
|
@arg @ref CRC_INPUTDATA_FORMAT_WORDS input data is a stream of words
|
||||||
|
(32-bit data)
|
||||||
|
|
||||||
|
Note that constant CRC_INPUT_FORMAT_UNDEFINED is defined but an initialization
|
||||||
|
error must occur if InputBufferFormat is not one of the three values listed
|
||||||
|
above */
|
||||||
|
} CRC_HandleTypeDef;
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Exported_Constants CRC Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Default_Polynomial_Value Default CRC generating polynomial
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define DEFAULT_CRC32_POLY 0x04C11DB7U /*!< X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1 */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Default_InitValue Default CRC computation initialization value
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Initial CRC default value */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Default_Polynomial Indicates whether or not default polynomial is used
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define DEFAULT_POLYNOMIAL_ENABLE ((uint8_t)0x00U) /*!< Enable default generating polynomial 0x04C11DB7 */
|
||||||
|
#define DEFAULT_POLYNOMIAL_DISABLE ((uint8_t)0x01U) /*!< Disable default generating polynomial 0x04C11DB7 */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Default_InitValue_Use Indicates whether or not default init value is used
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define DEFAULT_INIT_VALUE_ENABLE ((uint8_t)0x00U) /*!< Enable initial CRC default value */
|
||||||
|
#define DEFAULT_INIT_VALUE_DISABLE ((uint8_t)0x01U) /*!< Disable initial CRC default value */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Polynomial_Sizes Polynomial sizes to configure the peripheral
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define CRC_POLYLENGTH_32B 0x00000000U /*!< Resort to a 32-bit long generating polynomial */
|
||||||
|
#define CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< Resort to a 16-bit long generating polynomial */
|
||||||
|
#define CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< Resort to a 8-bit long generating polynomial */
|
||||||
|
#define CRC_POLYLENGTH_7B CRC_CR_POLYSIZE /*!< Resort to a 7-bit long generating polynomial */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Polynomial_Size_Definitions CRC polynomial possible sizes actual definitions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define HAL_CRC_LENGTH_32B 32U /*!< 32-bit long CRC */
|
||||||
|
#define HAL_CRC_LENGTH_16B 16U /*!< 16-bit long CRC */
|
||||||
|
#define HAL_CRC_LENGTH_8B 8U /*!< 8-bit long CRC */
|
||||||
|
#define HAL_CRC_LENGTH_7B 7U /*!< 7-bit long CRC */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Input_Buffer_Format Input Buffer Format
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* WARNING: CRC_INPUT_FORMAT_UNDEFINED is created for reference purposes but
|
||||||
|
* an error is triggered in HAL_CRC_Init() if InputDataFormat field is set
|
||||||
|
* to CRC_INPUT_FORMAT_UNDEFINED: the format MUST be defined by the user for
|
||||||
|
* the CRC APIs to provide a correct result */
|
||||||
|
#define CRC_INPUTDATA_FORMAT_UNDEFINED 0x00000000U /*!< Undefined input data format */
|
||||||
|
#define CRC_INPUTDATA_FORMAT_BYTES 0x00000001U /*!< Input data in byte format */
|
||||||
|
#define CRC_INPUTDATA_FORMAT_HALFWORDS 0x00000002U /*!< Input data in half-word format */
|
||||||
|
#define CRC_INPUTDATA_FORMAT_WORDS 0x00000003U /*!< Input data in word format */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Exported_Macros CRC Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Reset CRC handle state.
|
||||||
|
* @param __HANDLE__ CRC handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset CRC Data Register.
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set CRC INIT non-default value
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @param __INIT__ 32-bit initial value
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_INITIALCRCVALUE_CONFIG(__HANDLE__, __INIT__) ((__HANDLE__)->Instance->INIT = (__INIT__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Store data in the Independent Data (ID) register.
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @param __VALUE__ Value to be stored in the ID register
|
||||||
|
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the data stored in the Independent Data (ID) register.
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
|
||||||
|
* @retval Value of the ID register
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Private macros --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Private_Macros CRC Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IS_DEFAULT_POLYNOMIAL(DEFAULT) (((DEFAULT) == DEFAULT_POLYNOMIAL_ENABLE) || \
|
||||||
|
((DEFAULT) == DEFAULT_POLYNOMIAL_DISABLE))
|
||||||
|
|
||||||
|
#define IS_DEFAULT_INIT_VALUE(VALUE) (((VALUE) == DEFAULT_INIT_VALUE_ENABLE) || \
|
||||||
|
((VALUE) == DEFAULT_INIT_VALUE_DISABLE))
|
||||||
|
|
||||||
|
#define IS_CRC_POL_LENGTH(LENGTH) (((LENGTH) == CRC_POLYLENGTH_32B) || \
|
||||||
|
((LENGTH) == CRC_POLYLENGTH_16B) || \
|
||||||
|
((LENGTH) == CRC_POLYLENGTH_8B) || \
|
||||||
|
((LENGTH) == CRC_POLYLENGTH_7B))
|
||||||
|
|
||||||
|
#define IS_CRC_INPUTDATA_FORMAT(FORMAT) (((FORMAT) == CRC_INPUTDATA_FORMAT_BYTES) || \
|
||||||
|
((FORMAT) == CRC_INPUTDATA_FORMAT_HALFWORDS) || \
|
||||||
|
((FORMAT) == CRC_INPUTDATA_FORMAT_WORDS))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include CRC HAL Extended module */
|
||||||
|
#include "stm32l4xx_hal_crc_ex.h"
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Exported_Functions CRC Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Initialization and de-initialization functions ****************************/
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc);
|
||||||
|
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc);
|
||||||
|
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc);
|
||||||
|
void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Peripheral Control functions ***********************************************/
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
|
||||||
|
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Peripheral State and Error functions ***************************************/
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_HAL_CRC_H */
|
150
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h
Normal file
150
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_hal_crc_ex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of CRC HAL extended module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_HAL_CRC_EX_H
|
||||||
|
#define STM32L4xx_HAL_CRC_EX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CRCEx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRCEx_Exported_Constants CRC Extended Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRCEx_Input_Data_Inversion Input Data Inversion Modes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define CRC_INPUTDATA_INVERSION_NONE 0x00000000U /*!< No input data inversion */
|
||||||
|
#define CRC_INPUTDATA_INVERSION_BYTE CRC_CR_REV_IN_0 /*!< Byte-wise input data inversion */
|
||||||
|
#define CRC_INPUTDATA_INVERSION_HALFWORD CRC_CR_REV_IN_1 /*!< HalfWord-wise input data inversion */
|
||||||
|
#define CRC_INPUTDATA_INVERSION_WORD CRC_CR_REV_IN /*!< Word-wise input data inversion */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRCEx_Output_Data_Inversion Output Data Inversion Modes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define CRC_OUTPUTDATA_INVERSION_DISABLE 0x00000000U /*!< No output data inversion */
|
||||||
|
#define CRC_OUTPUTDATA_INVERSION_ENABLE CRC_CR_REV_OUT /*!< Bit-wise output data inversion */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup CRCEx_Exported_Macros CRC Extended Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set CRC output reversal
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_OUTPUTREVERSAL_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_REV_OUT)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unset CRC output reversal
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_OUTPUTREVERSAL_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(CRC_CR_REV_OUT))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set CRC non-default polynomial
|
||||||
|
* @param __HANDLE__ CRC handle
|
||||||
|
* @param __POLYNOMIAL__ 7, 8, 16 or 32-bit polynomial
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_CRC_POLYNOMIAL_CONFIG(__HANDLE__, __POLYNOMIAL__) ((__HANDLE__)->Instance->POL = (__POLYNOMIAL__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRCEx_Private_Macros CRC Extended Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IS_CRC_INPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_INPUTDATA_INVERSION_NONE) || \
|
||||||
|
((MODE) == CRC_INPUTDATA_INVERSION_BYTE) || \
|
||||||
|
((MODE) == CRC_INPUTDATA_INVERSION_HALFWORD) || \
|
||||||
|
((MODE) == CRC_INPUTDATA_INVERSION_WORD))
|
||||||
|
|
||||||
|
#define IS_CRC_OUTPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_OUTPUTDATA_INVERSION_DISABLE) || \
|
||||||
|
((MODE) == CRC_OUTPUTDATA_INVERSION_ENABLE))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @addtogroup CRCEx_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CRCEx_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Initialization and de-initialization functions ****************************/
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength);
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode);
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_HAL_CRC_EX_H */
|
1954
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h
Normal file
1954
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h
Normal file
File diff suppressed because it is too large
Load Diff
637
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h
Normal file
637
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h
Normal file
@ -0,0 +1,637 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_ll_cortex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of CORTEX LL module.
|
||||||
|
@verbatim
|
||||||
|
==============================================================================
|
||||||
|
##### How to use this driver #####
|
||||||
|
==============================================================================
|
||||||
|
[..]
|
||||||
|
The LL CORTEX driver contains a set of generic APIs that can be
|
||||||
|
used by user:
|
||||||
|
(+) SYSTICK configuration used by @ref LL_mDelay and @ref LL_Init1msTick
|
||||||
|
functions
|
||||||
|
(+) Low power mode configuration (SCB register of Cortex-MCU)
|
||||||
|
(+) MPU API to configure and enable regions
|
||||||
|
(+) API to access to MCU info (CPUID register)
|
||||||
|
(+) API to enable fault handler (SHCSR accesses)
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_LL_CORTEX_H
|
||||||
|
#define STM32L4xx_LL_CORTEX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL CORTEX
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U /*!< AHB clock divided by 8 selected as SysTick clock source.*/
|
||||||
|
#define LL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk /*!< AHB clock selected as SysTick clock source. */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_FAULT Handler Fault type
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_HANDLER_FAULT_USG SCB_SHCSR_USGFAULTENA_Msk /*!< Usage fault */
|
||||||
|
#define LL_HANDLER_FAULT_BUS SCB_SHCSR_BUSFAULTENA_Msk /*!< Bus fault */
|
||||||
|
#define LL_HANDLER_FAULT_MEM SCB_SHCSR_MEMFAULTENA_Msk /*!< Memory management fault */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __MPU_PRESENT
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_CTRL_HFNMI_PRIVDEF MPU Control
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_CTRL_HFNMI_PRIVDEF_NONE 0x00000000U /*!< Disable NMI and privileged SW access */
|
||||||
|
#define LL_MPU_CTRL_HARDFAULT_NMI MPU_CTRL_HFNMIENA_Msk /*!< Enables the operation of MPU during hard fault, NMI, and FAULTMASK handlers */
|
||||||
|
#define LL_MPU_CTRL_PRIVILEGED_DEFAULT MPU_CTRL_PRIVDEFENA_Msk /*!< Enable privileged software access to default memory map */
|
||||||
|
#define LL_MPU_CTRL_HFNMI_PRIVDEF (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) /*!< Enable NMI and privileged SW access */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_REGION MPU Region Number
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_REGION_NUMBER0 0x00U /*!< REGION Number 0 */
|
||||||
|
#define LL_MPU_REGION_NUMBER1 0x01U /*!< REGION Number 1 */
|
||||||
|
#define LL_MPU_REGION_NUMBER2 0x02U /*!< REGION Number 2 */
|
||||||
|
#define LL_MPU_REGION_NUMBER3 0x03U /*!< REGION Number 3 */
|
||||||
|
#define LL_MPU_REGION_NUMBER4 0x04U /*!< REGION Number 4 */
|
||||||
|
#define LL_MPU_REGION_NUMBER5 0x05U /*!< REGION Number 5 */
|
||||||
|
#define LL_MPU_REGION_NUMBER6 0x06U /*!< REGION Number 6 */
|
||||||
|
#define LL_MPU_REGION_NUMBER7 0x07U /*!< REGION Number 7 */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_REGION_SIZE MPU Region Size
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_REGION_SIZE_32B (0x04U << MPU_RASR_SIZE_Pos) /*!< 32B Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_64B (0x05U << MPU_RASR_SIZE_Pos) /*!< 64B Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_128B (0x06U << MPU_RASR_SIZE_Pos) /*!< 128B Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_256B (0x07U << MPU_RASR_SIZE_Pos) /*!< 256B Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_512B (0x08U << MPU_RASR_SIZE_Pos) /*!< 512B Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_1KB (0x09U << MPU_RASR_SIZE_Pos) /*!< 1KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_2KB (0x0AU << MPU_RASR_SIZE_Pos) /*!< 2KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_4KB (0x0BU << MPU_RASR_SIZE_Pos) /*!< 4KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_8KB (0x0CU << MPU_RASR_SIZE_Pos) /*!< 8KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_16KB (0x0DU << MPU_RASR_SIZE_Pos) /*!< 16KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_32KB (0x0EU << MPU_RASR_SIZE_Pos) /*!< 32KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_64KB (0x0FU << MPU_RASR_SIZE_Pos) /*!< 64KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_128KB (0x10U << MPU_RASR_SIZE_Pos) /*!< 128KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_256KB (0x11U << MPU_RASR_SIZE_Pos) /*!< 256KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_512KB (0x12U << MPU_RASR_SIZE_Pos) /*!< 512KB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_1MB (0x13U << MPU_RASR_SIZE_Pos) /*!< 1MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_2MB (0x14U << MPU_RASR_SIZE_Pos) /*!< 2MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_4MB (0x15U << MPU_RASR_SIZE_Pos) /*!< 4MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_8MB (0x16U << MPU_RASR_SIZE_Pos) /*!< 8MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_16MB (0x17U << MPU_RASR_SIZE_Pos) /*!< 16MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_32MB (0x18U << MPU_RASR_SIZE_Pos) /*!< 32MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_64MB (0x19U << MPU_RASR_SIZE_Pos) /*!< 64MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_128MB (0x1AU << MPU_RASR_SIZE_Pos) /*!< 128MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_256MB (0x1BU << MPU_RASR_SIZE_Pos) /*!< 256MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_512MB (0x1CU << MPU_RASR_SIZE_Pos) /*!< 512MB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_1GB (0x1DU << MPU_RASR_SIZE_Pos) /*!< 1GB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_2GB (0x1EU << MPU_RASR_SIZE_Pos) /*!< 2GB Size of the MPU protection region */
|
||||||
|
#define LL_MPU_REGION_SIZE_4GB (0x1FU << MPU_RASR_SIZE_Pos) /*!< 4GB Size of the MPU protection region */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_REGION_PRIVILEDGES MPU Region Privileges
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_REGION_NO_ACCESS (0x00U << MPU_RASR_AP_Pos) /*!< No access*/
|
||||||
|
#define LL_MPU_REGION_PRIV_RW (0x01U << MPU_RASR_AP_Pos) /*!< RW privileged (privileged access only)*/
|
||||||
|
#define LL_MPU_REGION_PRIV_RW_URO (0x02U << MPU_RASR_AP_Pos) /*!< RW privileged - RO user (Write in a user program generates a fault) */
|
||||||
|
#define LL_MPU_REGION_FULL_ACCESS (0x03U << MPU_RASR_AP_Pos) /*!< RW privileged & user (Full access) */
|
||||||
|
#define LL_MPU_REGION_PRIV_RO (0x05U << MPU_RASR_AP_Pos) /*!< RO privileged (privileged read only)*/
|
||||||
|
#define LL_MPU_REGION_PRIV_RO_URO (0x06U << MPU_RASR_AP_Pos) /*!< RO privileged & user (read only) */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_TEX MPU TEX Level
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_TEX_LEVEL0 (0x00U << MPU_RASR_TEX_Pos) /*!< b000 for TEX bits */
|
||||||
|
#define LL_MPU_TEX_LEVEL1 (0x01U << MPU_RASR_TEX_Pos) /*!< b001 for TEX bits */
|
||||||
|
#define LL_MPU_TEX_LEVEL2 (0x02U << MPU_RASR_TEX_Pos) /*!< b010 for TEX bits */
|
||||||
|
#define LL_MPU_TEX_LEVEL4 (0x04U << MPU_RASR_TEX_Pos) /*!< b100 for TEX bits */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_INSTRUCTION_ACCESS MPU Instruction Access
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_INSTRUCTION_ACCESS_ENABLE 0x00U /*!< Instruction fetches enabled */
|
||||||
|
#define LL_MPU_INSTRUCTION_ACCESS_DISABLE MPU_RASR_XN_Msk /*!< Instruction fetches disabled*/
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_SHAREABLE_ACCESS MPU Shareable Access
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_ACCESS_SHAREABLE MPU_RASR_S_Msk /*!< Shareable memory attribute */
|
||||||
|
#define LL_MPU_ACCESS_NOT_SHAREABLE 0x00U /*!< Not Shareable memory attribute */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_CACHEABLE_ACCESS MPU Cacheable Access
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_ACCESS_CACHEABLE MPU_RASR_C_Msk /*!< Cacheable memory attribute */
|
||||||
|
#define LL_MPU_ACCESS_NOT_CACHEABLE 0x00U /*!< Not Cacheable memory attribute */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EC_BUFFERABLE_ACCESS MPU Bufferable Access
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_MPU_ACCESS_BUFFERABLE MPU_RASR_B_Msk /*!< Bufferable memory attribute */
|
||||||
|
#define LL_MPU_ACCESS_NOT_BUFFERABLE 0x00U /*!< Not Bufferable memory attribute */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif /* __MPU_PRESENT */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function checks if the Systick counter flag is active or not.
|
||||||
|
* @note It can be used in timeout function on application side.
|
||||||
|
* @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
|
||||||
|
{
|
||||||
|
return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures the SysTick clock source
|
||||||
|
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource
|
||||||
|
* @param Source This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
|
||||||
|
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source)
|
||||||
|
{
|
||||||
|
if (Source == LL_SYSTICK_CLKSOURCE_HCLK)
|
||||||
|
{
|
||||||
|
SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the SysTick clock source
|
||||||
|
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
|
||||||
|
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void)
|
||||||
|
{
|
||||||
|
return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable SysTick exception request
|
||||||
|
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_SYSTICK_EnableIT(void)
|
||||||
|
{
|
||||||
|
SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable SysTick exception request
|
||||||
|
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_SYSTICK_DisableIT(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks if the SYSTICK interrupt is enabled or disabled.
|
||||||
|
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Processor uses sleep as its low power mode
|
||||||
|
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_EnableSleep(void)
|
||||||
|
{
|
||||||
|
/* Clear SLEEPDEEP bit of Cortex System Control Register */
|
||||||
|
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Processor uses deep sleep as its low power mode
|
||||||
|
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_EnableDeepSleep(void)
|
||||||
|
{
|
||||||
|
/* Set SLEEPDEEP bit of Cortex System Control Register */
|
||||||
|
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures sleep-on-exit when returning from Handler mode to Thread mode.
|
||||||
|
* @note Setting this bit to 1 enables an interrupt-driven application to avoid returning to an
|
||||||
|
* empty main application.
|
||||||
|
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void)
|
||||||
|
{
|
||||||
|
/* Set SLEEPONEXIT bit of Cortex System Control Register */
|
||||||
|
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Do not sleep when returning to Thread mode.
|
||||||
|
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void)
|
||||||
|
{
|
||||||
|
/* Clear SLEEPONEXIT bit of Cortex System Control Register */
|
||||||
|
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the
|
||||||
|
* processor.
|
||||||
|
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_EnableEventOnPend(void)
|
||||||
|
{
|
||||||
|
/* Set SEVEONPEND bit of Cortex System Control Register */
|
||||||
|
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are
|
||||||
|
* excluded
|
||||||
|
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_LPM_DisableEventOnPend(void)
|
||||||
|
{
|
||||||
|
/* Clear SEVEONPEND bit of Cortex System Control Register */
|
||||||
|
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EF_HANDLER HANDLER
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable a fault in System handler control register (SHCSR)
|
||||||
|
* @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_EnableFault
|
||||||
|
* @param Fault This parameter can be a combination of the following values:
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_USG
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_BUS
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_MEM
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_HANDLER_EnableFault(uint32_t Fault)
|
||||||
|
{
|
||||||
|
/* Enable the system handler fault */
|
||||||
|
SET_BIT(SCB->SHCSR, Fault);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable a fault in System handler control register (SHCSR)
|
||||||
|
* @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_DisableFault
|
||||||
|
* @param Fault This parameter can be a combination of the following values:
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_USG
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_BUS
|
||||||
|
* @arg @ref LL_HANDLER_FAULT_MEM
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_HANDLER_DisableFault(uint32_t Fault)
|
||||||
|
{
|
||||||
|
/* Disable the system handler fault */
|
||||||
|
CLEAR_BIT(SCB->SHCSR, Fault);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Implementer code
|
||||||
|
* @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer
|
||||||
|
* @retval Value should be equal to 0x41 for ARM
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Variant number (The r value in the rnpn product revision identifier)
|
||||||
|
* @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant
|
||||||
|
* @retval Value between 0 and 255 (0x0: revision 0)
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Constant number
|
||||||
|
* @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetConstant
|
||||||
|
* @retval Value should be equal to 0xF for Cortex-M4 devices
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CPUID_GetConstant(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Part number
|
||||||
|
* @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo
|
||||||
|
* @retval Value should be equal to 0xC24 for Cortex-M4
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Revision number (The p value in the rnpn product revision identifier, indicates patch release)
|
||||||
|
* @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision
|
||||||
|
* @retval Value between 0 and 255 (0x1: patch 1)
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __MPU_PRESENT
|
||||||
|
/** @defgroup CORTEX_LL_EF_MPU MPU
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable MPU with input options
|
||||||
|
* @rmtoll MPU_CTRL ENABLE LL_MPU_Enable
|
||||||
|
* @param Options This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF_NONE
|
||||||
|
* @arg @ref LL_MPU_CTRL_HARDFAULT_NMI
|
||||||
|
* @arg @ref LL_MPU_CTRL_PRIVILEGED_DEFAULT
|
||||||
|
* @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_MPU_Enable(uint32_t Options)
|
||||||
|
{
|
||||||
|
/* Enable the MPU*/
|
||||||
|
WRITE_REG(MPU->CTRL, (MPU_CTRL_ENABLE_Msk | Options));
|
||||||
|
/* Ensure MPU settings take effects */
|
||||||
|
__DSB();
|
||||||
|
/* Sequence instruction fetches using update settings */
|
||||||
|
__ISB();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable MPU
|
||||||
|
* @rmtoll MPU_CTRL ENABLE LL_MPU_Disable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_MPU_Disable(void)
|
||||||
|
{
|
||||||
|
/* Make sure outstanding transfers are done */
|
||||||
|
__DMB();
|
||||||
|
/* Disable MPU*/
|
||||||
|
WRITE_REG(MPU->CTRL, 0U);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if MPU is enabled or not
|
||||||
|
* @rmtoll MPU_CTRL ENABLE LL_MPU_IsEnabled
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_MPU_IsEnabled(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(MPU->CTRL, MPU_CTRL_ENABLE_Msk) == (MPU_CTRL_ENABLE_Msk));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable a MPU region
|
||||||
|
* @rmtoll MPU_RASR ENABLE LL_MPU_EnableRegion
|
||||||
|
* @param Region This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER0
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER1
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER2
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER3
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER4
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER5
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER6
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER7
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_MPU_EnableRegion(uint32_t Region)
|
||||||
|
{
|
||||||
|
/* Set Region number */
|
||||||
|
WRITE_REG(MPU->RNR, Region);
|
||||||
|
/* Enable the MPU region */
|
||||||
|
SET_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure and enable a region
|
||||||
|
* @rmtoll MPU_RNR REGION LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RBAR REGION LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RBAR ADDR LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR XN LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR AP LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR S LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR C LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR B LL_MPU_ConfigRegion\n
|
||||||
|
* MPU_RASR SIZE LL_MPU_ConfigRegion
|
||||||
|
* @param Region This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER0
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER1
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER2
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER3
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER4
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER5
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER6
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER7
|
||||||
|
* @param Address Value of region base address
|
||||||
|
* @param SubRegionDisable Sub-region disable value between Min_Data = 0x00 and Max_Data = 0xFF
|
||||||
|
* @param Attributes This parameter can be a combination of the following values:
|
||||||
|
* @arg @ref LL_MPU_REGION_SIZE_32B or @ref LL_MPU_REGION_SIZE_64B or @ref LL_MPU_REGION_SIZE_128B or @ref LL_MPU_REGION_SIZE_256B or @ref LL_MPU_REGION_SIZE_512B
|
||||||
|
* or @ref LL_MPU_REGION_SIZE_1KB or @ref LL_MPU_REGION_SIZE_2KB or @ref LL_MPU_REGION_SIZE_4KB or @ref LL_MPU_REGION_SIZE_8KB or @ref LL_MPU_REGION_SIZE_16KB
|
||||||
|
* or @ref LL_MPU_REGION_SIZE_32KB or @ref LL_MPU_REGION_SIZE_64KB or @ref LL_MPU_REGION_SIZE_128KB or @ref LL_MPU_REGION_SIZE_256KB or @ref LL_MPU_REGION_SIZE_512KB
|
||||||
|
* or @ref LL_MPU_REGION_SIZE_1MB or @ref LL_MPU_REGION_SIZE_2MB or @ref LL_MPU_REGION_SIZE_4MB or @ref LL_MPU_REGION_SIZE_8MB or @ref LL_MPU_REGION_SIZE_16MB
|
||||||
|
* or @ref LL_MPU_REGION_SIZE_32MB or @ref LL_MPU_REGION_SIZE_64MB or @ref LL_MPU_REGION_SIZE_128MB or @ref LL_MPU_REGION_SIZE_256MB or @ref LL_MPU_REGION_SIZE_512MB
|
||||||
|
* or @ref LL_MPU_REGION_SIZE_1GB or @ref LL_MPU_REGION_SIZE_2GB or @ref LL_MPU_REGION_SIZE_4GB
|
||||||
|
* @arg @ref LL_MPU_REGION_NO_ACCESS or @ref LL_MPU_REGION_PRIV_RW or @ref LL_MPU_REGION_PRIV_RW_URO or @ref LL_MPU_REGION_FULL_ACCESS
|
||||||
|
* or @ref LL_MPU_REGION_PRIV_RO or @ref LL_MPU_REGION_PRIV_RO_URO
|
||||||
|
* @arg @ref LL_MPU_TEX_LEVEL0 or @ref LL_MPU_TEX_LEVEL1 or @ref LL_MPU_TEX_LEVEL2 or @ref LL_MPU_TEX_LEVEL4
|
||||||
|
* @arg @ref LL_MPU_INSTRUCTION_ACCESS_ENABLE or @ref LL_MPU_INSTRUCTION_ACCESS_DISABLE
|
||||||
|
* @arg @ref LL_MPU_ACCESS_SHAREABLE or @ref LL_MPU_ACCESS_NOT_SHAREABLE
|
||||||
|
* @arg @ref LL_MPU_ACCESS_CACHEABLE or @ref LL_MPU_ACCESS_NOT_CACHEABLE
|
||||||
|
* @arg @ref LL_MPU_ACCESS_BUFFERABLE or @ref LL_MPU_ACCESS_NOT_BUFFERABLE
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_MPU_ConfigRegion(uint32_t Region, uint32_t SubRegionDisable, uint32_t Address, uint32_t Attributes)
|
||||||
|
{
|
||||||
|
/* Set Region number */
|
||||||
|
WRITE_REG(MPU->RNR, Region);
|
||||||
|
/* Set base address */
|
||||||
|
WRITE_REG(MPU->RBAR, (Address & 0xFFFFFFE0U));
|
||||||
|
/* Configure MPU */
|
||||||
|
WRITE_REG(MPU->RASR, (MPU_RASR_ENABLE_Msk | Attributes | SubRegionDisable << MPU_RASR_SRD_Pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable a region
|
||||||
|
* @rmtoll MPU_RNR REGION LL_MPU_DisableRegion\n
|
||||||
|
* MPU_RASR ENABLE LL_MPU_DisableRegion
|
||||||
|
* @param Region This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER0
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER1
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER2
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER3
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER4
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER5
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER6
|
||||||
|
* @arg @ref LL_MPU_REGION_NUMBER7
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_MPU_DisableRegion(uint32_t Region)
|
||||||
|
{
|
||||||
|
/* Set Region number */
|
||||||
|
WRITE_REG(MPU->RNR, Region);
|
||||||
|
/* Disable the MPU region */
|
||||||
|
CLEAR_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* __MPU_PRESENT */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_LL_CORTEX_H */
|
||||||
|
|
467
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.h
Normal file
467
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.h
Normal file
@ -0,0 +1,467 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_ll_crc.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of CRC LL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_LL_CRC_H
|
||||||
|
#define STM32L4xx_LL_CRC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CRC)
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL CRC
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRC_POLYLENGTH_32B 0x00000000U /*!< 32 bits Polynomial size */
|
||||||
|
#define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< 16 bits Polynomial size */
|
||||||
|
#define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< 8 bits Polynomial size */
|
||||||
|
#define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0) /*!< 7 bits Polynomial size */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRC_INDATA_REVERSE_NONE 0x00000000U /*!< Input Data bit order not affected */
|
||||||
|
#define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0 /*!< Input Data bit reversal done by byte */
|
||||||
|
#define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1 /*!< Input Data bit reversal done by half-word */
|
||||||
|
#define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0) /*!< Input Data bit reversal done by word */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRC_OUTDATA_REVERSE_NONE 0x00000000U /*!< Output Data bit order not affected */
|
||||||
|
#define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT /*!< Output Data bit reversal done by bit */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EC_Default_Polynomial_Value Default CRC generating polynomial value
|
||||||
|
* @brief Normal representation of this polynomial value is
|
||||||
|
* X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2 + X + 1 .
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRC_DEFAULT_CRC32_POLY 0x04C11DB7U /*!< Default CRC generating polynomial value */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EC_Default_InitValue Default CRC computation initialization value
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRC_DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Default CRC computation initialization value */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write a value in CRC register
|
||||||
|
* @param __INSTANCE__ CRC Instance
|
||||||
|
* @param __REG__ Register to be written
|
||||||
|
* @param __VALUE__ Value to be written in the register
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read a value in CRC register
|
||||||
|
* @param __INSTANCE__ CRC Instance
|
||||||
|
* @param __REG__ Register to be read
|
||||||
|
* @retval Register value
|
||||||
|
*/
|
||||||
|
#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the CRC calculation unit.
|
||||||
|
* @note If Programmable Initial CRC value feature
|
||||||
|
* is available, also set the Data Register to the value stored in the
|
||||||
|
* CRC_INIT register, otherwise, reset Data Register to its default value.
|
||||||
|
* @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
SET_BIT(CRCx->CR, CRC_CR_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure size of the polynomial.
|
||||||
|
* @rmtoll CR POLYSIZE LL_CRC_SetPolynomialSize
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param PolySize This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_32B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_16B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_8B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_7B
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return size of the polynomial.
|
||||||
|
* @rmtoll CR POLYSIZE LL_CRC_GetPolynomialSize
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_32B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_16B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_8B
|
||||||
|
* @arg @ref LL_CRC_POLYLENGTH_7B
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_POLYSIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the reversal of the bit order of the input data
|
||||||
|
* @rmtoll CR REV_IN LL_CRC_SetInputDataReverseMode
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param ReverseMode This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_NONE
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_BYTE
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_WORD
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRCx->CR, CRC_CR_REV_IN, ReverseMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return type of reversal for input data bit order
|
||||||
|
* @rmtoll CR REV_IN LL_CRC_GetInputDataReverseMode
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_NONE
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_BYTE
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
|
||||||
|
* @arg @ref LL_CRC_INDATA_REVERSE_WORD
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_IN));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the reversal of the bit order of the Output data
|
||||||
|
* @rmtoll CR REV_OUT LL_CRC_SetOutputDataReverseMode
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param ReverseMode This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
|
||||||
|
* @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRCx->CR, CRC_CR_REV_OUT, ReverseMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return type of reversal of the bit order of the Output data
|
||||||
|
* @rmtoll CR REV_OUT LL_CRC_GetOutputDataReverseMode
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
|
||||||
|
* @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_OUT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the Programmable initial CRC value.
|
||||||
|
* @note If the CRC size is less than 32 bits, the least significant bits
|
||||||
|
* are used to write the correct value
|
||||||
|
* @note LL_CRC_DEFAULT_CRC_INITVALUE could be used as value for InitCrc parameter.
|
||||||
|
* @rmtoll INIT INIT LL_CRC_SetInitialData
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param InitCrc Value to be programmed in Programmable initial CRC value register
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRCx->INIT, InitCrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current Initial CRC value.
|
||||||
|
* @note If the CRC size is less than 32 bits, the least significant bits
|
||||||
|
* are used to read the correct value
|
||||||
|
* @rmtoll INIT INIT LL_CRC_GetInitialData
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Value programmed in Programmable initial CRC value register
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(CRCx->INIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the Programmable polynomial value
|
||||||
|
* (coefficients of the polynomial to be used for CRC calculation).
|
||||||
|
* @note LL_CRC_DEFAULT_CRC32_POLY could be used as value for PolynomCoef parameter.
|
||||||
|
* @note Please check Reference Manual and existing Errata Sheets,
|
||||||
|
* regarding possible limitations for Polynomial values usage.
|
||||||
|
* For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
|
||||||
|
* @rmtoll POL POL LL_CRC_SetPolynomialCoef
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param PolynomCoef Value to be programmed in Programmable Polynomial value register
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRCx->POL, PolynomCoef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current Programmable polynomial value
|
||||||
|
* @note Please check Reference Manual and existing Errata Sheets,
|
||||||
|
* regarding possible limitations for Polynomial values usage.
|
||||||
|
* For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
|
||||||
|
* @rmtoll POL POL LL_CRC_GetPolynomialCoef
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Value programmed in Programmable Polynomial value register
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(CRCx->POL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_LL_EF_Data_Management Data_Management
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write given 32-bit data to the CRC calculator
|
||||||
|
* @rmtoll DR DR LL_CRC_FeedData32
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRCx->DR, InData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write given 16-bit data to the CRC calculator
|
||||||
|
* @rmtoll DR DR LL_CRC_FeedData16
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param InData 16 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFF
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData)
|
||||||
|
{
|
||||||
|
__IO uint16_t *pReg;
|
||||||
|
|
||||||
|
pReg = (__IO uint16_t *)(__IO void *)(&CRCx->DR); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
*pReg = InData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write given 8-bit data to the CRC calculator
|
||||||
|
* @rmtoll DR DR LL_CRC_FeedData8
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param InData 8 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFF
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData)
|
||||||
|
{
|
||||||
|
*(uint8_t __IO *)(&CRCx->DR) = (uint8_t) InData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current CRC calculation result. 32 bits value is returned.
|
||||||
|
* @rmtoll DR DR LL_CRC_ReadData32
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(CRCx->DR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current CRC calculation result. 16 bits value is returned.
|
||||||
|
* @note This function is expected to be used in a 16 bits CRC polynomial size context.
|
||||||
|
* @rmtoll DR DR LL_CRC_ReadData16
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Current CRC calculation result as stored in CRC_DR register (16 bits).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint16_t)READ_REG(CRCx->DR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current CRC calculation result. 8 bits value is returned.
|
||||||
|
* @note This function is expected to be used in a 8 bits CRC polynomial size context.
|
||||||
|
* @rmtoll DR DR LL_CRC_ReadData8
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Current CRC calculation result as stored in CRC_DR register (8 bits).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint8_t)READ_REG(CRCx->DR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return current CRC calculation result. 7 bits value is returned.
|
||||||
|
* @note This function is expected to be used in a 7 bits CRC polynomial size context.
|
||||||
|
* @rmtoll DR DR LL_CRC_ReadData7
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Current CRC calculation result as stored in CRC_DR register (7 bits).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return data stored in the Independent Data(IDR) register.
|
||||||
|
* @note This register can be used as a temporary storage location.
|
||||||
|
* @note Refer to the Reference Manual to get the authorized data length in bits.
|
||||||
|
* @rmtoll IDR IDR LL_CRC_Read_IDR
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @retval Value stored in CRC_IDR register
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(CRCx->IDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Store data in the Independent Data(IDR) register.
|
||||||
|
* @note This register can be used as a temporary storage location.
|
||||||
|
* @note Refer to the Reference Manual to get the authorized data length in bits.
|
||||||
|
* @rmtoll IDR IDR LL_CRC_Write_IDR
|
||||||
|
* @param CRCx CRC Instance
|
||||||
|
* @param InData value to be stored in CRC_IDR register
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
|
||||||
|
{
|
||||||
|
#if (CRC_IDR_IDR == 0x0FFU)
|
||||||
|
*((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
|
||||||
|
#else
|
||||||
|
WRITE_REG(CRCx->IDR, InData);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(USE_FULL_LL_DRIVER)
|
||||||
|
/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif /* USE_FULL_LL_DRIVER */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* defined(CRC) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_LL_CRC_H */
|
785
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h
Normal file
785
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h
Normal file
@ -0,0 +1,785 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_ll_crs.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of CRS LL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_LL_CRS_H
|
||||||
|
#define STM32L4xx_LL_CRS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CRS)
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL CRS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRS_LL_Exported_Constants CRS Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_GET_FLAG Get Flags Defines
|
||||||
|
* @brief Flags defines which can be used with LL_CRS_ReadReg function
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_ISR_SYNCOKF CRS_ISR_SYNCOKF
|
||||||
|
#define LL_CRS_ISR_SYNCWARNF CRS_ISR_SYNCWARNF
|
||||||
|
#define LL_CRS_ISR_ERRF CRS_ISR_ERRF
|
||||||
|
#define LL_CRS_ISR_ESYNCF CRS_ISR_ESYNCF
|
||||||
|
#define LL_CRS_ISR_SYNCERR CRS_ISR_SYNCERR
|
||||||
|
#define LL_CRS_ISR_SYNCMISS CRS_ISR_SYNCMISS
|
||||||
|
#define LL_CRS_ISR_TRIMOVF CRS_ISR_TRIMOVF
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_IT IT Defines
|
||||||
|
* @brief IT defines which can be used with LL_CRS_ReadReg and LL_CRS_WriteReg functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_CR_SYNCOKIE CRS_CR_SYNCOKIE
|
||||||
|
#define LL_CRS_CR_SYNCWARNIE CRS_CR_SYNCWARNIE
|
||||||
|
#define LL_CRS_CR_ERRIE CRS_CR_ERRIE
|
||||||
|
#define LL_CRS_CR_ESYNCIE CRS_CR_ESYNCIE
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_SYNC_DIV Synchronization Signal Divider
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_SYNC_DIV_1 ((uint32_t)0x00U) /*!< Synchro Signal not divided (default) */
|
||||||
|
#define LL_CRS_SYNC_DIV_2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
|
||||||
|
#define LL_CRS_SYNC_DIV_4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
|
||||||
|
#define LL_CRS_SYNC_DIV_8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
|
||||||
|
#define LL_CRS_SYNC_DIV_16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
|
||||||
|
#define LL_CRS_SYNC_DIV_32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
|
||||||
|
#define LL_CRS_SYNC_DIV_64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
|
||||||
|
#define LL_CRS_SYNC_DIV_128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_SYNC_SOURCE Synchronization Signal Source
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00U) /*!< Synchro Signal source GPIO */
|
||||||
|
#define LL_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
|
||||||
|
#define LL_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_SYNC_POLARITY Synchronization Signal Polarity
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00U) /*!< Synchro Active on rising edge (default) */
|
||||||
|
#define LL_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_FREQERRORDIR Frequency Error Direction
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_CRS_FREQ_ERROR_DIR_UP ((uint32_t)0x00U) /*!< Upcounting direction, the actual frequency is above the target */
|
||||||
|
#define LL_CRS_FREQ_ERROR_DIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EC_DEFAULTVALUES Default Values
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief Reset value of the RELOAD field
|
||||||
|
* @note The reset value of the RELOAD field corresponds to a target frequency of 48 MHz
|
||||||
|
* and a synchronization signal frequency of 1 kHz (SOF signal from USB)
|
||||||
|
*/
|
||||||
|
#define LL_CRS_RELOADVALUE_DEFAULT ((uint32_t)0xBB7FU)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset value of Frequency error limit.
|
||||||
|
*/
|
||||||
|
#define LL_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x22U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset value of the HSI48 Calibration field
|
||||||
|
* @note The default value is 64 for STM32L412xx/L422xx, 32 otherwise, which corresponds
|
||||||
|
* to the middle of the trimming interval.
|
||||||
|
* The trimming step is around 67 kHz between two consecutive TRIM steps.
|
||||||
|
* A higher TRIM value corresponds to a higher output frequency
|
||||||
|
*/
|
||||||
|
#if defined (STM32L412xx) || defined (STM32L422xx)
|
||||||
|
#define LL_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)64U)
|
||||||
|
#else
|
||||||
|
#define LL_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)32U)
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup CRS_LL_Exported_Macros CRS Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write a value in CRS register
|
||||||
|
* @param __INSTANCE__ CRS Instance
|
||||||
|
* @param __REG__ Register to be written
|
||||||
|
* @param __VALUE__ Value to be written in the register
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read a value in CRS register
|
||||||
|
* @param __INSTANCE__ CRS Instance
|
||||||
|
* @param __REG__ Register to be read
|
||||||
|
* @retval Register value
|
||||||
|
*/
|
||||||
|
#define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EM_Exported_Macros_Calculate_Reload Exported_Macros_Calculate_Reload
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
|
||||||
|
* @note The RELOAD value should be selected according to the ratio between
|
||||||
|
* the target frequency and the frequency of the synchronization source after
|
||||||
|
* prescaling. It is then decreased by one in order to reach the expected
|
||||||
|
* synchronization on the zero value. The formula is the following:
|
||||||
|
* RELOAD = (fTARGET / fSYNC) -1
|
||||||
|
* @param __FTARGET__ Target frequency (value in Hz)
|
||||||
|
* @param __FSYNC__ Synchronization signal frequency (value in Hz)
|
||||||
|
* @retval Reload value (in Hz)
|
||||||
|
*/
|
||||||
|
#define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup CRS_LL_Exported_Functions CRS Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EF_Configuration Configuration
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable Frequency error counter
|
||||||
|
* @note When this bit is set, the CRS_CFGR register is write-protected and cannot be modified
|
||||||
|
* @rmtoll CR CEN LL_CRS_EnableFreqErrorCounter
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_CEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable Frequency error counter
|
||||||
|
* @rmtoll CR CEN LL_CRS_DisableFreqErrorCounter
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_CEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Frequency error counter is enabled or not
|
||||||
|
* @rmtoll CR CEN LL_CRS_IsEnabledFreqErrorCounter
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable Automatic trimming counter
|
||||||
|
* @rmtoll CR AUTOTRIMEN LL_CRS_EnableAutoTrimming
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable Automatic trimming counter
|
||||||
|
* @rmtoll CR AUTOTRIMEN LL_CRS_DisableAutoTrimming
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Automatic trimming is enabled or not
|
||||||
|
* @rmtoll CR AUTOTRIMEN LL_CRS_IsEnabledAutoTrimming
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set HSI48 oscillator smooth trimming
|
||||||
|
* @note When the AUTOTRIMEN bit is set, this field is controlled by hardware and is read-only
|
||||||
|
* @rmtoll CR TRIM LL_CRS_SetHSI48SmoothTrimming
|
||||||
|
* @param Value a number between Min_Data = 0 and Max_Data = 127 for STM32L412xx/L422xx or 63 otherwise
|
||||||
|
* @note Default value can be set thanks to @ref LL_CRS_HSI48CALIBRATION_DEFAULT
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_CR_TRIM_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get HSI48 oscillator smooth trimming
|
||||||
|
* @rmtoll CR TRIM LL_CRS_GetHSI48SmoothTrimming
|
||||||
|
* @retval a number between Min_Data = 0 and Max_Data = 127 for STM32L412xx/L422xx or 63 otherwise
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_CR_TRIM_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set counter reload value
|
||||||
|
* @rmtoll CFGR RELOAD LL_CRS_SetReloadCounter
|
||||||
|
* @param Value a number between Min_Data = 0 and Max_Data = 0xFFFF
|
||||||
|
* @note Default value can be set thanks to @ref LL_CRS_RELOADVALUE_DEFAULT
|
||||||
|
* Otherwise it can be calculated in using macro @ref __LL_CRS_CALC_CALCULATE_RELOADVALUE (_FTARGET_, _FSYNC_)
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get counter reload value
|
||||||
|
* @rmtoll CFGR RELOAD LL_CRS_GetReloadCounter
|
||||||
|
* @retval a number between Min_Data = 0 and Max_Data = 0xFFFF
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set frequency error limit
|
||||||
|
* @rmtoll CFGR FELIM LL_CRS_SetFreqErrorLimit
|
||||||
|
* @param Value a number between Min_Data = 0 and Max_Data = 255
|
||||||
|
* @note Default value can be set thanks to @ref LL_CRS_ERRORLIMIT_DEFAULT
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_CFGR_FELIM_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get frequency error limit
|
||||||
|
* @rmtoll CFGR FELIM LL_CRS_GetFreqErrorLimit
|
||||||
|
* @retval A number between Min_Data = 0 and Max_Data = 255
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_CFGR_FELIM_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set division factor for SYNC signal
|
||||||
|
* @rmtoll CFGR SYNCDIV LL_CRS_SetSyncDivider
|
||||||
|
* @param Divider This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_1
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_2
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_4
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_8
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_16
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_32
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_64
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_128
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get division factor for SYNC signal
|
||||||
|
* @rmtoll CFGR SYNCDIV LL_CRS_GetSyncDivider
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_1
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_2
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_4
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_8
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_16
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_32
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_64
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_128
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set SYNC signal source
|
||||||
|
* @rmtoll CFGR SYNCSRC LL_CRS_SetSyncSignalSource
|
||||||
|
* @param Source This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_LSE
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_USB
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get SYNC signal source
|
||||||
|
* @rmtoll CFGR SYNCSRC LL_CRS_GetSyncSignalSource
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_LSE
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_USB
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set input polarity for the SYNC signal source
|
||||||
|
* @rmtoll CFGR SYNCPOL LL_CRS_SetSyncPolarity
|
||||||
|
* @param Polarity This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_POLARITY_RISING
|
||||||
|
* @arg @ref LL_CRS_SYNC_POLARITY_FALLING
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get input polarity for the SYNC signal source
|
||||||
|
* @rmtoll CFGR SYNCPOL LL_CRS_GetSyncPolarity
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_POLARITY_RISING
|
||||||
|
* @arg @ref LL_CRS_SYNC_POLARITY_FALLING
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure CRS for the synchronization
|
||||||
|
* @rmtoll CR TRIM LL_CRS_ConfigSynchronization\n
|
||||||
|
* CFGR RELOAD LL_CRS_ConfigSynchronization\n
|
||||||
|
* CFGR FELIM LL_CRS_ConfigSynchronization\n
|
||||||
|
* CFGR SYNCDIV LL_CRS_ConfigSynchronization\n
|
||||||
|
* CFGR SYNCSRC LL_CRS_ConfigSynchronization\n
|
||||||
|
* CFGR SYNCPOL LL_CRS_ConfigSynchronization
|
||||||
|
* @param HSI48CalibrationValue a number between Min_Data = 0 and Max_Data = 127 for STM32L412xx/L422xx or 63 otherwise
|
||||||
|
* @param ErrorLimitValue a number between Min_Data = 0 and Max_Data = 0xFFFF
|
||||||
|
* @param ReloadValue a number between Min_Data = 0 and Max_Data = 255
|
||||||
|
* @param Settings This parameter can be a combination of the following values:
|
||||||
|
* @arg @ref LL_CRS_SYNC_DIV_1 or @ref LL_CRS_SYNC_DIV_2 or @ref LL_CRS_SYNC_DIV_4 or @ref LL_CRS_SYNC_DIV_8
|
||||||
|
* or @ref LL_CRS_SYNC_DIV_16 or @ref LL_CRS_SYNC_DIV_32 or @ref LL_CRS_SYNC_DIV_64 or @ref LL_CRS_SYNC_DIV_128
|
||||||
|
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO or @ref LL_CRS_SYNC_SOURCE_LSE or @ref LL_CRS_SYNC_SOURCE_USB
|
||||||
|
* @arg @ref LL_CRS_SYNC_POLARITY_RISING or @ref LL_CRS_SYNC_POLARITY_FALLING
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
|
||||||
|
{
|
||||||
|
MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
|
||||||
|
MODIFY_REG(CRS->CFGR,
|
||||||
|
CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL,
|
||||||
|
ReloadValue | (ErrorLimitValue << CRS_CFGR_FELIM_Pos) | Settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EF_CRS_Management CRS_Management
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generate software SYNC event
|
||||||
|
* @rmtoll CR SWSYNC LL_CRS_GenerateEvent_SWSYNC
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_SWSYNC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the frequency error direction latched in the time of the last
|
||||||
|
* SYNC event
|
||||||
|
* @rmtoll ISR FEDIR LL_CRS_GetFreqErrorDirection
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_CRS_FREQ_ERROR_DIR_UP
|
||||||
|
* @arg @ref LL_CRS_FREQ_ERROR_DIR_DOWN
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the frequency error counter value latched in the time of the last SYNC event
|
||||||
|
* @rmtoll ISR FECAP LL_CRS_GetFreqErrorCapture
|
||||||
|
* @retval A number between Min_Data = 0x0000 and Max_Data = 0xFFFF
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_ISR_FECAP_Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EF_FLAG_Management FLAG_Management
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC event OK signal occurred or not
|
||||||
|
* @rmtoll ISR SYNCOKF LL_CRS_IsActiveFlag_SYNCOK
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC warning signal occurred or not
|
||||||
|
* @rmtoll ISR SYNCWARNF LL_CRS_IsActiveFlag_SYNCWARN
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Synchronization or trimming error signal occurred or not
|
||||||
|
* @rmtoll ISR ERRF LL_CRS_IsActiveFlag_ERR
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Expected SYNC signal occurred or not
|
||||||
|
* @rmtoll ISR ESYNCF LL_CRS_IsActiveFlag_ESYNC
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC error signal occurred or not
|
||||||
|
* @rmtoll ISR SYNCERR LL_CRS_IsActiveFlag_SYNCERR
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC missed error signal occurred or not
|
||||||
|
* @rmtoll ISR SYNCMISS LL_CRS_IsActiveFlag_SYNCMISS
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Trimming overflow or underflow occurred or not
|
||||||
|
* @rmtoll ISR TRIMOVF LL_CRS_IsActiveFlag_TRIMOVF
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear the SYNC event OK flag
|
||||||
|
* @rmtoll ICR SYNCOKC LL_CRS_ClearFlag_SYNCOK
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear the SYNC warning flag
|
||||||
|
* @rmtoll ICR SYNCWARNC LL_CRS_ClearFlag_SYNCWARN
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also
|
||||||
|
* the ERR flag
|
||||||
|
* @rmtoll ICR ERRC LL_CRS_ClearFlag_ERR
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear Expected SYNC flag
|
||||||
|
* @rmtoll ICR ESYNCC LL_CRS_ClearFlag_ESYNC
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
|
||||||
|
{
|
||||||
|
WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRS_LL_EF_IT_Management IT_Management
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable SYNC event OK interrupt
|
||||||
|
* @rmtoll CR SYNCOKIE LL_CRS_EnableIT_SYNCOK
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable SYNC event OK interrupt
|
||||||
|
* @rmtoll CR SYNCOKIE LL_CRS_DisableIT_SYNCOK
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC event OK interrupt is enabled or not
|
||||||
|
* @rmtoll CR SYNCOKIE LL_CRS_IsEnabledIT_SYNCOK
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable SYNC warning interrupt
|
||||||
|
* @rmtoll CR SYNCWARNIE LL_CRS_EnableIT_SYNCWARN
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable SYNC warning interrupt
|
||||||
|
* @rmtoll CR SYNCWARNIE LL_CRS_DisableIT_SYNCWARN
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if SYNC warning interrupt is enabled or not
|
||||||
|
* @rmtoll CR SYNCWARNIE LL_CRS_IsEnabledIT_SYNCWARN
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable Synchronization or trimming error interrupt
|
||||||
|
* @rmtoll CR ERRIE LL_CRS_EnableIT_ERR
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_ERRIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable Synchronization or trimming error interrupt
|
||||||
|
* @rmtoll CR ERRIE LL_CRS_DisableIT_ERR
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_ERRIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Synchronization or trimming error interrupt is enabled or not
|
||||||
|
* @rmtoll CR ERRIE LL_CRS_IsEnabledIT_ERR
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable Expected SYNC interrupt
|
||||||
|
* @rmtoll CR ESYNCIE LL_CRS_EnableIT_ESYNC
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
|
||||||
|
{
|
||||||
|
SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable Expected SYNC interrupt
|
||||||
|
* @rmtoll CR ESYNCIE LL_CRS_DisableIT_ESYNC
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
|
||||||
|
{
|
||||||
|
CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if Expected SYNC interrupt is enabled or not
|
||||||
|
* @rmtoll CR ESYNCIE LL_CRS_IsEnabledIT_ESYNC
|
||||||
|
* @retval State of bit (1 or 0).
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
|
||||||
|
{
|
||||||
|
return (READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(USE_FULL_LL_DRIVER)
|
||||||
|
/** @defgroup CRS_LL_EF_Init Initialization and de-initialization functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
ErrorStatus LL_CRS_DeInit(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif /* USE_FULL_LL_DRIVER */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* defined(CRS) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_LL_CRS_H */
|
1979
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dac.h
Normal file
1979
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dac.h
Normal file
File diff suppressed because it is too large
Load Diff
2430
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h
Normal file
2430
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h
Normal file
File diff suppressed because it is too large
Load Diff
1981
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.h
Normal file
1981
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.h
Normal file
File diff suppressed because it is too large
Load Diff
1359
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h
Normal file
1359
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h
Normal file
File diff suppressed because it is too large
Load Diff
1056
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_gpio.h
Normal file
1056
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_gpio.h
Normal file
File diff suppressed because it is too large
Load Diff
2272
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h
Normal file
2272
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h
Normal file
File diff suppressed because it is too large
Load Diff
1675
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_pwr.h
Normal file
1675
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_pwr.h
Normal file
File diff suppressed because it is too large
Load Diff
6233
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h
Normal file
6233
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h
Normal file
File diff suppressed because it is too large
Load Diff
1627
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h
Normal file
1627
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h
Normal file
File diff suppressed because it is too large
Load Diff
329
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.h
Normal file
329
Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_ll_utils.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of UTILS LL module.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
@verbatim
|
||||||
|
==============================================================================
|
||||||
|
##### How to use this driver #####
|
||||||
|
==============================================================================
|
||||||
|
[..]
|
||||||
|
The LL UTILS driver contains a set of generic APIs that can be
|
||||||
|
used by user:
|
||||||
|
(+) Device electronic signature
|
||||||
|
(+) Timing functions
|
||||||
|
(+) PLL configuration functions
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32L4xx_LL_UTILS_H
|
||||||
|
#define STM32L4xx_LL_UTILS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_LL UTILS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup UTILS_LL_Private_Constants UTILS Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Max delay can be used in LL_mDelay */
|
||||||
|
#define LL_MAX_DELAY 0xFFFFFFFFU
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unique device ID register base address
|
||||||
|
*/
|
||||||
|
#define UID_BASE_ADDRESS UID_BASE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Flash size data register base address
|
||||||
|
*/
|
||||||
|
#define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Package data register base address
|
||||||
|
*/
|
||||||
|
#define PACKAGE_BASE_ADDRESS PACKAGE_BASE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup UTILS_LL_Private_Macros UTILS Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup UTILS_LL_ES_INIT UTILS Exported structures
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief UTILS PLL structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t PLLM; /*!< Division factor for PLL VCO input clock.
|
||||||
|
This parameter can be a value of @ref RCC_LL_EC_PLLM_DIV
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_PLL_ConfigDomain_SYS(). */
|
||||||
|
|
||||||
|
uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock.
|
||||||
|
This parameter must be a number between Min_Data = 8 and Max_Data = 86
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_PLL_ConfigDomain_SYS(). */
|
||||||
|
|
||||||
|
uint32_t PLLR; /*!< Division for the main system clock.
|
||||||
|
This parameter can be a value of @ref RCC_LL_EC_PLLR_DIV
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_PLL_ConfigDomain_SYS(). */
|
||||||
|
} LL_UTILS_PLLInitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief UTILS System, AHB and APB buses clock configuration structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
|
||||||
|
This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_SetAHBPrescaler(). */
|
||||||
|
|
||||||
|
uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
|
||||||
|
This parameter can be a value of @ref RCC_LL_EC_APB1_DIV
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_SetAPB1Prescaler(). */
|
||||||
|
|
||||||
|
uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
|
||||||
|
This parameter can be a value of @ref RCC_LL_EC_APB2_DIV
|
||||||
|
|
||||||
|
This feature can be modified afterwards using unitary function
|
||||||
|
@ref LL_RCC_SetAPB2Prescaler(). */
|
||||||
|
|
||||||
|
} LL_UTILS_ClkInitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */
|
||||||
|
#define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP64 0x00000000U /*!< LQFP64 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_WLCSP64 0x00000001U /*!< WLCSP64 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP100 0x00000002U /*!< LQFP100 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_BGA132 0x00000003U /*!< BGA132 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP144_CSP72 0x00000004U /*!< LQFP144, WLCSP81 or WLCSP72 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFQFPN32 0x00000008U /*!< UFQFPN32 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFQFPN48 0x0000000AU /*!< UFQFPN48 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP48 0x0000000BU /*!< LQFP48 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_WLCSP49 0x0000000CU /*!< WLCSP49 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFBGA64 0x0000000DU /*!< UFBGA64 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFBGA100 0x0000000EU /*!< UFBGA100 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFBGA169_CSP115 0x00000010U /*!< UFBGA169 or WLCSP115 package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP100_DSI 0x00000012U /*!< LQFP100 with DSI package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_WLCSP144_DSI 0x00000013U /*!< WLCSP144 with DSI package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFBGA144_DSI 0x00000013U /*!< UFBGA144 with DSI package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_UFBGA169_DSI 0x00000014U /*!< UFBGA169 with DSI package type */
|
||||||
|
#define LL_UTILS_PACKAGETYPE_LQFP144_DSI 0x00000015U /*!< LQFP144 with DSI package type */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Word0 of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval UID[31:0]: X and Y coordinates on the wafer expressed in BCD format
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_GetUID_Word0(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Word1 of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval UID[63:32]: Wafer number (UID[39:32]) & LOT_NUM[23:0] (UID[63:40])
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_GetUID_Word1(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Word2 of the unique device identifier (UID based on 96 bits)
|
||||||
|
* @retval UID[95:64]: Lot number (ASCII encoded) - LOT_NUM[55:24]
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_GetUID_Word2(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Flash memory size
|
||||||
|
* @note This bitfield indicates the size of the device Flash memory expressed in
|
||||||
|
* Kbytes. As an example, 0x040 corresponds to 64 Kbytes.
|
||||||
|
* @retval FLASH_SIZE[15:0]: Flash memory size
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_GetFlashSize(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)) & 0xFFFFU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Package type
|
||||||
|
* @retval Returned value can be one of the following values:
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP64 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP100 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_BGA132 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_CSP72 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFQFPN32 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFQFPN48 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP48 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_WLCSP49 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFBGA64 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFBGA100 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFBGA169 (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP100_DSI (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_WLCSP144_DSI (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFBGA144_DSI (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_UFBGA169_DSI (*)
|
||||||
|
* @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_DSI (*)
|
||||||
|
*
|
||||||
|
* (*) value not defined in all devices.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t LL_GetPackageType(void)
|
||||||
|
{
|
||||||
|
return (uint32_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x1FU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_LL_EF_DELAY DELAY
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function configures the Cortex-M SysTick source of the time base.
|
||||||
|
* @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
|
||||||
|
* @note When a RTOS is used, it is recommended to avoid changing the SysTick
|
||||||
|
* configuration by calling this function, for a delay use rather osDelay RTOS service.
|
||||||
|
* @param Ticks Number of ticks
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
|
||||||
|
{
|
||||||
|
/* Configure the SysTick to have interrupt in 1ms time base */
|
||||||
|
SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */
|
||||||
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */
|
||||||
|
}
|
||||||
|
|
||||||
|
void LL_Init1msTick(uint32_t HCLKFrequency);
|
||||||
|
void LL_mDelay(uint32_t Delay);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup UTILS_EF_SYSTEM SYSTEM
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
void LL_SetSystemCoreClock(uint32_t HCLKFrequency);
|
||||||
|
ErrorStatus LL_SetFlashLatency(uint32_t HCLKFrequency);
|
||||||
|
ErrorStatus LL_PLL_ConfigSystemClock_MSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
|
||||||
|
LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
|
||||||
|
ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
|
||||||
|
LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
|
||||||
|
ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass,
|
||||||
|
LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32L4xx_LL_UTILS_H */
|
516
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c
Normal file
516
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c
Normal file
@ -0,0 +1,516 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_hal_crc.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief CRC HAL module driver.
|
||||||
|
* This file provides firmware functions to manage the following
|
||||||
|
* functionalities of the Cyclic Redundancy Check (CRC) peripheral:
|
||||||
|
* + Initialization and de-initialization functions
|
||||||
|
* + Peripheral Control functions
|
||||||
|
* + Peripheral State functions
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### How to use this driver #####
|
||||||
|
===============================================================================
|
||||||
|
[..]
|
||||||
|
(+) Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE();
|
||||||
|
(+) Initialize CRC calculator
|
||||||
|
(++) specify generating polynomial (peripheral default or non-default one)
|
||||||
|
(++) specify initialization value (peripheral default or non-default one)
|
||||||
|
(++) specify input data format
|
||||||
|
(++) specify input or output data inversion mode if any
|
||||||
|
(+) Use HAL_CRC_Accumulate() function to compute the CRC value of the
|
||||||
|
input data buffer starting with the previously computed CRC as
|
||||||
|
initialization value
|
||||||
|
(+) Use HAL_CRC_Calculate() function to compute the CRC value of the
|
||||||
|
input data buffer starting with the defined initialization value
|
||||||
|
(default or non-default) to initiate CRC calculation
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx_hal.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC CRC
|
||||||
|
* @brief CRC HAL module driver.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAL_CRC_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/** @defgroup CRC_Private_Functions CRC Private Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_t BufferLength);
|
||||||
|
static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint32_t BufferLength);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Exported_Functions CRC Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||||
|
* @brief Initialization and Configuration functions.
|
||||||
|
*
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### Initialization and de-initialization functions #####
|
||||||
|
===============================================================================
|
||||||
|
[..] This section provides functions allowing to:
|
||||||
|
(+) Initialize the CRC according to the specified parameters
|
||||||
|
in the CRC_InitTypeDef and create the associated handle
|
||||||
|
(+) DeInitialize the CRC peripheral
|
||||||
|
(+) Initialize the CRC MSP (MCU Specific Package)
|
||||||
|
(+) DeInitialize the CRC MSP
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the CRC according to the specified
|
||||||
|
* parameters in the CRC_InitTypeDef and create the associated handle.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
|
||||||
|
{
|
||||||
|
/* Check the CRC handle allocation */
|
||||||
|
if (hcrc == NULL)
|
||||||
|
{
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
|
||||||
|
|
||||||
|
if (hcrc->State == HAL_CRC_STATE_RESET)
|
||||||
|
{
|
||||||
|
/* Allocate lock resource and initialize it */
|
||||||
|
hcrc->Lock = HAL_UNLOCKED;
|
||||||
|
/* Init the low level hardware */
|
||||||
|
HAL_CRC_MspInit(hcrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
/* check whether or not non-default generating polynomial has been
|
||||||
|
* picked up by user */
|
||||||
|
assert_param(IS_DEFAULT_POLYNOMIAL(hcrc->Init.DefaultPolynomialUse));
|
||||||
|
if (hcrc->Init.DefaultPolynomialUse == DEFAULT_POLYNOMIAL_ENABLE)
|
||||||
|
{
|
||||||
|
/* initialize peripheral with default generating polynomial */
|
||||||
|
WRITE_REG(hcrc->Instance->POL, DEFAULT_CRC32_POLY);
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, CRC_POLYLENGTH_32B);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* initialize CRC peripheral with generating polynomial defined by user */
|
||||||
|
if (HAL_CRCEx_Polynomial_Set(hcrc, hcrc->Init.GeneratingPolynomial, hcrc->Init.CRCLength) != HAL_OK)
|
||||||
|
{
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check whether or not non-default CRC initial value has been
|
||||||
|
* picked up by user */
|
||||||
|
assert_param(IS_DEFAULT_INIT_VALUE(hcrc->Init.DefaultInitValueUse));
|
||||||
|
if (hcrc->Init.DefaultInitValueUse == DEFAULT_INIT_VALUE_ENABLE)
|
||||||
|
{
|
||||||
|
WRITE_REG(hcrc->Instance->INIT, DEFAULT_CRC_INITVALUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WRITE_REG(hcrc->Instance->INIT, hcrc->Init.InitValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* set input data inversion mode */
|
||||||
|
assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(hcrc->Init.InputDataInversionMode));
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, hcrc->Init.InputDataInversionMode);
|
||||||
|
|
||||||
|
/* set output data inversion mode */
|
||||||
|
assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(hcrc->Init.OutputDataInversionMode));
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, hcrc->Init.OutputDataInversionMode);
|
||||||
|
|
||||||
|
/* makes sure the input data format (bytes, halfwords or words stream)
|
||||||
|
* is properly specified by user */
|
||||||
|
assert_param(IS_CRC_INPUTDATA_FORMAT(hcrc->InputDataFormat));
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_READY;
|
||||||
|
|
||||||
|
/* Return function status */
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeInitialize the CRC peripheral.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
|
||||||
|
{
|
||||||
|
/* Check the CRC handle allocation */
|
||||||
|
if (hcrc == NULL)
|
||||||
|
{
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
|
||||||
|
|
||||||
|
/* Check the CRC peripheral state */
|
||||||
|
if (hcrc->State == HAL_CRC_STATE_BUSY)
|
||||||
|
{
|
||||||
|
return HAL_BUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
/* Reset CRC calculation unit */
|
||||||
|
__HAL_CRC_DR_RESET(hcrc);
|
||||||
|
|
||||||
|
/* Reset IDR register content */
|
||||||
|
CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR);
|
||||||
|
|
||||||
|
/* DeInit the low level hardware */
|
||||||
|
HAL_CRC_MspDeInit(hcrc);
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_RESET;
|
||||||
|
|
||||||
|
/* Process unlocked */
|
||||||
|
__HAL_UNLOCK(hcrc);
|
||||||
|
|
||||||
|
/* Return function status */
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initializes the CRC MSP.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
|
||||||
|
{
|
||||||
|
/* Prevent unused argument(s) compilation warning */
|
||||||
|
UNUSED(hcrc);
|
||||||
|
|
||||||
|
/* NOTE : This function should not be modified, when the callback is needed,
|
||||||
|
the HAL_CRC_MspInit can be implemented in the user file
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeInitialize the CRC MSP.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
|
||||||
|
{
|
||||||
|
/* Prevent unused argument(s) compilation warning */
|
||||||
|
UNUSED(hcrc);
|
||||||
|
|
||||||
|
/* NOTE : This function should not be modified, when the callback is needed,
|
||||||
|
the HAL_CRC_MspDeInit can be implemented in the user file
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
|
||||||
|
* @brief management functions.
|
||||||
|
*
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### Peripheral Control functions #####
|
||||||
|
===============================================================================
|
||||||
|
[..] This section provides functions allowing to:
|
||||||
|
(+) compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer
|
||||||
|
using combination of the previous CRC value and the new one.
|
||||||
|
|
||||||
|
[..] or
|
||||||
|
|
||||||
|
(+) compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer
|
||||||
|
independently of the previous CRC value.
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer
|
||||||
|
* starting with the previously computed CRC as initialization value.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param pBuffer pointer to the input data buffer, exact input data format is
|
||||||
|
* provided by hcrc->InputDataFormat.
|
||||||
|
* @param BufferLength input data buffer length (number of bytes if pBuffer
|
||||||
|
* type is * uint8_t, number of half-words if pBuffer type is * uint16_t,
|
||||||
|
* number of words if pBuffer type is * uint32_t).
|
||||||
|
* @note By default, the API expects a uint32_t pointer as input buffer parameter.
|
||||||
|
* Input buffer pointers with other types simply need to be cast in uint32_t
|
||||||
|
* and the API will internally adjust its input data processing based on the
|
||||||
|
* handle field hcrc->InputDataFormat.
|
||||||
|
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
|
||||||
|
*/
|
||||||
|
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
|
||||||
|
{
|
||||||
|
uint32_t index; /* CRC input data buffer index */
|
||||||
|
uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
switch (hcrc->InputDataFormat)
|
||||||
|
{
|
||||||
|
case CRC_INPUTDATA_FORMAT_WORDS:
|
||||||
|
/* Enter Data to the CRC calculator */
|
||||||
|
for (index = 0U; index < BufferLength; index++)
|
||||||
|
{
|
||||||
|
hcrc->Instance->DR = pBuffer[index];
|
||||||
|
}
|
||||||
|
temp = hcrc->Instance->DR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CRC_INPUTDATA_FORMAT_BYTES:
|
||||||
|
temp = CRC_Handle_8(hcrc, (uint8_t *)pBuffer, BufferLength);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CRC_INPUTDATA_FORMAT_HALFWORDS:
|
||||||
|
temp = CRC_Handle_16(hcrc, (uint16_t *)(void *)pBuffer, BufferLength); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_READY;
|
||||||
|
|
||||||
|
/* Return the CRC computed value */
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer
|
||||||
|
* starting with hcrc->Instance->INIT as initialization value.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param pBuffer pointer to the input data buffer, exact input data format is
|
||||||
|
* provided by hcrc->InputDataFormat.
|
||||||
|
* @param BufferLength input data buffer length (number of bytes if pBuffer
|
||||||
|
* type is * uint8_t, number of half-words if pBuffer type is * uint16_t,
|
||||||
|
* number of words if pBuffer type is * uint32_t).
|
||||||
|
* @note By default, the API expects a uint32_t pointer as input buffer parameter.
|
||||||
|
* Input buffer pointers with other types simply need to be cast in uint32_t
|
||||||
|
* and the API will internally adjust its input data processing based on the
|
||||||
|
* handle field hcrc->InputDataFormat.
|
||||||
|
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
|
||||||
|
*/
|
||||||
|
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
|
||||||
|
{
|
||||||
|
uint32_t index; /* CRC input data buffer index */
|
||||||
|
uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
/* Reset CRC Calculation Unit (hcrc->Instance->INIT is
|
||||||
|
* written in hcrc->Instance->DR) */
|
||||||
|
__HAL_CRC_DR_RESET(hcrc);
|
||||||
|
|
||||||
|
switch (hcrc->InputDataFormat)
|
||||||
|
{
|
||||||
|
case CRC_INPUTDATA_FORMAT_WORDS:
|
||||||
|
/* Enter 32-bit input data to the CRC calculator */
|
||||||
|
for (index = 0U; index < BufferLength; index++)
|
||||||
|
{
|
||||||
|
hcrc->Instance->DR = pBuffer[index];
|
||||||
|
}
|
||||||
|
temp = hcrc->Instance->DR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CRC_INPUTDATA_FORMAT_BYTES:
|
||||||
|
/* Specific 8-bit input data handling */
|
||||||
|
temp = CRC_Handle_8(hcrc, (uint8_t *)pBuffer, BufferLength);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CRC_INPUTDATA_FORMAT_HALFWORDS:
|
||||||
|
/* Specific 16-bit input data handling */
|
||||||
|
temp = CRC_Handle_16(hcrc, (uint16_t *)(void *)pBuffer, BufferLength); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_READY;
|
||||||
|
|
||||||
|
/* Return the CRC computed value */
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
|
||||||
|
* @brief Peripheral State functions.
|
||||||
|
*
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### Peripheral State functions #####
|
||||||
|
===============================================================================
|
||||||
|
[..]
|
||||||
|
This subsection permits to get in run-time the status of the peripheral.
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the CRC handle state.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @retval HAL state
|
||||||
|
*/
|
||||||
|
HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
|
||||||
|
{
|
||||||
|
/* Return CRC handle state */
|
||||||
|
return hcrc->State;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CRC_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enter 8-bit input data to the CRC calculator.
|
||||||
|
* Specific data handling to optimize processing time.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param pBuffer pointer to the input data buffer
|
||||||
|
* @param BufferLength input data buffer length
|
||||||
|
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
|
||||||
|
*/
|
||||||
|
static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_t BufferLength)
|
||||||
|
{
|
||||||
|
uint32_t i; /* input data buffer index */
|
||||||
|
uint16_t data;
|
||||||
|
__IO uint16_t *pReg;
|
||||||
|
|
||||||
|
/* Processing time optimization: 4 bytes are entered in a row with a single word write,
|
||||||
|
* last bytes must be carefully fed to the CRC calculator to ensure a correct type
|
||||||
|
* handling by the peripheral */
|
||||||
|
for (i = 0U; i < (BufferLength / 4U); i++)
|
||||||
|
{
|
||||||
|
hcrc->Instance->DR = ((uint32_t)pBuffer[4U * i] << 24U) | \
|
||||||
|
((uint32_t)pBuffer[(4U * i) + 1U] << 16U) | \
|
||||||
|
((uint32_t)pBuffer[(4U * i) + 2U] << 8U) | \
|
||||||
|
(uint32_t)pBuffer[(4U * i) + 3U];
|
||||||
|
}
|
||||||
|
/* last bytes specific handling */
|
||||||
|
if ((BufferLength % 4U) != 0U)
|
||||||
|
{
|
||||||
|
if ((BufferLength % 4U) == 1U)
|
||||||
|
{
|
||||||
|
*(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = pBuffer[4U * i]; /* Derogation MisraC2012 R.11.5 */
|
||||||
|
}
|
||||||
|
if ((BufferLength % 4U) == 2U)
|
||||||
|
{
|
||||||
|
data = ((uint16_t)(pBuffer[4U * i]) << 8U) | (uint16_t)pBuffer[(4U * i) + 1U];
|
||||||
|
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
*pReg = data;
|
||||||
|
}
|
||||||
|
if ((BufferLength % 4U) == 3U)
|
||||||
|
{
|
||||||
|
data = ((uint16_t)(pBuffer[4U * i]) << 8U) | (uint16_t)pBuffer[(4U * i) + 1U];
|
||||||
|
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
*pReg = data;
|
||||||
|
|
||||||
|
*(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = pBuffer[(4U * i) + 2U]; /* Derogation MisraC2012 R.11.5 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the CRC computed value */
|
||||||
|
return hcrc->Instance->DR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enter 16-bit input data to the CRC calculator.
|
||||||
|
* Specific data handling to optimize processing time.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param pBuffer pointer to the input data buffer
|
||||||
|
* @param BufferLength input data buffer length
|
||||||
|
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
|
||||||
|
*/
|
||||||
|
static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint32_t BufferLength)
|
||||||
|
{
|
||||||
|
uint32_t i; /* input data buffer index */
|
||||||
|
__IO uint16_t *pReg;
|
||||||
|
|
||||||
|
/* Processing time optimization: 2 HalfWords are entered in a row with a single word write,
|
||||||
|
* in case of odd length, last HalfWord must be carefully fed to the CRC calculator to ensure
|
||||||
|
* a correct type handling by the peripheral */
|
||||||
|
for (i = 0U; i < (BufferLength / 2U); i++)
|
||||||
|
{
|
||||||
|
hcrc->Instance->DR = ((uint32_t)pBuffer[2U * i] << 16U) | (uint32_t)pBuffer[(2U * i) + 1U];
|
||||||
|
}
|
||||||
|
if ((BufferLength % 2U) != 0U)
|
||||||
|
{
|
||||||
|
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */
|
||||||
|
*pReg = pBuffer[2U * i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the CRC computed value */
|
||||||
|
return hcrc->Instance->DR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
223
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c
Normal file
223
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l4xx_hal_crc_ex.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Extended CRC HAL module driver.
|
||||||
|
* This file provides firmware functions to manage the extended
|
||||||
|
* functionalities of the CRC peripheral.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
@verbatim
|
||||||
|
================================================================================
|
||||||
|
##### How to use this driver #####
|
||||||
|
================================================================================
|
||||||
|
[..]
|
||||||
|
(+) Set user-defined generating polynomial through HAL_CRCEx_Polynomial_Set()
|
||||||
|
(+) Configure Input or Output data inversion
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx_hal.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRCEx CRCEx
|
||||||
|
* @brief CRC Extended HAL module driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAL_CRC_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @defgroup CRCEx_Exported_Functions CRC Extended Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup CRCEx_Exported_Functions_Group1 Extended Initialization/de-initialization functions
|
||||||
|
* @brief Extended Initialization and Configuration functions.
|
||||||
|
*
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### Extended configuration functions #####
|
||||||
|
===============================================================================
|
||||||
|
[..] This section provides functions allowing to:
|
||||||
|
(+) Configure the generating polynomial
|
||||||
|
(+) Configure the input data inversion
|
||||||
|
(+) Configure the output data inversion
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the CRC polynomial if different from default one.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param Pol CRC generating polynomial (7, 8, 16 or 32-bit long).
|
||||||
|
* This parameter is written in normal representation, e.g.
|
||||||
|
* @arg for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
|
||||||
|
* @arg for a polynomial of degree 16, X^16 + X^12 + X^5 + 1 is written 0x1021
|
||||||
|
* @param PolyLength CRC polynomial length.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg @ref CRC_POLYLENGTH_7B 7-bit long CRC (generating polynomial of degree 7)
|
||||||
|
* @arg @ref CRC_POLYLENGTH_8B 8-bit long CRC (generating polynomial of degree 8)
|
||||||
|
* @arg @ref CRC_POLYLENGTH_16B 16-bit long CRC (generating polynomial of degree 16)
|
||||||
|
* @arg @ref CRC_POLYLENGTH_32B 32-bit long CRC (generating polynomial of degree 32)
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength)
|
||||||
|
{
|
||||||
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
uint32_t msb = 31U; /* polynomial degree is 32 at most, so msb is initialized to max value */
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_CRC_POL_LENGTH(PolyLength));
|
||||||
|
|
||||||
|
/* check polynomial definition vs polynomial size:
|
||||||
|
* polynomial length must be aligned with polynomial
|
||||||
|
* definition. HAL_ERROR is reported if Pol degree is
|
||||||
|
* larger than that indicated by PolyLength.
|
||||||
|
* Look for MSB position: msb will contain the degree of
|
||||||
|
* the second to the largest polynomial member. E.g., for
|
||||||
|
* X^7 + X^6 + X^5 + X^2 + 1, msb = 6. */
|
||||||
|
while ((msb-- > 0U) && ((Pol & ((uint32_t)(0x1U) << (msb & 0x1FU))) == 0U))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (PolyLength)
|
||||||
|
{
|
||||||
|
case CRC_POLYLENGTH_7B:
|
||||||
|
if (msb >= HAL_CRC_LENGTH_7B)
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CRC_POLYLENGTH_8B:
|
||||||
|
if (msb >= HAL_CRC_LENGTH_8B)
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CRC_POLYLENGTH_16B:
|
||||||
|
if (msb >= HAL_CRC_LENGTH_16B)
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CRC_POLYLENGTH_32B:
|
||||||
|
/* no polynomial definition vs. polynomial length issue possible */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = HAL_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (status == HAL_OK)
|
||||||
|
{
|
||||||
|
/* set generating polynomial */
|
||||||
|
WRITE_REG(hcrc->Instance->POL, Pol);
|
||||||
|
|
||||||
|
/* set generating polynomial size */
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, PolyLength);
|
||||||
|
}
|
||||||
|
/* Return function status */
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Reverse Input data mode.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param InputReverseMode Input Data inversion mode.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg @ref CRC_INPUTDATA_INVERSION_NONE no change in bit order (default value)
|
||||||
|
* @arg @ref CRC_INPUTDATA_INVERSION_BYTE Byte-wise bit reversal
|
||||||
|
* @arg @ref CRC_INPUTDATA_INVERSION_HALFWORD HalfWord-wise bit reversal
|
||||||
|
* @arg @ref CRC_INPUTDATA_INVERSION_WORD Word-wise bit reversal
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode)
|
||||||
|
{
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(InputReverseMode));
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
/* set input data inversion mode */
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, InputReverseMode);
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_READY;
|
||||||
|
|
||||||
|
/* Return function status */
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Reverse Output data mode.
|
||||||
|
* @param hcrc CRC handle
|
||||||
|
* @param OutputReverseMode Output Data inversion mode.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg @ref CRC_OUTPUTDATA_INVERSION_DISABLE no CRC inversion (default value)
|
||||||
|
* @arg @ref CRC_OUTPUTDATA_INVERSION_ENABLE bit-level inversion (e.g. for a 8-bit CRC: 0xB5 becomes 0xAD)
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode)
|
||||||
|
{
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(OutputReverseMode));
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_BUSY;
|
||||||
|
|
||||||
|
/* set output data inversion mode */
|
||||||
|
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, OutputReverseMode);
|
||||||
|
|
||||||
|
/* Change CRC peripheral state */
|
||||||
|
hcrc->State = HAL_CRC_STATE_READY;
|
||||||
|
|
||||||
|
/* Return function status */
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
6
Makefile
6
Makefile
@ -1,5 +1,5 @@
|
|||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
# File automatically-generated by tool: [projectgenerator] version: [3.17.1] date: [Tue Sep 27 08:33:11 CEST 2022]
|
# File automatically-generated by tool: [projectgenerator] version: [3.17.1] date: [Fri Dec 09 08:47:57 CET 2022]
|
||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
@ -75,7 +75,9 @@ Middlewares/Third_Party/FreeRTOS/Source/timers.c \
|
|||||||
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
|
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
|
||||||
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
|
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
|
||||||
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
|
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_iwdg.c
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_iwdg.c \
|
||||||
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c \
|
||||||
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c
|
||||||
|
|
||||||
# ASM sources
|
# ASM sources
|
||||||
ASM_SOURCES = \
|
ASM_SOURCES = \
|
||||||
|
2071
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul.c
Normal file
2071
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul.c
Normal file
File diff suppressed because it is too large
Load Diff
142
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul.h
Normal file
142
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul.h
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file EEPROM_Emul/Core/eeprom_emul.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief This file contains all the functions prototypes for the EEPROM
|
||||||
|
* emulation firmware library.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
|
* the "License"; You may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at:
|
||||||
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __EEPROM_EMUL_H
|
||||||
|
#define __EEPROM_EMUL_H
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "eeprom_emul_conf.h"
|
||||||
|
#include "eeprom_emul_types.h"
|
||||||
|
#include "flash_interface.h"
|
||||||
|
|
||||||
|
/** @addtogroup EEPROM_Emulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup EEPROM_Private_Constants EEPROM Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Private_Other_Constants Private Other Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Page definitions */
|
||||||
|
#define PAGE_SIZE FLASH_PAGE_SIZE /*!< Page size */
|
||||||
|
#define PAGE_HEADER_SIZE EE_ELEMENT_SIZE * 4U /*!< Page Header is 4 elements to save page state */
|
||||||
|
#define NB_MAX_ELEMENTS_BY_PAGE ((PAGE_SIZE - PAGE_HEADER_SIZE) / EE_ELEMENT_SIZE) /*!< Max number of elements by page */
|
||||||
|
#define PAGES_NUMBER (((((NB_OF_VARIABLES + NB_MAX_ELEMENTS_BY_PAGE) / NB_MAX_ELEMENTS_BY_PAGE) * 2U) * CYCLES_NUMBER) + GUARD_PAGES_NUMBER)
|
||||||
|
/*!< Number of consecutives pages used by the application */
|
||||||
|
#define NB_MAX_WRITTEN_ELEMENTS ((NB_MAX_ELEMENTS_BY_PAGE * PAGES_NUMBER) / 2U) /*!< Max number of elements written before triggering pages transfer */
|
||||||
|
#define START_PAGE PAGE(START_PAGE_ADDRESS) /*!< Page index of the 1st page used for EEPROM emul, in the bank */
|
||||||
|
#define END_EEPROM_ADDRESS (START_PAGE_ADDRESS + (PAGES_NUMBER * FLASH_PAGE_SIZE) - 1) /*!< Last address of EEPROM emulation flash pages */
|
||||||
|
|
||||||
|
/* No page define */
|
||||||
|
#define EE_NO_PAGE_FOUND ((uint32_t)0xFFFFFFFFU)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/** @defgroup EEPROM_Private_Macros EEPROM Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Macros_Pages Macros to manipulate pages
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Macros to manipulate pages */
|
||||||
|
#ifdef SECURE_FEATURES
|
||||||
|
#define PAGE_ADDRESS(__PAGE__) (uint32_t)(FLASH_BASE_NS + (__PAGE__) * PAGE_SIZE + ((START_PAGE_ADDRESS - FLASH_BASE_NS) / BANK_SIZE) * BANK_SIZE) /*!< Get page address from page index */
|
||||||
|
#define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE_NS) % BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */
|
||||||
|
#else
|
||||||
|
#define PAGE_ADDRESS(__PAGE__) (uint32_t)(FLASH_BASE + (__PAGE__) * PAGE_SIZE + ((START_PAGE_ADDRESS - FLASH_BASE) / BANK_SIZE) * BANK_SIZE) /*!< Get page address from page index */
|
||||||
|
#define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE) % BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */
|
||||||
|
#endif
|
||||||
|
#define PREVIOUS_PAGE(__PAGE__) (uint32_t)((((__PAGE__) - START_PAGE - 1U + PAGES_NUMBER) % PAGES_NUMBER) + START_PAGE) /*!< Get page index of previous page, among circular page list */
|
||||||
|
#define FOLLOWING_PAGE(__PAGE__) (uint32_t)((((__PAGE__) - START_PAGE + 1U) % PAGES_NUMBER) + START_PAGE) /*!< Get page index of following page, among circular page list */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Macros_Elements Macros to manipulate elements
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Macros to manipulate elements */
|
||||||
|
#define EE_VIRTUALADDRESS_VALUE(__ELEMENT__) (EE_VIRTUALADDRESS_TYPE)((__ELEMENT__) & EE_MASK_VIRTUALADDRESS) /*!< Get virtual address value from element value */
|
||||||
|
#define EE_DATA_VALUE(__ELEMENT__) (EE_DATA_TYPE)(((__ELEMENT__) & EE_MASK_DATA) >> EE_DATA_SHIFT) /*!< Get Data value from element value */
|
||||||
|
#define EE_CRC_VALUE(__ELEMENT__) (EE_CRC_TYPE)(((__ELEMENT__) & EE_MASK_CRC) >> EE_CRC_SHIFT) /*!< Get Crc value from element value */
|
||||||
|
#define EE_ELEMENT_VALUE(__VIRTADDR__,__DATA__,__CRC__) (((EE_ELEMENT_TYPE)(__DATA__) << EE_DATA_SHIFT) | (__CRC__) << EE_CRC_SHIFT | (__VIRTADDR__)) /*!< Get element value from virtual addr, data and crc values */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
/** @defgroup EEPROM_Exported_Functions EEPROM Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
EE_Status EE_Format(EE_Erase_type EraseType);
|
||||||
|
EE_Status EE_Init(EE_Erase_type EraseType);
|
||||||
|
#if defined(EE_ACCESS_32BITS)
|
||||||
|
EE_Status EE_ReadVariable32bits(uint16_t VirtAddress, uint32_t* pData);
|
||||||
|
EE_Status EE_WriteVariable32bits(uint16_t VirtAddress, uint32_t Data);
|
||||||
|
#endif
|
||||||
|
#if defined(FLASH_LINES_128B)
|
||||||
|
EE_Status EE_ReadVariable96bits(uint16_t VirtAddress, uint64_t* pData);
|
||||||
|
EE_Status EE_WriteVariable96bits(uint16_t VirtAddress, uint64_t* Data);
|
||||||
|
#endif
|
||||||
|
EE_Status EE_ReadVariable16bits(uint16_t VirtAddress, uint16_t* pData);
|
||||||
|
EE_Status EE_WriteVariable16bits(uint16_t VirtAddress, uint16_t Data);
|
||||||
|
EE_Status EE_ReadVariable8bits(uint16_t VirtAddress, uint8_t* pData);
|
||||||
|
EE_Status EE_WriteVariable8bits(uint16_t VirtAddress, uint8_t Data);
|
||||||
|
EE_Status EE_CleanUp(void);
|
||||||
|
EE_Status EE_CleanUp_IT(void);
|
||||||
|
EE_Status EE_DeleteCorruptedFlashAddress(uint32_t Address);
|
||||||
|
void EE_EndOfCleanup_UserCallback(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* __EEPROM_EMUL_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
90
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul_conf.h
Normal file
90
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul_conf.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file eeprom_emul_conf.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief EEPROM emulation configuration file.
|
||||||
|
* This file should be copied to the application folder and renamed
|
||||||
|
* to eeprom_emul_conf.h.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
|
* the "License"; You may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at:
|
||||||
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup EEPROM_Emulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __EEPROM_EMUL_CONF_H
|
||||||
|
#define __EEPROM_EMUL_CONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @addtogroup EEPROM_Private_Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Private_Configuration_Constants Private Configuration Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Configuration of eeprom emulation in flash, can be custom */
|
||||||
|
#define START_PAGE_ADDRESS 0x0801F000U /*!< Start address of the second last page in flash, for EEPROM emulation */
|
||||||
|
#define CYCLES_NUMBER 1U /*!< Number of 10Kcycles requested, minimum 1 for 10Kcycles (default), for instance 10 to reach 100Kcycles. This factor will increase pages number */
|
||||||
|
#define GUARD_PAGES_NUMBER 0U /*!< Number of guard pages avoiding frequent transfers (must be multiple of 2): 0,2,4.. */
|
||||||
|
|
||||||
|
/* Configuration of crc calculation for eeprom emulation in flash */
|
||||||
|
#define CRC_POLYNOMIAL_LENGTH LL_CRC_POLYLENGTH_16B /* CRC polynomial lenght 16 bits */
|
||||||
|
#define CRC_POLYNOMIAL_VALUE 0x8005U /* Polynomial to use for CRC calculation */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup EEPROM_Exported_Constants EEPROM Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Exported_Configuration_Constants Exported Configuration Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define NB_OF_VARIABLES 6U /*!< Number of variables to handle in eeprom */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* __EEPROM_EMUL_CONF_H */
|
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
118
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul_types.h
Normal file
118
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul_types.h
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file EEPROM_Emul/Core/eeprom_emul_types.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief This file contains all the functions prototypes for the EEPROM
|
||||||
|
* emulation firmware library.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
|
* the "License"; You may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at:
|
||||||
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __EEPROM_EMUL_TYPES_H
|
||||||
|
#define __EEPROM_EMUL_TYPES_H
|
||||||
|
|
||||||
|
/** @addtogroup EEPROM_Emulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup EEPROM_Exported_Constants EEPROM Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup Exported_Other_Constants Exported Other Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EE Status enum definition.
|
||||||
|
*/
|
||||||
|
/* Define of the return value */
|
||||||
|
typedef enum {
|
||||||
|
/* External return codes : ok */
|
||||||
|
EE_OK = 0U,
|
||||||
|
|
||||||
|
/* External return codes : errors */
|
||||||
|
EE_ERASE_ERROR,
|
||||||
|
EE_WRITE_ERROR,
|
||||||
|
EE_ERROR_NOACTIVE_PAGE,
|
||||||
|
EE_ERROR_NOERASE_PAGE,
|
||||||
|
EE_ERROR_NOERASING_PAGE,
|
||||||
|
EE_ERROR_NOACTIVE_NORECEIVE_NOVALID_PAGE,
|
||||||
|
EE_NO_DATA,
|
||||||
|
EE_INVALID_VIRTUALADDRESS,
|
||||||
|
EE_INVALID_PAGE,
|
||||||
|
EE_INVALID_PAGE_SEQUENCE,
|
||||||
|
EE_INVALID_ELEMENT,
|
||||||
|
EE_TRANSFER_ERROR,
|
||||||
|
EE_DELETE_ERROR,
|
||||||
|
EE_INVALID_BANK_CFG,
|
||||||
|
|
||||||
|
/* Internal return code */
|
||||||
|
EE_NO_PAGE_FOUND,
|
||||||
|
EE_PAGE_NOTERASED,
|
||||||
|
EE_PAGE_ERASED,
|
||||||
|
EE_PAGE_FULL,
|
||||||
|
|
||||||
|
/* External return code : action required */
|
||||||
|
EE_CLEANUP_REQUIRED = 0x100U,
|
||||||
|
|
||||||
|
#ifdef DUALCORE_FLASH_SHARING
|
||||||
|
/* Value returned when a program or erase operation is requested but
|
||||||
|
* the flash is already used by CPU2 */
|
||||||
|
EE_FLASH_USED,
|
||||||
|
EE_SEM_TIMEOUT,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} EE_Status;
|
||||||
|
|
||||||
|
/* Type of page erasing:
|
||||||
|
EE_FORCED_ERASE --> pages to erase are erased unconditionnally
|
||||||
|
EE_CONDITONAL_ERASE --> pages to erase are erased only if not fully erased */
|
||||||
|
typedef enum {
|
||||||
|
EE_FORCED_ERASE,
|
||||||
|
EE_CONDITIONAL_ERASE
|
||||||
|
} EE_Erase_type;
|
||||||
|
|
||||||
|
#if (defined DUALCORE_FLASH_SHARING) || (defined FLASH_LINES_128B)
|
||||||
|
/* Type of write operations:
|
||||||
|
EE_TRANSFER --> Used by WriteDoubleWord to know when the operation ongoing is a transfer
|
||||||
|
EE_SIMPLE_WRITE --> Used by WriteDoubleWord to know when the operation ongoing is a simple writing */
|
||||||
|
typedef enum {
|
||||||
|
EE_TRANSFER,
|
||||||
|
EE_SIMPLE_WRITE,
|
||||||
|
EE_SET_PAGE,
|
||||||
|
EE_INIT_WRITE
|
||||||
|
} EE_Write_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Masks of EE_Status return codes */
|
||||||
|
#define EE_STATUSMASK_ERROR (uint16_t)0x00FFU /*!< Mask on EE_Status return code, selecting error codes */
|
||||||
|
#define EE_STATUSMASK_CLEANUP (uint16_t)0x0100U /*!< Mask on EE_Status return code, selecting cleanup request codes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* __EEPROM_EMUL_TYPES_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
279
Middlewares/ST/EEPROM_Emul/Porting/STM32L4/flash_interface.c
Normal file
279
Middlewares/ST/EEPROM_Emul/Porting/STM32L4/flash_interface.c
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file EEPROM_Emul/Porting/STM32L4/flash_interface.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief This file provides all the EEPROM emulation flash interface functions.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
|
* the "License"; You may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at:
|
||||||
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "eeprom_emul.h"
|
||||||
|
#include "flash_interface.h"
|
||||||
|
|
||||||
|
/** @addtogroup EEPROM_Emulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
#if defined(FLASH_BANK_2)
|
||||||
|
static uint32_t GetBankNumber(uint32_t Address);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/** @addtogroup EEPROM_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write a double word at the given address in Flash
|
||||||
|
* @param Address Where to write
|
||||||
|
* @param Data What to write
|
||||||
|
* @retval EE_Status
|
||||||
|
* - EE_OK: on success
|
||||||
|
* - EE_WRITE_ERROR: if an error occurs
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data)
|
||||||
|
{
|
||||||
|
return HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase a page in polling mode
|
||||||
|
* @param Page Page number
|
||||||
|
* @param NbPages Number of pages to erase
|
||||||
|
* @retval EE_Status
|
||||||
|
* - EE_OK: on success
|
||||||
|
* - EE error code: if an error occurs
|
||||||
|
*/
|
||||||
|
EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages)
|
||||||
|
{
|
||||||
|
EE_Status status = EE_OK;
|
||||||
|
FLASH_EraseInitTypeDef s_eraseinit;
|
||||||
|
uint32_t bank = FLASH_BANK_1, page_error = 0U;
|
||||||
|
|
||||||
|
#if defined(FLASH_BANK_2)
|
||||||
|
bank = GetBankNumber(PAGE_ADDRESS(Page));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
|
s_eraseinit.NbPages = NbPages;
|
||||||
|
s_eraseinit.Page = Page;
|
||||||
|
s_eraseinit.Banks = bank;
|
||||||
|
|
||||||
|
/* Erase the Page: Set Page status to ERASED status */
|
||||||
|
if (HAL_FLASHEx_Erase(&s_eraseinit, &page_error) != HAL_OK)
|
||||||
|
{
|
||||||
|
status = EE_ERASE_ERROR;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase a page with interrupt enabled
|
||||||
|
* @param Page Page number
|
||||||
|
* @param NbPages Number of pages to erase
|
||||||
|
* @retval EE_Status
|
||||||
|
* - EE_OK: on success
|
||||||
|
* - EE error code: if an error occurs
|
||||||
|
*/
|
||||||
|
EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages)
|
||||||
|
{
|
||||||
|
EE_Status status = EE_OK;
|
||||||
|
FLASH_EraseInitTypeDef s_eraseinit;
|
||||||
|
uint32_t bank = FLASH_BANK_1;
|
||||||
|
|
||||||
|
#if defined(FLASH_BANK_2)
|
||||||
|
bank = GetBankNumber(PAGE_ADDRESS(Page));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
|
s_eraseinit.NbPages = NbPages;
|
||||||
|
s_eraseinit.Page = Page;
|
||||||
|
s_eraseinit.Banks = bank;
|
||||||
|
|
||||||
|
/* Erase the Page: Set Page status to ERASED status */
|
||||||
|
if (HAL_FLASHEx_Erase_IT(&s_eraseinit) != HAL_OK)
|
||||||
|
{
|
||||||
|
status = EE_ERASE_ERROR;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Flush the caches if needed to keep coherency when the flash content is modified
|
||||||
|
*/
|
||||||
|
void FI_CacheFlush()
|
||||||
|
{
|
||||||
|
/* To keep its coherency, flush the D-Cache: its content is not updated after a flash erase. */
|
||||||
|
__HAL_FLASH_DATA_CACHE_DISABLE();
|
||||||
|
__HAL_FLASH_DATA_CACHE_RESET();
|
||||||
|
__HAL_FLASH_DATA_CACHE_ENABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(FLASH_BANK_2)
|
||||||
|
/**
|
||||||
|
* @brief Gets the bank of a given address
|
||||||
|
* @param Address Address of the FLASH Memory
|
||||||
|
* @retval Bank_Number The bank of a given address
|
||||||
|
*/
|
||||||
|
static uint32_t GetBankNumber(uint32_t Address)
|
||||||
|
{
|
||||||
|
uint32_t bank = 0U;
|
||||||
|
|
||||||
|
if (READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE) == 0U)
|
||||||
|
{
|
||||||
|
/* No Bank swap */
|
||||||
|
if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
|
||||||
|
{
|
||||||
|
bank = FLASH_BANK_1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bank = FLASH_BANK_2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Bank swap */
|
||||||
|
if (Address < (FLASH_BASE + FLASH_BANK_SIZE))
|
||||||
|
{
|
||||||
|
bank = FLASH_BANK_2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bank = FLASH_BANK_1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bank;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delete corrupted Flash address, can be called from NMI. No Timeout.
|
||||||
|
* @param Address Address of the FLASH Memory to delete
|
||||||
|
* @retval EE_Status
|
||||||
|
* - EE_OK: on success
|
||||||
|
* - EE error code: if an error occurs
|
||||||
|
*/
|
||||||
|
EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address)
|
||||||
|
{
|
||||||
|
uint32_t dcachetoreactivate = 0U;
|
||||||
|
EE_Status status = EE_OK;
|
||||||
|
|
||||||
|
/* Deactivate the data cache if they are activated to avoid data misbehavior */
|
||||||
|
if(READ_BIT(FLASH->ACR, FLASH_ACR_DCEN) != RESET)
|
||||||
|
{
|
||||||
|
/* Disable data cache */
|
||||||
|
__HAL_FLASH_DATA_CACHE_DISABLE();
|
||||||
|
dcachetoreactivate = 1U;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set FLASH Programmation bit */
|
||||||
|
SET_BIT(FLASH->CR, FLASH_CR_PG);
|
||||||
|
|
||||||
|
/* Program double word of value 0 */
|
||||||
|
*(__IO uint32_t*)(Address) = (uint32_t)0U;
|
||||||
|
*(__IO uint32_t*)(Address+4U) = (uint32_t)0U;
|
||||||
|
|
||||||
|
/* Wait programmation completion */
|
||||||
|
while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if error occured */
|
||||||
|
if((__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PROGERR)) ||
|
||||||
|
(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) ||
|
||||||
|
(__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR)) || (__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)))
|
||||||
|
{
|
||||||
|
status = EE_DELETE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check FLASH End of Operation flag */
|
||||||
|
if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
|
||||||
|
{
|
||||||
|
/* Clear FLASH End of Operation pending bit */
|
||||||
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear FLASH Programmation bit */
|
||||||
|
CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
if(dcachetoreactivate == 1U)
|
||||||
|
{
|
||||||
|
/* Reset data cache */
|
||||||
|
__HAL_FLASH_DATA_CACHE_RESET();
|
||||||
|
/* Enable data cache */
|
||||||
|
__HAL_FLASH_DATA_CACHE_ENABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear FLASH ECCD bit */
|
||||||
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if the configuration is 128-bits bank or 2*64-bits bank
|
||||||
|
* @param None
|
||||||
|
* @retval EE_Status
|
||||||
|
* - EE_OK: on success
|
||||||
|
* - EE error code: if an error occurs
|
||||||
|
*/
|
||||||
|
EE_Status FI_CheckBankConfig(void)
|
||||||
|
{
|
||||||
|
#if defined (FLASH_OPTR_DBANK)
|
||||||
|
FLASH_OBProgramInitTypeDef sOBCfg;
|
||||||
|
EE_Status status;
|
||||||
|
|
||||||
|
/* Request the Option Byte configuration :
|
||||||
|
- User and RDP level are always returned
|
||||||
|
- WRP and PCROP are not requested */
|
||||||
|
sOBCfg.WRPArea = 0xFF;
|
||||||
|
sOBCfg.PCROPConfig = 0xFF;
|
||||||
|
HAL_FLASHEx_OBGetConfig(&sOBCfg);
|
||||||
|
|
||||||
|
/* Check the value of the DBANK user option byte */
|
||||||
|
if ((sOBCfg.USERConfig & OB_DBANK_64_BITS) != 0)
|
||||||
|
{
|
||||||
|
status = EE_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = EE_INVALID_BANK_CFG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
#else
|
||||||
|
/* No feature 128-bits single bank, so always 64-bits dual bank */
|
||||||
|
return EE_OK;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
125
Middlewares/ST/EEPROM_Emul/Porting/STM32L4/flash_interface.h
Normal file
125
Middlewares/ST/EEPROM_Emul/Porting/STM32L4/flash_interface.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file EEPROM_Emul/Porting/STM32L4/flash_interface.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief This file contains all the functions prototypes for the EEPROM
|
||||||
|
* emulation flash interface.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under BSD 3-Clause license,
|
||||||
|
* the "License"; You may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at:
|
||||||
|
* opensource.org/licenses/BSD-3-Clause
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __FLASH_INTERFACE_H
|
||||||
|
#define __FLASH_INTERFACE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l4xx_hal.h"
|
||||||
|
#include "stm32l4xx_ll_crc.h"
|
||||||
|
#include "stm32l4xx_ll_bus.h"
|
||||||
|
|
||||||
|
/** @addtogroup EEPROM_Emulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @addtogroup EEPROM_Private_Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup Private_Other_Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
|
||||||
|
#define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
|
||||||
|
|
||||||
|
/* Page state header */
|
||||||
|
#define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
|
||||||
|
#define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
|
||||||
|
#define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
|
||||||
|
#define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
|
||||||
|
#define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
|
||||||
|
|
||||||
|
/* Description of the 8 Bytes (64 bits) element in flash */
|
||||||
|
/* Bit: 63 32 31 16 15 0 */
|
||||||
|
/* <--- Data Value -----> <-unused-> <-VirtAddr-> */
|
||||||
|
#define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
|
||||||
|
#define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
|
||||||
|
#define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
|
||||||
|
#define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
|
||||||
|
#define EE_CRC_TYPE uint16_t /*!< Type of Crc */
|
||||||
|
#define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
|
||||||
|
#define EE_DATA_TYPE uint32_t /*!< Type of Data */
|
||||||
|
#define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
|
||||||
|
#define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
|
||||||
|
#define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
|
||||||
|
#define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
|
||||||
|
#define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/** @addtogroup EEPROM_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/** @addtogroup EEPROM_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
|
||||||
|
EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
|
||||||
|
EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
|
||||||
|
EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
|
||||||
|
EE_Status FI_CheckBankConfig(void);
|
||||||
|
void FI_CacheFlush(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* __FLASH_INTERFACE_H */
|
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
File diff suppressed because it is too large
Load Diff
1337
PeltierControllerV2.srec
Normal file
1337
PeltierControllerV2.srec
Normal file
File diff suppressed because it is too large
Load Diff
@ -82,16 +82,17 @@ Mcu.CPN=STM32L432KBU6
|
|||||||
Mcu.Family=STM32L4
|
Mcu.Family=STM32L4
|
||||||
Mcu.IP0=ADC1
|
Mcu.IP0=ADC1
|
||||||
Mcu.IP1=CAN1
|
Mcu.IP1=CAN1
|
||||||
Mcu.IP10=SYS
|
Mcu.IP10=SPI1
|
||||||
Mcu.IP2=DAC1
|
Mcu.IP11=SYS
|
||||||
Mcu.IP3=DMA
|
Mcu.IP2=CRC
|
||||||
Mcu.IP4=FREERTOS
|
Mcu.IP3=DAC1
|
||||||
Mcu.IP5=I2C1
|
Mcu.IP4=DMA
|
||||||
Mcu.IP6=IWDG
|
Mcu.IP5=FREERTOS
|
||||||
Mcu.IP7=NVIC
|
Mcu.IP6=I2C1
|
||||||
Mcu.IP8=RCC
|
Mcu.IP7=IWDG
|
||||||
Mcu.IP9=SPI1
|
Mcu.IP8=NVIC
|
||||||
Mcu.IPNb=11
|
Mcu.IP9=RCC
|
||||||
|
Mcu.IPNb=12
|
||||||
Mcu.Name=STM32L432K(B-C)Ux
|
Mcu.Name=STM32L432K(B-C)Ux
|
||||||
Mcu.Package=UFQFPN32
|
Mcu.Package=UFQFPN32
|
||||||
Mcu.Pin0=PC14-OSC32_IN (PC14)
|
Mcu.Pin0=PC14-OSC32_IN (PC14)
|
||||||
@ -111,9 +112,10 @@ Mcu.Pin20=PB4 (NJTRST)
|
|||||||
Mcu.Pin21=PB5
|
Mcu.Pin21=PB5
|
||||||
Mcu.Pin22=PB6
|
Mcu.Pin22=PB6
|
||||||
Mcu.Pin23=PB7
|
Mcu.Pin23=PB7
|
||||||
Mcu.Pin24=VP_FREERTOS_VS_CMSIS_V2
|
Mcu.Pin24=VP_CRC_VS_CRC
|
||||||
Mcu.Pin25=VP_IWDG_VS_IWDG
|
Mcu.Pin25=VP_FREERTOS_VS_CMSIS_V2
|
||||||
Mcu.Pin26=VP_SYS_VS_Systick
|
Mcu.Pin26=VP_IWDG_VS_IWDG
|
||||||
|
Mcu.Pin27=VP_SYS_VS_Systick
|
||||||
Mcu.Pin3=PA1
|
Mcu.Pin3=PA1
|
||||||
Mcu.Pin4=PA2
|
Mcu.Pin4=PA2
|
||||||
Mcu.Pin5=PA4
|
Mcu.Pin5=PA4
|
||||||
@ -121,12 +123,12 @@ Mcu.Pin6=PA5
|
|||||||
Mcu.Pin7=PA6
|
Mcu.Pin7=PA6
|
||||||
Mcu.Pin8=PA7
|
Mcu.Pin8=PA7
|
||||||
Mcu.Pin9=PB0
|
Mcu.Pin9=PB0
|
||||||
Mcu.PinsNb=27
|
Mcu.PinsNb=28
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32L432KBUx
|
Mcu.UserName=STM32L432KBUx
|
||||||
MxCube.Version=6.4.0
|
MxCube.Version=6.6.1
|
||||||
MxDb.Version=DB.6.0.40
|
MxDb.Version=DB.6.0.60
|
||||||
NVIC.ADC1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.ADC1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
@ -246,7 +248,7 @@ ProjectManager.StackSize=0x400
|
|||||||
ProjectManager.TargetToolchain=Makefile
|
ProjectManager.TargetToolchain=Makefile
|
||||||
ProjectManager.ToolChainLocation=
|
ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UnderRoot=false
|
ProjectManager.UnderRoot=false
|
||||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_DAC1_Init-DAC1-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_I2C1_Init-I2C1-false-HAL-true,9-MX_IWDG_Init-IWDG-false-HAL-true
|
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_DAC1_Init-DAC1-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_I2C1_Init-I2C1-false-HAL-true,9-MX_IWDG_Init-IWDG-false-HAL-true,10-MX_CRC_Init-CRC-false-HAL-true
|
||||||
RCC.ADCCLockSelection=RCC_ADCCLKSOURCE_SYSCLK
|
RCC.ADCCLockSelection=RCC_ADCCLKSOURCE_SYSCLK
|
||||||
RCC.ADCFreq_Value=80000000
|
RCC.ADCFreq_Value=80000000
|
||||||
RCC.AHBFreq_Value=80000000
|
RCC.AHBFreq_Value=80000000
|
||||||
@ -311,6 +313,8 @@ SPI1.Direction=SPI_DIRECTION_2LINES
|
|||||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,CLKPhase
|
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,CLKPhase
|
||||||
SPI1.Mode=SPI_MODE_MASTER
|
SPI1.Mode=SPI_MODE_MASTER
|
||||||
SPI1.VirtualType=VM_MASTER
|
SPI1.VirtualType=VM_MASTER
|
||||||
|
VP_CRC_VS_CRC.Mode=CRC_Activate
|
||||||
|
VP_CRC_VS_CRC.Signal=CRC_VS_CRC
|
||||||
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
|
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
|
||||||
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
|
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
|
||||||
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
|
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
|
||||||
|
@ -67,6 +67,8 @@ excludes:
|
|||||||
# If a CubeMX makefile is present it will automatically include the include directories from that makefile.
|
# If a CubeMX makefile is present it will automatically include the include directories from that makefile.
|
||||||
includeDirectories:
|
includeDirectories:
|
||||||
- Core/**
|
- Core/**
|
||||||
|
- Middlewares/**
|
||||||
|
- Drivers/**
|
||||||
|
|
||||||
|
|
||||||
# Files that should be included in the compilation.
|
# Files that should be included in the compilation.
|
||||||
@ -76,9 +78,12 @@ includeDirectories:
|
|||||||
# these should be escaped with a: \ or the name should be in double quotes e.g. "HARDWARE_DRIVER*.c"
|
# these should be escaped with a: \ or the name should be in double quotes e.g. "HARDWARE_DRIVER*.c"
|
||||||
sourceFiles:
|
sourceFiles:
|
||||||
- Core/**
|
- Core/**
|
||||||
|
- Middlewares/**
|
||||||
|
- Drivers/**
|
||||||
|
- startup_stm32l432xx.s
|
||||||
|
|
||||||
|
|
||||||
# When no makefile is present it will show a warning pop-up.
|
# When no makefile is present it will show a warning pop-up.
|
||||||
# However when compilation without the CubeMX Makefile is desired, this can be turned of.
|
# However when compilation without the CubeMX Makefile is desired, this can be turned of.
|
||||||
suppressMakefileWarning: false
|
suppressMakefileWarning: true
|
||||||
|
|
@ -62,6 +62,8 @@ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
|
|||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
|
||||||
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c \
|
||||||
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
|
||||||
@ -82,6 +84,8 @@ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \
|
|||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
|
||||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
|
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
|
||||||
|
Middlewares/ST/EEPROM_Emul/Core/eeprom_emul.c \
|
||||||
|
Middlewares/ST/EEPROM_Emul/Porting/STM32L4/flash_interface.c \
|
||||||
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
|
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
|
||||||
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
|
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
|
||||||
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
|
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
|
||||||
@ -154,8 +158,6 @@ C_DEFS = \
|
|||||||
|
|
||||||
# CXX defines
|
# CXX defines
|
||||||
CXX_DEFS = \
|
CXX_DEFS = \
|
||||||
-DSTM32L432xx \
|
|
||||||
-DUSE_HAL_DRIVER
|
|
||||||
|
|
||||||
|
|
||||||
# AS includes
|
# AS includes
|
||||||
@ -172,6 +174,8 @@ C_INCLUDES = \
|
|||||||
-IDrivers/CMSIS/Include \
|
-IDrivers/CMSIS/Include \
|
||||||
-IDrivers/STM32L4xx_HAL_Driver/Inc \
|
-IDrivers/STM32L4xx_HAL_Driver/Inc \
|
||||||
-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
|
-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
|
||||||
|
-IMiddlewares/ST/EEPROM_Emul/Core \
|
||||||
|
-IMiddlewares/ST/EEPROM_Emul/Porting/STM32L4 \
|
||||||
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
|
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
|
||||||
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
|
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
|
||||||
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
|
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
|
||||||
@ -211,7 +215,7 @@ LIBDIR = \
|
|||||||
|
|
||||||
|
|
||||||
# Additional LD Flags from config file
|
# Additional LD Flags from config file
|
||||||
ADDITIONALLDFLAGS = -specs=nano.specs
|
ADDITIONALLDFLAGS =
|
||||||
|
|
||||||
LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
if %1.==. goto:FEHLER
|
if %1.==. goto:FEHLER
|
||||||
start "" "C:\Program Files\srecord\bin\srec_cat.exe" build/PeltierControllerV3.hex -Intel -o PeltierControllerV%1.srec -Motorola
|
start "" "C:\Program Files\srecord\bin\srec_cat.exe" build/PeltierControllerV3.hex -Intel -o PeltierControllerV%1.srec -Motorola
|
||||||
|
goto:END
|
||||||
:FEHLER
|
:FEHLER
|
||||||
echo Das Script muss folgendermassen aufgerufen werden: %0 Versionsnummer
|
echo Das Script muss folgendermassen aufgerufen werden: %0 Versionsnummer
|
||||||
|
:END
|
Reference in New Issue
Block a user