DEENESPTFRRUARHIKOZHNL

CAN Driver (Can)

ModulCan (CAN Driver)
BSW-Modul-ID80
Standard-Header#include "Can.h"
SWS-SpezifikationAUTOSAR_SWS_CANDriver.pdf
ClusterCAN

Module guideAI-GENERATED

Controls the CAN controller hardware and mediates transmission, reception, and state changes to the CAN Interface.
AI-GENERATED unreviewed Model: claude-opus-5-5 · Effort: high · Temperature: not controllable · Prompt: b6833c934a77 Provenance Open questions (2)
Causal anchor: R20-11 Valid from R20-11 Synthesized for this specification release.
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Controls the CAN controller hardware and mediates transmission, reception, and state changes to the CAN Interface.

The CAN driver controls the CAN controllers of a hardware unit and is the hardware layer beneath the CAN Interface. It reports reception, transmission confirmation, bus-off, and mode changes to it via callback [SWS_Can_00234]. After Can_Init, all controllers are in STOPPED. Each controller is started individually and asynchronously with Can_SetControllerMode; success is only reported subsequently [SWS_Can_00230]. Transmission is performed with Can_Write via hardware transmit handles. If no transmit object is free, the driver returns CAN_BUSY, and CanIf buffers the request.

The CAN driver encapsulates all access to the CAN controllers of a hardware unit. It serves the CAN Interface as its sole user and reports reception, transmission confirmation, bus-off, and mode changes via predefined CanIf callbacks [SWS_Can_00234]. The ECU State Manager initializes it with Can_Init and a hardware-specific Can_ConfigType [SWS_Can_00223]. After that, the driver is in CAN_READY and all controllers are in STOPPED SWS CANDriver p. 29.

kontext EcuM EcuM Can Can (CAN-Treiber) EcuM->Can Can_Init / Can_DeInit SchM BSW Scheduler SchM->Can Can_MainFunction_* CanSM CanSM CanIf CanIf CanSM->CanIf Mode requests CanIf->CanSM Mode and bus-off notifications CanIf->Can Can_Write, Can_SetControllerMode, Can_CheckWakeup, Abfragen Can->EcuM EcuM_CheckWakeup, EcuM_SetWakeupEvent Can->CanIf CanIf_RxIndication, CanIf_TxConfirmation, CanIf_ControllerBusOff, CanIf_ControllerModeIndication HW CAN-Controller (Hardware) Can->HW Registerzugriff Det Det Can->Det Det_ReportError / Det_ReportRuntimeError Os Os Can->Os GetCounterValue HW->Can Interrupts / Statusflags

Context diagram: Embedding of Can between EcuM, BSW Scheduler, CanIf, DET, Os, and the controller hardware. Sources: [SWS_Can_00234], SWS CANDriver p. 78

Each controller passes through the states UNINIT, STOPPED, STARTED, and SLEEP [SWS_Can_91013]. It is started individually and asynchronously with Can_SetControllerMode: E_OK only means "accepted" [SWS_Can_00230]. The driver reports the reached state later via CanIf_ControllerModeIndication SWS CANDriver p. 33. Bus-off leads the controller to STOPPED without hardware recovery; a bus wakeup leads it from SLEEP to STOPPED SWS CANDriver p. 35.

controllerzustand reset Power-on-Reset UNINIT CAN_CS_UNINIT reset->UNINIT STOPPED CAN_CS_STOPPED UNINIT->STOPPED Can_Init STOPPED->UNINIT Can_DeInit STOPPED->STOPPED Can_SetBaudrate STARTED CAN_CS_STARTED STOPPED->STARTED Can_SetControllerMode(CAN_CS_STARTED) SLEEP CAN_CS_SLEEP STOPPED->SLEEP Can_SetControllerMode(CAN_CS_SLEEP) STARTED->STOPPED Can_SetControllerMode(CAN_CS_STOPPED) or bus-off (hardware) SLEEP->UNINIT Can_DeInit SLEEP->STOPPED Can_SetControllerMode(CAN_CS_STOPPED) or wakeup from bus SLEEP->SLEEP Can_SetBaudrate

State diagram: Transitions of a controller through software calls as well as bus-off and wakeup events. Sources: [SWS_Can_91010], SWS CANDriver p. 38

Transmission is performed using Can_Write(Hth, PduInfo). The two most significant bits of Can_IdType distinguish CAN 2.0 and CAN FD as well as standard and extended ID [SWS_Can_00233] [SWS_Can_00416]. If no transmit object is free, the driver returns CAN_BUSY, and CanIf buffers the request [SWS_Can_00039] SWS CANDriver p. 47. Events are detected via interrupt or by polling. Cyclic main functions are provided for polling SWS CANDriver p. 41:

  • Write and Read: transmit confirmations and reception
  • BusOff and Wakeup: bus-off and wakeup events
  • Mode: mode transitions

The main functions are defined in [SWS_Can_00225] through [SWS_Can_00228] and [SWS_Can_00368].

In case of an error, the driver reports development errors such as CAN_E_UNINIT or CAN_E_TRANSITION to the DET [SWS_Can_91019]. Functions with a return value then return E_NOT_OK SWS CANDriver p. 48. Bus-off recovery is handled by CanSM via CanIf. The restart is presumed to occur via Can_SetControllerMode(CAN_CS_STARTED) again SWS CANInterface p. 138. Error state and error counters can be queried; however, the counter values are not considered a reliable bus state [SWS_Can_91004] [SWS_Can_00516]. Question (open)

Role: hardware-oriented driver between CanIf and CAN controllers

The CAN driver encapsulates all access to the CAN hardware of a hardware unit. State changes of the controllers occur only via Can_Init, Can_SetBaudrate, and Can_SetControllerMode. The driver does not store the state transitions itself SWS CANDriver p. 30. Its upper communication partner is the CAN Interface. All callbacks invoked by the driver are implemented in CanIf and are not configurable: CanIf_RxIndication, CanIf_TxConfirmation, CanIf_ControllerBusOff, and CanIf_ControllerModeIndication. In addition, it requires Det_ReportRuntimeError and the Os service GetCounterValue [SWS_Can_00234] SWS CANDriver p. 73. Imported types originate, among others, from ComStack_Types, EcuM, and Os [SWS_Can_00222].

The ECU State Manager initializes the driver via Can_Init. According to the implementation note, it calls the function at most once at runtime [SWS_Can_00223] SWS CANDriver p. 29. The cyclic main functions are called directly by the BSW Scheduler. They have neither parameters nor return values and are non-reentrant; no execution order is prescribed SWS CANDriver p. 78. The driver offers no callbacks toward lower layers. External CAN controllers may only be accessed via synchronous MCAL APIs such as SPI SWS CANDriver p. 76.

kontext EcuM EcuM Can Can (CAN-Treiber) EcuM->Can Can_Init / Can_DeInit SchM BSW Scheduler SchM->Can Can_MainFunction_* CanSM CanSM CanIf CanIf CanSM->CanIf Mode requests CanIf->CanSM Mode and bus-off notifications CanIf->Can Can_Write, Can_SetControllerMode, Can_CheckWakeup, Abfragen Can->EcuM EcuM_CheckWakeup, EcuM_SetWakeupEvent Can->CanIf CanIf_RxIndication, CanIf_TxConfirmation, CanIf_ControllerBusOff, CanIf_ControllerModeIndication HW CAN-Controller (Hardware) Can->HW Registerzugriff Det Det Can->Det Det_ReportError / Det_ReportRuntimeError Os Os Can->Os GetCounterValue HW->Can Interrupts / Statusflags

Context diagram: Can is initialized by EcuM, called cyclically by the BSW Scheduler, and used by CanIf. It reports to CanIf, EcuM, and DET, and uses Os for timeouts. Sources: [SWS_Can_00234], SWS CANDriver p. 45, SWS CANDriver p. 78

From power-on to STARTED: driver and controller states

The driver as a whole recognizes only the states CAN_UNINIT and CAN_READY. After reset, it is in CAN_UNINIT. Can_Init initializes all controllers according to the configuration and transitions to CAN_READY thereafter. Can_DeInit sets the module state to CAN_UNINIT before deinitializing the controllers [SWS_Can_00223] [SWS_Can_91002] SWS CANDriver p. 29.

Separate from this, each controller has four states from Can_ControllerStateType: CAN_CS_UNINIT, CAN_CS_STOPPED, CAN_CS_STARTED, and CAN_CS_SLEEP [SWS_Can_91013].

  • In STOPPED, the controller is initialized, but does not participate in bus communication and sends neither error frames nor acknowledges.
  • STARTED is normal operation.
  • SLEEP differs from STOPPED only on hardware with sleep mode SWS CANDriver p. 31.

Can_Init sets all controllers to STOPPED SWS CANDriver p. 32. Can_DeInit transitions them from STOPPED or SLEEP to UNINIT [SWS_Can_91010] SWS CANDriver p. 38. There is no direct path from STARTED to UNINIT SWS CANDriver p. 38.

controllerzustand reset Power-on-Reset UNINIT CAN_CS_UNINIT reset->UNINIT STOPPED CAN_CS_STOPPED UNINIT->STOPPED Can_Init STOPPED->UNINIT Can_DeInit STOPPED->STOPPED Can_SetBaudrate STARTED CAN_CS_STARTED STOPPED->STARTED Can_SetControllerMode(CAN_CS_STARTED) SLEEP CAN_CS_SLEEP STOPPED->SLEEP Can_SetControllerMode(CAN_CS_SLEEP) STARTED->STOPPED Can_SetControllerMode(CAN_CS_STOPPED) or bus-off (hardware) SLEEP->UNINIT Can_DeInit SLEEP->STOPPED Can_SetControllerMode(CAN_CS_STOPPED) or wakeup from bus SLEEP->SLEEP Can_SetBaudrate

State diagram: lifecycle of a CAN controller. Software and bus events trigger transitions; return to UNINIT is only possible via Can_DeInit from STOPPED or SLEEP. Sources: [SWS_Can_91013], [SWS_Can_91010], SWS CANDriver p. 38, SWS CANDriver p. 34, SWS CANDriver p. 35

Each controller is started individually with Can_SetControllerMode(CAN_CS_STARTED) SWS CANDriver p. 29. The service operates asynchronously: E_OK only indicates that the request was accepted [SWS_Can_00230]. Upon each transition to STARTED, the controller is reinitialized using the configuration last used by Can_Init or Can_SetBaudrate SWS CANDriver p. 59. The hardware may apply the transition with a delay. Therefore, the driver reports the reached state only subsequently via CanIf_ControllerModeIndication; whether the target is reached is monitored by an upper layer SWS CANDriver p. 33. Polled mode transitions are detected by Can_MainFunction_Mode [SWS_Can_00368]. Can_GetControllerMode synchronously queries the current mode [SWS_Can_91014].

Initialization and start of a CAN controllerEcuMCanIf-Nutzer (z. B. CanSM)CanIfCanBSW SchedulerCAN-ControllerUse Case: InitialisierungCan_Init(Config)Configure all controllersController: CAN_CS_STOPPEDModul: CAN_READYUse Case: Controller einzeln startenCanIf_SetControllerMode(STARTED)Can_SetControllerMode(Controller, CAN_CS_STARTED)Neuinitialisierung,Start anfordernE_OK (Anforderung angenommen)E_OKloopUntil transition takes effectCan_MainFunction_Mode()Statusflag lesenCanIf_ControllerModeIndication(ControllerId, CAN_CS_STARTED)<User_ControllerModeIndication>

Sequence diagram: initialization by EcuM and asynchronous start of a controller. The success notification only follows after polling in Can_MainFunction_Mode. Sources: [SWS_Can_00230], [SWS_Can_00368], SWS CANInterface p. 156, SWS CANDriver p. 29

Transmission via hardware transmit handles

CanIf passes transmit requests with Can_Write(Hth, PduInfo). The Hth specifies the hardware transmit object and thus also the controller, because HTH numbers are unique within a hardware unit [SWS_Can_00233]. Can_HwHandleType covers 0..0x0FF by default and, if there are more than 255 hardware objects, the extended range up to 0xFFFF [SWS_Can_00429]. Can_PduType bundles the fields swPduHandle, length, id, and sdu [SWS_Can_00415].

In Can_IdType, the two most significant bits encode the frame type [SWS_Can_00416]:

  • 00: CAN with standard ID
  • 01: CAN FD with standard ID
  • 10: CAN with extended ID
  • 11: CAN FD with extended ID

This allows CAN 2.0 and CAN FD frames to be mixed at frame level, provided an FD baud rate configuration is active for the controller SWS CANDriver p. 49 SWS CANInterface p. 71.

Can_Write must be thread-safe because CanIf_Transmit is reentrant. The driver returns CAN_BUSY if no transmit object is free or if a preemptive call cannot be executed reentrantly [SWS_Can_00039] SWS CANDriver p. 47. CanIf then buffers the request. If an object becomes free, CanIf calls Can_Write again in priority order SWS CANInterface p. 48. The driver keeps the swPduHandle available until the corresponding CanIf_TxConfirmation SWS CANDriver p. 35. Multiplexed Transmission can be configured statically to prevent priority inversion; multiple hardware objects then form an HTH SWS CANDriver p. 40.

Transmission of an L-PDU with confirmationCanIfCanCAN-ControllerBSW SchedulerCan_Write(Hth, PduInfo)altHardware-Sendeobjekt freiswPduHandle je HTH merkenL-PDU ins Hardwareobjekt,Trigger transmissionE_OKNo object available or not reentrantly executableCAN_BUSYBuffer L-PDU in CanIfTxBufferFrame transmitted and acknowledged by busaltInterrupt-BetriebTX-InterruptPolling-BetriebCan_MainFunction_Write()Check pending confirmationsCanIf_TxConfirmation(swPduHandle)optBuffered L-PDU for this HTHCan_Write(Hth, highest-priority L-PDU)

Sequence diagram: transmit request with paths E_OK and CAN_BUSY, followed by confirmation via interrupt or polling. Afterward, CanIf can provide a buffered L-PDU. Sources: [SWS_Can_00233], [SWS_Can_00039], SWS CANInterface p. 142, SWS CANInterface p. 48

Reception and the cyclic main functions

Upon reception, the driver calls CanIf_RxIndication. It passes ID, hardware object, and abstract CanIf ControllerId as well as length and pointer to the L-SDU. For extended frames, it sets the MSB of the ID so that CanIf detects the frame type SWS CANDriver p. 43. Optionally, a configurable L-PDU callout <LPDU_CalloutName> is interposed beforehand [SWS_Can_00443]. If it returns false, the L-PDU is not processed further according to the document passage (R25-11) SWS CANDriver p. 77.

Events are detected via interrupt or by polling status flags. Pure polling operation without any interrupts must be configurable. In polling operation, the main functions invoke the same callbacks, only from task context instead of ISR context SWS CANDriver p. 41. Each main function polls one type of event:

The R20-11 descriptions of Read and Write mention only the case POLLING [SWS_Can_00225] [SWS_Can_00226]. The document passages of later releases add MIXED; then only objects with CanHardwareObjectUsesPolling = TRUE are polled SWS CANDriver p. 81 SWS CANDriver p. 79. The R20-11 requirements do not support this extension. If multiple periods are configured via CanMainFunctionRWPeriods, the function names receive the suffix _<ShortName> [SWS_Can_00441] SWS CANDriver p. 122. In the absence of any polling, a main function may be implemented as an empty define SWS CANDriver p. 81.

Reception of an L-PDU in polling modeBSW SchedulerCanCAN-ControllerL-PDU-CalloutCanIfCanIf-NutzerloopzyklischCan_MainFunction_Read()Check for new L-PDUsaltneue L-PDU vorhandenID normieren (Extended: MSB = 1),Daten ggf. in angepassten PufferoptL-PDU-Callout konfiguriert<LPDU_CalloutName>(Hrh, CanId, CanDataLegth, CanSduPtr)true / falseIf false: discard L-PDUCanIf_RxIndication(Mailbox, PduInfoPtr)Rx indication to userNo new L-PDU

Sequence diagram: reception in polling mode with ID normalization, optional L-PDU callout, and forwarding to CanIf. Sources: [SWS_Can_00226], [SWS_Can_00443], SWS CANInterface p. 153, SWS CANDriver p. 43

Sleep, wakeup, and interrupt control

The driver handles only wakeups detected by the controller itself, not those via the transceiver SWS CANDriver p. 45. Upon a hardware wakeup, the controller transitions from SLEEP to STOPPED. The triggering L-PDU is not processed further. EcuM_CheckWakeup is called in the interrupt or in Can_MainFunction_Wakeup, with the source configured via CanWakeupSourceRef SWS CANDriver p. 35. EcuM then calls Can_CheckWakeup via CanIf. This function reports a detected wakeup via EcuM_SetWakeupEvent [SWS_Can_00360] SWS CANDriver p. 63. EcuM and CanIf validate against spurious wakeups without driver involvement SWS CANDriver p. 45.

Can_DisableControllerInterrupts and Can_EnableControllerInterrupts are reentrant and act in a nested manner. After n disable calls, n enable calls are necessary. An enable without a preceding disable has no effect [SWS_Can_00231] [SWS_Can_00232] SWS CANDriver p. 61 SWS CANDriver p. 62.

Wakeup from CAN busCAN-ControllerCanEcuMCanIfUse Case: Controller in CAN_CS_SLEEPWakeup event from busaltInterrupt-BetriebWakeup-ISRPolling-BetriebCan_MainFunction_Wakeup()Controller SLEEP -> STOPPED,Do not process triggering L-PDUEcuM_CheckWakeup(source from CanWakeupSourceRef)Check wakeup source via CanIfCan_CheckWakeup(Controller)optWakeup erkanntEcuM_SetWakeupEventE_OKValidierung gegen FehlwakeupsBy EcuM and CanIf, without Can

Sequence diagram: bus wakeup from SLEEP, notification to EcuM, and query via CanIf with Can_CheckWakeup. Sources: [SWS_Can_00360], [SWS_Can_00228], SWS CANDriver p. 45, SWS CANDriver p. 35

Configuration sets, partitions, and instance reference

Can_Init receives a pointer to Can_ConfigType. This hardware-specific structure contains settings for all controllers and references to the individual controller configurations [SWS_Can_00223] [SWS_Can_00413]. The module supports VARIANT-PRE-COMPILE and VARIANT-POST-BUILD SWS CANDriver p. 96. In the post-build example, one of several configuration sets is selected when calling Can_Init EXP LayeredSoftwareArchitecture p. 120. For each controller, CanController defines, among other things, CanRxProcessing, CanTxProcessing, CanBusoffProcessing, CanWakeupProcessing, and at least one CanControllerBaudrateConfig SWS CANDriver p. 101.

In multi-partition systems, the module operates in each partition as an independent instance. An API call takes effect only in its own partition [SWS_Can_CONSTR_00508]. Three rules apply to partition assignment:

  • The partitions in CanControllerEcucPartitionRef must be a subset of the partitions in CanEcucPartitionRef [SWS_Can_CONSTR_00509].
  • Controller and transceiver channel of a communication channel reference the same partition [SWS_Can_CONSTR_00510].
  • The driver rejects unsupported assignments [SWS_Can_00507].

Multiple Can modules in an ECU are distinguished by a modified function prefix SWS CANDriver p. 51.

Behavior in the event of an error

When development error detection is active, the driver reports development errors to the DET. The codes range from CAN_E_PARAM_POINTER (0x01) via CAN_E_UNINIT (0x05) and CAN_E_TRANSITION (0x06) to CAN_E_INIT_FAILED (0x09) [SWS_Can_91019]. After returning from the DET, the function returns immediately; functions with a return value then return E_NOT_OK SWS CANDriver p. 48. Some examples:

CAN_E_DATALOST is defined as a runtime error for lost received messages [SWS_Can_91020]. It is presumed to be reported via the required Det_ReportRuntimeError [SWS_Can_00234]. Question Q-50225b25430c9660 (open)

If a controller enters bus-off, it transitions from STARTED to STOPPED. The driver performs no hardware recovery. It reports the event via interrupt or in Can_MainFunction_BusOff via CanIf_ControllerBusOff [SWS_Can_00227] SWS CANDriver p. 35. Recovery is handled by CanSM, which CanIf informs with CanSM_ControllerBusOff SWS CANInterface p. 138. Interpretation: The restart is presumed to occur via Can_SetControllerMode(CAN_CS_STARTED) again, which reloads the configuration in the process SWS CANDriver p. 59. Question Q-83e484ab9f8b1aac (open)

Bus-off detection and notificationCAN-ControllerCanBSW SchedulerCanIfCanSMController erreicht Bus-offaltInterrupt-BetriebBus-off-InterruptPolling-BetriebCan_MainFunction_BusOff()Statusbit lesenSTARTED -> STOPPED,no hardware recoveryCanIf_ControllerBusOff(ControllerId)CanSM_ControllerBusOffBus-off recovery is handled by CanSMUse Case: Neustart (Interpretation)Neustart anfordern (Interpretation)Can_SetControllerMode(Controller, CAN_CS_STARTED)Reinitialization withzuletzt verwendeter Konfiguration

Sequence diagram: detection and reporting of a bus-off up to the CanSM. The restart marked as an interpretation is not explicitly supported by evidence. Sources: [SWS_Can_00227], [SWS_Can_00234], SWS CANDriver p. 35, SWS CANInterface p. 138

For diagnostics, Can_GetControllerErrorState returns the error state: ACTIVE, PASSIVE, or BUSOFF [SWS_Can_91004] [SWS_Can_91003]. The Rx and Tx error counters can also be queried. If the controller does not provide them, the functions return E_NOT_OK. Because the hardware maintains the counters asynchronously, the values are unsuitable for assumptions about the bus state [SWS_Can_00511] [SWS_Can_00516] SWS CANDriver p. 67. Can_ErrorType describes a superset of typical hardware error types, from bit errors to bus-lock [SWS_Can_91021].

To handle non-responsive hardware, the driver uses an OsCounter for timeouts SWS CANDriver p. 23. If a mode change does not take effect within CanTimeoutDuration, Can_SetControllerMode exits the function instead of blocking SWS CANDriver p. 33. If a bus wakeup occurs during the transition to sleep mode, Can_SetControllerMode(CAN_CS_STOPPED) returns E_NOT_OK SWS CANDriver p. 35.

Further detailed evidence

Many document passages originate from R23-11 through R25-11. The cited requirements are normative for R20-11. The state diagram SWS CANDriver p. 38 originates directly from R20-11.

AI-generated guide based on the requirements and document passages provided in the payload for R20-11. Assumptions are identified as an interpretation; the specification remains authoritative.

CAN Driver (Can)

The CAN driver provides hardware-dependent access to the internal and external CAN controllers (CAN 2.0B, CAN FD, CAN XL).

Funktionen — Übersicht

Typen — Übersicht

Funktionen & Typen — Detailansicht

function Can_Init [SWS_Can_00223] 📄 PDF

void Can_Init (const Can_ConfigType* Config);

This function initializes the module.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 8afbe47dbadd Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The synchronous, non-reentrant function Can_Init initializes the entire CAN driver module as well as the associated hardware units according to the passed configuration [SWS_Can_00223].

Usage and Call Context

The call to Can_Init is mandatory during the startup phase of the ECU by the ECU State Manager, before any other function of the CAN driver may be called [SWS_Can_91012]. As a parameter, the function takes a pointer to the driver configuration (const Can_ConfigType*) via Config and returns no value [SWS_Can_00223].

Initialization Scope and State Transitions

As part of the initialization, the function sets all required hardware registers and initializes all CAN controllers AUTOSAR_SWS_CANDriver p. 33:

  • Initialization of static variables and internal flags [SWS_Can_91012],
  • Configuration of common settings for the complete CAN hardware unit [SWS_Can_91012],
  • Controller-specific settings for each individual CAN controller [SWS_Can_91012].

The function call triggers state transitions of the CAN hardware AUTOSAR_SWS_CANDriver p. 10, where Can_Init performs the register configuration to transition the controllers into the intended base state [SWS_Can_91010] AUTOSAR_SWS_CANDriver p. 36.

Concurrency and Limitations

Since Can_Init is specified as non-reentrant, no parallel or repeated call may take place during an ongoing initialization [SWS_Can_00223]. Furthermore, certain global settings of the hardware unit can only be set within Can_Init AUTOSAR_SWS_CANDriver p. 33.

This usage note was generated automatically based on the specification data of AUTOSAR Classic R20-11.

Implementer's Guide to follow (complexity I1)

function Can_DeInit [SWS_Can_91002] 📄 PDF

void Can_DeInit (void);

This function de - initializes the module.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 982976925c7a Provenance Open questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The function Can_DeInit serves to deinitialize the CAN driver module ([SWS_Can_91002]). It has the signature void Can_DeInit(void), takes no parameters, returns no value, and is executed synchronously and non-reentrantly ([SWS_Can_91002]). The interface is available via the header Can.h ([SWS_Can_91002]).

The call initiates a software-controlled state transition (AUTOSAR_SWS_CANDriver p. 10; AUTOSAR_SWS_CANDriver p. 41). In doing so, Can_DeInit changes the module state (AUTOSAR_SWS_CANDriver p. 33) and resets all CAN controllers (AUTOSAR_SWS_CANDriver p. 41).

Concurrency and Limitations

Strict preconditions and sequencing requirements regarding hardware and module states apply to the execution:

Interaction

The error and transition behavior reflects the cleaned-up driver workflows, according to which invalid state transitions are intercepted uniformly ([SWS_Can_00441]).

This text was generated by an AI based on the specification AUTOSAR CP R20-11.

function Can_SetBaudrate [SWS_CAN_00491] 📄 PDF

Std_ReturnType Can_SetBaudrate (uint8 Controller, uint16 BaudRateConfig ID); ⚠️

This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.

function Can_SetControllerMode [SWS_Can_00230] 📄 PDF

Std_ReturnType Can_SetControllerMode (uint8 Controller, Can_ControllerStateType Transition);

This function performs software triggered state transitions of the CAN controller State machine.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: a4b356b48b8a Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The function Can_SetControllerMode (provided via Can.h with service ID 0x03) performs software-triggered state transitions of the CAN controller state machine ([SWS_Can_00230], AUTOSAR_SWS_CANDriver p. 35). It performs the hardware-related register settings to bring about the transitions between the basic controller states UNINIT, STOPPED, STARTED, and SLEEP ([SWS_Can_91010], AUTOSAR_SWS_CANDriver §7.3 “CAN Controller State Machine”).

Usage and Semantics

The call is made with the parameter Controller to identify the CAN controller and Transition of type Can_ControllerStateType to specify the desired state transition ([SWS_Can_00230]). The service is defined as asynchronous and non-reentrant (Non Reentrant) ([SWS_Can_00230]). A return value of E_OK confirms that the request was accepted; E_NOT_OK indicates that the request was rejected and a development error is present ([SWS_Can_00230], [SWS_Can_00441]).

Sequence and Interaction

After setting the register configuration, Can_SetControllerMode is exited again (AUTOSAR_SWS_CANDriver p. 38). Since the Can module does not store the hardware state changes itself ([SWS_Can_91010]), the cyclic function Can_Mainfunction_Mode presumably handles the asynchronous completion or verification of the transition initiated by Can_SetControllerMode (AUTOSAR_SWS_CANDriver p. 38). Question Q-03edb1b665a1624b (open)

This text was generated by an AI based on the specification data of AUTOSAR R20-11.

Implementer's Guide to follow (complexity I1)

function Can_DisableControllerInterrupts [SWS_Can_00231] 📄 PDF

void Can_DisableControllerInterrupts (uint8 Controller);

This function disables all interrupts for this CAN controller.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 9d72b1d46d5d Provenance Open questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The synchronous and reentrant function Can_DisableControllerInterrupts disables all interrupts for a specified CAN controller ([SWS_Can_00231]). The parameter is passed via Controller without a return value ([SWS_Can_00231]).

Regarding call context and concurrency, the function is designed to be reentrant and supports multiple calls (AUTOSAR_SWS_CANDriver §8.3 “Can_DisableControllerInterrupts”). Interpretation: Multiple calls are likely to increment an internal nesting counter, so that the interrupts are only re-enabled after a corresponding number of enable calls (AUTOSAR_SWS_CANDriver §8.3 “Can_DisableControllerInterrupts”, AUTOSAR_SWS_CANDriver §8.3 “Can_DisableControllerInterrupts”). Question Q-61be56207aa92ee0 (open)

In the area of error handling, the specification requires raising error CAN_E_UNINIT if the driver module is not yet initialized when called (AUTOSAR_SWS_CANDriver §8.3 “Can_DisableControllerInterrupts”). In addition, the specification requires raising another error (AUTOSAR_SWS_CANDriver §8.3 “Can_DisableControllerInterrupts”); presumably this serves to check for an invalid controller identifier. Question (open)

In interaction within the CAN driver, the call serves to protect controller-related critical sections while the controller remains active (AUTOSAR_SWS_CANDriver §7.5 “Interrupt handling”). Formal cleanups and historical interface changes of the driver are documented in the release notes ([SWS_Can_00441]).

This text was created by an AI and serves as an additional usage note to the specification.

function Can_EnableControllerInterrupts [SWS_Can_00232] 📄 PDF

void Can_EnableControllerInterrupts (uint8 Controller);

This function enables all allowed interrupts.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 374e141963cb Provenance Open questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The synchronous and reentrant function Can_EnableControllerInterrupts re-enables all allowed interrupts for the CAN controller specified via the parameter Controller ([SWS_Can_00232]). It has no return value and is provided via the header file Can.h ([SWS_Can_00232]).

Regarding the control flow, the function reads software control flags (AUTOSAR_SWS_CANDriver p. 65). If the interrupts of the controller were previously disabled multiple times, Can_EnableControllerInterrupts must be called just as many times before the actual enabling (AUTOSAR_SWS_CANDriver p. 65). Interpretation: The driver presumably manages nested lock sections via internal counters or flags, so that the hardware interrupts are re-enabled only after fully balancing all disable calls. Question Q-6781f0fc9ad7d221 (open)

If the function is called before the CAN driver has been properly initialized, it reports the error CAN_E_UNINIT (AUTOSAR_SWS_CANDriver p. 66). This is likely treated as a development error in the driver context ([SWS_Can_00441]). Question Q-efbbcf03a2589e4e (open) In the uninitialized state, the function performs no further actions on the controller (AUTOSAR_SWS_CANDriver p. 66).

This usage note was generated automatically based on the specification.

function Can_CheckWakeup [SWS_Can_00360] 📄 PDF

Std_ReturnType Can_CheckWakeup (uint8 Controller);

This function checks if a wakeup has occurred for the given controller.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 720a4fc64f2a Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Usage and Behavior

The synchronous function Can_CheckWakeup checks for a specific CAN controller whether a wake-up event has been detected ([SWS_Can_00360], AUTOSAR_SWS_CANDriver p. 48, AUTOSAR_SWS_CANDriver p. 67). It is available via the header file Can.h and has the service ID 0x0b ([SWS_Can_00360]).

  • Parameters: Controller (in) designates the identifier of the CAN controller whose state is to be checked for a wake-up ([SWS_Can_00360]).
  • Return value: Returns Std_ReturnType. The return value E_OK indicates that the API call was accepted, while E_NOT_OK indicates rejection ([SWS_Can_00360]).
  • Concurrency: The function is defined as non-reentrant (Non Reentrant) ([SWS_Can_00360]).

Configuration and Error Handling

The availability of the function is configurable at pre-compile time; the service Can_CheckWakeup can be included in or excluded from the code via this mechanism (AUTOSAR_SWS_CANDriver p. 67, AUTOSAR_SWS_CANDriver p. 97). If the function is called before the CAN driver has been initialized, it reports the error CAN_E_UNINIT (AUTOSAR_SWS_CANDriver p. 67).

Interaction

The call to Can_CheckWakeup is typically triggered by the CAN Interface (AUTOSAR_SWS_CANDriver p. 48). In the event of a wake-up event on the bus, CanIf_CheckWakeup can be called during the execution of EcuM_CheckWakeup (AUTOSAR_SWS_CANInterface §7.18.4.1 “Wake-up detection”). According to [SWS_CANIF_00395], CanIf queries via Can_CheckWakeup() or CanTrcv_CheckWakeup() which specific hardware device caused the bus wake-up (AUTOSAR_SWS_CANInterface p. 55).

This usage note was generated automatically and is based exclusively on the specifications of AUTOSAR Release R20-11.

function Can_GetControllerRxErrorCounter [SWS_Can_00511] 📄 PDF

Std_ReturnType Can_GetControllerRxErrorCounter (uint8 ControllerId, uint8* RxErrorCounterPtr);

Returns the Rx error counter for a CAN controller. This value might not be available for all CAN controllers, in which cas e E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Rx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.

function Can_GetControllerTxErrorCounter [SWS_Can_00516] 📄 PDF

Std_ReturnType Can_GetControllerTxErrorCounter (uint8 ControllerId, uint8* TxErrorCounterPtr);

Returns the Tx error counter for a CAN controller. This value might not be available for all CAN controllers, in which case E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Tx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.

function Can_Write [SWS_Can_00233] 📄 PDF

Std_ReturnType Can_Write (Can_HwHandleType Hth, const Can_PduType* PduInfo);

This function is called by Can If to pass a CAN message to Can Drv for transmission.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: f2d4ad3f2f32 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Usage and Semantics

The function Can_Write is called synchronously by the module CanIf to pass a CAN message to the CAN driver (CanDrv) for transmission ([SWS_Can_00233]). The caller passes two parameters:

  • Hth: Hardware transmit handle that defines the transmit object to be used and implicitly determines the controller, as the handle numbers are unique within a hardware unit ([SWS_Can_00233]).
  • PduInfo: Pointer to a structure containing SDU payload data, data length, and CAN identifier ([SWS_Can_00233]).

Before transmitting, the function checks the addressed hardware transmit object (SWS_CANDriver p. 73) and backs up the passed swPduHandle (SWS_CANDriver p. 43). Via the return value of type Std_ReturnType (SRS_BSWGeneral §5.2.3.6 “Types and keywords”), E_OK indicates acceptance of the request, while CAN_BUSY indicates that no hardware transmit buffer is available ([SWS_Can_00233], SWS_CANDriver p. 51).

Error handling

If a development error occurs during execution, the function returns E_NOT_OK ([SWS_Can_00233], [SWS_Can_00441]). Interpretation: Specific DET error codes are not explicitly mentioned in the available extract; however, faulty handles or invalid pointers are likely to result in returning E_NOT_OK. Question Q-ca947a7e0e4fd7d6 (open)

Concurrency and Limitations

Can_Write is specified as reentrant or thread-safe ([SWS_Can_00233], SWS_CANDriver p. 49). If a preemptive call cannot be executed reentrantly on the driver side, this is also reported to CanIf via the return value CAN_BUSY ([SWS_Can_00233]). The caller must ensure that the PDU memory remains valid and unmodified until the function call returns (SWS_CANDriver p. 45).

Interaction

Via [SWS_Can_00416], the type of PDU is conveyed upon the call (SWS_CANDriver p. 51), with the driver supporting transmission up to the maximum PDU length (SWS_CANDriver p. 52).

This usage note was generated automatically based on the specification documents of AUTOSAR R20-11.

function <LPDU_CalloutName> [SWS_Can_00443] 📄 PDF

boolean <LPDU_CalloutName> (uint8 Hrh, Can_IdType CanId, uint8 CanDataLegth, const uint8* CanSduPtr);

-

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 3538baa0cf7b Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Usage and Call Context

The configurable call-out interface <LPDU_CalloutName> is optionally called by the AUTOSAR CAN module each time an L-PDU is received (SWS_CANDriver §8.4.1 “Call-out function”). The declaration of the function is provided via the header file Can_Externals.h ([SWS_Can_00443]). The actual name of the function is configured in a project-specific manner ([SWS_Can_00443]).

The hardware receive handle Hrh, the identifier CanId, the data length CanDataLegth, and a pointer to the payload CanSduPtr are passed as input parameters ([SWS_Can_00443]).

Filtering and return value

The function returns a boolean value. If the call-out returns false, the received L-PDU must not be processed further ([SWS_Can_00444]). Interpretation: If the call returns true, the regular forwarding of the L-PDU to the upper layers is likely to take place. Question Q-e96e75e93881c3af (open)

Concurrency and Limitations

The function is assigned the service ID 0x20 and specified as asynchronous (Asynchronous) and non-reentrant (Non Reentrant) ([SWS_Can_00443]). Because it is non-reentrant, concurrent calls must not occur in the same context.

This text was generated by an AI and serves as guidance. The requirements of the AUTOSAR specification are binding.

function Can_MainFunction_Write [SWS_Can_00225] 📄 PDF

void Can_MainFunction_Write (void);

This function performs the polling of TX confirmation when CAN_ TX_ PROCESSING is set to POLLING.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: a6cd22a9e2b1 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The function Can_MainFunction_Write performs cyclic polling of transmit confirmations (TX confirmation) if the parameter CAN_TX_PROCESSING is configured to POLLING [SWS_Can_00225], AUTOSAR SWS CAN Driver §7 “Scheduled functions”. It takes no parameters (void Can_MainFunction_Write(void)), has the service ID 0x01, and is provided to the scheduler via the header file SchM_Can.h [SWS_Can_00225]. Via configuration switches, the function can be enabled or disabled for processing PDU transmission AUTOSAR SWS CAN Driver §10 “CanMainFunctionWrite”.

If no polling is used for transmission in the system at all, Can_MainFunction_Write shall be implemented as an empty define according to the specification AUTOSAR SWS CAN Driver §7 “Scheduled functions”. This is likely intended to avoid unnecessary scheduler overhead in purely interrupt-driven systems. Question Q-2152a35397130945 (open)

In interaction with Can_MainFunction_Read and Can_MainFunction_BusOff, the routine forms the cyclic interface of the driver to the SchM AUTOSAR SWS CAN Driver §7 “Scheduled functions”. Confirmation processing takes place either directly at the hardware resource or in the context of Can_MainFunction_Write, depending on the mode AUTOSAR SWS CAN Driver §7 “Hardware Resources”. The specific call and mapping depend on the respective referenced elements AUTOSAR SWS CAN Driver §10 “CanMainFunctionWrite”, AUTOSAR SWS CAN Driver §10 “Call Context”, supported by controller-related Tx processing [SWS_Can_00441].

This usage note was generated automatically based on the specification AUTOSAR R20-11.

function Can_MainFunction_Read [SWS_Can_00226] 📄 PDF

void Can_MainFunction_Read (void);

This function performs the polling of RX indications when CAN_ RX_ PROCESSING is set to POLLING.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 2c7a6a6247b4 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The function Can_MainFunction_Read serves for cyclic querying (polling) of CAN receive messages ([SWS_Can_00226]). It has the signature void Can_MainFunction_Read (void) with service ID 0x08 and is provided for execution control via the header file SchM_Can.h ([SWS_Can_00226]).

Usage and Configuration

The function executes the polling of RX indications when the configuration parameter CAN_RX_PROCESSING is set to POLLING ([SWS_Can_00226]). In the system, this processing can be configured per controller ([SWS_Can_00441]). If no polling is used in the CAN driver at all, Can_MainFunction_Read can be defined as an empty macro (AUTOSAR_SWS_CANDriver p. 77).

Concurrency and Limitations

The call occurs periodically in the scheduler context according to the parameterized trigger period (AUTOSAR_SWS_CANDriver p. 22). Strict conditions apply to the execution:

Interpretation: The configured call interval of the task would likely need to be dimensioned such that a processing phase is always finished before the next cycle starts, since reentrancy is not permitted (AUTOSAR_SWS_CANDriver p. 47). Question Q-1f2fa9db14970b12 (open)

This text was generated by an AI based on the AUTOSAR specification R20-11.

function Can_MainFunction_BusOff [SWS_Can_00227] 📄 PDF

void Can_MainFunction_BusOff (void);

This function performs the polling of bus - off events that are configured statically as 'to be polled'.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d6a62aee0c17 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The scheduled main function Can_MainFunction_BusOff serves for cyclic polling of bus-off events of the CAN controllers, provided they are statically configured to be polled [SWS_Can_00227], [SWS_Can_00109]. It has the signature void Can_MainFunction_BusOff(void), takes no parameters, returns no value, and is provided via the header SchM_Can.h for execution control [SWS_Can_00227].

Usage and Interaction

Hardware events can be detected in the CAN driver either via interrupt or by polling corresponding status flags, with the query configuration being hardware-dependent [SWS_Can_00099]. The driver can also be configured to dispense entirely with interrupts [SWS_Can_00007]. If no polling is used system-wide at all, the Can module may implement the function as an empty macro [SWS_Can_00183].

If a bus-off event is detected via status bits in Can_MainFunction_BusOff, the module performs the necessary register settings—such as to prevent automatic hardware recovery SWS_CANDriver §7.3 “CAN Controller State Machine”, [SWS_Can_91010]. Subsequently, the module notifies the upper layer CanIf via the associated callback, in which the software state change of the controller takes place SWS_CANDriver §7.3 “CAN Controller State Machine”.

Call Context and Restrictions

In polled operation, the call context of the callback notification is not the ISR, but the executing task of Can_MainFunction_BusOff; nevertheless, all callback functions must be implemented as if they were called from the ISR context SWS_CANDriver §7.9 “Notification concept”. Regarding reentrancy, the payload contains no explicit information; presumably the function is non-reentrant because it accesses global controller registers and states. Question Q-38fcd72c40ce3e66 (open)

This usage note was generated by an AI and is based exclusively on specification excerpts of AUTOSAR version R20-11.

function Can_MainFunction_Wakeup [SWS_Can_00228] 📄 PDF

void Can_MainFunction_Wakeup (void);

This function performs the polling of wake - up events that are configured statically as 'to be polled'.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ce643213c50c Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The main function Can_MainFunction_Wakeup performs cyclic polling of wake-up events that are statically configured to be polled ([SWS_Can_00228]). The function has the signature void Can_MainFunction_Wakeup(void), takes no parameters, returns no value, and is provided via the header SchM_Can.h for the Schedule Manager (AUTOSAR_SWS_CANDriver p. 79). The execution period of the function is configured in seconds (AUTOSAR_SWS_CANDriver p. 92).

Within the CAN controller state machine (SWS_CANDriver §7.3 “CAN Controller State Machine”), external hardware wake-up events can be signaled via a status bit queried in Can_MainFunction_Wakeup instead of via interrupts ([SWS_Can_91010]). In addition, during state transitions, the function polls a corresponding flag of the CAN status register until it signals that the change has taken effect ([SWS_Can_00370]). After a successful state change, the CAN driver reports the new state to the CAN interface using the callback function CanIf_ControllerModeIndication, referenced to the abstract CanIf ControllerId ([SWS_Can_00370]).

Regarding configuration and resource usage, the API Can_MainFunction_Wakeup() can be enabled or disabled for handling wake-up events (AUTOSAR_SWS_CANDriver p. 97). If no polling is used for wake-up events in the ECU at all, Can_MainFunction_Wakeup can be defined as an empty macro (AUTOSAR_SWS_CANDriver p. 79).

This usage note was generated automatically based on the specification AUTOSAR CP R20-11.

function Can_MainFunction_Mode [SWS_Can_00368] 📄 PDF

void Can_MainFunction_Mode (void);

This function performs the polling of CAN controller mode transitions.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: feee99301166 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Usage and Operation

The scheduled main function Can_MainFunction_Mode ([SWS_Can_00368]) performs the polling of state transitions of the CAN controllers. It has neither input parameters nor a return value (void Can_MainFunction_Mode(void), service ID 0x0c) and is declared via the header SchM_Can.h SWS_CANDriver §8.5.1.5 “Can_MainFunction_Mode”.

The function is called cyclically on a continuous basis (AUTOSAR_SWS_CANInterface p. 143). It checks the hardware to determine whether the mode of a CAN controller has changed. When a change is detected, the CAN interface is notified via the call to CanIf_ControllerModeIndication(Controller, ControllerMode).

Asynchronous Mode Monitoring

If a mode change was previously requested via Can_SetControllerMode() and this call returns successfully to CanIf, Can_MainFunction_Mode detects the completed state transition of the controller hardware. It then informs CanIf asynchronously via CanIf_ControllerModeIndication about the new state, such as CAN_CS_STARTED AUTOSAR_SWS_CANInterface p. 144.

Call Context and Constraints

Due to its provision via SchM_Can.h and its definition as a scheduled function, the periodic invocation is likely performed by the BSW Scheduler. Question Q-42edbc2aa591e8d7 (open) Specific error codes or development steps are not defined in the payload for this function.

This text was created by an AI based on the AUTOSAR specifications.

Implementer's Guide to follow (complexity I1)

type Can_ConfigType [SWS_Can_00413] 📄 PDF

This is the type of the external data structure containing the overall initialization data for the CAN driver and SFR settings affecting all controllers. Furthermore it contains pointers to controller configuration structures. The contents of the initializ ation data structure are CAN hardware specific.

type Can_PduType [SWS_Can_00415] 📄 PDF

This type unites Pdu Id (sw Pdu Handle), Sdu Length (length), Sdu Data (sdu), and Can Id (id) for any CAN L - SDU.

type Can_IdType [SWS_Can_00416] 📄 PDF

Represents the Identifier of an L - PDU. The two most significant bits specify the frame type: 00 CAN message with Standard CAN ID 01 CAN FD frame with Standard CAN ID 10 CAN message with Extended CAN ID 11 CAN FD frame with Extended CAN ID

type Can_HwHandleType [SWS_Can_00429] 📄 PDF

Represents the hardware object handles of a CAN hardware unit. For CAN hardware units with more than 255 HW objects use extended range.

type Can_HwType [SWS_CAN_00496] 📄 PDF

This type defines a data structure which clearly provides an Hardware Object Handle including its corresponding CAN Controller and therefore Can Drv as well as the specific Can Id.

type Can_ErrorStateType [SWS_Can_91003] 📄 PDF

Error states of a CAN controller.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 0cb922d28e06 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The enumeration type Can_ErrorStateType from Can_GeneralTypes.h describes the error and operating states of a CAN controller [SWS_Can_91003]. It maps the behavior of the controller on the CAN bus via three states SWS_CANDriver §8.2.7 “Can_ErrorStateType”:

  • CAN_ERRORSTATE_ACTIVE: The CAN controller fully participates in bus communication [SWS_Can_91003].
  • CAN_ERRORSTATE_PASSIVE: The CAN controller participates in communication, but no longer sends active error frames (Error Frames) [SWS_Can_91003].
  • CAN_ERRORSTATE_BUSOFF: The CAN controller is isolated from the bus as a result of severe transmission errors and no longer participates in communication [SWS_Can_91003].

At runtime, the state is queried via the synchronous driver service Can_GetControllerErrorState [SWS_Can_91004]. Its output parameter ErrorStatePtr receives the determined value. The same signature is also used by the higher-level function CanIf_GetControllerErrorState in the CAN Interface AUTOSAR_SWS_CANInterface p. 78 “CanIf_GetControllerErrorState”. Regarding concurrency, Can_GetControllerErrorState is specified as non-reentrant for the same ControllerId [SWS_Can_91004].

In case of error, Can_GetControllerErrorState provides the return value E_NOT_OK, upon successful query E_OK [SWS_Can_91004]. When development error detection (DET) is enabled, a call prior to driver initialization leads to error CAN_E_UNINIT [SWS_Can_91005]. An invalid ControllerId triggers the development error CAN_E_PARAM_CONTROLLER [SWS_Can_91006], and passing a null pointer for ErrorStatePtr is rejected with a development error [SWS_Can_91007].

Interpretation: The caller is likely required to allocate the memory area for ErrorStatePtr independently, since the interface treats the pointer as a pure output parameter and precludes null pointers via a development error. Question Q-5c907c21bcb50893 (open)

This text was generated by an AI based on the AUTOSAR specification R20-11.

Implementer's Guide to follow (complexity I1)

type Can_ControllerStateType [SWS_Can_91013] 📄 PDF

States that are used by the several Controller Mode functions.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 5eb69ce0444e Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The enumeration type Can_ControllerStateType defines the fundamental operating states of a CAN controller: CAN_CS_UNINIT, CAN_CS_STARTED, CAN_CS_STOPPED, and CAN_CS_SLEEP [SWS_Can_91013]. The type is used across modules for software-controlled state management of the CAN controller state machine [SWS_Can_00017].

The values are used in the following contexts:

Regarding concurrency and error handling: The driver functions Can_SetControllerMode and Can_GetControllerMode are non-reentrant [SWS_Can_00230], [SWS_Can_91014]. If Can_GetControllerMode is called before driver initialization, the development error CAN_E_UNINIT is reported and E_NOT_OK is returned [SWS_Can_91016]. The callback function CanSM_ControllerModeIndication is reentrant for different controllers and reports an unconfigured controller ID with CANSM_E_PARAM_CONTROLLER to the DET [SWS_CanSM_00396], [SWS_CanSM_00397].

This usage note is based on the definitions in the specifications of the CAN Driver, CAN Interface, and CAN State Manager in AUTOSAR Classic R20-11.

Implementer's Guide to follow (complexity I1)

type Can_ErrorType [SWS_Can_91021] 📄 PDF

The enumeration represents a superset of CAN Error Types which typical CAN HW is able to report. That means not all CAN HW will be able to support the complete set.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: e538be0a65be Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The enumeration type Can_ErrorType defines a standardized superset of CAN error causes that typical CAN hardware can detect and report to higher layers [SWS_Can_91021]. It is provided via the header file Can_GeneralTypes.h SWS_CANDriver §8.2.9 “Can_ErrorType”.

Since the enumeration is designed as a superset, not every CAN controller necessarily supports all specified values [SWS_Can_91021]. The defined error states include:

  • Bit errors during bus monitoring (CAN_ERROR_BIT_MONITORING1, CAN_ERROR_BIT_MONITORING0, or collectively CAN_ERROR_BIT),
  • Acknowledgment errors (CAN_ERROR_CHECK_ACK_FAILED, CAN_ERROR_ACK_DELIMITER),
  • Transmitter loss of arbitration (CAN_ERROR_ARBITRATION_LOST),
  • Overload conditions caused by full receive buffers (CAN_ERROR_OVERLOAD),
  • Format and bit-stuffing violations (CAN_ERROR_CHECK_FORM_FAILED, CAN_ERROR_CHECK_STUFFING_FAILED),
  • CRC errors (CAN_ERROR_CHECK_CRC_FAILED), and
  • a persistent bus lock at dominant level (CAN_ERROR_BUS_LOCK) SWS_CANDriver §8.2.9 “Can_ErrorType”.

In the interaction of BSW modules, the type serves as a parameter of the callback function CanIf_ErrorNotification for forwarding controller errors to the CAN interface AUTOSAR_SWS_CANInterface §8.x “CanIf_ErrorNotification”. The passed value is likely to correspond to the error state detected by the underlying hardware AUTOSAR_SWS_CANDriver §7.x “Error Notification”. Question Q-d23c45dd3b23ec71 (open)

This text was generated by an AI and serves for technical orientation.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/CP_MOD_Can
Status
unspecified
Version
AUTOSAR/AP/record/CP_MOD_Can@rel:R20-11#382d5b38
Content hash
382d5b38
Source
https://www.autosar.org/fileadmin/standards/R20-11/CP/AUTOSAR_SWS_CANDriver.pdf#nameddest=SWS_Can_00223

Initialization and status

Can_DeInit function

This function de - initializes the module.

void Can_DeInit (void);

This function returns the version information of this module.

void Can_GetVersionInfo (Std_VersionInfoType* versioninfo);
Can_Init function

This function initializes the module.

void Can_Init (const Can_ConfigType* Config);

Services

This function checks if a wakeup has occurred for the given controller.

Std_ReturnType Can_CheckWakeup (uint8 Controller);

This function disables all interrupts for this CAN controller.

void Can_DisableControllerInterrupts (uint8 Controller);

This function enables all allowed interrupts.

void Can_EnableControllerInterrupts (uint8 Controller);

This service obtains the error state of the CAN controller.

Std_ReturnType Can_GetControllerErrorState (uint8 ControllerId, Can_ErrorStateType* ErrorStatePtr);

This service reports about the current status of the requested CAN controller.

Std_ReturnType Can_GetControllerMode (uint8 Controller, Can_ControllerStateType* ControllerModePtr);

Returns the Rx error counter for a CAN controller. This value might not be available for all CAN controllers, in which cas e E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Rx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.

Std_ReturnType Can_GetControllerRxErrorCounter (uint8 ControllerId, uint8* RxErrorCounterPtr);

Returns the Tx error counter for a CAN controller. This value might not be available for all CAN controllers, in which case E_ NOT_ OK would be returned. Please note that the value of the counter might not be correct at the moment the API returns it, because the Tx counter is handled asynchronously in hardware. Applications should not trust this value for any assumption about the current bus state.

Std_ReturnType Can_GetControllerTxErrorCounter (uint8 ControllerId, uint8* TxErrorCounterPtr);

This service shall set the baud rate configuration of the CAN controller. Depending on necessary baud rate modifications the controller might have to reset.

Std_ReturnType Can_SetBaudrate (uint8 Controller, uint16 BaudRateConfig ID); ⚠️

This function performs software triggered state transitions of the CAN controller State machine.

Std_ReturnType Can_SetControllerMode (uint8 Controller, Can_ControllerStateType Transition);
Can_Write function

This function is called by Can If to pass a CAN message to Can Drv for transmission.

Std_ReturnType Can_Write (Can_HwHandleType Hth, const Can_PduType* PduInfo);

Callouts and expected interfaces

-

boolean <LPDU_CalloutName> (uint8 Hrh, Can_IdType CanId, uint8 CanDataLegth, const uint8* CanSduPtr);

Cyclic

This function performs the polling of bus - off events that are configured statically as 'to be polled'.

void Can_MainFunction_BusOff (void);

This function performs the polling of CAN controller mode transitions.

void Can_MainFunction_Mode (void);

This function performs the polling of RX indications when CAN_ RX_ PROCESSING is set to POLLING.

void Can_MainFunction_Read (void);

This function performs the polling of wake - up events that are configured statically as 'to be polled'.

void Can_MainFunction_Wakeup (void);

This function performs the polling of TX confirmation when CAN_ TX_ PROCESSING is set to POLLING.

void Can_MainFunction_Write (void);

Types

This is the type of the external data structure containing the overall initialization data for the CAN driver and SFR settings affecting all controllers. Furthermore it contains pointers to controller configuration structures. The contents of the initializ ation data structure are CAN hardware specific.

States that are used by the several Controller Mode functions.

Error states of a CAN controller.

The enumeration represents a superset of CAN Error Types which typical CAN HW is able to report. That means not all CAN HW will be able to support the complete set.

Represents the hardware object handles of a CAN hardware unit. For CAN hardware units with more than 255 HW objects use extended range.

This type defines a data structure which clearly provides an Hardware Object Handle including its corresponding CAN Controller and therefore Can Drv as well as the specific Can Id.

Represents the Identifier of an L - PDU. The two most significant bits specify the frame type: 00 CAN message with Standard CAN ID 01 CAN FD frame with Standard CAN ID 10 CAN message with Extended CAN ID 11 CAN FD frame with Extended CAN ID

This type unites Pdu Id (sw Pdu Handle), Sdu Length (length), Sdu Data (sdu), and Can Id (id) for any CAN L - SDU.