Stop autogenerating config.rs file
This commit is contained in:
parent
0311381490
commit
ccad9c169b
|
@ -28,4 +28,5 @@ default = ["avr-std-stub"]
|
|||
|
||||
[dependencies]
|
||||
avr-std-stub = { version = "1.0", optional = true }
|
||||
const_env--value = "0.1"
|
||||
target-cpu-macro = "0.1"
|
||||
|
|
|
@ -46,7 +46,6 @@ fn main() {
|
|||
};
|
||||
let current_mcu_name = current_mcu.device.name.clone();
|
||||
|
||||
generate_config_module().unwrap();
|
||||
generate_cores(&[current_mcu]).unwrap();
|
||||
|
||||
println!("cargo:rustc-cfg=avr_mcu_{}", normalize_device_name(¤t_mcu_name));
|
||||
|
@ -59,23 +58,6 @@ fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {
|
|||
generate_cores_mod_rs(mcus)
|
||||
}
|
||||
|
||||
fn generate_config_module() -> Result<(), io::Error> {
|
||||
let path = base_output_path().join("config.rs");
|
||||
let mut f = File::create(&path)?;
|
||||
|
||||
let clock: u64 = if cfg!(arch = "avr") {
|
||||
env::var("AVR_CPU_FREQUENCY_HZ")
|
||||
.expect("Please set the '$AVR_CPU_FREQUENCY_HZ' environment variable")
|
||||
.parse()
|
||||
.expect("The $AVR_CPU_FREQUENCY_HZ environment variable is not an integer")
|
||||
} else {
|
||||
DEFAULT_FREQUENCY_HZ_FOR_NON_AVR_DOCS
|
||||
};
|
||||
writeln!(f, "/// The clock frequency of device being targeted in Hertz.")?;
|
||||
writeln!(f, "pub const CPU_FREQUENCY_HZ: u32 = {};", clock)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_core_module(mcu: &Mcu) -> Result<(), io::Error> {
|
||||
let path = cores_path().join(format!("{}.rs", core_module_name(mcu)));
|
||||
let mut file = File::create(&path)?;
|
||||
|
|
|
@ -1,2 +1,13 @@
|
|||
#[cfg(target_arch = "avr")] use const_env::value_from_env;
|
||||
|
||||
/// The clock frequency of device being targeted in Hertz.
|
||||
pub const CPU_FREQUENCY_HZ: u32 = 16000000;
|
||||
#[cfg(target_arch = "avr")]
|
||||
pub const CPU_FREQUENCY_HZ: u32 = value_from_env!("AVR_CPU_FREQUENCY_HZ": u32);
|
||||
|
||||
/// The clock frequency of device being targeted in Hertz.
|
||||
///
|
||||
/// This value is arbitrarily set to 16MHz as this crate is currently being targeted for a non-AVR
|
||||
/// device.
|
||||
#[cfg(not(target_arch = "avr"))]
|
||||
pub const CPU_FREQUENCY_HZ: u32 = 16_000_000; // Choose a nice default when not targeting AVR.
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#[cfg(feature = "avr-std-stub")] extern crate avr_std_stub;
|
||||
|
||||
extern crate const_env__value as const_env;
|
||||
|
||||
pub use self::register::{Register, RegisterBits, RegisterValue};
|
||||
pub use self::pin::{DataDirection, Pin};
|
||||
|
||||
|
|
Loading…
Reference in New Issue