AUTOSAR_SWS_GPTDriver
AUTOSAR_SWS_GPTDriver
简介和功能概述
This specification specifies the functionality, API and the configuration of the AUTOSAR Basic Software module GPT driver.
The GPT driver is part of the microcontroller abstraction layer (MCAL). It initializes and controls the internal General Purpose Timer(s) (GPT) of the microcontroller.
The GPT driver provides services and configuration parameters for
- Starting and stopping hardware timers
- Getting timer values
- Controlling time triggered interrupt notifications, if supported by hardware
- Controlling time triggered wakeup interrupts, if supported by hardware
The tick duration of a timer channel depends on channel specific settings (part of GPT driver) as well as on system clock and settings of the clock tree controlled by the MCU module. The tick duration is not limited by this specification.
Not all hardware timers must be controlled by the GPT module. Some timers may be controlled by AUTOSAR Operating System or Complex Drivers directly. The number of timer channels controlled by the GPT driver depends on hardware, implementation and system configuration.
Beside the possibility to configure individual timer channels with individual properties, some free running up counters - so-called GPT Predef Timers - are defined. These timers have predefined tick durations and predefined number of bits (physical time units and ranges). The GPT Predef Timers are used by the Time Service module.
The GPT driver only generates time bases. Further time based functionality on driver level is covered by other MCAL modules like:
- PWM Driver (driver for pulse width modulation)
- ICU Driver (driver for input capture unit)
- OCU Driver (driver for output compare unit)
首字母缩略词和缩写
Only a few acronyms and abbreviations are listed here which are helpful to understand this document or which have a local scope. Further information can be found in the official AUTOSAR glossary [13].
Input documents
[1] List of Basic Software Modules
- AUTOSAR_TR_BSWModuleList.pdf
[2] Layered Software Architecture
- AUTOSAR_EXP_LayeredSoftwareArchitecture.pdf
[3] General Requirements on Basic Software Modules
- AUTOSAR_SRS_BSWGeneral.pdf
[4] Specification of Standard Types
- AUTOSAR_SWS_StandardTypes.pdf
[5] Specification of Default Error Tracer
- AUTOSAR_SWS_DefaultErrorTracer.pdf
[6] Specification of ECU Configuration
- AUTOSAR_TPS_ECUConfiguration.pdf
[7] Specification of Diagnostic Event Manager
- AUTOSAR_SWS_DiagnosticEventManager.pdf
[8] Specification of ECU State Manager
- AUTOSAR_SWS_ECUStateManager.pdf
[9] General Requirements on SPAL
- AUTOSAR_SRS_SPALGeneral.pdf
[10] Requirements on GPT Driver
- AUTOSAR_SRS_GPTDriver.pdf
[11] Specification of ICU Driver
- AUTOSAR_SWS_ICUDriver.pdf
[12] Specification of MCU Driver
- AUTOSAR_SWS_MCUDriver.pdf
[13] Glossary
- AUTOSAR_TR_Glossary.pdf
[14] Basic Software Module Description Template
- AUTOSAR_TPS_BSWModuleDescriptionTemplate.pdf
[15] General Specification of Basic Software Modules
- AUTOSAR_SWS_BSWGeneral.pdf
Related standards and norms
[16] IEC 7498-1 The Basic Model, IEC Norm, 1994
Related specification
AUTOSAR provides a General Specification on Basic Software modules [15] (SWS BSW General), which is also valid for GPT Driver.
Thus, the specification SWS BSW General shall be considered as additional and required specification for GPT Driver.
对其他模块的依赖
Module DET [5]
In development mode the Error hook-function of module DET [5] will be called.
Module MCU [12]
The GPT depends on the system clock, prescaler(s) and PLL. Thus, changes of the system clock (e.g. PLL on to PLL off) also affect the clock settings of the GPT hardware. Module GPT will not take care of settings which configure the clock, prescaler(s) and PLL in its init function. This has to be done by the MCU module [12]. Hence the conversions between time and ticks shall be part of an upper layer.
Module EcuM [8]
The GPT driver reports the wakeup interrupts to the ECU State Manager for further processing.
File structure
The file structure is not defined within this specification completely. It depends on the implementation. The GPT driver shall provide at least the following files, if the conditions described are fulfilled:
[SWS_Gpt_00261]
[SRS_BSW_00164]
- Gpt_Irq.c shall include Gpt.h for the prototype declaration of the notification functions.
[SWS_Gpt_00375]
[ ]
- Gpt.c shall include Det.h in any case to be able to raise runtime error.
需求可追溯性
This chapter refers to input requirements specified in the SRS documents (Software Requirements Specifications) that are applicable for this software module.
The table below lists links to specification items of the GPT driver SWS document, which satisfy the input requirements. Only functional requirements are referenced.
General behavior
The GPT driver provides services for starting and stopping timer channels (logical timer instances assigned to a timer hardware), individual for each channel by calling of:
Gpt_StartTimer
Gpt_StopTimer
The "target time" is passed as a parameter to Gpt_StartTimer. So, for each start of a timer channel, the target time can be set individually.
The states and the state transitions of a timer channel are shown in Figure 1.
[SWS_Gpt_00329]
[ ]
- A timer channel starts counting at value zero.
[SWS_Gpt_00185]
[ ]
- If a timer channel is configured in "one-shot mode": If the timer has reached the target time (timer value = target time), the timer shall stop automatically and maintain its timer value unchanged. The channel state shall change from "running" to "expired".
- If a timer channel is configured in "continuous mode": If the timer has reached the target time (timer value = target time), the timer shall continue running with the value "0" at next timer tick. So, the time interval of the recurrence is: target time + 1. This interval shall be independently of implementation, e.g. interrupt delays.
[SWS_Gpt_00330]
[ ]
- If a timer channel is configured in "continuous mode": If supported by hardware, it shall be possible to realize a free running timer. This means: A timer which rolls over automatically by hardware, if the target time is set to the maximum value the timer is able to count (max value = 2n -1, n = number of bits).
Gpt_GetTimeElapsed
Gpt_GetTimeRemaining
[SWS_Gpt_00331]
[ ]
- If supported by hardware, a timer channel shall be able to be configured to call a notification function. If enabled, the function is called when the target time is reached (timer value = target time).
Interrupt notifications can be enabled and disabled at runtime individually for each channel by calling of:
Gpt_EnableNotification
Gpt_DisableNotification
[SWS_Gpt_00127]
[SRS_Gpt_13601]
- If supported by hardware, a timer channel shall be able to be configured as wakeup source of the ECU. If enabled, the wakeup occurs when the target time is reached (timer value = target time).
Wakeup interrupts can be enabled and disabled at runtime individually for each channel by calling of:
Gpt_EnableWakeup
Gpt_DisableWakeup
After initialization the GPT driver is in "normal mode". A wakeup interrupt can only occur when the driver is switched to "sleep mode". The operation mode can be set by calling of:
Gpt_SetMode
For a detailled description on wakeup handling please refer to the ECU State Manager specification [8].
The operation modes and the possible mode transitions of the GPT driver are shown in Figure 5.
Beside the possibility to configure individual timer channels with individual properties, some GPT Predef Timers are defined. The API specified for "GPT timer channels" can not be used for GPT Predef Timers.
[SWS_Gpt_00382]
[SRS_Gpt_13604]
- A GPT Predef Timer is a free running up counter (user point of view). If the timer has reached the maximum value (max value = 2n -1, n=number of bits), the timer shall continue running with the value "0" at next timer tick.
[SWS_Gpt_00383]
[SRS_Gpt_13605]
Which GPT Predef Timer(s) can be enabled depends on clock and available timer hardware (prescaler, width of timer register). It is recommended to enable all GPT Predef Timers to ensure compatibility of time based functionality for all platforms.
It is recommended to use one hardware timer per tick duration and to supply the hardware timer directly with the clock source "fclock = 1 / (tick duration)" by good choice of clock and prescaler(s). By this, the values of the timer counter register can be used directly without any need of adaptation (computation) for performance reasons. A lower bit timer can be derived from a higher bit timer by a simple software mask operation.
For implementation of GPT Predef Timers, special hardware features may be used:
- Timers may be cascaded asynchronously to use a timer as a prescaler.
- Timers may be cascaded synchronously to extend the timer range (number of bits).
- Timers with bit number greater than 32 bit may be used.
- Assembler code may be used to perform 64 bit arithmetic, if necessary GPT internal, e.g. if a 48 bit timer with tick duration 250 ns or 1 |¨¬s is used for all GPT Predef Timers.
[SWS_Gpt_00385]
[SRS_Gpt_13606]
- It shall be possible to configure which GPT Predef Timers are enabled.
[SWS_Gpt_00386]
[ ]
- If a GPT Predef Timer is enabled, the timer(s) with the same tick duration and lower bit number(s) shall be enabled also.
Implementation specific configuration parameters are allowed if needed, e.g. to select the used hardware unit.
All enabled GPT Predef Timers run after calling of:
Gpt_Init
(SWS_Gpt_00390)
Gpt_SetMode(GPT_MODE_NORMAL)
(SWS_Gpt_00392)
All enabled GPT Predef Timers are stopped by calling of:
Gpt_DeInit
(SWS_Gpt_00391)
Gpt_SetMode(GPT_MODE_SLEEP)
(SWS_Gpt_00393)
The current time value of the GPT Predef Timers can be got by calling of:
Gpt_GetPredefTimerValue
(SWS_Gpt_00394)
Version checking
For details refer to the chapter 5.1.8 "Version Check" in SWS_BSWGeneral.
Error classification
Section 7.x "Error Handling" of the document "General Specification of Basic Software Modules" describes the error handling of the Basic Software in detail. Above all, it constitutes a classification scheme consisting of five error types which may occur in BSW modules.
Based on this foundation, the following section specifies particular errors arranged in the respective subsections below.
Development Errors
[SWS_Gpt_91000]
[ ]
[SWS_Gpt_91001]
[ ]
API specification
Imported types
In this chapter all types included from the following modules are listed:
[SWS_Gpt_00278]
[SRS_BSW_00348]
Type Definitions
Gpt_ConfigType
[SWS_Gpt_00357]
[SRS_BSW_00404]
[SRS_BSW_00405]
[SRS_BSW_00438]
[SRS_BSW_00305]
[SRS_BSW_00414]
[SRS_SPAL_12263]
Gpt_ChannelType
[SWS_Gpt_00358]
[SRS_BSW_00305]
Gpt_ValueType
[SWS_Gpt_00359]
[SRS_BSW_00305]
[SRS_SPAL_12063]
[SRS_Gpt_12328]
Gpt_ModeType
[SWS_Gpt_00360]
[SRS_BSW_00441]
[SRS_BSW_00305]
Gpt_PredefTimerType
[SWS_Gpt_00389]
[SRS_Gpt_13605]
Function definitions
This is a list of functions provided for upper layer modules.
Gpt_GetVersionInfo
[SWS_Gpt_00279]
[SRS_BSW_00407]
[SWS_Gpt_00338]
[SRS_BSW_00323]
- If development error detection is enabled for the GPT module: If the parameter VersionInfoPtr is a null pointer, the function Gpt_GetVersionInfo shall raise the error GPT_E_PARAM_POINTER.
Gpt_Init
[SWS_Gpt_00280]
[SRS_BSW_00404]
[SRS_BSW_00405]
[SRS_BSW_00438]
[SRS_BSW_00101]
[SRS_BSW_00358]
[SRS_BSW_00414]
[SRS_SPAL_12057]
[SWS_Gpt_00006]
[SRS_BSW_00101]
[SRS_SPAL_12057]
- The function Gpt_Init shall initialize the hardware timer module according to a configuration set referenced by ConfigPtr.
[SWS_Gpt_00107]
[ ]
- The function Gpt_Init shall disable all interrupt notifications, controlled by the GPT driver.
[SWS_Gpt_00068]
[SRS_SPAL_12125]
- The function Gpt_Init shall only initialize the configured resources. Resources that are not configured in the configuration file shall not be touched.
The following rules regarding initialization of controller registers shall apply to this driver implementation:
[SWS_Gpt_00352]
[SRS_SPAL_12461]
- If the hardware allows for only one usage of the register, the driver module implementing that functionality is responsible for initializing the register.
[SWS_Gpt_00353]
[SRS_SPAL_12461]
- If the register can affect several hardware modules and if it is an I/O register it shall be initialized by the PORT driver.
[SWS_Gpt_00354]
[SRS_SPAL_12461]
- If the register can affect several hardware modules and if it is not an I/O register it shall be initialized by the MCU driver.
[SWS_Gpt_00355]
[SRS_SPAL_12461]
- One-time writable registers that require initialization directly after reset shall be initialized by the startup code.
[SWS_Gpt_00356]
[SRS_SPAL_12461]
- All other registers shall be initialized by the startup code.
[SWS_Gpt_00307]
[ ]
- If development error detection is enabled for the GPT module: If the GPT driver is not in operation mode "uninitialized", the function Gpt_Init shall raise the error GPT_E_ALREADY_INITIALIZED.
[SWS_Gpt_00258]
[ ]
- The function Gpt_Init shall disable all wakeup interrupts, controlled by the GPT driver.
[SWS_Gpt_00339]
[ ]
- The function Gpt_Init shall set the operation mode of the GPT driver to "normal mode". This leads to a behavior like Gpt_SetMode is called with parameter GPT_MODE_NORMAL.
[SWS_Gpt_00309]
[ ]
- A re-initialization of the GPT driver by executing the Gpt_Init function requires a de-initialization before by executing a Gpt_DeInit.
[SWS_Gpt_00390]
[SRS_Gpt_13607]
- The function Gpt_Init shall start all enabled GPT Predef Timers at value "0".
Gpt_DeInit
[SWS_Gpt_00281]
[SRS_BSW_00336]
[SRS_SPAL_12163]
[SRS_Gpt_12116]
[SWS_Gpt_00008]
[SRS_BSW_00336]
[SRS_SPAL_12163]
[SRS_Gpt_12116]
- The function Gpt_DeInit shall deinitialize the hardware used by the GPT driver (depending on configuration) to the power on reset state. Values of registers which are not writeable are excluded. It's the responsibility of the hardware design that the state does not lead to undefined activities in the MCU.
[SWS_Gpt_00105]
[ ]
- The function Gpt_DeInit shall disable all interrupt notifications and wakeup interrupts, controlled by the GPT driver.
[SWS_Gpt_00162]
[SRS_Gpt_12116]
- The function Gpt_DeInit shall influence only the peripherals, which are allocated by the static configuration.
[SWS_Gpt_00308]
[SRS_Gpt_12116]
- If a postbuild multiple selectable configuration variant was used, the function Gpt_DeInit shall further influence only the peripherals, which are allocated by the runtime configuration set passed by the previous call of the function Gpt_Init.
[SWS_Gpt_00194]
[SRS_BSW_00171]
- The function Gpt_DeInit shall be pre compile time configurable On/Off by the configuration parameter: GptDeInitApi.
[SWS_Gpt_00363]
[ ]
- The function Gpt_DeInit shall set the operation mode of the GPT driver to "uninitialized".
[SWS_Gpt_00234]
[ ]
- If any timer channel is in state "running", the function Gpt_DeInit shall raise the runtime error GPT_E_BUSY.
[SWS_Gpt_00220]
[SRS_BSW_00406]
- If development error detection is enabled for the GPT module: If the driver is not initialized, the function Gpt_DeInit shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00391]
[SRS_Gpt_13607]
- The function Gpt_DeInit shall stop all enabled GPT Predef Timers.
Gpt_GetTimeElapsed
[SWS_Gpt_00282]
[SRS_Gpt_12117]
[SWS_Gpt_00010]
[SRS_Gpt_12117]
- The function Gpt_GetTimeElapsed shall return the time already elapsed. When the channel is in mode "one-shot mode", this is the value relative to the point in time, the channel has been started.
[SWS_Gpt_00361]
[ ]
- When the channel is in mode "continuous mode", the return value of Gpt_GetTimeElapsed is the value relative to the last recurrence (target time reached) or to the start of the channel before the first recurrence occurs.
[SWS_Gpt_00295]
[ ]
- If the function Gpt_GetTimeElapsed is called on a timer channel in state "initialized" (channel started never before), the function shall return the value "0".
[SWS_Gpt_00297]
[ ]
- If the function Gpt_GetTimeElapsed is called on a timer channel in state "stopped", the function shall return the time value at the moment of stopping.
[SWS_Gpt_00299]
[ ]
- If the function Gpt_GetTimeElapsed is called on a channel configured for "one-shot mode" in state "expired" (timer has reached the target time), the function shall return the target time.
[SWS_Gpt_00113]
[ ]
- The function Gpt_GetTimeElapsed shall be fully reentrant, this means even for the same timer channel.
[SWS_Gpt_00195]
[SRS_BSW_00171]
- The function Gpt_GetTimeElapsed shall be pre compile time configurable On/Off by the configuration parameter: GptTimeElapsedApi.
[SWS_Gpt_00222]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_GetTimeElapsed shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00210]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_GetTimeElapsed shall raise the error GPT_E_PARAM_CHANNEL.
Gpt_GetTimeRemaining
[SWS_Gpt_00283]
[SRS_Gpt_12117]
[SWS_Gpt_00083]
[SRS_Gpt_12117]
- The function Gpt_GetTimeRemaining shall return the timer value remaining until the target time will be reached next time. The remaining time is the "target time" minus the time already elapsed.
[SWS_Gpt_00301]
[ ]
- If the function Gpt_GetTimeRemaining is called on a timer channel in state "initialized" (channel started never before), the function shall return the value "0".
[SWS_Gpt_00303]
[ ]
- If the function Gpt_GetTimeRemaining is called on a timer channel in state "stopped", the function shall return the remaining time value at the moment of stopping.
[SWS_Gpt_00305]
[ ]
- If the function Gpt_GetTimeRemaining is called on a channel configured for "one-shot mode" in state "expired" (timer has reached the target time), the function shall return the value "0".
[SWS_Gpt_00114]
[ ]
- The function Gpt_GetTimeRemaining shall be fully reentrant, this means even for the same timer channel.
[SWS_Gpt_00196]
[SRS_BSW_00171]
- The function Gpt_GetTimeRemaining shall be pre compile time configurable On/Off by the configuration parameter: GptTimeRemainingApi.
[SWS_Gpt_00223]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_GetTimeRemaining shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00211]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_GetTimeRemaining shall raise the error GPT_E_PARAM_CHANNEL.
Gpt_StartTimer
[SWS_Gpt_00284]
[SRS_Gpt_12128]
[SWS_Gpt_00274]
[SRS_Gpt_12128]
- The function Gpt_StartTimer shall start the selected timer channel with a defined target time.
[SWS_Gpt_00275]
[SRS_Gpt_12128]
- If configured and enabled, an interrupt notification or a wakeup interrupt occurs, when the target time is reached.
[SWS_Gpt_00115]
[ ]
- The function Gpt_StartTimer shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00364]
[ ]
- The state of the selected timer channel shall be changed to "running" if Gpt_StartTimer is called.
[SWS_Gpt_00212]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_StartTimer shall raise the error GPT_E_PARAM_CHANNEL.
[SWS_Gpt_00218]
[SRS_BSW_00323]
- If development error detection is enabled for GPT module: The function Gpt_StartTimer shall raise the error GPT_E_PARAM_VALUE if the parameter Value is "0" or not within the allowed range (exceeding the maximum timer resolution).
[SWS_Gpt_00224]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_StartTimer shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00084]
[ ]
- If the function Gpt_StartTimer is called on a channel in state "running", the function shall raise the runtime error GPT_E_BUSY.
Gpt_StopTimer
[SWS_Gpt_00285]
[SRS_Gpt_12119]
[SWS_Gpt_00013]
[SRS_Gpt_12119]
- The function Gpt_StopTimer shall stop the selected timer channel.
[SWS_Gpt_00343]
[ ]
- The state of the selected timer channel shall be changed to "stopped" if Gpt_StopTimer is called.
[SWS_Gpt_00099]
[ ]
- If development error detection is enabled for GPT module: If the function Gpt_StopTimer is called on a channel in state "initialized", "stopped" or "expired", the function shall not raise a development error.
[SWS_Gpt_00344]
[ ]
- If the function Gpt_StopTimer is called on a channel in state "initialized", "stopped" or "expired", the function shall leave without any action (no change of the channel state).
[SWS_Gpt_00116]
[ ]
- The function Gpt_StopTimer shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00213]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_StopTimer shall raise the error GPT_E_PARAM_CHANNEL.
[SWS_Gpt_00225]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_StopTimer shall raise the error GPT_E_UNINIT.
Gpt_EnableNotification
[SWS_Gpt_00286]
[SRS_Gpt_12121]
[SWS_Gpt_00014]
[SRS_SPAL_00157]
[SRS_SPAL_12067]
[SRS_Gpt_12121]
- The function Gpt_EnableNotification shall enable the interrupt notification of the referenced channel configured for notification (see also SWS_Gpt_00233). The function shall save an attribute like "notification enabled" of the channel.
Comment:
This attribute affects the interrupt notification always when the driver is in "normal mode". In "sleep mode" the attribute has no influence.
[SWS_Gpt_00117]
[ ]
- The function Gpt_EnableNotification shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00199]
[SRS_BSW_00171]
- The function Gpt_EnableNotification shall be pre compile time configurable On/Off by the configuration parameter: GptEnableDisableNotificationApi.
[SWS_Gpt_00226]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_EnableNotification shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00214]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_EnableNotification shall raise the error GPT_E_PARAM_CHANNEL.
[SWS_Gpt_00377]
[ ]
- If development error detection is enabled for GPT module: If no valid notification function is configured (GptNotification), the function Gpt_EnableNotification shall raise the error GPT_E_PARAM_CHANNEL.
Gpt_DisableNotification
[SWS_Gpt_00287]
[SRS_Gpt_12122]
[SWS_Gpt_00015]
[SRS_SPAL_00157]
[SRS_Gpt_12122]
[SRS_SPAL_12067]
- The function Gpt_DisableNotification shall disable the interrupt notification of the referenced channel configured for notification (see also SWS_Gpt_00233). The function shall save an attribute like "notification disabled" of the channel.
Comment:
This attribute affects the interrupt notification always when the driver is in "normal mode". In "sleep mode" the attribute has no influence.
[SWS_Gpt_00118]
[ ]
- The function Gpt_DisableNotification shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00200]
[SRS_BSW_00171]
- The function Gpt_DisableNotification shall be pre compile time configurable On/Off by the configuration parameter: GptEnableDisableNotificationApi.
[SWS_Gpt_00227]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_DisableNotification shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00217]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration), the function Gpt_DisableNotification shall raise the error GPT_E_PARAM_CHANNEL.
[SWS_Gpt_00379]
[ ]
- If development error detection is enabled for GPT module: If no valid notification function is configured (GptNotification), the function Gpt_DisableNotification shall raise the error GPT_E_PARAM_CHANNEL.
Gpt_SetMode
[SWS_Gpt_00288]
[SRS_SPAL_12169]
[SRS_Gpt_13603]
[SWS_Gpt_00151]
[SRS_SPAL_12169]
[SRS_Gpt_13603]
- The function Gpt_SetMode shall set the operation mode of the GPT driver to the given mode parameter.
[SWS_Gpt_00255]
[ ]
- The function Gpt_SetMode is only available if the configuration parameter GptReportWakeupSource is enabled.
[SWS_Gpt_00152]
[SRS_Gpt_13603]
- If the parameter Mode has the value GPT_MODE_NORMAL: The function Gpt_SetMode shall enable the interrupt notification for all channels which are configured for notification and the notification is enabled (stored attribute) via the function Gpt_EnableNotification prior. All other interrupt notifications shall be disabled.
[SWS_Gpt_00153]
[SRS_Gpt_13603]
- If the parameter Mode has the value GPT_MODE_SLEEP: The function Gpt_SetMode shall enable the wakeup interrupts for all channels which are configured for wakeup and the wakeup is enabled (stored attribute) via the function Gpt_EnableWakeup prior. All other wakeup interrupts shall be disabled.
[SWS_Gpt_00164]
[ ]
- If the function Gpt_SetMode is called with parameter Mode has the value GPT_MODE_SLEEP: All timer channels in state "running" which are not configured for wakeup or not enabled for wakeup interruption (stored attribute) via Gpt_EnableWakeup shall be stopped and their state shall be changed to "stopped".
[SWS_Gpt_00165]
[ ]
- If the parameter Mode has the value GPT_MODE_NORMAL, the function Gpt_SetMode shall not restart automatically the timer channels which have been stopped by entering the sleep mode.
[SWS_Gpt_00341]
[ ]
- If the parameter has the value GPT_MODE_SLEEP the function Gpt_SetMode shall not start a wakeup timer automatically. First, the user shall call Gpt_StartTimer to start a wakeup timer, after this the user shall call Gpt_SetMode with parameter GPT_MODE_SLEEP.
[SWS_Gpt_00228]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_SetMode shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00231]
[ ]
- If development error detection is enabled for GPT module: The function Gpt_SetMode shall raise the error GPT_E_PARAM_MODE if the parameter Mode is invalid.
[SWS_Gpt_00201]
[SRS_BSW_00171]
- The function Gpt_SetMode shall be pre compile time configurable On/Off by the configuration parameter: GptWakeupFunctionalityApi.
[SWS_Gpt_00392]
[SRS_Gpt_13607]
- If the parameter Mode has the value GPT_MODE_NORMAL: If the driver is in "sleep mode", the function Gpt_SetMode shall restart all enabled GPT Predef Timers at value "0".
[SWS_Gpt_00393]
[SRS_Gpt_13607]
- If the parameter Mode has the value GPT_MODE_SLEEP: The function Gpt_SetMode shall stop all enabled GPT Predef Timers.
Gpt_DisableWakeup
[SWS_Gpt_00289]
[SRS_Gpt_13602]
[SWS_Gpt_00159]
[SRS_Gpt_13602]
- The function Gpt_DisableWakeup shall disable the wakeup interrupt of the referenced channel configured for wakeup. The function shall save an attribute like "wakeup disabled" of the channel.
Comment:
This attribute affects the wakeup interrupt always when the driver is in "sleep mode". In "normal mode" the attribute has no influence.
[SWS_Gpt_00157]
[ ]
- The function Gpt_DisableWakeup is only feasible, if GptReportWakeupSource is statically configured available.
[SWS_Gpt_00155]
[ ]
- The function Gpt_DisableWakeup shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00202]
[SRS_BSW_00171]
- The function Gpt_DisableWakeup shall be pre compile time configurable On/Off by the configuration parameter: GptWakeupFunctionalityApi.
[SWS_Gpt_00215]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration) or channel wakeup is not enabled by configuration (GptEnableWakeup), the function Gpt_DisableWakeup shall raise the error GPT_E_PARAM_CHANNEL.
[SWS_Gpt_00229]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_DisableWakeup shall raise the error GPT_E_UNINIT.
Gpt_EnableWakeup
[SWS_Gpt_00290]
[SRS_Gpt_13602]
[SWS_Gpt_00160]
[SRS_Gpt_13602]
- The function Gpt_EnableWakeup shall enable the wakeup interrupt of the referenced channel configured for wakeup. The function shall save an attribute like "wakeup enabled" of the channel.
Comment:
This attribute affects the wakeup interrupt always when the driver is in "sleep mode". In "normal mode" the attribute has no influence.
[SWS_Gpt_00158]
[ ]
- The function Gpt_EnableWakeup is only feasible, if GptReportWakeupSource is statically configured available.
[SWS_Gpt_00156]
[ ]
- The function Gpt_EnableWakeup shall be reentrant, if the timer channels used in concurrent calls are different.
[SWS_Gpt_00203]
[SRS_BSW_00171]
- The function Gpt_EnableWakeup shall be pre compile time configurable On/Off by the configuration parameter: GptWakeupFunctionalityApi.
[SWS_Gpt_00230]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_EnableWakeup shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00216]
[ ]
- If development error detection is enabled for GPT module: If the parameter Channel is invalid (not within the range specified by configuration) or channel wakeup is not enabled by configuration (GptEnableWakeup), the function Gpt_EnableWakeup shall raise the error GPT_E_PARAM_CHANNEL.
Gpt_CheckWakeup
[SWS_Gpt_00328]
[ ]
[SWS_Gpt_00321]
[ ]
- The function Gpt_CheckWakeup shall check if a wakeup capable GPT channel is the source for a wakeup event and call EcuM_SetWakeupEvent to indicate a valid timer wakeup event to the ECU State Manager [8].
[SWS_Gpt_00322]
[ ]
- The function Gpt_CheckWakeup is only feasible, if GptReportWakeupSource is statically configured available.
[SWS_Gpt_00323]
[ ]
- The function Gpt_CheckWakeup shall be reentrant, by reason of possible usage in concurrent interrupt service routines.
[SWS_Gpt_00324]
[ ]
- The function Gpt_CheckWakeup shall be pre compile time configurable On/Off by the configuration parameter: GptWakeupFunctionalityApi.
[SWS_Gpt_00325]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_CheckWakeup shall raise the error GPT_E_UNINIT.
Gpt_GetPredefTimerValue
[SWS_Gpt_00394]
[SRS_Gpt_13608]
Note:
It is strongly recommended to check the return value of the function Gpt_GetPredefTimerValue on user software level. When E_NOT_OK is returned the time value - pointed by TimeValuePtr - may be invalid and must not be used.
[SWS_Gpt_00395]
[SRS_Gpt_13608]
- The function Gpt_GetPredefTimerValue shall return the current value of the GPT Predef Timer passed by PredefTimer.
[SWS_Gpt_00396]
[ ]
- If the timer value of the function Gpt_GetPredefTimerValue is less than 32 bit (16bit or 24bit timer), the upper bits shall be filled with zero.
[SWS_Gpt_00397]
[SRS_Gpt_13608]
- The function Gpt_GetPredefTimerValue shall be fully reentrant, this means even for the same GPT Predef Timer.
[SWS_Gpt_00402]
[SRS_BSW_00406]
- If the GPT driver is not initialized, in "sleep mode" or the GPT Predef Timer is not enabled, the function Gpt_GetPredefTimerValue shall return E_NOT_OK.
Note:
This is to inform user software if the hardware timer is not running, independent of development error detection is enabled for GPT module enabled/disabled for the GPT module. The function Gpt_GetPredefTimerValue is used by the Time Service module which is part of the Services Layer. The user of the Time Service module shall have a chance to cope with missed timer support.
[SWS_Gpt_00398]
[SRS_BSW_00406]
- If development error detection is enabled for GPT module: If the driver is not initialized, the function Gpt_GetPredefTimerValue shall raise the error GPT_E_UNINIT.
[SWS_Gpt_00399]
[SRS_BSW_00323]
- If development error detection is enabled for GPT module: If the parameter PredefTimer is invalid, the function Gpt_GetPredefTimerValue shall raise the development error GPT_E_PARAM_PREDEF_TIMER.
[SWS_Gpt_00400]
[ ]
- If development error detection is enabled for GPT module: If the GPT Predef Timer passed by the parameter PredefTimer is not enabled, the function Gpt_GetPredefTimerValue shall raise the development error GPT_E_PARAM_PREDEF_TIMER.
[SWS_Gpt_00401]
[ ]
- If the driver is in "sleep mode", the function Gpt_GetPredefTimerValue shall raise the runtime error GPT_E_MODE.
[SWS_Gpt_00403]
[SRS_BSW_00369]
[SRS_BSW_00323]
- If development error detection is enabled for GPT module: If the parameter TimeValuePtr is a null pointer, the function Gpt_GetPredefTimerValue shall raise the error GPT_E_PARAM_POINTER.
Expected Interfaces
In this chapter all interfaces required from other modules are listed.
Mandatory Interfaces
This chapter defines all interfaces, which are required to fulfill the core functionality of the module.
[SWS_Gpt_00405]
[SRS_SPAL_00157]
[SRS_SPAL_12064]
Optional Interfaces
This chapter defines all interfaces, which are required to fulfill an optional functionality of the module.
[SWS_Gpt_00406]
[SRS_SPAL_00157]
[SWS_Gpt_00326]
[ ]
- EcuM_CheckWakeup shall be called within the Interrupt Service Routine, servicing the GPT channel wakeup event on wakeup-capable channels.
[SWS_Gpt_00327]
[SRS_SPAL_12129]
- The ISR, providing the wakeup events, shall be responsible for resetting the interrupt flags (if needed by hardware).
Configurable Interfaces
In this chapter all interfaces are listed where the target function could be configured. The target function is usually a call-back function. The names of these kinds of interfaces is not fixed because they are configurable.
GPT Notification
[SWS_Gpt_00292]
[SRS_BSW_00375]
[SRS_SPAL_12069]
The notification prototype Gpt_Notification_<channel> is for the notification callback function and shall be implemented by the user.
The GPT module's environment shall declare a separate notification for each channel to avoid parameters in notification services and to improve run time efficiency.
[SWS_Gpt_00086]
[ ]
- The callback notifications Gpt_Notification_<channel> shall be configurable as pointers to user defined functions within the configuration structure.
[SWS_Gpt_00209]
[SRS_BSW_00375]
[SRS_SPAL_12069]
- Each channel shall provide its own notification if configured.
[SWS_Gpt_00093]
[ ]
- When disabled, the GPT Driver will send no notification.
[SWS_Gpt_00233]
[SRS_SPAL_12067]
[SRS_Gpt_12120]
- The GPT Driver shall invoke a notification whenever the defined target time of the channel is reached.
[SWS_Gpt_00206]
[SRS_SPAL_12129]
- The ISR, providing the timer events, shall be responsible for resetting the interrupt flags (if needed by hardware) and calling the according notification function.
[SWS_Gpt_00362]
[ ]
- For all available channels, callback functions have to be declared by the configuration tool.
Error detection
[SWS_Gpt_00332]
[SRS_SPAL_12448]
- If the GptDevErrorDetect switch is enabled: When a development error occurs the corresponding GPT function shall skip the desired functionality (leave service without any action).
Sequence diagrams
All functions except Gpt_Init, Gpt_DeInit, Gpt_GetVersionInfo and Gpt_SetMode are synchronous and re-entrant.
Gpt_Init
The ECU State Manager (EcuM) is responsible for calling the init function.
Channel 2 is configured as "Continuous Mode"
Channel 1 is configured for "One-shot Mode"
The sequence diagram shown in this chapter explains the behavior of the driver, when the notification is disabled, while the timer is still running in continuous mode. If the notification is disabled, the user will not be informed, when the timer reaches the target time the 2nd time (period 2). This notification is discarded and not made up again, when the notification is reenabled.
Note:
Sequence charts on timer wakeup can be found in the ECU state manager specification [8].
Configuration specification
In general, this chapter defines configuration parameters and their clustering into containers. In order to support the specification Chapter 10.1 describes fundamentals. It also specifies a template (table) you shall use for the parameter specification. We intend to leave Chapter 10.1 in the specification to guarantee comprehension.
Chapter 10.2 specifies the structure (containers) and the parameters of the module GPT.
Chapter 10.3 specifies published information of the module GPT.
How to read this chapter
For details refer to the chapter 10.1 "Introduction to configuration specification" in SWS_BSWGeneral.
Containers and configuration parameters
The following chapters summarize all configuration parameters. The detailed meanings of the parameters describe Chapter 7 and Chapter 8
[SWS_Gpt_00407]
[ ]
- The GPT module shall reject configurations with partition mappings which are not supported by the implementation.
Gpt
[SWS_Gpt_CONSTR_00001]
[ ]
- The ECUC partitions referenced by GptKernelEcucPartitionRef shall be a subset of the ECUC partitions referenced by GptEcucPartitionRef.
[SWS_Gpt_CONSTR_00003]
[ ]
- If GptEcucPartitionRef references one or more ECUC partitions, GptKernelEcucPartitionRef shall have a multiplicity of one and reference one of these ECUC partitions as well.
[SWS_Gpt_CONSTR_00005]
[ ]
- In case of partition local timer resources, the module will operate as an independent instance in each of the partitions, means the called API will only target the partition it is called in.
GptClockReferencePoint
[SWS_Gpt_CONSTR_00002]
[ ]
- The ECUC partitions referenced by GptGroupEcucPartitionRef shall be a subset of the ECUC partitions referenced by GptEcucPartitionRef.
[SWS_Gpt_CONSTR_00004]
[ ]
- If GptEcucPartitionRef references one or more ECUC partitions, GptKernelEcucPartitionRef shall have a multiplicity of greater than zero and reference one or several of these ECUC partitions as well.
GptWakeupConfiguration
[SWS_Gpt_00380]
[ ]
- The standardized common published parameters as required by SRS_BSW_00402 in the SRS General on Basic Software Modules [3] shall be published within the header file of this module and need to be provided in the BSW Module Description. The according module abbreviation can be found in the List of Basic Software Modules [1].
Additional module-specific published parameters are listed below if applicable.
评论
发表评论