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