diff --git a/neotron-bmc-commands/Cargo.toml b/neotron-bmc-commands/Cargo.toml index a8784e3..5cd49ee 100644 --- a/neotron-bmc-commands/Cargo.toml +++ b/neotron-bmc-commands/Cargo.toml @@ -4,7 +4,7 @@ edition = "2021" license = "BlueOak-1.0.0" name = "neotron-bmc-commands" repository = "https://github.com/neotron-compute/neotron-bmc" -version = "0.1.0" +version = "0.2.0" homepage = "https://github.com/neotron-compute" readme = "README.md" diff --git a/neotron-bmc-commands/README.md b/neotron-bmc-commands/README.md index df85bf7..e6f736d 100644 --- a/neotron-bmc-commands/README.md +++ b/neotron-bmc-commands/README.md @@ -217,17 +217,17 @@ 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 (Low) - -Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details. - -### Address 0x72 - Speaker Tone Period (High) +### Address 0x71 - Speaker Tone Period (High) Sets the upper 8 bits of the tone period. This is the inverse of frequency, in 48 kHz units. A value of `48000 / 440 = 109 = 0x006D` will give you a Concert-pitch A (440 Hz). Write that value as `0x00` in the high register and `0x6D` in the low register. +### Address 0x72 - Speaker Tone Period (Low) + +Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details. + ### Address 0x73 - Speaker Tone Duty Cycle Sets the duty-cycle of the speaker tone. A value of 127 is 50:50 (a square wave). diff --git a/neotron-bmc-commands/src/lib.rs b/neotron-bmc-commands/src/lib.rs index 3e63262..821a89c 100644 --- a/neotron-bmc-commands/src/lib.rs +++ b/neotron-bmc-commands/src/lib.rs @@ -139,16 +139,16 @@ pub enum Command { /// * Length: 1 /// * Mode: R/W SpeakerDuration = 0x70, - /// # Speaker Period (Low byte) - /// Low byte of 16-bit period (in 48kHz ticks) + /// # Speaker Tone Period (High byte) + /// High byte of 16-bit period (in 48kHz ticks) /// * Length: 1 /// * Mode: R/W - SpeakerPeriodLow = 0x71, - /// # Speaker Period (High byte) - /// High byte of 16-bit period (in 48kHz ticks) + SpeakerPeriodHigh = 0x71, + /// # Speaker Tone Period (Low byte) + /// Low byte of 16-bit period (in 48kHz ticks) /// * Length: 1 /// * Mode: R/W - SpeakerPeriodHigh = 0x72, + SpeakerPeriodLow = 0x72, /// # Speaker Duty Cycle /// Speaker Duty cycle, in 1/255 /// * Length: 1 diff --git a/neotron-bmc-pico/Cargo.lock b/neotron-bmc-pico/Cargo.lock index 0158d1e..2d36697 100644 --- a/neotron-bmc-pico/Cargo.lock +++ b/neotron-bmc-pico/Cargo.lock @@ -284,14 +284,14 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "neotron-bmc-commands" -version = "0.1.0" +version = "0.2.0" dependencies = [ "num_enum", ] [[package]] name = "neotron-bmc-pico" -version = "0.5.3" +version = "0.5.4" dependencies = [ "cortex-m", "cortex-m-rtic", diff --git a/neotron-bmc-pico/Cargo.toml b/neotron-bmc-pico/Cargo.toml index 7481b6d..3043f91 100644 --- a/neotron-bmc-pico/Cargo.toml +++ b/neotron-bmc-pico/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" license = "GPL-3.0-or-later" name = "neotron-bmc-pico" readme = "README.md" -version = "0.5.3" +version = "0.5.4" [dependencies] cortex-m = { version = "0.7.5", features = ["inline-asm", "critical-section-single-core"] } @@ -17,7 +17,7 @@ heapless= "0.7" panic-probe = { version = "0.3", features = ["print-defmt"] } stm32f0xx-hal = { version = "0.18", features = ["stm32f030x6", "rt"] } neotron-bmc-protocol = { version = "0.1", path = "../neotron-bmc-protocol", features = ["defmt"] } -neotron-bmc-commands = { version = "0.1", path = "../neotron-bmc-commands" } +neotron-bmc-commands = { version = "0.2", path = "../neotron-bmc-commands" } systick-monotonic = "1.0" embedded-hal = "*" diff --git a/neotron-bmc-pico/src/speaker.rs b/neotron-bmc-pico/src/speaker.rs index 9df3122..cf809e8 100644 --- a/neotron-bmc-pico/src/speaker.rs +++ b/neotron-bmc-pico/src/speaker.rs @@ -37,7 +37,7 @@ impl RegisterState { } pub fn set_period_high(&mut self, period_high: u8) { - self.period = (self.period & 0xff00) | period_high as u16; + self.period = (self.period & 0x00ff) | ((period_high as u16) << 8); } pub fn period_low(&self) -> u8 { @@ -45,7 +45,7 @@ impl RegisterState { } pub fn set_period_low(&mut self, period_low: u8) { - self.period = (self.period() & 0xff) | ((period_low as u16) << 8); + self.period = (self.period & 0xff00) | period_low as u16; } pub fn duration(&self) -> u16 {