Skip to content

Commit 35810b3

Browse files
committed
Swap period high and period low.
The bytes mean the same thing but now they are labelled correctly.
1 parent 8e75d18 commit 35810b3

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

neotron-bmc-commands/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,16 @@ should set the other three registers (if required) before setting this register.
217217
There is no way to know when the tone is ended; the host should keep track of
218218
the duration it set and wait the appropriate period of time.
219219

220-
### Address 0x71 - Speaker Tone Period (High)
220+
### Address 0x71 - Speaker Tone Period (Low)
221221

222-
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in 48 kHz units.
222+
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
223223

224-
### Address 0x72 - Speaker Tone Period (Low)
224+
### Address 0x72 - Speaker Tone Period (High)
225225

226-
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
226+
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in
227+
48 kHz units. A value of `48000 / 440 = 109 = 0x006D` will give you a
228+
Concert-pitch A (440 Hz). Write that value as `0x00` in the high register and
229+
`0x6D` in the low register.
227230

228231
### Address 0x73 - Speaker Tone Duty Cycle
229232

neotron-bmc-commands/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! # Neotron BMC Commands
2-
//!
3-
//! Definitions of all the commands supported by the BMC.
1+
#![doc = include_str!("../README.md")]
42

53
#![no_std]
64

@@ -142,16 +140,16 @@ pub enum Command {
142140
/// * Length: 1
143141
/// * Mode: R/W
144142
SpeakerDuration = 0x70,
145-
/// # Speaker Period (High byte)
146-
/// High byte of period (in 48kHz ticks)
143+
/// # Speaker Period (Low byte)
144+
/// Low byte of 16-bit period (in 48kHz ticks)
147145
/// * Length: 1
148146
/// * Mode: R/W
149-
SpeakerPeriodHigh = 0x71,
147+
SpeakerPeriodLow = 0x71,
150148
/// # Speaker Period (High byte)
151-
/// High byte of period (in 48kHz ticks)
149+
/// High byte of 16-bit period (in 48kHz ticks)
152150
/// * Length: 1
153151
/// * Mode: R/W
154-
SpeakerPeriodLow = 0x72,
152+
SpeakerPeriodHigh = 0x72,
155153
/// # Speaker Duty Cycle
156154
/// Speaker Duty cycle, in 1/255
157155
/// * Length: 1

neotron-bmc-pico/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ where
892892
}
893893
(proto::RequestType::ShortWrite, Ok(Command::SpeakerPeriodHigh)) => {
894894
defmt::debug!("Writing speaker period (high = {})", req.length_or_data);
895-
register_state.speaker.set_period_low(req.length_or_data);
895+
register_state.speaker.set_period_high(req.length_or_data);
896896
proto::Response::new_without_data(proto::ResponseResult::Ok)
897897
}
898898
(proto::RequestType::Read, Ok(Command::SpeakerPeriodLow)) => {
@@ -902,7 +902,7 @@ where
902902
}
903903
(proto::RequestType::ShortWrite, Ok(Command::SpeakerPeriodLow)) => {
904904
defmt::debug!("Writing speaker period (low = {})", req.length_or_data);
905-
register_state.speaker.set_period_high(req.length_or_data);
905+
register_state.speaker.set_period_low(req.length_or_data);
906906
proto::Response::new_without_data(proto::ResponseResult::Ok)
907907
}
908908
(proto::RequestType::Read, Ok(Command::SpeakerDutyCycle)) => {

0 commit comments

Comments
 (0)