MCAL (Microcontroller Abstraction Layer) — AUTOSAR Classic Platform BSW의 최하위 sub-layer. 표준화된 디바이스 드라이버 집합으로, μC 하드웨어의 세부를 감추고 상위 BSW에 균일한 API를 제공한다. “표준 디바이스 드라이버”가 핵심 정체성 — 공급자가 달라도 API가 같아야 portability가 성립한다.
구성 요소
- Microcontroller Drivers — 코어 자체 (클럭, 리셋, Watchdog 등)
- Memory Drivers — 내부 Flash, EEPROM 등
- Crypto Drivers — HW 암호 가속기
- Wireless Communication Drivers
- Communication Drivers — CAN, LIN, FlexRay, Ethernet MAC 드라이버
- I/O Drivers — PORT, DIO, ADC, ICU, OCU, PWM (I/O 계열은 IO Hardware Abstraction가 API·Notification 모두를 소비)
Internal Driver
드라이버는 제어 대상 디바이스의 위치에 따라 분류된다.
- Internal device — μC 내부에 존재 (예: Internal EEPROM, Internal CAN controller, Internal ADC)
- Internal driver — Internal device용 드라이버. MCAL 소속이 된다
External Driver(외부 칩용)는 ECU Abstraction Layer 소속이다. 즉 MCAL은 “칩 내부” 경계를 기준으로 정의된다.
문서 구조 — SRS / SWS
각 드라이버는 두 종류의 PDF 스펙으로 정의된다.
| 문서 | 내용 |
|---|---|
| AUTOSARSRS | Software Requirements Specification (무엇을 해야 하는가) |
| AUTOSARSWS | Software Specification (API·데이터 타입 상세) |
예: AUTOSAR_SRS_PWMDriver.pdf + AUTOSAR_SWS_PWMDriver.pdf. 둘 다 Document Status Final, Classic Platform 소속.
이 분리는 소프트웨어 요구공학의 요구사항 ↔ 명세 분리 원칙을 드라이버 레벨에 그대로 적용한 것이다.
예시 — PWM Driver
커스텀 데이터 타입
Pwm_ChannelType
Pwm_PeriodType // uint (8..32 bit) - μC 플랫폼별 최적 크기
Pwm_OutputStateType
Pwm_ConfigTypePwm_PeriodType 이 uint(8..32 bit)로 열린 것이 MCAL 설계 철학의 핵심 — “Implementation specific to have the most efficient implementation on a specific microcontroller platform”. 8-bit μC에는 uint8, 32-bit μC에는 uint32로 구현해 효율을 극대화한다. 상위 BSW는 타입 이름만 참조하므로 이식성이 유지된다.
함수 시그니처
Pwm_Init(...)
Pwm_SetDutyCycle(...)
Pwm_SetPeriodAndDuty(...)
Pwm_GetOutputState(...)
Pwm_SetPowerState(...)Pwm_SetPeriodAndDuty 스펙:
| Attribute | 내용 |
|---|---|
| Service name | Pwm_SetPeriodAndDuty |
| Syntax | void Pwm_SetPeriodAndDuty(Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle) |
| Sync/Async | Asynchronous |
| Reentrancy | Reentrant for different channel numbers |
| Description | PWM 채널의 주기와 duty cycle 설정 |
Reentrancy가 “for different channel numbers”로 제한되는 것에 주목. 동일 채널에 대해 동시에 호출하면 경쟁 상태가 발생할 수 있어, MCAL 레벨에서도 공유 자원 보호가 설계 고려사항이다 (공유 자원과 경쟁 상태).
MCAL과 portability
MCAL은 “μC만 바뀌면 이 계층만 교체” 하는 구조를 성립시킨다. 상위 ECU Abstraction Layer / Services 계층은 MCAL API만 보므로 μC 벤더(Infineon / RENESAS / NXP) 교체가 국소화된다.
비교: Complex Driver는 비표준이라 ECU 교체 시 재구현 필요. External Driver(외부 칩 드라이버)는 MCAL이 아닌 ECU Abstraction Layer 소속 — μC 독립이면서 ECU 보드·외부 디바이스 의존이기 때문.