Skip to content

Commit

Permalink
docs(env-macros): add an extra param for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories authored and kaspar030 committed Feb 29, 2024
1 parent f45f85a commit e1f3e6a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
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 @@ -40,7 +40,8 @@ cfg_if::cfg_if! {

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 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

0 comments on commit e1f3e6a

Please sign in to comment.