Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(env-macros): add an extra param for documentation #123

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/riot-rs-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ async fn init_task(mut peripherals: arch::OptionalPeripherals) {
use crate::sendcell::SendCell;
use embassy_net::{Stack, StackResources};

const STACK_RESOURCES: usize =
riot_rs_utils::usize_from_env_or!("CONFIG_STACK_RESOURCES", 4);
const MAX_CONCURRENT_SOCKETS: usize = riot_rs_utils::usize_from_env_or!(
"CONFIG_NETWORK_MAX_CONCURRENT_SOCKETS",
4,
"maximum number of concurrent sockets allowed by the network stack"
);

let config = network::config();

Expand All @@ -174,7 +177,7 @@ async fn init_task(mut peripherals: arch::OptionalPeripherals) {
let stack = &*make_static!(Stack::new(
device,
config,
make_static!(StackResources::<STACK_RESOURCES>::new()),
make_static!(StackResources::<MAX_CONCURRENT_SOCKETS>::new()),
seed
));

Expand Down
9 changes: 7 additions & 2 deletions src/riot-rs-embassy/src/wifi/cyw43.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ use riot_rs_utils::str_from_env_or;
use self::rpi_pico_w::{Cyw43Periphs, CywSpi, Irqs, CYW43_PWR};
use crate::{arch::OptionalPeripherals, make_static};

const WIFI_NETWORK: &str = str_from_env_or!("CONFIG_WIFI_NETWORK", "test_network");
const WIFI_PASSWORD: &str = str_from_env_or!("CONFIG_WIFI_PASSWORD", "test_password");
const WIFI_NETWORK: &str = str_from_env_or!(
"CONFIG_WIFI_NETWORK",
"test_network",
"Wi-Fi SSID (network name)"
);
const WIFI_PASSWORD: &str =
str_from_env_or!("CONFIG_WIFI_PASSWORD", "test_password", "Wi-Fi password");

pub type NetworkDevice = cyw43::NetDriver<'static>;

Expand Down
3 changes: 2 additions & 1 deletion src/riot-rs-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
}
else {
mod arch {
pub fn init() {}

Check warning on line 33 in src/riot-rs-rt/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

function `init` is never used

warning: function `init` is never used --> src/riot-rs-rt/src/lib.rs:33:20 | 33 | pub fn init() {} | ^^^^
pub fn benchmark<F: Fn()>(_iterations: usize, _f: F) -> core::result::Result<usize, ()> {

Check warning on line 34 in src/riot-rs-rt/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

this returns a `Result<_, ()>`

warning: this returns a `Result<_, ()>` --> src/riot-rs-rt/src/lib.rs:34:13 | 34 | pub fn benchmark<F: Fn()>(_iterations: usize, _f: F) -> core::result::Result<usize, ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use a custom `Error` type instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err = note: `#[warn(clippy::result_unit_err)]` on by default
unimplemented!();
}
}
Expand All @@ -40,7 +40,8 @@

pub use arch::benchmark;

const ISR_STACKSIZE: usize = riot_rs_utils::usize_from_env_or!("CONFIG_ISR_STACKSIZE", 8192);
const ISR_STACKSIZE: usize =
riot_rs_utils::usize_from_env_or!("CONFIG_ISR_STACKSIZE", 8192, "ISR stack size (in bytes)");

#[link_section = ".isr_stack"]
#[used(linker)]
Expand All @@ -62,7 +63,7 @@
pub static INIT_FUNCS: [fn()] = [..];

#[inline]
fn startup() -> ! {

Check warning on line 66 in src/riot-rs-rt/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

function `startup` is never used

warning: function `startup` is never used --> src/riot-rs-rt/src/lib.rs:66:4 | 66 | fn startup() -> ! { | ^^^^^^^ | = note: `#[warn(dead_code)]` on by default
arch::init();

#[cfg(feature = "debug-console")]
Expand All @@ -86,7 +87,7 @@
{
#[cfg(test)]
test_main();
loop {}

Check warning on line 90 in src/riot-rs-rt/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> src/riot-rs-rt/src/lib.rs:90:9 | 90 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/riot-rs-utils/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ macro_rules! define_env_with_default_macro {
($macro_name:ident, $parse_fn_name:ident, $output_type_name:literal) => {
#[macro_export]
macro_rules! $macro_name {
($env_var:literal, $default:expr) => {
// $doc is currently unused
($env_var:literal, $default:expr, $doc:literal) => {
if let Some(str_value) = option_env!($env_var) {
if let Ok(value) = $crate::env::konst::primitive::$parse_fn_name(str_value) {
value
Expand All @@ -30,7 +31,8 @@ define_env_with_default_macro!(usize_from_env_or, parse_usize, "a usize");

#[macro_export]
macro_rules! str_from_env_or {
($env_var:literal, $default:expr) => {
// $doc is currently unused
($env_var:literal, $default:expr, $doc:literal) => {
if let Some(str_value) = option_env!($env_var) {
str_value
} else {
Expand Down
Loading