AUTOSAR SWS SPIHandlerDriver
AUTOSAR SWS SPIHandlerDriver
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.5 SpiChannel.......................................................................................... 85
10.2.6 SpiChannelList .................................................................................... 87
10.2.7 SpiJob ................................................................................................. 88
10.2.8 SpiExternalDevice ............................................................................... 89
10.2.9 SpiDriver ............................................................................................. 93
10.2.10 SpiPublishedInformation .................................................................. 94
10.3 Published information ................................................................................. 94
10.4 Configuration concept ................................................................................ 94
11 Not applicable requirements .......................................................................... 97
12 Appendix ........................................................................................................ 98
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
Thus, the specification SWS BSW General shall be considered as additional and re-
quired specification for SPI Handler Driver.
4.1 Limitations
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
parameters
SRS_BSW_00369 All AUTOSAR Basic Software Modules SWS_Spi_00048
shall not return specific development
error codes via the API
SRS_BSW_00375 Basic Software Modules shall report SWS_Spi_00999
wake-up reasons
SRS_BSW_00385 List possible error notifications SWS_Spi_00004
SRS_BSW_00399 Parameter-sets shall be located in a SWS_Spi_00999
separate segment and shall be loaded
after the code
SRS_BSW_00400 Parameter shall be selected from mul- SWS_Spi_00999
tiple sets of parameters after code has
been loaded and started
SRS_BSW_00401 Documentation of multiple instances of SWS_Spi_00999
configuration parameters shall be
available
SRS_BSW_00405 BSW Modules shall support multiple SWS_Spi_00008, SWS_Spi_00013
configuration sets
SRS_BSW_00406 A static status variable denoting if a SWS_Spi_00015, SWS_Spi_00046,
BSW module is initialized shall be SWS_Spi_00373
initialized with value 0 before any APIs
of the BSW module is called
SRS_BSW_00413 An index-based accessing of the in- SWS_Spi_00999
stances of BSW modules shall be
done
SRS_BSW_00416 The sequence of modules to be initial- SWS_Spi_00999
ized shall be configurable
SRS_BSW_00417 Software which is not part of the SW-C SWS_Spi_00999
shall report error events only after the
DEM is fully operational.
SRS_BSW_00422 Pre-de-bouncing of error status infor- SWS_Spi_00999
mation is done within the DEM
SRS_BSW_00423 BSW modules with AUTOSAR inter- SWS_Spi_00999
faces shall be describable with the
means of the SW-C Template
SRS_BSW_00424 BSW module main processing func- SWS_Spi_00999
tions shall not be allowed to enter a
wait state
SRS_BSW_00426 BSW Modules shall ensure data con- SWS_Spi_00999
sistency of data which is shared be-
tween BSW modules
SRS_BSW_00427 ISR functions shall be defined and SWS_Spi_00999
documented in the BSW module de-
scription template
SRS_BSW_00428 A BSW module shall state if its main SWS_Spi_00999
processing function(s) has to be exe-
cuted in a specific order or sequence
SRS_BSW_00429 Access to OS is restricted SWS_Spi_00999
SRS_BSW_00432 Modules should have separate main SWS_Spi_00999
processing functions for read/receive
16 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
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.
[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.⌋ ()
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_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.
independently to Spi_DataBufferType.
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 buff-
ering but it is not able to take care of the consistency of the data in the buffer during
transmission. The size of the Channel buffer is fixed.⌋ (SRS_Spi_12025,
SRS_Spi_12253)
[SWS_Spi_00049] ⌈ The channel data received shall be stored in 1 entry deep in-
ternal buffers by channel. The SPI Handler/Driver shall not take care of the overwrit-
ing of these “receive” buffers by another transmission on the same channel.⌋ ()
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_00280] ⌈ The buffer provided by the application for the SPI Handler
Driver 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.
use … Small data transfer devices (up to 10 Bytes).
EB Channels
It provides… Efficient mechanism to support large stream communication.
Send constant data out of ROM tables and spare RAM size.
Send various data tables each for a different device (highly complex
ASICS with several integrated peripheral devices, also mixed signal
types, could exceed IB HW buffer size)
Suggested use Large streams communication.
… EEPROM communication.
Control of complex HW Chips .
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:
Read and write functions can not guarantee the data integrity while Channel data is
being transmitted.
ECU with functions related to SPI networks having different priorities but also for
ECU using low speed external devices.
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)
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:
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.
28 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
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 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
[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 Sections 7.4.1, 7.4.2 and 7.4.5 summarize the errors that the SPI Handler/Driver
shall be able to detect.
[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)⌋ ()
[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_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_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 spec-
ified 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_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).⌋ ()
[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.⌋ ()
35 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
8 API specification
[SWS_Spi_00063] ⌈ For the type Spi_ConfigType, the definition for each Chan-
nel shall contain:
Buffer usage with EB/IB Channel
Transmit data width (1 up to 32 bits)
Number of data buffers for IB Channels (at least 1) or it is the maximum of da-
ta for EB Channels (a value of 0 makes no sense)
Transfer start LSB or MSB
Default transmit value⌋ (SRS_Spi_12257, SRS_Spi_12025, SRS_Spi_12197,
SRS_Spi_12024)
[SWS_Spi_00009] ⌈ For the type Spi_ConfigType, the definition for each Job
shall contain:
Assigned SPI HW Unit
Assigned Chip Select pin (it is possible to assign no pin)
Chip select functionality on/off
Chip select pin polarity high or low
Baud rate
Timing between clock and chip select
Shift clock idle low or idle high
Data shift with leading or trailing edge
Priority (4 levels are available from 0, the lower to 3, the higher)
Job finish end notification function
MCU dependent properties for the Job (only if needed)
Fixed link of Channels (at least one)⌋ (SRS_BSW_00344,
SRS_SPAL_12056, SRS_SPAL_12125, SRS_Spi_12093, SRS_Spi_12094,
SRS_Spi_12256, SRS_Spi_12257, SRS_Spi_12025, SRS_Spi_12179,
SRS_Spi_12026, SRS_Spi_12259, SRS_Spi_12258, SRS_Spi_12260,
SRS_Spi_12032, SRS_Spi_12033, SRS_Spi_12150)
[SWS_Spi_00064] ⌈ For the type Spi_ConfigType, the definition for each Se-
quence shall contain:
Collection of Jobs (at least one)
Interruptible or not interruptible after each Job
Sequence finish end notification function⌋ (SRS_SPAL_12056,
SRS_Spi_12179, SRS_Spi_12260, SRS_Spi_12199, SRS_Spi_12150)
[SWS_Spi_00010] ⌈ For the type Spi_ConfigType, the configuration will map the
Jobs to the different SPI hardware units and the devices.⌋ (SRS_Spi_12093,
SRS_Spi_12257)
8.2.2 Spi_StatusType
[SWS_Spi_00373] ⌈
Name: Spi_StatusType
Type: Enumeration
Range: SPI_UNINIT 0x00 The SPI Handler/Driver is not initialized or not usable.
SPI_IDLE 0x01 The SPI Handler/Driver is not currently transmitting any
Job.
SPI_BUSY 0x02 The SPI Handler/Driver is performing a SPI Job (trans-
mit).
Description: This type defines a range of specific status for SPI Handler/Driver.
Available via: Spi.h
⌋ (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.⌋ ()
37 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
[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.⌋ ()
8.2.3 Spi_JobResultType
[SWS_Spi_00374] ⌈
Name: Spi_JobResultType
Type: Enumeration
Range: SPI_JOB_OK -- The last transmission of the Job has been finished success-
fully.
SPI_JOB_PENDING -- The SPI Handler/Driver is performing a SPI Job. The mean-
ing of this status is equal to SPI_BUSY.
SPI_JOB_FAILED -- The last transmission of the Job has failed.
SPI_JOB_QUEUED -- An asynchronous transmit Job has been accepted, while
actual transmission for this Job has not started yet.
Description: This type defines a range of specific Jobs status for SPI Handler/Driver.
Available via: Spi.h
⌋ ()
[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
Type: Enumeration
Range: SPI_SEQ_OK -- The last transmission of the Sequence has been finished
successfully.
SPI_SEQ_PENDING -- The SPI Handler/Driver is performing a SPI Sequence. The
meaning of this status is equal to SPI_BUSY.
SPI_SEQ_FAILED -- The last transmission of the Sequence has failed.
SPI_SEQ_CANCELED -- The last transmission of the Sequence has been canceled
by user.
Description: This type defines a range of specific Sequences status for SPI Handler/Driver.
Available via: Spi.h
⌋ ()
[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
Type: uint8
Description: Type of application data buffer elements.
Available via: Spi.h
⌋ ()
8.2.6 Spi_NumberOfDataType
[SWS_Spi_00377] ⌈
Name: Spi_NumberOfDataType
Type: uint16
Description: Type for defining the number of data elements of the type Spi_DataBufferType to
send and / or receive by Channel
Available via: Spi.h
⌋ ()
[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
Type: uint8
Description: Specifies the identification (ID) for a Channel.
Available via: Spi.h
⌋ ()
[SWS_Spi_00356] ⌈ The type Spi_ChannelType specifies the identification (ID) for
a Channel.⌋ ()
8.2.8 Spi_JobType
[SWS_Spi_00379] ⌈
Name: Spi_JobType
Type: uint16
Description: Specifies the identification (ID) for a Job.
Available via: Spi.h
⌋ ()
[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
Type: uint8
Description: Specifies the identification (ID) for a sequence of jobs.
Available via: Spi.h
⌋ ()
[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
Type: uint8
Description: Specifies the identification (ID) for a SPI Hardware microcontroller peripheral
(unit).
Available via: Spi.h
⌋ ()
[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
Type: Enumeration
Range: SPI_POLLING_MODE -- The asynchronous mechanism is ensured by polling, so
interrupts related to SPI busses handled asynchronously
are disabled.
SPI_INTERRUPT_MODE -- The asynchronous mechanism is ensured by interrupt, so
interrupts related to SPI busses handled asynchronously
are enabled.
Description: Specifies the asynchronous mechanism mode for SPI busses handled asynchro-
nously in LEVEL 2.
Available via: Spi.h
⌋ ()
[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.⌋ ()
[SWS_Spi_00175] ⌈
Service name: Spi_Init
Syntax: void Spi_Init(
const Spi_ConfigType* ConfigPtr
)
Service ID[hex]: 0x00
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): ConfigPtr Pointer to configuration set
Parameters (in- None
out):
Parameters (out): None
Return value: None
Description: Service for SPI initialization.
Available via: Spi.h
⌋ ()
[SWS_Spi_00299] ⌈ The function Spi_Init provides the service for SPI initializati-
on.⌋ ()
[SWS_Spi_00013] ⌈ The function Spi_Init shall initialize all SPI relevant regis-
ters 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_00082] ⌈ The function Spi_Init shall define default values for required
parameters of the structure referenced by the ConfigPtr. For example: all buffer
pointers shall be initialized as a null value pointer.⌋ ()
[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
Syntax: Std_ReturnType Spi_DeInit(
void
)
Service ID[hex]: 0x01
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): None
Parameters (in- None
out):
Parameters (out): None
Std_ReturnType E_OK: de-initialisation command has been accepted
Return value:
E_NOT_OK: de-initialisation command has not been accepted
Description: Service for SPI de-initialization.
Available via: Spi.h
⌋ ()
[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
value of this function shall be E_NOT_OK.⌋ ()
[SWS_Spi_00303] ⌈ The function Spi_DeInit provides the service for SPI de-
initialization.⌋ ()
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] ⌈
Service name: Spi_WriteIB
Syntax: Std_ReturnType Spi_WriteIB(
Spi_ChannelType Channel,
const Spi_DataBufferType* DataBufferPtr
)
Service ID[hex]: 0x02
Sync/Async: Synchronous
Reentrancy: Reentrant
Channel Channel ID.
Parameters (in): DataBufferPtr Pointer to source data buffer. If this pointer is null, it is assumed
that the data to be transmitted is not relevant and the default
transmit value of this channel will be used instead.
Parameters (in- None
out):
Parameters (out): None
Std_ReturnType E_OK: write command has been accepted
Return value:
E_NOT_OK: write command has not been accepted
Description: Service for writing one or more data to an IB SPI Handler/Driver Channel specified
by parameter.
Available via: Spi.h
⌋ ()
[SWS_Spi_00305] ⌈ When the API Spi_WriteIB command has been accepted the
function returns the value E_OK.⌋ ()
44 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
[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
Syntax: Std_ReturnType Spi_AsyncTransmit(
Spi_SequenceType Sequence
)
Service ID[hex]: 0x03
Sync/Async: Asynchronous
Reentrancy: Reentrant
Parameters (in): Sequence Sequence ID.
Parameters (in- None
out):
Parameters (out): None
Std_ReturnType E_OK: Transmission command has been accepted
Return value:
E_NOT_OK: Transmission command has not been accepted
Description: Service to transmit data on the SPI bus.
Available via: Spi.h
⌋ ()
[SWS_Spi_00310] ⌈ When the API Spi_AsyncTransmit command has not been ac-
cepted the function shall return the value E_NOT_OK.⌋ ()
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
Syntax: Std_ReturnType Spi_ReadIB(
Spi_ChannelType Channel,
Spi_DataBufferType* DataBufferPointer
)
Service ID[hex]: 0x04
Sync/Async: Synchronous
Reentrancy: Reentrant
47 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
[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
Syntax: Std_ReturnType Spi_SetupEB(
Spi_ChannelType Channel,
const Spi_DataBufferType* SrcDataBufferPtr,
Spi_DataBufferType* DesDataBufferPtr,
48 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
Spi_NumberOfDataType Length
)
Service ID[hex]: 0x05
Sync/Async: Synchronous
Reentrancy: Reentrant
Channel Channel ID.
SrcDataBufferPtr Pointer to source data buffer.
Parameters (in): Length Length (number of data elements) of the data to be transmitted
from SrcDataBufferPtr and/or received from DesDataBufferPtr
Min.: 1
Max.: Max of data specified at configuration for this channel
Parameters (in- DesDataBufferPtr Pointer to destination data buffer in RAM.
out):
Parameters (out): None
Std_ReturnType E_OK: Setup command has been accepted
Return value:
E_NOT_OK: Setup command has not been accepted
Description: Service to setup the buffers and the length of data for the EB SPI Handler/Driver
Channel specified.
Available via: Spi.h
⌋ ()
[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)
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
Syntax: Spi_StatusType Spi_GetStatus(
void
)
Service ID[hex]: 0x06
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters (in- None
out):
Parameters (out): None
Return value: Spi_StatusType Spi_StatusType
Description: Service returns the SPI Handler/Driver software module status.
Available via: Spi.h
⌋ ()
8.3.8 Spi_GetJobResult
[SWS_Spi_00182] ⌈
Service name: Spi_GetJobResult
Syntax: Spi_JobResultType Spi_GetJobResult(
Spi_JobType Job
)
Service ID[hex]: 0x07
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Job Job ID. An invalid job ID will return an undefined result.
Parameters (in- None
out):
Parameters (out): None
Return value: Spi_JobResultType Spi_JobResultType
Description: This service returns the last transmission result of the specified Job.
Available via: Spi.h
⌋ ()
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
Syntax: Spi_SeqResultType Spi_GetSequenceResult(
Spi_SequenceType Sequence
)
Service ID[hex]: 0x08
Sync/Async: Synchronous
Reentrancy: Reentrant
Sequence Sequence ID. An invalid sequence ID will return an undefined
Parameters (in):
result.
Parameters (in- None
out):
Parameters (out): None
Return value: Spi_SeqResultType Spi_SeqResultType
Description: This service returns the last transmission result of the specified Sequence.
Available via: Spi.h
⌋ ()
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] ⌈
Service name: Spi_GetVersionInfo
Syntax: void Spi_GetVersionInfo(
Std_VersionInfoType* versioninfo
)
Service ID[hex]: 0x09
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters (in- None
out):
Parameters (out): versioninfo Pointer to where to store the version information of this module.
Return value: None
Description: This service returns the version information of this module.
Available via: Spi.h
⌋ ()
8.3.11 Spi_SyncTransmit
[SWS_Spi_00185] ⌈
Service name: Spi_SyncTransmit
Syntax: Std_ReturnType Spi_SyncTransmit(
Spi_SequenceType Sequence
)
Service ID[hex]: 0x0a
Sync/Async: Asynchronous
Reentrancy: Reentrant
Parameters (in): Sequence Sequence ID.
Parameters (in- None
out):
Parameters (out): None
Std_ReturnType E_OK: Transmission command has been accepted
Return value:
E_NOT_OK: Transmission command has not been accepted
53 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
8.3.12 Spi_GetHWUnitStatus
[SWS_Spi_00186] ⌈
Service name: Spi_GetHWUnitStatus
54 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
8.3.13 Spi_Cancel
[SWS_Spi_00187] ⌈
Service name: Spi_Cancel
Syntax: void Spi_Cancel(
Spi_SequenceType Sequence
)
Service ID[hex]: 0x0c
Sync/Async: Asynchronous
Reentrancy: Reentrant
Parameters (in): Sequence Sequence ID.
Parameters (in- None
out):
55 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
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
Syntax: Std_ReturnType Spi_SetAsyncMode(
Spi_AsyncModeType Mode
)
Service ID[hex]: 0x0d
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): Mode New mode required.
Parameters (in- None
out):
Parameters (out): None
Std_ReturnType E_OK: Setting command has been done
Return value:
E_NOT_OK: setting command has not been accepted
Description: Service to set the asynchronous mechanism mode for SPI busses handled asyn-
chronously.
Available via: Spi.h
⌋ ()
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.
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.
57 of 100 Document ID 038: AUTOSAR_SWS_SPIHandlerDriver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0
8.5.1 Spi_MainFunction_Handling
[SWS_Spi_00189] ⌈
Service name: Spi_MainFunction_Handling
Syntax: void Spi_MainFunction_Handling(
void
)
Service ID[hex]: 0x10
Description: --
Available via: SchM_Spi.h
⌋ ()
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.
The SPI Handler/Driver module requires some interfaces to fulfill its core functionali-
ty.
[SWS_Spi_00389]⌈
API function Header Description
File
Det_ReportRuntimeError Det.h Service to report runtime errors. If a callout has been config-
ured then this callout shall be called.
⌋ ()
This chapter defines all interfaces which are required to fulfill an optional functionality
of SPI Handler/Driver module.
[SWS_Spi_00339] ⌈
API function Header Description
File
Dem_SetEventStatus Dem.h Called by SW-Cs or BSW modules to report monitor status
information to the Dem. BSW modules calling
Dem_SetEventStatus can safely ignore the return value.
Det_ReportError Det.h Service to report development errors.
⌋ ()
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 re-
quired 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)
Syntax: void (*Spi_JobEndNotification)(
void
)
Sync/Async: Synchronous
Reentrancy: Reentrant
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)
Syntax: void (*Spi_SeqEndNotification)(
void
)
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters (in- None
out):
Parameters (out): None
Return value: None
Description: Callback routine provided by the user for each Sequence to notify the caller that a
sequence has been finished.
Available via: Spi_Externals.h
⌋ ()
Note: This routine might be called on interrupt level, depending on the calling func-
tion.
9 Sequence diagrams
9.1 Initialization
Spi_Init(const
Spi_ConfigType*)
Spi_Init()
Description:
Initialization of SPI Handler/Driver is
Spi_Init(const
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:
<Spi_Seq0EndNotification>() When a Job transmission ends, if it is configured,
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
Sequence process is Description:
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.
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
[SWS_Spi_00390] DRAFT ⌈ The SPI module shall reject configurations with partition
mappings 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
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
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
Name SpiDevErrorDetect
Parent Container SpiGeneral
Description Switches the development error detection and notification on or off.
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
Description Maps the SPI driver to zero or multiple ECUC partitions to make the driver
API available in the according partition.
Tags:
atp.Status=draft
Multiplicity 0..*
Type Reference to [ EcucPartition ]
Post-Build Variant Multi-
true
plicity
Post-Build Variant Value true
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
No Included Containers
10.2.4 SpiSequence
SWS Item ECUC_Spi_00106 :
Container Name SpiSequence
Description All data needed to configure one SPI-sequence
Configuration Parameters
No Included Containers
10.2.5 SpiChannel
SWS Item ECUC_Spi_00104 :
Container Name SpiChannel
Description All data needed to configure one SPI-channel
Configuration Parameters
Type EcucIntegerParamDef
Range 1 .. 32
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
Range 0 .. 65535
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
dependency: The SPI_CHANNEL_TYPE parameter has to be configured
as IB for this Channel. The SPI_CHANNEL_BUFFERS_ALLOWED pa-
rameter has to be configured as 0 or 2.
No Included Containers
10.2.6 SpiChannelList
SWS Item ECUC_Spi_00233 :
Container Name SpiChannelList
Description References to SPI channels and their order within the Job.
Configuration Parameters
Multiplicity 1
Type Reference to [ SpiChannel ]
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
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
Name SpiJobPriority
Parent Container SpiJob
Description Priority set accordingly to SPI093: 0, lowest, 3, highest priority
Multiplicity 1
Type EcucIntegerParamDef
Range 0 .. 3
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
Included Containers
Container Name Multiplicity Scope / Dependency
SpiChannelList 1..* References to SPI channels and their order within the Job.
10.2.8 SpiExternalDevice
SWS Item ECUC_Spi_00207 :
Container Name SpiExternalDevice
The communication settings of an external device. Closely linked to Spi-
Description
Job.
Configuration Parameters
Type EcucEnumerationParamDef
Range HIGH --
LOW --
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
No Included Containers
10.2.9 SpiDriver
SWS Item ECUC_Spi_00091 :
Container Name SpiDriver
This container contains the configuration parameters and sub containers of
Description
the AUTOSAR Spi module.
Configuration Parameters
plicity
Post-Build Variant Value true
Multiplicity ConfigurationPre-compile time X VARIANT-PRE-COMPILE
Class Link time X VARIANT-LINK-TIME
Post-build time X VARIANT-POST-BUILD
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
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
10.2.10 SpiPublishedInformation
SWS Item ECUC_Spi_00235 :
Container Name SpiPublishedInformation
Description Container holding all SPI specific published information parameters
Configuration Parameters
No Included Containers
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,
CS_LOW,
2 (Number of Jobs), EB,
CLK_2MHz,
{EEP_CMD_JOB, 8 bits,
1 (time in µs),
EEP_DATA_JOB} (List of 1 data to TxD,
EEP_WRITE_SEQ 0 EEP_CMD_JOB 0 Polarity 180, EEP_CMD_CH 0
Jobs), MSB First,
Falling Edge,
Not Interruptible, Default value is
3,
EEP_vidEndOfWriteSeq 0x00
EEP_vidEndOfStartWrJob,
1 (Number of Channels)
{EEP_CMD_CH} (List of Chan-
nels)
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} (List of
Polarity 180, 1 data to TxD,
EEP_READ_SEQ 1 Jobs), EEP_DATA_JOB 1 EEP_ADR_CH 1
Falling Edge, MSB First,
Not Interruptible,
2, Default value is
EEP_vidEndOfReadSeq
NULL, 0x0000
3 (Number of Channels)
{EEP_CMD_CH, EEP_ADR_CH,
EEP_DATA_CH} (List of Chan-
nels)
EB,
8 bits,
32 data to TxD,
EEP_DATA_CH 2
MSB First,
Default value is
0x00
99 of 100 AUTOSAR_SWS_SPIHandler_Driver
- AUTOSAR confidential -
Specification of SPI Handler / Driver
AUTOSAR CP Release 4.4.0