Services and Utilities

Normative

The shared services a driver reports through and relies on: logging, critical sections, the interrupt-definition macro, and the standard memory utilities. These are the services the module pages forward-reference (for the CAN example, the Expected interfaces group in API Reference). Keywords per Requirement Keywords.

Logging (Log Manager)

Drivers report development and runtime errors — and informational events — through the Log Manager.

LogM_LogLevel (via LogM.h):

Level

Value

Meaning

LOGM_LOG_LEVEL_INFO

0x00

Confirmation that things work as expected.

LOGM_LOG_LEVEL_WARNING

0x01

Something worth reporting happened; not critical.

LOGM_LOG_LEVEL_DEVERR

0x02

Development error — wrong usage (e.g. a bad parameter).

LOGM_LOG_LEVEL_RTERR

0x03

Runtime error — a critical runtime condition.

LogM_Report (via LogM.h) — the service used to log an event:

void LogM_Report(LogM_LogLevel logLevel, uint16 moduleId,
                 uint8 instanceId, uint8 apiId, uint8 eventId);

Parameter

Meaning

logLevel

Log level matching the event (see above).

moduleId

Module id of the caller (see Module identifiers).

instanceId

Zero-based instance index; 0 for single-instance modules.

apiId

Id of the API reporting the event.

eventId

Event (error) id.

Synchronous and reentrant. Because of the five parameters, an implementation may provide LogM_Report as a macro or LOCAL_INLINE wrapper that packs the ids and forwards to an optimized backend, as long as the external signature is unchanged.

Critical sections

Available via SchM_<Mip>.h. A driver brackets a region needing exclusive access; the integrator supplies the implementation. Both are synchronous and reentrant.

Service

Meaning

void <Mip>_EnterCriticalSection(void)

Enter exclusive control; nothing preempts the driver operation after this call.

void <Mip>_ExitCriticalSection(void)

Leave exclusive control.

Keep exclusive regions as short as possible to minimise interrupt latency and blocking of time-critical operations.

Interrupt definition (ISR macro)

Available via Os.h. Interrupt service routines MUST be defined with the ISR() macro, which hides the compiler/OS-specific handler keyword:

#include "Os.h"

ISR(<IsrName>)
{
    /* interrupt handling code */
}

Standard memory utilities

Available via Std_Lib.h. Common buffer helpers shared across modules. They may access the buffer in several access sizes (byte/2-byte/4-byte) for performance, so they MUST NOT be used on buffers with access-size restrictions (e.g. some HW peripheral buffers). Std_MemCmp / Std_MemCheck are not constant-time and are unsuitable for security-critical comparison.

Function

Meaning

void Std_MemCpy(void* dstPtr, const void* srcPtr, uint32 count)

Copy count bytes srcdst (regions must not overlap).

void Std_MemClr(void* dstPtr, uint32 count)

Clear count bytes to 0.

void Std_MemSet(void* dstPtr, uint8 pattern, uint32 count)

Fill count bytes with pattern.

sint8 Std_MemCmp(const void* buffA, const void* buffB, uint32 count)

Compare; 0 equal, <0 / >0 at first differing byte.

Std_ReturnType Std_MemCheck(const void* buff, uint8 pattern, uint32 count)

E_OK if all count bytes equal pattern, else E_NOT_OK.

An implementation may realise these by reusing existing compiler/platform functions (e.g. a macro mapping Std_MemSet to memset) or an inline wrapper.