oxidecomputer / oxidecomputer/pmbus

want a `SMBALERT_MASK::CommandData` that depends on the type of the register being masked

Open
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
11
Forks
5
Avg merge
1h 10m
Merged PRs (30d)
2

Description

As seen in oxidecomputer/hubris#2511, it would be nice to have a typed abstraction for SMBALERT_MASK which constructs command data based on which status register's CommandData is used as the mask, i.e. which emits the correct register address for the status register being masked. One can very easily just write code such as this:

    pub fn set_status_iout_smbalert_mask(
        &self,
        mask: STATUS_IOUT::CommandData,
    ) -> Result<(), i2c::ResponseCode> {
        self.device
            .write(&[
                CommandCode::SMBALERT_MASK as u8,
                CommandCode::STATUS_IOUT as u8,
                mask.0,
            ])
    }

and, in fact, I have, but it feels a bit dirty --- as though one is basically doing an end run around all the typed abstractions the pmbus crate provides. I would like to figure out a way to have a version of set_smbalert_mask that could take any status register (and only any status register)'s command data, and just did the right thing with it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the existing typed abstractions for SMBALERT_MASK, status registers, and their CommandData types. Determine how a generic set_smbalert_mask can accept only status-register CommandData while deriving the correct status-register address; it is done when the resulting command data emits the appropriate address without bypassing the crate's typed abstractions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.