Skip to content

Emulator Bus Transfer/Message Parsing Boiler-Plate #59211

@aaronemassey

Description

@aaronemassey

Is your enhancement proposal related to a problem? Please describe.

There is considerable boiler-plate when adding new peripheral
emulators. Specifically, when adding new I2C peripheral emulators the i2c
transfer

from must be implemented by each new emulator. Every new implementation of the
i2c transfer function has its own
implementation
for parsing i2c messages into emulator read/writes.

Since this transfer function is largely boiler-plate, mistakes from one
implementation can make it into another implmemenation due to copy pasting
code.

Describe the solution you'd like

Some common simplified i2c parsing code for emulators. Since it's for emulators
it wouldn't have to be nearly as complete as the real thing. We'd have to be
able to reduce voilerplate for byte word read/writes but also 2-byte word
read/writes as is the case for SMBus.

We'd also need to be able to handle different number of bits used to represent
register offsets.

Describe alternatives you've considered

Status Quo:

We could wait until there are more emulators and thus more examples of
boiler-plate in Zephyr emulators before creating/maintaining some shared code to
ameliorate the problem.

Pros:

  • No work to be done
  • No shared code to maintain

Cons:

  • Each transfer function still has boiler-plate code to maintain
  • Still boiler-plate code that can be copy pasted with errors

Additional context

Note: I'll eventually get to this but it's fairly low on my priority. If someone
wants to pick this up, especially someone more familiar with the variety of I2C
transactions, I'd be happy to assist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementChanges/Updates/Additions to existing featuresNeeds reviewThis PR needs attention from Zephyr's maintainersarea: Emulation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions