From 4b451634e7739e8e87cb9cce90a352a350df0861 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Mon, 5 Nov 2018 20:16:51 +1300 Subject: [PATCH] Rename AVR_FREQUENCY to AVR_FREQUENCY_HZ A bit less ambiguous. --- core_generator/build.rs | 4 ++-- src/modules/spi/clock.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core_generator/build.rs b/core_generator/build.rs index 72c015c..cd2bf15 100644 --- a/core_generator/build.rs +++ b/core_generator/build.rs @@ -42,8 +42,8 @@ fn generate_config_module() -> Result<(), io::Error> { let path = src_path().join("config.rs"); let mut f = File::create(&path)?; - let clock = env!("AVR_CPU_FREQUENCY"); - writeln!(f, "pub const CPU_FREQUENCY: u32 = {};", clock)?; + let clock = env!("AVR_CPU_FREQUENCY_HZ"); + writeln!(f, "pub const CPU_FREQUENCY_HZ: u32 = {};", clock)?; Ok(()) } diff --git a/src/modules/spi/clock.rs b/src/modules/spi/clock.rs index aea8ff0..92fe90c 100644 --- a/src/modules/spi/clock.rs +++ b/src/modules/spi/clock.rs @@ -19,17 +19,17 @@ pub struct ClockMask(pub u8); impl ClockMask { /// Gets the clock mask for a specific baute rate. pub fn with_clock(spi_clock: u32) -> ClockMask { - let mut divider_bits = if spi_clock >= config::CPU_FREQUENCY / 2 { + let mut divider_bits = if spi_clock >= config::CPU_FREQUENCY_HZ / 2 { 0 - } else if spi_clock >= config::CPU_FREQUENCY / 4 { + } else if spi_clock >= config::CPU_FREQUENCY_HZ / 4 { 1 - } else if spi_clock >= config::CPU_FREQUENCY / 8 { + } else if spi_clock >= config::CPU_FREQUENCY_HZ / 8 { 2 - } else if spi_clock >= config::CPU_FREQUENCY / 16 { + } else if spi_clock >= config::CPU_FREQUENCY_HZ / 16 { 3 - } else if spi_clock >= config::CPU_FREQUENCY / 32 { + } else if spi_clock >= config::CPU_FREQUENCY_HZ / 32 { 4 - } else if spi_clock >= config::CPU_FREQUENCY / 64 { + } else if spi_clock >= config::CPU_FREQUENCY_HZ / 64 { 5 } else { 6