Skip to content

Commit

Permalink
Add feature flag for cpu_clock_hz() (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnathancn committed Nov 18, 2022
1 parent a539289 commit 1ffc1a2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion freertos-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ allocator = []
sync = ["interrupt"]
time = ["interrupt"]
hooks = []
interrupt = []
interrupt = []
cpu_clock = []
2 changes: 2 additions & 0 deletions freertos-rust/src/freertos/shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ UBaseType_t freertos_rs_get_system_state(TaskStatus_t * const pxTaskStatusArray,
return uxTaskGetSystemState(pxTaskStatusArray, uxArraySize, pulTotalRunTime);
}

#ifdef configCPU_CLOCK_HZ
unsigned long freertos_rs_get_configCPU_CLOCK_HZ() {
return configCPU_CLOCK_HZ;
}
#endif

TickType_t freertos_rs_get_portTICK_PERIOD_MS() {
return portTICK_PERIOD_MS;
Expand Down
1 change: 1 addition & 0 deletions freertos-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@ pub use crate::timers::*;
#[cfg(any(feature = "time", feature = "sync"))]
pub use crate::units::*;

#[cfg(feature = "cpu_clock")]
pub use crate::utils::cpu_clock_hz;
pub use crate::utils::shim_sanity_check;
1 change: 1 addition & 0 deletions freertos-rust/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C" {
xTimeIncrement: FreeRtosTickType,
);
pub fn freertos_rs_vTaskDelay(xTicksToDelay: FreeRtosTickType);
#[cfg(feature = "cpu_clock")]
pub fn freertos_rs_get_configCPU_CLOCK_HZ() -> FreeRtosUnsignedLong;
pub fn freertos_rs_get_portTICK_PERIOD_MS() -> FreeRtosTickType;

Expand Down
1 change: 1 addition & 0 deletions freertos-rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct TypeSizeError {
rust_size: usize,
}

#[cfg(feature = "cpu_clock")]
pub fn cpu_clock_hz() -> u32 {
unsafe { freertos_rs_get_configCPU_CLOCK_HZ() }
}
Expand Down

0 comments on commit 1ffc1a2

Please sign in to comment.