AUTOSAR-like MCU Driver
The MCU driver provides services for basic microcontroller initialization, power down functionality, reset and microcontroller specific functions required by other MCAL [Microcontroller Abstraction Layer] software modules. The initialization services allow a flexible and application related MCU initialization in addition to the start-up code (see figure below). The start-up code is very MCU specific. The start-up code is provided by Evidence Srl within Erika Enterprise.
MCU driver Features:
- Initialization of MCU clock, PLL, clock prescalers and MCU clock distribution
- Initialization of RAM sections
- Activation of μC reduced power modes
- Activation of a μC reset
- Provides a service to get the reset reason from hardware
The MCU driver accesses the microcontroller hardware directly and is located in the Microcontroller Abstraction Layer.
To enable AUTOSAR-like MCU Driver in Erika Enterprise compiler toolchain, the following
EE_OPT attribute is needed in the
OS object of the OSEK/VDX configuration:
EE_OPT = "__AS_MCU_DRIVER__";
The configuration C header file inclusion is done by
CFLAGS attribute in the
OS object of the OSEK/VDX configuration:
CFLAGS = "-I<PATH>";
<PATH> is the absolute or relative directory path which configuration C header file is stored.
Instead the configurations C source file is added to the compilation process by
APP_SRC attribute in the
CPU_DATA object of the OSEK/VDX configuration:
APP_SRC = "<PATH>/Mcu_Cfg.c";
<PATH> is the absolute or relative directory path which configuration C source file is stored.
typedef uint8 Std_ReturnType
Standard Return Type.
This type can be used as standard API return type which is shared between AUTOSAR-like modules.
The Std_ReturnType shall normally be used with value E_OK or E_NOT_OK. If those return values are not sufficient user specific values can be defined by using the 6 least specific bits.
Standard Version Informations Type.
This type shall be used to request the version of a AUTOSAR-like module using the <Module Name>_GetVersionInfo() function.
Software Version Major Number.
Software Version Minor Number.
Software Version Patch Number.
MCU Configuration Parameters.
The structure Mcu_ConfigType is an external data structure (i.e. implementation specific) and shall contain the initialization data for the MCU module. It shall contain:
- MCU dependent properties
- Reset Configuration
- Definition of MCU modes
- Definition of Clock settings
- Definition of RAM sections
The structure Mcu_ConfigType shall provide a configurable (enable/disable) clock failure notification if the MCU provides an interrupt for such detection. If the clock failure is detected with other HW mechanisms e.g., the generation of a trap, this notification shall be disabled and the failure reporting shall be done outside the MCU driver.
The definitions for each MCU mode within the structure Mcu_ConfigType shall contain: (depending on MCU)
- MCU specific properties
- Change of CPU clock
- Change of Peripheral clock
- Change of PLL settings
- Change of MCU power supply
The definitions for each Clock setting within the structure Mcu_ConfigType shall contain:
- MCU specific properties as, e.g., clock safety features and special clock distribution settings
- PLL settings /start lock options
- Internal oscillator setting
The definitions for each RAM section within the structure Mcu_ConfigType shall contain:
- RAM section base address
- Section size
- Data pre-setting to be initialized
Usage of linker symbols instead of scalar values is allowed.
PLL Status Type.
The type Mcu_PllStatusType is the type of the return value of the API function Mcu_GetPllStatus().
The type of Mcu_PllStatusType is an enumeration with the following values: MCU_PLL_LOCKED, MCU_PLL_UNLOCKED, MCU_PLL_STATUS_UNDEFINED.
- MCU_PLL_LOCKED: PLL is locked.
- MCU_PLL_UNLOCKED: PLL is unlocked.
- MCU_PLL_STATUS_UNDEFINED: PLL Status is unknown.
typedef uint Mcu_ClockType
The type Mcu_ClockType defines the identification (ID) for clock setting configured via the configuration structure.
The type shall be uint8, uint16 or uint32, depending on μC platform.
This type represents the different reset that a specified MCU can have.
The MCU module shall provide at least the values MCU_POWER_ON_RESET and MCU_RESET_UNDEFINED.
Note: Additional reset types may be added depending on MCU.
- MCU_POWER_ON_RESET: Power On Reset (default)
- MCU_WATCHDOG_RESET: Internal Watchdog Timer Reset
- MCU_SW_RESET: Software Reset
- MCU_RESET_UNDEFINED: Reset is undefined
typedef uint Mcu_RawResetType
Raw Reset Type.
The type Mcu_RawResetType specifies the reset reason in raw register format, read from a reset status register.
The type shall be uint8, uint16 or uint32 based on best performance.
typedef uint Mcu_ModeType
The Mcu_ModeType specifies the identification (ID) for a MCU mode, configured via configuration structure.
The type shall be uint8, uint16 or uint32.
Usage examples of the AUTOSAR-like MCU Driver for can be found at examples/cortex_mx/lm4f232xxxx/as