Skip to content

Commit

Permalink
Merge branch 'release/v0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Jan 22, 2023
2 parents 281a1a0 + b020f25 commit bb08ff2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* None

## v0.5.2

* Handle 'Alt' reads and writes.

## v0.5.1

* Adds a PC speaker driver using TIM14
Expand Down
12 changes: 8 additions & 4 deletions neotron-bmc-commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,20 @@ TODO

### Address 0x70 - Speaker Tone Duration

TODO
Sets the duration of the tone to be played, and starts the tone playing. You
should set the other three registers (if required) before setting this register.

There is no way to know when the tone is ended; the host should keep track of
the duration it set and wait the appropriate period of time.

### Address 0x71 - Speaker Tone Period (High)

TODO
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in 48 kHz units.

### Address 0x72 - Speaker Tone Period (Low)

TODO
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.

### Address 0x73 - Speaker Tone Duty Cycle

TODO
Sets the duty-cycle of the speaker tone. A value of 127 is 50:50 (a square wave).
2 changes: 1 addition & 1 deletion neotron-bmc-pico/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Jonathan 'theJPster' Pallant <github@thejpster.org.uk>"]
name = "neotron-bmc-pico"
edition = "2018"
version = "0.5.1"
version = "0.5.2"

[dependencies]
cortex-m = { version = "0.7.5", features = ["inline-asm", "critical-section-single-core"] }
Expand Down
17 changes: 10 additions & 7 deletions neotron-bmc-pico/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,8 @@ where
let mut data = [0u8; 1];

// What do they want?
let rsp = match (req.request_type, Command::try_from(req.register)) {
(proto::RequestType::Read, Ok(Command::ProtocolVersion))
| (proto::RequestType::ReadAlt, Ok(Command::ProtocolVersion)) => {
let rsp = match (req.request_type.flatten(), Command::try_from(req.register)) {
(proto::RequestType::Read, Ok(Command::ProtocolVersion)) => {
defmt::trace!("Reading ProtocolVersion");
// They want the Protocol Version we support. Give them v0.1.1.
let length = req.length_or_data as usize;
Expand All @@ -838,8 +837,7 @@ where
proto::Response::new_without_data(proto::ResponseResult::BadLength)
}
}
(proto::RequestType::Read, Ok(Command::FirmwareVersion))
| (proto::RequestType::ReadAlt, Ok(Command::FirmwareVersion)) => {
(proto::RequestType::Read, Ok(Command::FirmwareVersion)) => {
defmt::trace!("Reading FirmwareVersion");
// They want the Firmware Version string.
let length = req.length_or_data as usize;
Expand All @@ -851,8 +849,7 @@ where
proto::Response::new_without_data(proto::ResponseResult::BadLength)
}
}
(proto::RequestType::Read, Ok(Command::Ps2KbBuffer))
| (proto::RequestType::ReadAlt, Ok(Command::Ps2KbBuffer)) => {
(proto::RequestType::Read, Ok(Command::Ps2KbBuffer)) => {
defmt::trace!("Reading Ps2KbBuffer");
let length = req.length_or_data as usize;
if length > 0 && length <= register_state.scratch.len() {
Expand Down Expand Up @@ -882,6 +879,7 @@ where
}
(proto::RequestType::ShortWrite, Ok(Command::SpeakerDuration)) => {
defmt::debug!("Writing speaker duration ({})", req.length_or_data);
// This update actually causes the speaker to beep
register_state
.speaker
.set_duration(req.length_or_data as u16 * 10);
Expand Down Expand Up @@ -919,6 +917,11 @@ where
}
_ => {
// Sorry, that register / request type is not supported
defmt::warn!(
"Unknown register operation {:?} on 0x{:02x}",
req.request_type,
req.register
);
proto::Response::new_without_data(proto::ResponseResult::BadRegister)
}
};
Expand Down
13 changes: 13 additions & 0 deletions neotron-bmc-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ pub struct ProtocolVersion {
// Impls
// ============================================================================

impl RequestType {
/// Converts an 'alt' command into a regular command.
///
/// Once you've checked for duplicates, you don't care which you've got.
pub fn flatten(self) -> Self {
match self {
RequestType::LongWrite | RequestType::LongWriteAlt => RequestType::LongWrite,
RequestType::ShortWrite | RequestType::ShortWriteAlt => RequestType::ShortWrite,
RequestType::Read | RequestType::ReadAlt => RequestType::Read,
}
}
}

impl Request {
/// Make a new Read Request, requesting the given register and number of
/// bytes.
Expand Down

0 comments on commit bb08ff2

Please sign in to comment.