Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 80 additions & 1 deletion drv/i2c-devices/src/mwocp68.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,23 @@ pub struct Mwocp68 {
#[derive(Copy, Clone, PartialEq)]
pub struct FirmwareRev(pub [u8; 4]);

#[derive(Copy, Clone, PartialEq, Default)]
#[derive(Copy, Clone, PartialEq, Eq, Default)]
pub struct SerialNumber(pub [u8; 12]);

/// Manufacturer model number.
///
/// Per Murata Application Note ACAN-114.A01.D03 "PMBus Communication Protocol",
/// this is always a 17-byte ASCII string. It should be "MWOCP68-3600-D-RM".
#[derive(Copy, Clone, PartialEq, Eq, Default)]
pub struct ModelNumber(pub [u8; 17]);

/// Manufacturer ID.
///
/// Per Murata Application Note ACAN-114.A01.D03 "PMBus Communication Protocol",
/// this is always a 9-byte ASCII string. It should be "Murata-PS".
#[derive(Copy, Clone, PartialEq, Eq, Default)]
pub struct MfrId(pub [u8; 9]);

//
// The boot loader command -- sent via BOOT_LOADER_CMD -- is unfortunately odd
// in that its command code is overloaded with BOOT_LOADER_STATUS. (That is,
Expand Down Expand Up @@ -89,6 +103,12 @@ pub enum Error {
code: ResponseCode,
},
ChecksumNotSuccessful,
BadModelNumberRead {
code: ResponseCode,
},
BadMfrIdRead {
code: ResponseCode,
},
}

impl From<BadValidation> for Error {
Expand Down Expand Up @@ -535,6 +555,65 @@ impl Mwocp68 {
Ok(serial)
}

///
/// Returns the manufacturer model number of the PSU.
///
pub fn model_number(&self) -> Result<ModelNumber, Error> {
let mut model = ModelNumber::default();
let _ = self
.device
.read_block(CommandCode::MFR_MODEL as u8, &mut model.0)
.map_err(|code| Error::BadModelNumberRead { code })?;
Ok(model)
}

///
/// Returns the manufacturer ID of the PSU.
///
pub fn mfr_id(&self) -> Result<MfrId, Error> {
let mut id = MfrId::default();
let _ = self
.device
.read_block(CommandCode::MFR_ID as u8, &mut id.0)
.map_err(|code| Error::BadMfrIdRead { code })?;
Ok(id)
}

pub fn status_word(&self) -> Result<STATUS_WORD::CommandData, Error> {
// Per ACAN-114, this is always on page 0.
pmbus_rail_read!(self.device, 0, STATUS_WORD)
}

pub fn status_iout(&self) -> Result<STATUS_IOUT::CommandData, Error> {
// Per ACAN-114, this is always on page 0.
pmbus_rail_read!(self.device, 0, STATUS_IOUT)
}

pub fn status_vout(&self) -> Result<STATUS_VOUT::CommandData, Error> {
// Per ACAN-114, this is always on page 0.
pmbus_rail_read!(self.device, 0, STATUS_VOUT)
}

pub fn status_input(&self) -> Result<STATUS_INPUT::CommandData, Error> {
pmbus_read!(self.device, STATUS_INPUT)
}

pub fn status_cml(&self) -> Result<STATUS_CML::CommandData, Error> {
pmbus_read!(self.device, STATUS_CML)
}

pub fn status_temperature(
&self,
) -> Result<STATUS_TEMPERATURE::CommandData, Error> {
pmbus_read!(self.device, STATUS_TEMPERATURE)
}

pub fn status_mfr_specific(
&self,
) -> Result<STATUS_MFR_SPECIFIC::CommandData, Error> {
pmbus_read!(self.device, STATUS_MFR_SPECIFIC)
}

fn get_boot_loader_status(
&self,
) -> Result<BOOT_LOADER_STATUS::CommandData, Error> {
Expand Down
11 changes: 9 additions & 2 deletions drv/psc-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ edition = "2021"
drv-packrat-vpd-loader.path = "../packrat-vpd-loader"
drv-psc-seq-api.path = "../psc-seq-api"
drv-stm32xx-sys-api = { path = "../../drv/stm32xx-sys-api", features = ["family-stm32h7"] }
drv-i2c-api = { path ="../../drv/i2c-api", features = ["component-id"] }
drv-i2c-devices.path = "../../drv/i2c-devices"
task-jefe-api.path = "../../task/jefe-api"
task-packrat-api = { path = "../../task/packrat-api", features = ["serde"] }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
ringbuf = { path = "../../lib/ringbuf" }
ringbuf = { path = "../../lib/ringbuf", features = ["counters"] }
counters = { path = "../../lib/counters" }
static-cell = { path = "../../lib/static-cell" }
serde.workspace = true

[build-dependencies]
idol.workspace = true
build-util = {path = "../../build/util"}
build-util = { path = "../../build/util" }
build-i2c = { path = "../../build/i2c" }

# This section is here to discourage RLS/rust-analyzer from doing test builds,
# since test builds don't work for cross compilation.
Expand Down
7 changes: 7 additions & 0 deletions drv/psc-seq-server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
build_util::build_notifications()?;

let disposition = build_i2c::Disposition::Devices;

if let Err(e) = build_i2c::codegen(disposition) {
println!("cargo::error=code generation failed: {e}");
std::process::exit(1);
}
Ok(())
}
Loading
Loading