Autosar Sws Spihandlerdriver
Autosar Sws Spihandlerdriver
Autosar Sws Spihandlerdriver
AUTOSAR CP R20-11
Disclaimer
This work (specification and/or software implementation) and the material contained
in it, as released by AUTOSAR, is for the purpose of information only. AUTOSAR
and the companies that have contributed to it shall not be liable for any use of the
work.
The material contained in this work is protected by copyright and other types of
intellectual property rights. The commercial exploitation of the material contained in
this work requires a license to such intellectual property rights.
This work may be utilized or reproduced without any modification, in any form or by
any means, for informational purposes only. For any other purpose, no part of the
work may be utilized or reproduced, in any form or by any means, without permission
in writing from the publisher.
The work has been developed for automotive applications only. It has neither been
developed, nor tested for non-automotive applications.
The word AUTOSAR and the AUTOSAR logo are registered trademarks.
Table of Contents
10.2.2 SpiDemEventParameterRefs................................................................... 87
10.2.3 SpiGeneral ............................................................................................... 88
10.2.4 SpiSequence ............................................................................................ 93
10.2.5 SpiChannel............................................................................................... 95
10.2.6 SpiChannelList ......................................................................................... 98
10.2.7 SpiJob ...................................................................................................... 99
10.2.8 SpiExternalDevice .................................................................................. 101
10.2.9 SpiDriver ................................................................................................ 107
10.2.10 SpiPublishedInformation .................................................................. 108
10.3 Published information ............................................................................ 110
10.4 Configuration concept ............................................................................ 110
11 Not applicable requirements ................................................................................. 113
12 Appendix ............................................................................................................... 114
This specification describes the API for a monolithic SPI Handler/Driver. This soft-
ware module includes handling and driving functionalities. Main objectives of this
monolithic SPI Handler/Driver are to take the best of each microcontroller features
and to allow implementation optimization depending on static configuration to fit as
much as possible to ECU needs.
Acronym: Description:
DET Default Error Tracer – module to which errors are reported.
DEM Diagnostic Event Manager – module to which production relevant errors are report-
ed.
SPI Serial Peripheral Interface. It is exactly defined hereafter in this document.
CS Chip Select
MISO Master Input Slave Output
MOSI Master Output Slave Input
Abbreviation: Description:
EB Externally buffered channels. Buffers containing data to transfer are outside the SPI
Handler/Driver.
IB Internally buffered channels. Buffers containing data to transfer are inside the SPI
Handler/Driver.
ID Identification Number of an element (Channel, Job, Sequence).
Definition: Description:
Channel A Channel is a software exchange medium for data that are defined with the same
criteria: Config. Parameters, Number of Data elements with same size and data
pointers (Source & Destination) or location.
Job A Job is composed of one or several Channels with the same Chip Select (is not
released during the processing of Job). A Job is considered atomic and therefore
cannot be interrupted by another Job. A Job has an assigned priority.
Sequence A Sequence is a number of consecutive Jobs to transmit but it can be rescheduled
between Jobs using a priority mechanism. A Sequence transmission is interruptible
(by another Sequence transmission) or not depending on a static configuration.
3 Related documentation
[8] Glossary
AUTOSAR_TR_Glossary.pdf
Not related.
Thus, the specification SWS BSW General shall be considered as additional and re-
quired specification for SPI Handler Driver.
4.1 Limitations
No restrictions.
[SWS_Spi_00244] ⌈The SPI Handler/Driver module does not take care of setting
the registers which configure the clock, prescaler(s) and PLL in its init function. This
has to be done by the MCU module [9].⌋()
Note: SPI peripherals may depend on the system clock, prescaler(s) and PLL. Thus,
any change of the system clock (e.g. PLL on / PLL off / clock dividers) may also af-
fect the clock settings of the SPI hardware.
[SWS_Spi_00343] ⌈If Chip Selects are done using microcontroller pins the SPI
Handler/Driver has a relationship with PORT module [10]. In this case, this specifica-
tion assumes that these microcontroller pins are directly accessed by the SPI Han-
dler/Driver module without using APIs of DIO module.
Anyhow, the SPI depends on ECU hardware design and for that reason it may de-
pend on other modules.⌋()
6 Requirements traceability
7 Functional specification
The SPI (Serial Peripheral Interface) has a 4-wire synchronous serial interface. Data
communication is enabled with a Chip select wire (CS). Data is transmitted with a 3-
wire interface consisting of wires for serial data output (MOSI), serial data input (MI-
SO) and serial clock (CLOCK).
Feature #m
Feature #1
#1
#k
…
Feature #1
Feature #n
…
HAL
…
SPI Handler/Driver
MCAL
µC Simple SPI
Queued SPI
DMA SPI
This document specifies the following 3 Levels of Scalable Functionality for the SPI
Handler/Driver:
LEVEL 0, Simple Synchronous SPI Handler/Driver: the communication is
based on synchronous handling with a FIFO policy to handle multiple access-
es. Buffer usage is configurable to optimize and/or to take advantage of HW
capabilities.
To improve the scalability, each level has optional features which are configurable
(ON / OFF) or selectable. These are described in detail in the dedicated chapters.
This chapter, on the one hand, introduces common behavior and configuration for all
levels. On the other, it specifies the behavior of each level and also the allowed op-
tional features.
[SWS_Spi_00263] ⌈Chip Select shall be handled during Job transmission and shall
be released at the end of it. This Chip Select handling shall be done according to the
Job configuration parameters.⌋()
[SWS_Spi_00370] ⌈It shall be possible to define if the Chip Select handling is man-
aged autonomously by the HW peripheral, without explicit chip select control by the
driver, or the SPI driver shall drive the chip select lines explicitly as DIO (see
ECUC_Spi_00212).⌋()
A Channel is defined one time but it could belong to several Jobs according to the
user needs and this software specification.
[SWS_Spi_00368] ⌈Each Channel shall have an associated index which is used for
specifying the order of the Channel within the Job.⌋()
[SWS_Spi_00262] ⌈If a Job contains more than one Channel, all Channels con-
tained have the same Job properties during transmission and shall be linked together
statically.⌋()
A Job is defined one time but it could belong to several Sequences according to the
user needs and this software specification.
[SWS_Spi_00236] ⌈If it contains more than one, all Jobs contained have the same
Sequence properties during transmission and shall be linked together statically.⌋()
A Channel used for a transmission should have its parameters configured but it is
allowed to pass Null pointers as source and destination pointers to generate a dum-
my transmission (See also [SWS_Spi_00028] & [SWS_Spi_00030]).
Sequence a
linkage
Job n Job m
Channel x Channel y Channel z
CLOCK
MOSI D D D D D D D D D D D D D D D D
MISO D D D D D D D D D D D D D D D D
CSn
CSm
...
CSo
scheduling according
to job priority is done
data of Channel x is
initiated via API call
bus is arbitrated by
Channel of job n is
tranceived without
finished, the next
bus is released
bus is released
transmission of
Sequence a is
job m
job n
Channel data may differ from the hardware handled and user (client application) giv-
en. On the client side the data is handled in 8, 16 or 32bits mode base on SpiDa-
taWidth (see chapter 8.2.5). On the microcontroller side, the hardware may handle
between 1 and 32bits or may handle a fixed value (8 or 16bits) and this width is con-
figurable for each Channel (see SpiDataWidth)..
[SWS_Spi_00149] ⌈The SPI Handler/Driver shall take care of the differences be-
tween the frame width of channel (SpiDataWidth) and data access data type (given
by SWS_Spi_00437).⌋()
[SWS_Spi_00290] ⌈If data access casting type is superior to data width (for exam-
ple SpiDataWidth = 12bits, data access is 16 bits), the data transmitted through the
SPI Handler/Driver shall send the lower part, ignore the upper part. Receive the low-
er part, extend with zero.⌋()
This ensures that the user always gets the same interface.
In order to allow taking advantages of all microcontroller capabilities but also to allow
sending/receiving of data to/from a dedicated memory location, all levels have an
optional feature with respect to the location of Channel Buffers.
Both channel buffering methods may be used depending on the 3 use cases de-
scribed below:
Usage 0: the SPI Handler/Driver manages only Internal Buffers.
Usage 1: the SPI Handler/Driver manages only External Buffers.
Usage 2: the SPI Handler/Driver manages both buffers types.
[SWS_Spi_00052] ⌈For the IB Channels, the Handler/Driver shall provide the buffer-
ing but it is not able to take care of the consistency of the data in the buffer during
[SWS_Spi_00049] ⌈The channel data received shall be stored in 1 entry deep inter-
nal buffers by channel. The SPI Handler/Driver shall not take care of the overwriting
of these “receive” buffers by another transmission on the same channel.⌋()
[SWS_Spi_00438] ⌈The Handler/Driver shall provide separate buffer for receive and
transmit to ensure that transmitted data are not overwritten by the receive data.⌋()
The intention of External Buffer channels is to reuse existing buffers that are located
outside. That means the SPI Handler/Driver does not monitor them.
[SWS_Spi_00053] ⌈For EB Channels the application shall provide the buffering and
shall take care of the consistency of the data in the buffer during transmis-
sion.⌋(SRS_SPAL_12075, SRS_Spi_12025, SRS_Spi_12198, SRS_Spi_12200,
SRS_Spi_12261, SRS_Spi_12262, SRS_Spi_12202, SRS_Spi_12103)
[SWS_Spi_00112] ⌈The size of the Channel buffer is either fixed or variable. A max-
imum size for the Channel buffer shall be defined by the configuration.⌋()
[SWS_Spi_00280] ⌈The buffer provided by the application for the SPI Handler Driv-
er may have a different size.⌋()
IB Channels
It provides… A more abstracted concept (buffering mechanisms are hidden)
Actual and future optimal implementation taken profit of HW buffer facili-
ties (Given size of 256 bytes covers nowadays requirements).
Suggested Daisy-chain implementation.
Note:
For each channel, the user configures the number of IB buffers (at least 1) if IB is
selected for the current channel, or the maximum of data for EB buffers if EB is se-
lected for the current channel.
A simple synchronous transmission means that the function calling the transmission
service is blocked during the ongoing transmission until the transmission is finished.
Then SPI buses are assigned to Jobs and not to Sequences. Consequently, Jobs, on
different SPI buses, could belong to the same Sequence. Therefore:
[SWS_Spi_00084] ⌈If different Jobs (and consequently also Sequences) have com-
mon Channels, the SPI Handler/Driver’ environment shall ensure that read and/or
write functions are not called during transmission.⌋(SRS_Spi_12170)
Read and write functions can not guarantee the data integrity while Channel data is
being transmitted.
An asynchronous transmission means that the user calling the transmission service
is not blocked when the transmission is on-going. Furthermore, the user can be noti-
fied at the end of transmission1.
[SWS_Spi_00162] ⌈The LEVEL 1 SPI Handler/Driver shall offer an asynchronous
transfer service for SPI buses. An asynchronous transmission means that the user
calling the transmission service is not blocked when the transmission is on go-
ing.⌋(SRS_Spi_12099, SRS_Spi_12101, SRS_Spi_12103)
1
This basic asynchronous behaviour might be implemented either by using interrupt or by polling
mechanism. This software design choice is not in the scope of this document, but only solution is re-
quired for the LEVEL 1.
27 of 115 Document ID 38: AUTOSAR_SWS_SPIHandlerDriver
Specification of SPI Handler / Driver
AUTOSAR CP R20-11
This Handler/Driver will be used by several software modules which may be inde-
pendent from each other and also may belong to different layers. Therefore, priorities
will be assigned to Jobs in order to figure out specific cases of multiple accesses.
These cases usually occur within real time systems based on asynchronous mecha-
nisms.
[SWS_Spi_00093] ⌈Priority order of jobs shall be from the lower to the higher value
defined, higher value higher priority (from 0, the lower to 3, the higher, limited to 4
priority levels see [SWS_Spi_00009]).⌋(SRS_Spi_12260, SRS_Spi_12150)
With reference to Jobs priorities, this Handler/Driver needs rules to make a decision
in these specific cases of multiple accesses.
This monolithic SPI Handler/Driver is able to handle one to n SPI busses according
to the microcontroller used. But SPI busses are assigned to Jobs and not to Se-
quences. Consequently, Jobs on different SPI buses could belong to the same Se-
quence. Therefore:
[SWS_Spi_00118] ⌈If Jobs are configured with a specific end notification function,
the SPI Handler/Driver shall call this notification function at the end of the Job trans-
mission.⌋(SRS_Spi_12108)
The intention of the Mixed Sequences feature is to provide a software module with
specific asynchronous mechanisms, if, for instance, very long Sequences that could
or should be suspended by others with higher priority are used.
2
The intention of this requirement is not to enforce any implementation solution in comparison with
another one. But, it is only to ensure that anyhow, all Sequences will be considered as Non Interrupti-
ble Sequences.
30 of 115 Document ID 38: AUTOSAR_SWS_SPIHandlerDriver
Specification of SPI Handler / Driver
AUTOSAR CP R20-11
[SWS_Spi_00156] ⌈Both the polling mechanism and interrupt mechanism modes for
SPI busses shall be selectable during execution time (see [SWS_Spi_00188]).⌋()
For asynchronous levels, LEVEL 1 and LEVEL 2, the SPI Handler/Driver can call end
notification functions at the end of a Job and/or Sequence transmission (see
[SWS_Spi_00118]). In a second time, in case of interruptible Sequences (that could
be suspended), if another Sequence transmit request is pending, a rescheduling is
also done by the SPI Handler/Driver in order to elect the next Job to transmit (see
[SWS_Spi_00014]).
[SWS_Spi_00088] ⌈For asynchronous levels, LEVEL 1 and LEVEL 2, the SPI Han-
dler/Driver can call end notification functions at the end of a Job.⌋()
[SWS_Spi_00268] ⌈For asynchronous levels, LEVEL 1 and LEVEL 2, the SPI Han-
dler/Driver can call end notification functions at the end of a Sequence transmis-
sion.⌋()
[SWS_Spi_00270] ⌈In case call end notification function and rescheduling are fully
done by software, the order between these shall be first scheduling and then the call
of end notification function executed.⌋()
[SWS_Spi_00271] ⌈In case call end notification function and rescheduling are fully
done by hardware, the order could not be configured as required; the order shall be
completely documented.⌋()
The section 7.2 "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.
[SWS_Spi_91001]⌈
Error
Type of error Related error code
value
SPI_E_PARAM_
API service called with wrong parameter 0x0A
CHANNEL
API SPI_Init service called while the SPI driver has already SPI_E_ALREADY_
0x4A
been initialized INITIALIZED
⌋()
[SWS_Spi_91002]⌈
Type of error Related error code Error value
⌋()
[SWS_Spi_00383]⌈
Error Name: SPI_E_HARDWARE_ERROR
Short Description: An hardware error occurred during asynchronous or synchronous SPI
transmit
Long Description: This Extended Production Error shall be issued when any error bit inside
the SPI hardware transmit status register is raised
Fail The SPI transmit status register information shall be re-
ported to DEM as Dem_SetEventStatus
(SPI_E_HARDWARE_ERROR,
DEM_EVENT_STATUS_FAILED) when any error bit in-
side the SPI transmit status register is set.
(SWS_Spi_00385)
Detection Criteria:
Pass The SPI transmit status register information shall be re-
ported to DEM as Dem_SetEventStatus
(SPI_E_HARDWARE_ERROR,
DEM_EVENT_STATUS_PASSED) when no error bit in-
side the SPI transmit status register is set.
(SWS_Spi_00386)
Secondary Parameters: N/A
Time Required: N/A
Monitor Frequency continuous
⌋()
[SWS_Spi_00385]⌈ When any error bit inside the SPI transmit status register is set,
the SPI transmit status register information shall be reported to DEM as
Dem_SetEventStatus (SPI_E_HARDWARE_ERROR,
DEM_EVENT_STATUS_FAILED)⌋()
[SWS_Spi_00386]⌈ When no error bit inside the SPI transmit status register is set,
the SPI transmit status register information shall be reported to DEM as
Dem_SetEventStatus (SPI_E_HARDWARE_ERROR,
DEM_EVENT_STATUS_PASSED)⌋()
8 API specification
In this chapter all types included from the following modules are listed:
[]⌈
Module Header File Imported Type
Rte_Dem_Type.h Dem_EventIdType
Dem
Rte_Dem_Type.h Dem_EventStatusType
Std_Types.h Std_ReturnType
Std
Std_Types.h Std_VersionInfoType
⌋()
8.2 Type definitions
8.2.1 Spi_ConfigType
[SWS_Spi_00372]⌈
Name Spi_ConfigType
Kind Structure
Implementation Specific
Elements Type --
Comment The contents of the initialization data structure are SPI specific.
This type of the external data structure shall contain the initialization data for the SPI
Description
Handler/Driver.
Available
Spi.h
via
⌋()
[SWS_Spi_00344] ⌈The description of the type Spi_ConfigType is implementation
specific and it shall be provided for external use.⌋()
8.2.2 Spi_StatusType
[SWS_Spi_00373]⌈
Name Spi_StatusType
Kind Enumeration
Range SPI_IDLE 0x01 The SPI Handler/Driver is not currently transmitting any Job.
Description This type defines a range of specific status for SPI Handler/Driver.
⌋(SRS_BSW_00406, SRS_BSW_00335)
[SWS_Spi_00061] ⌈The type Spi_StatusType defines a range of specific status for
SPI Handler/Driver. It informs about the SPI Handler/Driver status or specified SPI
Hardware microcontroller peripheral.⌋(SRS_BSW_00335)
[SWS_Spi_00259] ⌈The type Spi_StatusType can be obtained calling the API ser-
vice Spi_GetStatus.⌋()
[SWS_Spi_00260] ⌈The type Spi_StatusType can be obtained calling the API ser-
vice Spi_GetHWUnitStatus.⌋()
[SWS_Spi_00011] ⌈After reset, the type Spi_StatusType shall have the default
value SPI_UNINIT.⌋()
[SWS_Spi_00346] ⌈API service Spi_GetStatus shall return SPI_IDLE when The SPI
Handler/Driver is not currently transmitting any Job.⌋()
[SWS_Spi_00347] ⌈API service Spi_GetStatus shall return SPI_BUSY when The
SPI Handler/Driver is performing a SPI Job transmit.⌋()
8.2.3 Spi_JobResultType
[SWS_Spi_00374]⌈
Name Spi_JobResultType
Kind Enumeration
Description This type defines a range of specific Jobs status for SPI Handler/Driver.
Available
Spi.h
via
⌋()
[SWS_Spi_00062] ⌈The type Spi_JobResultType defines a range of specific Jobs
status for SPI Handler/Driver.⌋(SRS_BSW_00335)
[SWS_Spi_00012] ⌈After reset, the type Spi_JobResultType shall have the de-
fault value SPI_JOB_OK.⌋()
8.2.4 Spi_SeqResultType
[SWS_Spi_00375]⌈
Name Spi_SeqResultType
Kind Enumeration
SPI_SEQ_ 0x03 The last transmission of the Sequence has been canceled
CANCELED by user.
Description This type defines a range of specific Sequences status for SPI Handler/Driver.
Available
Spi.h
via
⌋()
[SWS_Spi_00351] ⌈The type Spi_SeqResultType defines a range of specific Se-
quences status for SPI Handler/Driver and can be obtained calling the API service
Spi_GetSequenceResult, it shall be provided for external use.⌋()
[SWS_Spi_00017] ⌈After reset, the type Spi_SeqResultType shall have the de-
fault value SPI_SEQ_OK.⌋()
8.2.5 Spi_DataBufferType
[SWS_Spi_00376]⌈
Name Spi_DataBufferType
Kind Type
⌋()
[SWS_Spi_00355] ⌈Spi_DataBufferType defines the type of application data buffer
elements. Type is uint8. Access to the data is selected dynamically as is described in
SWS_SPI_00437. The data buffer has to be aligned to 32 bits. It shall be provided for
external use.⌋()
8.2.6 Spi_NumberOfDataType
[SWS_Spi_00377]⌈
Name Spi_NumberOfDataType
Kind Type
Derived
uint16
from
Type for defining the number of data elements of the type Spi_DataBufferType to
Description
send and / or receive by Channel
Available
Spi.h
via
⌋()
[SWS_Spi_00165] ⌈The type Spi_NumberOfDataType is used for defining the
number of data elements of the type specified in [SWS_SPI_00437] to send and / or
receive by Channel.⌋()
8.2.7 Spi_ChannelType
[SWS_Spi_00378]⌈
Name Spi_ChannelType
Kind Type
⌋()
8.2.8 Spi_JobType
[SWS_Spi_00379]⌈
Name Spi_JobType
Kind Type
⌋()
[SWS_Spi_00357] ⌈The type Spi_JobType specifies the identification (ID) for a
Job.⌋()
8.2.9 Spi_SequenceType
[SWS_Spi_00380]⌈
Name Spi_SequenceType
Kind Type
⌋()
[SWS_Spi_00358] ⌈The type Spi_SequenceType specifies the identification (ID) for
a sequence of jobs.⌋()
8.2.10 Spi_HWUnitType
[SWS_Spi_00381]⌈
Name Spi_HWUnitType
Kind Type
Description Specifies the identification (ID) for a SPI Hardware microcontroller peripheral (unit).
⌋()
[SWS_Spi_00359] ⌈The type Spi_HWUnitType specifies the identification (ID) for a
SPI Hardware microcontroller peripheral (unit).⌋()
8.2.11 Spi_AsyncModeType
[SWS_Spi_00382]⌈
Name Spi_AsyncModeType
Kind Enumeration
Available
Spi.h
via
⌋()
[SWS_Spi_00360] ⌈The type Spi_AsyncModeType specifies the asynchronous
mechanism mode for SPI buses handled asynchronously in LEVEL 2 and obtained
by the API Spi_SetAsyncMode.⌋()
8.3.1 Spi_Init
[SWS_Spi_00175]⌈
Service Name Spi_Init
void Spi_Init (
Syntax const Spi_ConfigType* ConfigPtr
)
Sync/Async Synchronous
⌋()
[SWS_Spi_00299] ⌈The function Spi_Init provides the service for SPI initializa-
tion.⌋()
[SWS_Spi_00013] ⌈The function Spi_Init shall initialize all SPI relevant registers
with the values of the structure referenced by the parameter Config-
Ptr.⌋(SRS_BSW_00405, SRS_BSW_00101, SRS_SPAL_12057,
SRS_SPAL_12125)
[SWS_Spi_00015] ⌈After the module initialization using the function Spi_Init, the
SPI Handler/Driver shall set its state to SPI_IDLE, the Sequences result to
SPI_SEQ_OK and the jobs result to SPI_JOB_OK.⌋(SRS_BSW_00406,
SRS_BSW_00101, SRS_SPAL_12057)
[SWS_Spi_00151] ⌈For LEVEL 2 (see chapter 7.2.5 and SPI103), the function
Spi_Init shall set the SPI Handler/Driver asynchronous mechanism mode to
SPI_POLLING_MODE by default. Interrupts related to SPI busses shall be disa-
bled.⌋()
8.3.2 Spi_DeInit
[SWS_Spi_00176]⌈
Service Name Spi_DeInit
Std_ReturnType Spi_DeInit (
Syntax void
)
Sync/Async Synchronous
Parameters
None
(inout)
⌋()
[SWS_Spi_00301] ⌈When the API Spi_DeInit has been accepted the return value of
this function shall be E_OK.⌋()
[SWS_Spi_00302] ⌈When the API Spi_DeInit has not been accepted the return val-
ue of this function shall be E_NOT_OK.⌋()
[SWS_Spi_00303] ⌈The function Spi_DeInit provides the service for SPI de-
initialization.⌋()
[SWS_Spi_00252] ⌈In case of the SPI Handler/Driver state is not SPI_BUSY, the
deInitialization function shall put all already initialized microcontroller SPI peripherals
into the same state such as Power On Reset.⌋()
[SWS_Spi_00253] ⌈The function call Spi_DeInit shall be rejected if the status of SPI
Handler/Driver is SPI_BUSY.⌋()
The SPI Handler/Driver shall have been initialized before the function Spi_DeInit
is called, otherwise see [SWS_Spi_00046].
8.3.3 Spi_WriteIB
[SWS_Spi_00177]⌈
44 of 115 Document ID 38: AUTOSAR_SWS_SPIHandlerDriver
Specification of SPI Handler / Driver
AUTOSAR CP R20-11
Std_ReturnType Spi_WriteIB (
Spi_ChannelType Channel,
Syntax const Spi_DataBufferType* DataBufferPtr
)
Service ID
0x02
[hex]
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
Parameters
None
(out)
Std_-
E_OK: write command has been accepted
Return value Return-
E_NOT_OK: write command has not been accepted
Type
Service for writing one or more data to an IB SPI Handler/Driver Channel specified
Description
by parameter.
⌋()
[SWS_Spi_00305] ⌈When the API Spi_WriteIB command has been accepted the
function returns the value E_OK.⌋()
[SWS_Spi_00306] ⌈When the API Spi_WriteIB command has not been accepted
the function returns the value E_NOT_OK.⌋()
[SWS_Spi_00307] ⌈The function Spi_WriteIB provides the service for writing one or
more data to an IB SPI Handler/Driver Channel by the respective parameter.⌋()
[SWS_Spi_00024] ⌈The function Spi_WriteIB shall take over the given parame-
ters, and save the pointed data to the internal buffer defined with the function
Spi_Init.⌋()
The SPI Handler/Driver shall have been initialized before the function Spi_WriteIB
is called, otherwise see [SWS_Spi_00046].
8.3.4 Spi_AsyncTransmit
[SWS_Spi_00178]⌈
Service Name Spi_AsyncTransmit
Std_ReturnType Spi_AsyncTransmit (
Syntax Spi_SequenceType Sequence
)
Sync/Async Asynchronous
Reentrancy Reentrant
Parameters
None
(inout)
⌋()
[SWS_Spi_00310] ⌈When the API Spi_AsyncTransmit command has not been ac-
cepted the function shall return the value E_NOT_OK.⌋()
shall not take in account this new request and this function shall return with value
E_NOT_OK, in this case.⌋()
function call of Spi_WriteIB for IB Channels but before the function call
Spi_ReadIB.⌋()
The SPI Handler/Driver shall have been initialized before the function
Spi_AsyncTransmit is called otherwise see [SWS_Spi_00046].
8.3.5 Spi_ReadIB
[SWS_Spi_00179]⌈
Service Name Spi_ReadIB
Std_ReturnType Spi_ReadIB (
Spi_ChannelType Channel,
Syntax Spi_DataBufferType* DataBufferPointer
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
Parameters
DataBufferPointer Pointer to destination data buffer in RAM
(out)
Service for reading synchronously one or more data from an IB SPI Handler/
Description
Driver Channel specified by parameter.
⌋()
[SWS_Spi_00315] ⌈The function Spi_ReadIB provides the service for reading syn-
chronously one or more data from an IB SPI Handler/Driver Channel specified by
parameter.⌋()
The SPI Handler/Driver shall have been initialized before the function Spi_ReadIB
is called otherwise see [SWS_Spi_00046].
8.3.6 Spi_SetupEB
[SWS_Spi_00180]⌈
Service Name Spi_SetupEB
Std_ReturnType Spi_SetupEB (
Spi_ChannelType Channel,
const Spi_DataBufferType* SrcDataBufferPtr,
Syntax
Spi_DataBufferType* DesDataBufferPtr,
Spi_NumberOfDataType Length
)
Service ID
0x05
[hex]
Sync/Async Synchronous
Reentrancy Reentrant
SrcData
Parameters Pointer to source data buffer.
BufferPtr
(in)
Length (number of data elements) of the data to be transmitted from
Length
SrcDataBufferPtr and/or received from DesDataBufferPtr Min.: 1 Max.:
Parameters DesData
Pointer to destination data buffer in RAM.
(inout) BufferPtr
Parameters
None
(out)
Std_-
E_OK: Setup command has been accepted
Return value Return-
E_NOT_OK: Setup command has not been accepted
Type
Service to setup the buffers and the length of data for the EB SPI Handler/Driver
Description
Channel specified.
⌋()
[SWS_Spi_00058] ⌈The function Spi_SetupEB shall set up the buffers and the
length of data for the specific EB SPI Handler/Driver Channel.⌋(SRS_Spi_12103)
[SWS_Spi_00067] ⌈The function Spi_SetupEB shall update the buffer pointers and
length attributes of the specified Channel with the provided val-
ues.⌋(SRS_Spi_12103)
As these attributes are persistent, they will be used for all succeeding calls to a
Transmit method (for the specified Channel).
The SPI Handler/Driver shall have been initialized before the function Spi_SetupEB
is called otherwise see [SWS_Spi_00046].
8.3.7 Spi_GetStatus
[SWS_Spi_00181]⌈
Service Name Spi_GetStatus
Spi_StatusType Spi_GetStatus (
Syntax void
)
Sync/Async Synchronous
Reentrancy Reentrant
⌋()
8.3.8 Spi_GetJobResult
[SWS_Spi_00182]⌈
Service Name Spi_GetJobResult
Spi_JobResultType Spi_GetJobResult (
Syntax Spi_JobType Job
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters (in) Job Job ID. An invalid job ID will return an undefined result.
Description This service returns the last transmission result of the specified Job.
⌋()
NOTE: Every new transmit job that has been accepted by the SPI Handler/Driver
overwrites the previous job result with SPI_JOB_QUEUED or SPI_JOB_PENDING.
8.3.9 Spi_GetSequenceResult
[SWS_Spi_00183]⌈
Service Name Spi_GetSequenceResult
Spi_SequenceType Sequence
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
Spi_SeqResult-
Return value Spi_SeqResultType
Type
Description This service returns the last transmission result of the specified Sequence.
⌋()
Note:
- Every new transmit sequence that has been accepted by the SPI Han-
dler/Driver overwrites the previous sequence result with SPI_SEQ_PENDING.
- If the SPI Handler/Driver has not been initialized before the function
Spi_GetSequenceResult is called, the return value is undefined.
8.3.10 Spi_GetVersionInfo
[SWS_Spi_00184]⌈
void Spi_GetVersionInfo (
Syntax Std_VersionInfoType* versioninfo
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters (out) versioninfo Pointer to where to store the version information of this module.
⌋()
[SWS_Spi_00371] ⌈If Det is enabled, the parameter versioninfo shall be checked for
being NULL. The error SPI_E_PARAM_POINTER shall be reported in case the value
is a NULL pointer.⌋()
8.3.11 Spi_SyncTransmit
[SWS_Spi_00185]⌈
Service Name Spi_SyncTransmit
Std_ReturnType Spi_SyncTransmit (
Syntax Spi_SequenceType Sequence
)
Sync/Async Asynchronous
Reentrancy Reentrant
Parameters
None
(inout)
⌋()
8.3.12 Spi_GetHWUnitStatus
[SWS_Spi_00186]⌈
Service Name Spi_GetHWUnitStatus
Spi_StatusType Spi_GetHWUnitStatus (
Syntax Spi_HWUnitType HWUnit
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
This service returns the status of the specified SPI Hardware microcontroller
Description
peripheral.
⌋()
8.3.13 Spi_Cancel
[SWS_Spi_00187]⌈
Service Name Spi_Cancel
void Spi_Cancel (
Syntax Spi_SequenceType Sequence
)
Sync/Async Asynchronous
Reentrancy Reentrant
⌋()
With other words, the Spi_Cancel function stops a Sequence transmission after a
(possible) on transmission Job ended and before a (potential) next Job transmission
starts.
8.3.14 Spi_SetAsyncMode
[SWS_Spi_00188]⌈
Service Name Spi_SetAsyncMode
Std_ReturnType Spi_SetAsyncMode (
Syntax Spi_AsyncModeType Mode
)
Sync/Async Synchronous
Parameters
None
(inout)
Service to set the asynchronous mechanism mode for SPI busses handled
Description
asynchronously.
⌋()
60 of 115 Document ID 38: AUTOSAR_SWS_SPIHandlerDriver
Specification of SPI Handler / Driver
AUTOSAR CP R20-11
[SWS_Spi_00171] ⌈If the function Spi_SetAsyncMode is called while the SPI Han-
dler/Driver status is SPI_BUSY and an asynchronous transmission is in progress, the
SPI Handler/Driver shall not change the AsyncModeType and keep the mode type as
it is. The function shall return the value E_NOT_OK.⌋()
This chapter lists all functions provided by the SPI module to lower layer modules.
The SPI Handler/Driver module belongs to the lowest layer of AUTOSAR Software
Architecture hence this module specification has not identified any callback functions.
This chapter lists all functions provided by the SPI Handler/Driver and called directly
by the Basic Software Module Scheduler.
The SPI Handler/Driver module requires a scheduled function for the management of
the asynchronous mode managed with polling (see SWS_Spi_00361). The specified
functions below exemplify how to implement them if they are needed.
8.5.1 Spi_MainFunction_Handling
[SWS_Spi_00189]⌈
Service Name Spi_MainFunction_Handling
void Spi_MainFunction_Handling (
Syntax void
)
Description --
⌋()
This function shall polls the SPI interrupts linked to HW Units allocated to the trans-
mission of SPI sequences to enable the evolution of transmission state machine.
This chapter lists all functions that the SPI Handler/Driver requires from other mod-
ules.
8.6.1 Mandatory Interfaces
The SPI Handler/Driver module requires some interfaces to fulfill its core functionali-
ty.
[SWS_Spi_00389]⌈ []⌈
Header
API Function Description
File
⌋()⌋()
This chapter defines all interfaces which are required to fulfill an optional functionality
of SPI Handler/Driver module.
[SWS_Spi_00339]⌈
API Header
Description
Function File
Det_-
Det.h Service to report development errors.
ReportError
⌋()
In this chapter all interfaces are listed where the target function could be configured.
The target function is usually a call-back function. The name of these interfaces is not
fixed because they are configurable.
[SWS_Spi_00265] ⌈For implement the call back function other modules are required
to provide the routines in the expected manner.⌋()
[SWS_Spi_00085] ⌈It is allowed to use the following API calls within the SPI callback
notifications:
Spi_ReadIB
Spi_WriteIB
Spi_SetupEB
Spi_GetJobResult
Spi_GetSequenceResult
Spi_GetHWUnitStatus
Spi_Cancel
All other SPI Handler/Driver API calls are not allowed.⌋()
8.6.3.1 Spi_JobEndNotification
[SWS_Spi_00192]⌈
Service Name (*Spi_JobEndNotification)
void (*Spi_JobEndNotification) (
Syntax void
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
Callback routine provided by the user for each Job to notify the caller that a job
Description
has been finished.
⌋()
Note: This routine might be called on interrupt level, depending on the calling func-
tion.
8.6.3.2 Spi_SeqEndNotification
[SWS_Spi_00193]⌈
Service Name (*Spi_SeqEndNotification)
void (*Spi_SeqEndNotification) (
Syntax void
)
Sync/Async Synchronous
Reentrancy Reentrant
Parameters
None
(inout)
Parameters
None
(out)
Callback routine provided by the user for each Sequence to notify the caller that a
Description
sequence has been finished.
⌋()
Note: This routine might be called on interrupt level, depending on the calling func-
tion.
[SWS_Spi_00031] ⌈The API parameter Channel shall have a value within the de-
fined channels in the initialization data structure, and the correct type of channel (IB
or EB) has to be used with services. Related error value: SPI_E_PARAM_CHANNEL.
Otherwise, the service is not done and the return value shall be E_NOT_OK.
⌋(SRS_BSW_00323)
[SWS_Spi_00032] ⌈The API parameters Sequence and Job shall have values within
the specified range of values. Related errors values: SPI_E_PARAM_SEQ or
SPI_E_PARAM_JOB.⌋(SRS_BSW_00323)
[SWS_Spi_00060] ⌈The API parameter Length of data shall have a value within the
specified buffer maximum value. Related error value:
SPI_E_PARAM_LENGTH.⌋(SRS_BSW_00323)
[SWS_Spi_00258] ⌈ If the API parameter Length related service is not done and the
return value shall be E_NOT_OK.⌋()
[SWS_Spi_00143] ⌈The API parameter HWUnit shall have a value within the speci-
fied range of values. Related error value: SPI_E_PARAM_UNIT.⌋()
[SWS_Spi_00288] ⌈If HWUnit related service is not done and the return value shall
be SPI_UNINIT.⌋()
[SWS_Spi_00046] ⌈If development error detection for the SPI module is enabled
and the SPI Handler/Driver’s environment calls any API function before initialization,
an error should be reported to the DET with the error value SPI_E_UNINIT according
to the configuration.⌋(SRS_BSW_00406)
[SWS_Spi_00233] ⌈
If development error detection for the SPI module is enabled, the calling of the rou-
tine SPI_Init() while the SPI driver is already initialized will cause a development error
SPI_E_ALREADY_INITIALIZED and the desired functionality shall be left without
any action.⌋()
[SWS_Spi_00254] ⌈If the Sequence and Job related service is not done and, de-
pending on services, either the return value shall be E_NOT_OK or a failed result
(SPI_JOB_FAILED or SPI_SEQ_FAILED).⌋()
[SWS_Spi_00256] ⌈The SPI Handler/Driver shall not process the invoked function
but, depending on the invoked function, shall either return the value E_NOT_OK or a
failed result (SPI_JOB_FAILED or SPI_SEQ_FAILED).⌋()
9 Sequence diagrams
9.1 Initialization
Spi_Init(const
Spi_ConfigType*)
Spi_Init()
The following sequence diagram shows an example of an Init / DeInit calls for a run-
ning mode transition.
Description:
Spi_Init(const Initialization of SPI Handler/Driver is
performed synchronously with a
Spi_ConfigType*)
parameter to run in a mode.
Spi_Init() For instance, "FullPowerConf" is the
structure containing all configurations
for the "RUN State" with PLL enable.
Use of SPI
Handler/Driver:
Embedded software Spi_GetStatus(Spi_StatusType)
execution, time and
code execution
undefined during this life Spi_GetStatus=SPI_BUSY()
period.
Spi_GetStatus(Spi_StatusType)
Spi_GetStatus=SPI_IDLE()
Description:
Use the get status service of SPI
Handler/Driver to know its state before
to de-initialize it.
Spi_DeInit(Std_ReturnType)
Spi_DeInit()
Spi_Init(const Description:
Spi_ConfigType*) Initialization of SPI Handler/Driver is performed
with a specific parameter to run in another
Spi_Init() mode.
Use of SPI
Handler/Driver: For instance, "ReducePowerConf" is the
Embedded software structure containing all configurations for the
execution, time and "SLEEP State" with PLL disable.
code execution
undefined during this life
period.
Spi_WriteIB(Std_ReturnType,
Description:
Spi_ChannelType, const Spi_DataBufferType*) Write to the Channel is done synchronously. You
pass the Channel ID and the buffer.
Spi_WriteIB()
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType)
Description:
Spi_AsyncTransmit() Transmission is performing asynchronously. The
SPI Handler/Driver records the sequence and
returns.
Description:
Seq0.Job1() Transmission processing (writing to SPI bus) is
done asynchronously according to the sequence
requested and the prioritization mechanism.
This case is not a Sequence of linked Jobs so the
SPI Handler/Driver becomes idle at the end of the
Channel transmission.
<Spi_Job1EndNotification>()
<Spi_Job1EndNotification>()
Description:
When a Job transmission ends, if it is configured,
<Spi_Seq0EndNotification>()
the “End Job Notification” of the Job process is
called.
<Spi_Seq0EndNotification>()
Description:
Spi_ReadIB(Std_ReturnType, Spi_ChannelType,
When the Sequence transmission ends, if it is
Spi_DataBufferType**) configured, the “End Seq Notification” of the
Sequence process is called.
Spi_ReadIB()
Description:
The received data will be allocated in the
configured receive buffers, and can be read using
the read function for IB Channels.
Description:
Write to a Channel is done synchronously. You
Spi_WriteIB(Std_ReturnType, pass the Channel ID and the buffer.
Spi_ChannelType, const Spi_DataBufferType*) In this case, Channels are within the same Job.
Spi_WriteIB()
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB() Description:
Transmission is performing asynchronously. The
SPI Handler/Driver records the sequence and
returns.
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType)
Spi_AsyncTransmit()
Description:
Transmission processing (writing to SPI bus) is
done asynchronously according to the sequence
requested and the prioritization mechanism.
Seq0.Job1() This case is not a sequence of linked Jobs. At the
end of Channels transmission the SPI
Handler/Driver becomes idle.
<Spi_Job1EndNotification>()
<Spi_Job1EndNotification>()
Description:
<Spi_Seq0EndNotification>() When a Job transmission ends, if it is configured,
the “End Job Notification” of the Job process is
called.
<Spi_Seq0EndNotification>()
Spi_ReadIB(Std_ReturnType, Spi_ChannelType,
Spi_DataBufferType**) Description:
When the Sequence transmission ends, if it is
Spi_ReadIB() configured, the “End Seq Notification” of the
Sequence process is called.
Description:
The received data, if there are, will be allocated
in the configured receive buffers, and can be
read using the read function for IB Channels.
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
loop Channel:=5...10
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
Description:
Write to a Channel is done synchronously. You
pass the Channel ID and the buffer.
Spi_WriteIB(Std_ReturnType, In this case, Channels are not within the same
Spi_ChannelType, const Spi_DataBufferType*) Job.
Spi_WriteIB()
loop Channel:=1...3
Description:
Spi_WriteIB(Std_ReturnType, Transmission is performing asynchronously. The
Spi_ChannelType, const Spi_DataBufferType*) SPI Handler/Driver records the sequence and
returns.
Spi_WriteIB()
Spi_AsyncTransmit(Std_ReturnType, Description:
Spi_SequenceType) Transmission processing (writing to SPI bus) is
done asynchronously according to the sequence
Spi_AsyncTransmit() requested and the prioritization mechanism.
This case is a sequence of linked Jobs. At the end
of Channels transmission the SPI Handler/Driver
becomes idle.
Seq0.Job1()
<Spi_Job1EndNotification>()
<Spi_Job1EndNotification>()
Description:
Seq0.Job2() When a Job transmission ends, if it is configured,
the “End Job Notification” of the Job process is
called.
<Spi_Seq0EndNotification>()
<Spi_Seq0EndNotification>() Description:
When the Sequence transmission ends, if it is
configured, the “End Seq Notification” of the
Sequence process is called.
Spi_ReadIB(Std_ReturnType, Spi_ChannelType,
Spi_DataBufferType**)
Spi_ReadIB()
Description:
The received data, if there are, will be allocated in
the configured receive buffers, and can be read
using the read function for IB Channels.
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
loop Channel:=5...10
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
loop Channel:=12...13
Description:
Write to a Channel is done
opt If channel needed synchronously. You pass the Channel ID
and the buffer.
In this case, Channels are not within the
Spi_WriteIB(Std_ReturnType, same Job.
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType)
Description:
Transmission is performing Spi_AsyncTransmit()
asynchronously. The SPI
Handler/Driver records the sequence
and returns.
Seq0.Job1 (part1)
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType)
Spi_AsyncTransmit() Description:
Transmission processing (writing to SPI
bus) is done asynchronously according to
the job requested and the prioritization
mechanism.
Seq0.Job1 (part2) This case concerns many Sequences of
many Jobs so at the end of a Job
<Spi_Job1EndNotification>() transmission SPI Handler/Driver schedule
the next Job to transmit.
The Job selected has the higher priority
<Spi_Job1EndNotification>() and could belong to another Sequence
only if the sequence on going is
configured as interruptible.
At the end of all Sequences transmission
Description: Seq1.Job0() SPI Handler/Driver becomes idle.
When a Job transmission ends, if it is configured, the “End Job
Notification” of the Job process is called.
<Spi_Seq1EndNotification>()
<Spi_Seq1EndNotification>()
Spi_ReadIB(Std_ReturnType, Spi_ChannelType,
Spi_DataBufferType**)
Spi_ReadIB()
Description: Seq0.Job2()
When the Sequence
transmission ends, if it is
configured, the “End Seq <Spi_Seq0EndNotification>()
Notification” of the
Description:
Sequence process is
called. The received data, if there are, will be
<Spi_Seq0EndNotification>()
allocated in the configured receive buffers,
and can be read using the read function
for IB Channels.
Spi_ReadIB(Spi_ChannelType, Spi_DataType*):
Std_ReturnType
Spi_ReadIB()
Spi_SetupEB()
Description:
Spi_AsyncTransmit(Std_ReturnType, Transmission is performing asynchronously. The
Spi_SequenceType) SPI Handler/Driver records the sequence and
returns.
Spi_AsyncTransmit()
Seq0.Job1() Description:
Transmission processing (writing to SPI bus) is
done asynchronously according to the sequence
requested and the prioritization mechanism.
This case is not a Sequence of linked Jobs so the
<Spi_Job1EndNotification>() SPI Handler/Driver becomes idle at the end of the
Channel transmission.
<Spi_Job1EndNotification>()
<Spi_Seq0EndNotification>()
<Spi_Seq0EndNotification>()
Description:
When a Job transmission ends, if it is configured,
the “End Job Notification” of the Job process is
called.
Description:
When the Sequence transmission ends, if it is
configured, the “End Seq Notification” of the
Sequence process is called.
Spi_SetupEB()
Description:
Setup a Channel; initialize buffer pointers and
length synchronously. Parameters are saved.
In this case, Channels are within the same Job.
Spi_SetupEB(Std_ReturnType, Spi_ChannelType, const
Spi_DataBufferType*, Spi_DataBufferType**, Spi_NumberOfDataType)
Spi_SetupEB()
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType) Description:
Transmission is performing asynchronously. The
Spi_AsyncTransmit() SPI Handler/Driver records the sequence and
returns.
Seq0.Job1()
<Spi_Job1EndNotification>() Description:
Transmission processing (writing to SPI bus) is
done asynchronously according to the
<Spi_Job1EndNotification>() sequence requested and the prioritization
mechanism.
This case is not a sequence of linked Jobs. At
the end of Channels transmission the SPI
Handler/Driver becomes idle.
<Spi_Seq0EndNotification>()
<Spi_Seq0EndNotification>()
Description:
When a Job transmission ends, if it is
configured, the “End Job Notification” of the
Job process is called.
Description:
When the Sequence transmission ends, if it is
configured, the “End Seq Notification” of the
Sequence process is called.
The received data, if there are, will be directly
stored in EB Channel receive buffer and can be
used such as.
Spi_SetupEB()
loop Channel:=5...10
Spi_SetupEB()
Description:
Setup a Channel; initialize buffer pointers and
length synchronously. Parameters are saved.
In this case, Channels are not within the same
Spi_SetupEB(Std_ReturnType, Spi_ChannelType, const Job.
Spi_DataBufferType*, Spi_DataBufferType**, Spi_NumberOfDataType)
Spi_SetupEB()
loop Channel:=1...3
Spi_AsyncTransmit(Std_ReturnType,
Spi_SequenceType)
Description:
Spi_AsyncTransmit() Transmission processing (writing to SPI bus) is
done asynchronously according to the job
requested and the prioritization mechanism.
This case is a Sequence of linked Jobs so at the
Seq0.Job1() end of a Job transmission SPI Handler/Driver
schedule the next Job to transmit.
At the end of Sequence transmission the SPI
Handler/Driver becomes idle.
<Spi_Job1EndNotification>()
<Spi_Job1EndNotification>()
Seq0.Job2()
Description:
When a Job transmission Description:
ends, if it is configured, the <Spi_Seq0EndNotification>() When the Sequence transmission ends, if it is
“End Job Notification” of the configured, the “End Seq Notification” of the
Job process is called. Sequence process is called.
<Spi_Seq0EndNotification>() The received data, if there are, will be directly
stored in EB Channel receive buffer and can be
used such as.
Description:
The received data will be allocated in the
configured receive buffers, and can be read using
the read function for IB Channels.
Spi_SetupEB()
loop Channel:=5...10
Spi_SetupEB()
Description:
Spi_SetupEB(Std_ReturnType, Spi_ChannelType, const Setup a Channel; initialize buffer pointers and
Spi_DataBufferType*, Spi_DataBufferType**, Spi_NumberOfDataType) length synchronously. Parameters are saved.
In this case, Jobs of those Channels are not
Spi_SetupEB() within the same Sequence.
loop Channel:=12...13
Spi_SetupEB()
Description:
Transmission is performing asynchronously. The
Spi_AsyncTransmit(Std_ReturnType, SPI Handler/Driver records the sequence and
Spi_SequenceType) returns.
Spi_AsyncTransmit()
Description:
Seq0.Job1 (part1) Transmission processing (writing to SPI bus) is
done asynchronously according to the job
Spi_AsyncTransmit(Std_ReturnType, requested and the prioritization mechanism.
Spi_SequenceType) This case concerns many Sequences of many
Jobs so at the end of a Job transmission SPI
Spi_AsyncTransmit() Handler/Driver schedule the next Job to
transmit.
The Job selected has the higher priority and
could belong to another Sequence only if the
sequence on going is configured as
Seq0.Job1 (part2) interruptible.
At the end of all Sequences transmission SPI
<Spi_Job1EndNotification>() Handler/Driver becomes idle.
<Spi_Job1EndNotification>()
Seq1.Job0()
<Spi_Seq1EndNotification>()
Description:
<Spi_Seq1EndNotification>() When a Job transmission ends, if it is
configured, the “End Job Notification” of the
Job process is called.
Seq0.Job2()
<Spi_Seq0EndNotification>() Description:
When the Sequence transmission ends, if it is
configured, the “End Seq Notification” of the
<Spi_Seq0EndNotification>() Sequence process is called.
The received data, if there are, will be directly
stored in EB Channel receive buffer and can be
used such as.
All kind of mixed Jobs transmission is possible according to the Channels configura-
tion and the priority requirement inside Sequences.
The user knows which Channels are in use. Then, according to the types of these
Channels, the appropriate methods shall be called.
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
loop Channel:=5...10
Spi_WriteIB()
loop Channel:=1...3
Spi_WriteIB(Std_ReturnType,
Spi_ChannelType, const Spi_DataBufferType*)
Spi_WriteIB()
Transmission is performing
synchronously. The SPI
Handler/Driver transmits the
complete Sequence and it returns.
At the end of Sequence
Spi_SyncTransmit(Std_ReturnType, transmission, the SPI
Spi_SequenceType) Handler/Driver becomes idle.
Seq0.Job1()
Seq0.Job2()
Spi_SyncTransmit() The received data, if there are, will
be allocated in the configured
receive buffers, and can be read
Spi_ReadIB(Std_ReturnType, using the read function for IB
Spi_ChannelType, Spi_DataBufferType**) Channels.
Spi_ReadIB()
Spi_SetupEB()
loop Channel:=5...10
loop Channel:=1...3
Spi_SetupEB()
Transmission is performing
synchronously. The SPI
Handler/Driver transmits the
complete Sequence and it returns.
At the end of Sequence
transmission, the SPI
Spi_SyncTransmit(Std_ReturnType, Handler/Driver becomes idle.
Spi_SequenceType)
Seq0.Job1()
Seq0.Job2() Description:
Spi_SyncTransmit() The received data, if there are, will
be directly stored in EB Channel
receive buffer and can be used
such as.
10 Configuration specification
The following chapters summarize all configuration parameters. The detailed mean-
ings of the parameters are described in Chapter 7 and Chapter 8. Further hardware /
implementation specific parameters can be added if necessary.
[SWS_Spi_00390] ⌈The SPI module shall reject configurations with partition map-
pings which are not supported by the implementation. ⌋()
10.2.1 Spi
SWS Item ECUC_Spi_00103 :
Module Name Spi
Module Description Configuration of the Spi (Serial Peripheral Interface) module.
Post-Build Variant Support true
Supported Config Variants VARIANT-LINK-TIME, VARIANT-POST-BUILD, VARIANT-PRE-COMPILE
Included Containers
Container Name Multiplicity Scope / Dependency
Container for the references to DemEventParameter elements
which shall be invoked using the API Dem_SetEventStatus in
case the corresponding error occurs. The EventId is taken
SpiDemEventParameterRefs 0..1 from the referenced DemEventParameter's DemEventId sym-
bolic value. The standardized errors are provided in this con-
tainer and can be extended by vendor-specific error refer-
ences.
This container contains the configuration parameters and sub
SpiDriver 1
containers of the AUTOSAR Spi module.
SpiGeneral 1 General configuration settings for SPI-Handler
Container holding all SPI specific published information pa-
SpiPublishedInformation 1
rameters
10.2.2 SpiDemEventParameterRefs
SWS Item ECUC_Spi_00240 :
Container Name SpiDemEventParameterRefs
Parent Container Spi
Container for the references to DemEventParameter elements which shall
be invoked using the API Dem_SetEventStatus in case the corresponding
Description error occurs. The EventId is taken from the referenced DemEventParame-
ter's DemEventId symbolic value. The standardized errors are provided in
this container and can be extended by vendor-specific error references.
Configuration Parameters
No Included Containers
10.2.3 SpiGeneral
SWS Item ECUC_Spi_00225 :
Container Name SpiGeneral
Parent Container Spi
Description General configuration settings for SPI-Handler
Configuration Parameters
IB = 0;
EB = 1;
IB/EB = 2;
Multiplicity 1
Type EcucIntegerParamDef
Range 0 .. 2
Default value --
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
Multiplicity 1
Type EcucBooleanParamDef
Default value false
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
SpiGeneral:
EcucParamConfContainerDef SpiLevelDelivered:
+parameter EcucIntegerParamDef
lowerMultiplicity = 1
upperMultiplicity = 1 min = 0
max = 2
SpiChannelBuffersAllowed:
+parameter EcucIntegerParamDef
min = 0
max = 2
+parameter SpiInterruptibleSeqAllowed:
EcucBooleanParamDef
SpiHwStatusApi:
+parameter EcucBooleanParamDef
+parameter
SpiCancelApi:
EcucBooleanParamDef
+parameter SpiVersionInfoApi:
EcucBooleanParamDef
defaultValue = false
+parameter SpiDevErrorDetect:
EcucBooleanParamDef
defaultValue = false
+parameter SpiSupportConcurrentSyncTransmit:
EcucBooleanParamDef
SpiMainFunctionPeriod:
EcucFloatParamDef
+parameter min = 0
max = INF
defaultValue = 0.01
lowerMultiplicity = 0
upperMultiplicity = 1
SpiEcucPartitionRef: EcucPartition:
+reference +destination EcucParamConfContainerDef
EcucReferenceDef
lowerMultiplicity = 0 lowerMultiplicity = 0
upperMultiplicity = * upperMultiplicity = *
SpiKernelEcucPartitionRef:
+reference +destination
EcucReferenceDef
lowerMultiplicity = 0
upperMultiplicity = 1
10.2.4 SpiSequence
SWS Item ECUC_Spi_00106 :
Container Name SpiSequence
Parent Container SpiDriver
Description All data needed to configure one SPI-sequence
Configuration Parameters
No Included Containers
SpiSeqEndNotification:
+parameter EcucFunctionNameDef
lowerMultiplicity = 0
upperMultiplicity = 1
+parameter SpiSequenceId:
EcucIntegerParamDef
symbolicNameValue = true
max = 255
10.2.5 SpiChannel
SWS Item ECUC_Spi_00104 :
Container Name SpiChannel
Parent Container SpiDriver
Description All data needed to configure one SPI-channel
Configuration Parameters
No Included Containers
SpiDriver: EcucParamConfContainerDef
lowerMultiplicity = 1
upperMultiplicity = 1
+subContainer
SpiChannel: SpiIbNBuffers:
+parameter
EcucParamConfContainerDef EcucIntegerParamDef
SpiDataWidth:
+parameter EcucIntegerParamDef
max = 32
min = 1
SpiEbMaxLength:
+parameter EcucIntegerParamDef
max = 65535
+parameter SpiChannelId:
EcucIntegerParamDef
symbolicNameValue = true
max = 255
10.2.6 SpiChannelList
SWS Item ECUC_Spi_00233 :
Container Name SpiChannelList
Parent Container SpiJob
Description References to SPI channels and their order within the Job.
Configuration Parameters
Multiplicity 1
Type EcucIntegerParamDef
Range 0 .. 255
Default value --
Post-Build Variant Value true
Value Configuration Class Pre-compile time X VARIANT-PRE-COMPILE
Link time X VARIANT-LINK-TIME
Post-build time X VARIANT-POST-BUILD
Scope / Dependency scope: local
No Included Containers
10.2.7 SpiJob
SWS Item ECUC_Spi_00105 :
Container Name SpiJob
Parent Container SpiDriver
All data needed to configure one SPI-Job, amongst others the connection
Description between the internal SPI unit and the special settings for an external de-
vice is done.
Configuration Parameters
Included Containers
Container Name Multiplicity Scope / Dependency
SpiChannelList 1..* References to SPI channels and their order within the Job.
SpiJob: SpiJobPriority:
EcucParamConfContainerDef +parameter EcucIntegerParamDef
upperMultiplicity = * max = 3
lowerMultiplicity = 1 min = 0
SpiJobEndNotification:
+parameter EcucFunctionNameDef
lowerMultiplicity = 0
upperMultiplicity = 1
SpiJobId: EcucIntegerParamDef
+parameter
symbolicNameValue = true
max = 65535
SpiExternalDevice:
+reference SpiDeviceAssignment: +destination EcucParamConfContainerDef
EcucReferenceDef
upperMultiplicity = *
lowerMultiplicity = 1
10.2.8 SpiExternalDevice
SWS Item ECUC_Spi_00207 :
Container Name SpiExternalDevice
Parent Container SpiDriver
The communication settings of an external device. Closely linked to Spi-
Description
Job.
Configuration Parameters
maxLength --
minLength --
regularExpression --
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
Multiplicity 1
Type EcucEnumerationParamDef
Range LEADING --
TRAILING --
Post-Build Variant
true
Value
Value Configura- Pre-compile time X VARIANT-PRE-COMPILE
tion Class Link time X VARIANT-LINK-TIME
Post-build time X VARIANT-POST-BUILD
Scope / Dependen- scope: local
cy
Value
Value Configura- Pre-compile time X VARIANT-PRE-COMPILE
tion Class Link time X VARIANT-LINK-TIME
Post-build time X VARIANT-POST-BUILD
Scope / Dependen- scope: local
cy
No Included Containers
SpiBaudrate:
SpiExternalDevice:
+parameter EcucFloatParamDef
EcucParamConfContainerDef
min = 0
max = INF LEADING:
upperMultiplicity = *
+literal EcucEnumerationLiteralDef
lowerMultiplicity = 1 +parameter SpiDataShiftEdge:
EcucEnumerationParamDef +literal
TRAILING:
EcucEnumerationLiteralDef
SpiTimeClk2Cs:
+parameter EcucFloatParamDef
max = 0.0001
min = 0
HIGH:
+literal EcucEnumerationLiteralDef
+parameter SpiShiftClockIdleLevel:
EcucEnumerationParamDef +literal
LOW:
EcucEnumerationLiteralDef
+parameter SpiEnableCs:
EcucBooleanParamDef
+literal CS_VIA_PERIPHERAL_ENGINE:
EcucEnumerationLiteralDef
SpiCsSelection: EcucEnumerationParamDef
+parameter
defaultValue = CS_VIA_PERIPHERAL_ENGINE
+literal
lowerMultiplicity = 0 CS_VIA_GPIO:
upperMultiplicity = 1 EcucEnumerationLiteralDef
LOW:
+literal
EcucEnumerationLiteralDef
+parameter SpiCsPolarity:
EcucEnumerationParamDef +literal
HIGH:
EcucEnumerationLiteralDef
+parameter SpiCsIdentifier:
EcucStringParamDef
symbolicNameValue = true
+literal CSIB0:
SpiHwUnit: EcucEnumerationLiteralDef
EcucEnumerationParamDef +literal
CSIB1:
+parameter EcucEnumerationLiteralDef
+literal
CSIB2:
EcucEnumerationLiteralDef
+literal
CSIB3:
EcucEnumerationLiteralDef
SpiDeviceEcucPartitionRef: EcucPartition:
+reference +destination EcucParamConfContainerDef
EcucReferenceDef
lowerMultiplicity = 0 lowerMultiplicity = 0
upperMultiplicity = * upperMultiplicity = *
SpiTimeCs2Clk:
+parameter EcucFloatParamDef
min = 0.00000001
max = 0.01
defaultValue = 0.000001
SpiTimeCs2Cs:
+parameter EcucFloatParamDef
min = 0.00000001
max = 0.01
defaultValue = 0.000001
10.2.9 SpiDriver
SWS Item ECUC_Spi_00091 :
Container Name SpiDriver
Parent Container Spi
This container contains the configuration parameters and sub containers of
Description
the AUTOSAR Spi module.
Configuration Parameters
Included Containers
Container Name Multiplicity Scope / Dependency
SpiChannel 1..* All data needed to configure one SPI-channel
The communication settings of an external device. Closely
SpiExternalDevice 1..*
linked to SpiJob.
All data needed to configure one SPI-Job, amongst others the
SpiJob 1..* connection between the internal SPI unit and the special set-
tings for an external device is done.
SpiSequence 1..* All data needed to configure one SPI-sequence
SpiDriver: EcucParamConfContainerDef
lowerMultiplicity = 1
upperMultiplicity = 1
10.2.10 SpiPublishedInformation
SWS Item ECUC_Spi_00235 :
Container Name SpiPublishedInformation
Parent Container Spi
No Included Containers
There is a relationship between the SPI Handler/Driver module and the modules that
use it. This relationship is resolved during the configuration stage and the result of it
influences the proper API and behaviour between those modules.
The user needs to provide to the SPI Handler/Driver part of the configuration to adapt
it to its necessities. The SPI Handler/Driver shall take this configuration and provide
the needed tools to the user.
The picture shows the information flow during the configuration of the SPI Han-
dler/Driver. It is shown only for one user, using an External EEPROM Driver as ex-
ample, but this situation is common to all users of the SPI Handler/Driver. To high-
light the situation where more users are affected, several overlapping documents are
drawn.
1. The user (External EEPROM Driver) of SPI Handler/Driver edits a XML con-
figuration file. This XML configuration file is the same used by the user to gen-
erate its own configuration.
2. For each ECU, a XML HW configuration document contains information which
should be used in order to configure some parameters.
3. The “SPI generation tool”. The Generation tool (here is reflected only the part
that generates code to SPI usage) shall generate the handles to export and
the instance of the configuration sets. In this step the software integrator will
provide missing information.
4. SPI instance configuration file. As a result of the generation all the symbolic
handlers needed by the user are included in the configuration header file of
the SPI Handler/Driver.
5. User gets the symbolic name of handlers. User imports the handle generated
to make use of them as requested by its XML configuration file.
12 Appendix
The table shown on the next page is just an example to help future users (and/or de-
velopers) that have to configure software modules to use the SPI Handler/Driver.
This table is independent of the Spi_ConfigType structure but contains all ele-
ments and aggregations like Channels, Jobs and Sequences.
EEP_WRITE_SEQ EEP_READ_SEQ
EEP_CMD_JOB EEP_DATA_JOB
SPI_BUS_0,
CS_EEPROM,
CS_ON,
2 (Number of Jobs), CS_LOW, EB,
{EEP_CMD_JOB, CLK_2MHz, 8 bits,
EEP_DATA_JOB} 1 (time in µs), 1 data to
EEP_WRITE_ EEP_CMD_J EEP_CMD
0 (List of Jobs), 0 Polarity 180, 0 TxD,
SEQ OB _CH
Not Interruptible, Falling Edge, MSB First,
EEP_vidEndOfWrit 3, Default value
eSeq EEP_vidEndOfStartWrJob, is 0x00
1 (Number of Channels)
{EEP_CMD_CH} (List of
Channels)
SPI_BUS_0,
CS_EEPROM,
CS_ON,
CS_LOW,
CLK_2MHz, EB,
1 (Number of Jobs),
1 (time in µs), 16 bits,
{EEP_DATA_JOB}
Polarity 180, 1 data to
EEP_READ_ (List of Jobs), EEP_DATA_ EEP_ADR_
1 1 Falling Edge, 1 TxD,
SEQ Not Interruptible, JOB CH
2, MSB First,
EEP_vidEndOfRea
NULL, Default value
dSeq
3 (Number of Channels) is 0x0000
{EEP_CMD_CH,
EEP_ADR_CH,
EEP_DATA_CH} (List of
Channels)
EB,
8 bits,
32 data to
EEP_DATA
2 TxD,
_CH
MSB First,
Default value
is 0x00