Skip to content

Commit 68dfe41

Browse files
committed
Fixed speaker register bug.
Also puts the protocol back as it was, and bumps the version to 0.2.0
1 parent 2dd6959 commit 68dfe41

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

neotron-bmc-commands/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ edition = "2021"
44
license = "BlueOak-1.0.0"
55
name = "neotron-bmc-commands"
66
repository = "https://github.com/neotron-compute/neotron-bmc"
7-
version = "0.1.0"
7+
version = "0.2.0"
88
homepage = "https://github.com/neotron-compute"
99
readme = "README.md"
1010

neotron-bmc-commands/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ 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 (Low)
221-
222-
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
223-
224-
### Address 0x72 - Speaker Tone Period (High)
220+
### Address 0x71 - Speaker Tone Period (High)
225221

226222
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in
227223
48 kHz units. A value of `48000 / 440 = 109 = 0x006D` will give you a
228224
Concert-pitch A (440 Hz). Write that value as `0x00` in the high register and
229225
`0x6D` in the low register.
230226

227+
### Address 0x72 - Speaker Tone Period (Low)
228+
229+
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
230+
231231
### Address 0x73 - Speaker Tone Duty Cycle
232232

233233
Sets the duty-cycle of the speaker tone. A value of 127 is 50:50 (a square wave).

neotron-bmc-commands/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ pub enum Command {
139139
/// * Length: 1
140140
/// * Mode: R/W
141141
SpeakerDuration = 0x70,
142-
/// # Speaker Period (Low byte)
143-
/// Low byte of 16-bit period (in 48kHz ticks)
142+
/// # Speaker Tone Period (High byte)
143+
/// High byte of 16-bit period (in 48kHz ticks)
144144
/// * Length: 1
145145
/// * Mode: R/W
146-
SpeakerPeriodLow = 0x71,
147-
/// # Speaker Period (High byte)
148-
/// High byte of 16-bit period (in 48kHz ticks)
146+
SpeakerPeriodHigh = 0x71,
147+
/// # Speaker Tone Period (Low byte)
148+
/// Low byte of 16-bit period (in 48kHz ticks)
149149
/// * Length: 1
150150
/// * Mode: R/W
151-
SpeakerPeriodHigh = 0x72,
151+
SpeakerPeriodLow = 0x72,
152152
/// # Speaker Duty Cycle
153153
/// Speaker Duty cycle, in 1/255
154154
/// * Length: 1

neotron-bmc-pico/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ heapless= "0.7"
1717
panic-probe = { version = "0.3", features = ["print-defmt"] }
1818
stm32f0xx-hal = { version = "0.18", features = ["stm32f030x6", "rt"] }
1919
neotron-bmc-protocol = { version = "0.1", path = "../neotron-bmc-protocol", features = ["defmt"] }
20-
neotron-bmc-commands = { version = "0.1", path = "../neotron-bmc-commands" }
20+
neotron-bmc-commands = { version = "0.2", path = "../neotron-bmc-commands" }
2121
systick-monotonic = "1.0"
2222
embedded-hal = "*"
2323

neotron-bmc-pico/src/speaker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ impl RegisterState {
3737
}
3838

3939
pub fn set_period_high(&mut self, period_high: u8) {
40-
self.period = (self.period & 0xff00) | period_high as u16;
40+
self.period = (self.period & 0x00ff) | ((period_high as u16) << 8);
4141
}
4242

4343
pub fn period_low(&self) -> u8 {
4444
(self.period & 0xff) as u8
4545
}
4646

4747
pub fn set_period_low(&mut self, period_low: u8) {
48-
self.period = (self.period() & 0xff) | ((period_low as u16) << 8);
48+
self.period = (self.period & 0xff00) | period_low as u16;
4949
}
5050

5151
pub fn duration(&self) -> u16 {

0 commit comments

Comments
 (0)