Driver configuration structures are not compatible with ROM functions on LLVM

ID: LPCBARESDK-1092

Status: Fixed

First reported: 6.0.22.1401

Fixed in: 6.0.24.1464

Description

When building with LLVM (e2 studio), the ROM driver initialization functions may not interpret certain configuration structure members correctly for peripherals like ADC and I2C. This issue arises because structure members defined with enumerations have differing sizes in LLVM compared to Keil.

For example, in the i2c_cfg structure, the enumeration type of certain members, such as mode, results in different memory offsets when built with Keil versus LLVM. In the Keil-built ROM i2c_init function, the mode member has an offset of 10, whereas in the LLVM build, it has an offset of 16. This discrepancy causes the ROM functions, which are built with Keil, to misinterpret the configuration structure when running code built with LLVM.

This issue is specific to ROM functions due to differences in how enumeration sizes are handled between compilers.

Workaround

When building with e2 studio, a quick solution is to enable the following options:

-fshort-enums -fshort-wchar