repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -3,10 +3,10 @@ /// HAL initialization error. #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum HalError { - /// Error indicating that HAL has already been created once. + /// Error indicating that the requested operation was called before HAL creation. + HalNotCreated, + /// Error indicating that ...
Shouldn't this be `HalAlreadyInitialized`?
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -20,88 +19,85 @@ use crate::user_peripherals::UserPeripherals; use internal_cell::InternalCell; use pac::{self, PMC, TC0}; -/// This lock will prevent from creating HAL instance twice in the system. -/// Since HAL manages the access to peripherals, creating and using multiple -/// instances of it could be unsafe...
```suggestion pub struct Hal; ```
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -20,88 +19,85 @@ use crate::user_peripherals::UserPeripherals; use internal_cell::InternalCell; use pac::{self, PMC, TC0}; -/// This lock will prevent from creating HAL instance twice in the system. -/// Since HAL manages the access to peripherals, creating and using multiple -/// instances of it could be unsafe...
Move public functions above the private ones
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -20,88 +19,85 @@ use crate::user_peripherals::UserPeripherals; use internal_cell::InternalCell; use pac::{self, PMC, TC0}; -/// This lock will prevent from creating HAL instance twice in the system. -/// Since HAL manages the access to peripherals, creating and using multiple -/// instances of it could be unsafe...
```suggestion /// Creates system peripherals of HAL. ```
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -110,49 +106,116 @@ impl SystemHal for Hal { type Duration = crate::time::TimerDurationU64<{ Hal::TIMER_FREQ }>; type Error = HalError; - fn configure_hardware(&mut self, config: SystemHardwareConfig) -> Result<(), HalError> { - // SAFETY: This is safe, because this is a single-core system, - ...
```suggestion /// Initializes global HAL instance using PAC peripherals. ```
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -110,49 +106,116 @@ impl SystemHal for Hal { type Duration = crate::time::TimerDurationU64<{ Hal::TIMER_FREQ }>; type Error = HalError; - fn configure_hardware(&mut self, config: SystemHardwareConfig) -> Result<(), HalError> { - // SAFETY: This is safe, because this is a single-core system, - ...
Is this necessary to have `fn create` and `fn configure_hardware` separate? If one has to be called after another, and `create` doesn't return anything it seems unnecessary.
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -8,7 +8,8 @@ use crate::drivers::{ }; /// System peripherals structure. These peripherals are represented as HAL drivers. -/// They are initialized on system init, and used directly by HAL to provide core functionality. +/// Some of these peripherals are available only during HAL initialization +/// (between Hal...
```suggestion /// (between SystemHal::create and SystemHal::configure_hardware calls). ```
aerugo
github_2023
others
39
n7space
Glamhoth
@@ -50,10 +49,7 @@ static TIME_MANAGER: TimeManager = TimeManager::new(); /// This shouldn't be created by hand by the user or anywhere else in the code. /// It should be used as a [singleton](crate::aerugo::AERUGO) that acts as a system API, /// both for user and for the internal system parts. -pub struct Aerugo { ...
```suggestion pub struct Aerugo; ```
aerugo
github_2023
others
35
n7space
SteelPh0enix
@@ -0,0 +1,8 @@ +[package] +authors = ["Filip Demski <glamhoth@protonmail.com>"] +edition = "2021" +name = "x86-basic-execution"
change name
aerugo
github_2023
others
33
n7space
Glamhoth
@@ -0,0 +1,16 @@ +#!/bin/bash + +set -euo pipefail + +if [ $# -eq 0 ] +then + for d in testbins/test-hal-*/; do + pushd $d > /dev/null + cargo build + popd > /dev/null + done +else + pushd examples/$1/ > /dev/null + cargo build + popd > /dev/null +fi
```suggestion for d in testbins/test-hal-*/; do pushd $d > /dev/null cargo build popd > /dev/null done ```
aerugo
github_2023
others
33
n7space
Glamhoth
@@ -58,6 +58,18 @@ jobs: - name: cargo build run: cargo build -p aerugo --features ${{ matrix.FEATURES }} + build-hal-tests: + name: Build HAL integration tests + runs-on: ubuntu-latest + steps:
```suggestion runs-on: ubuntu-latest needs: [rustfmt, clippy, build] steps: ```
aerugo
github_2023
python
33
n7space
Glamhoth
@@ -0,0 +1,162 @@ +"""Module containing some boilerplate, common to all tests that use `calldwell-rs` library.""" +import logging +from typing import Any, Callable, Optional, Tuple + +from .gdb_client import GDBClient +from .rtt_client import RTTClient + +RTT_SECTION_SYMBOL_NAME = "_SEGGER_RTT" +"""Section name of RTT ...
Shouldn't the docs be above the line they are documenting?
aerugo
github_2023
others
31
n7space
SteelPh0enix
@@ -0,0 +1,113 @@ +/// @SRS{ROS-BSP-010} +/// +/// Design Analisys is described in N7S-ROS-SVSR-001, chapter 6.2.
s/Analisys/Analysis
aerugo
github_2023
others
30
n7space
Glamhoth
@@ -0,0 +1,22 @@ +use assert_cmd::Command; +// use test_binary::build_test_binary; + +/// @SRS{ROS-FUN-BSP-TIC-020} +/// @SRS{ROS-FUN-BSP-TIC-030} +/// @SRS{ROS-FUN-BSP-TIC-040} +/// @SRS{ROS-FUN-BSP-TIC-050} +/// @SRS{ROS-FUN-BSP-TIC-060} +/// @SRS{ROS-FUN-BSP-TIC-070}
Add the test scenario from the `main.rs` here
aerugo
github_2023
others
30
n7space
Glamhoth
@@ -0,0 +1,22 @@ +use assert_cmd::Command; +// use test_binary::build_test_binary;
```suggestion ```
aerugo
github_2023
python
30
n7space
Glamhoth
@@ -77,11 +77,11 @@ def main(): # Default watchdog timeout is 16s. Watchdog in this test is set to 3s, but timeout must be # few seconds higher to compensate for communication delays and MCU clock inaccuracies. - gdb.wait_for_reset(timeout=5) + gdb.wait_for_reset(timeout=10) finish_test(ssh) ...
Necessary?
aerugo
github_2023
python
30
n7space
Glamhoth
@@ -1,6 +1,6 @@ import os -# import logging +import logging
Necessary?
aerugo
github_2023
others
29
n7space
Glamhoth
@@ -0,0 +1,139 @@ +//! Library providing software testing utilities for microcontrollers. +//! Also provides a panic handler that works over RTT. +//! Part of Calldwell testing framework. + +#![cfg(all(target_arch = "arm", target_os = "none"))] +#![deny(missing_docs)] +#![deny(warnings)] +#![no_std] + +mod streams; + +...
```suggestion /// # Generic Parameters ```
aerugo
github_2023
others
29
n7space
Glamhoth
@@ -0,0 +1,139 @@ +//! Library providing software testing utilities for microcontrollers. +//! Also provides a panic handler that works over RTT. +//! Part of Calldwell testing framework. + +#![cfg(all(target_arch = "arm", target_os = "none"))] +#![deny(missing_docs)] +#![deny(warnings)] +#![no_std] + +mod streams; + +...
```suggestion /// # Generic Parameters ```
aerugo
github_2023
others
26
n7space
SteelPh0enix
@@ -380,12 +419,82 @@ impl InitApi for Aerugo { Ok(()) } - fn subscribe_tasklet_to_event<T, C, const COND_COUNT: usize>( + /// Subscribes a tasklet to events. + /// + /// Tasklet subscribes for emited events. After subscription specific events has to be enabled
```suggestion /// Tasklet subscribes for emited events. After subscription, specific events have to be enabled ```
aerugo
github_2023
others
25
n7space
Glamhoth
@@ -0,0 +1,227 @@ +//! Module with functionalities of timer's channel in waveform mode. + +use pac::tc0::tc_channel::CMR_WAVEFORM_MODE; + +use super::{ + waveform_config::{ + ComparisonEffect, CountMode, ExternalEventConfig, OutputSignalEffects, RcCompareEffect, + RcCompareEffectFlags, WaveformModeConf...
Sets?
aerugo
github_2023
others
25
n7space
Glamhoth
@@ -0,0 +1,227 @@ +//! Module with functionalities of timer's channel in waveform mode. + +use pac::tc0::tc_channel::CMR_WAVEFORM_MODE; + +use super::{ + waveform_config::{ + ComparisonEffect, CountMode, ExternalEventConfig, OutputSignalEffects, RcCompareEffect, + RcCompareEffectFlags, WaveformModeConf...
Returns?
aerugo
github_2023
others
25
n7space
Glamhoth
@@ -0,0 +1,227 @@ +//! Module with functionalities of timer's channel in waveform mode. + +use pac::tc0::tc_channel::CMR_WAVEFORM_MODE; + +use super::{ + waveform_config::{ + ComparisonEffect, CountMode, ExternalEventConfig, OutputSignalEffects, RcCompareEffect, + RcCompareEffectFlags, WaveformModeConf...
Returns?
aerugo
github_2023
others
25
n7space
Glamhoth
@@ -0,0 +1,227 @@ +//! Module with functionalities of timer's channel in waveform mode. + +use pac::tc0::tc_channel::CMR_WAVEFORM_MODE; + +use super::{ + waveform_config::{ + ComparisonEffect, CountMode, ExternalEventConfig, OutputSignalEffects, RcCompareEffect, + RcCompareEffectFlags, WaveformModeConf...
Sets?
aerugo
github_2023
others
23
n7space
SteelPh0enix
@@ -414,6 +512,22 @@ impl InitApi for Aerugo { Ok(()) } + + fn set_tasklet_conditions<T, C, const COND_COUNT: usize>( + &'static self, + tasklet_handle: &TaskletHandle<T, C, COND_COUNT>, + condition_set: BooleanConditionSet<COND_COUNT>, + ) -> Result<(), Self::Error> { + ...
is this note somewhere where user can see it by reading documentation (attached to trait/function declaration)?
aerugo
github_2023
others
23
n7space
SteelPh0enix
@@ -0,0 +1,146 @@ +//! Boolean condition set. + +use heapless::Vec; + +use crate::aerugo::error::InitError; +use crate::boolean_condition::{BooleanCondition, BooleanConditionHandle}; +use crate::tasklet::TaskletPtr; + +/// Type of the set conditions list. +type ConditionsList<const N: usize> = Vec<&'static BooleanCondi...
use `iter().all()` instead of raw loop? it's both more idiomatic way, as well as possibly more optimal
aerugo
github_2023
others
23
n7space
SteelPh0enix
@@ -0,0 +1,146 @@ +//! Boolean condition set. + +use heapless::Vec; + +use crate::aerugo::error::InitError; +use crate::boolean_condition::{BooleanCondition, BooleanConditionHandle}; +use crate::tasklet::TaskletPtr; + +/// Type of the set conditions list. +type ConditionsList<const N: usize> = Vec<&'static BooleanCondi...
there should be equivalent to `iter().all()` that can be used here, if there is iterator support for our `Vec` type
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,108 @@ +//! Implementation of HAL Timer Counter driver. +pub mod channel; +pub mod channel_config; +mod tc_metadata; +pub mod timer_config; +pub mod timer_error; +pub mod waveform_config; + +use channel::*; +use tc_metadata::*; + +pub use channel::Channel; +pub use channel_config::*; +pub use timer_config::*...
```suggestion /// # Generic Parameters ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,108 @@ +//! Implementation of HAL Timer Counter driver. +pub mod channel; +pub mod channel_config; +mod tc_metadata; +pub mod timer_config; +pub mod timer_error; +pub mod waveform_config; + +use channel::*; +use tc_metadata::*; + +pub use channel::Channel; +pub use channel_config::*; +pub use timer_config::*...
Move to the end of the `impl` block
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,108 @@ +//! Implementation of HAL Timer Counter driver. +pub mod channel; +pub mod channel_config; +mod tc_metadata; +pub mod timer_config; +pub mod timer_error; +pub mod waveform_config; + +use channel::*; +use tc_metadata::*; + +pub use channel::Channel; +pub use channel_config::*; +pub use timer_config::*...
```suggestion /// Creates a new timer instance from PAC timer structure. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,108 @@ +//! Implementation of HAL Timer Counter driver. +pub mod channel; +pub mod channel_config; +mod tc_metadata; +pub mod timer_config; +pub mod timer_error; +pub mod waveform_config; + +use channel::*; +use tc_metadata::*; + +pub use channel::Channel; +pub use channel_config::*; +pub use timer_config::*...
There's no `?` in the code below. Also, it have to be safe, just `should` is not enough. :]
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Returns currently used clock source. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Sets the value of channel's `C` register. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Reads channel's status register, and clean interrupt status flags after that. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Trait representing channel's ID /// /// It's type-level equivalent of ChannelNo enumeration. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Enumeration listing available channels. /// /// It's value-level equivalent of ChannelId trait. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Enables selected interrupts. /// /// State of other interrupts will not be changed. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Disables selected interrupts. /// /// State of other interrupts will not be changed. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Transforms the channel into a type with different state and/or mode. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Creates new timer channel. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Resets the hardware state of the timer to correctly reflect it's typestate. /// /// In this state, the function will disable timer's channel. /// Our typestate should always be treated as "hard" guarantee, to which the hardware /// state of timer's channel is always synchroniz...
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,456 @@ +//! Module representing timer counter's channel + +use core::marker::PhantomData; +use pac::tc0::tc_channel::TC_CHANNEL; + +use super::channel_config::*; +use super::TcMetadata; +use super::WaveformModeConfig; + +/// Structure representing a timer's channel. +pub struct Channel<Timer, ID, State, Mode...
```suggestion /// Sets waveform mode configuration. ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -0,0 +1,39 @@ +//! Module with PAC TC metadata implementation. +pub(super) use pac::tc0::RegisterBlock; +use pac::{Interrupt, TC0, TC1, TC2, TC3}; + +/// Amount of channels per timer instance. +const CHANNELS_COUNT_PER_TIMER: usize = 3; + +/// Trait for PAC timer counter instances. +/// This trait erases the type of...
```suggestion /// Trait for PAC timer counter instances. /// /// This trait erases the type of TC instance, so it can be used as generic argument for [`Timer`](super::Timer) ```
aerugo
github_2023
others
24
n7space
Glamhoth
@@ -5,6 +5,12 @@ use pac; /// Peripherals structure. /// These peripherals can be used to create HAL drivers in user code. pub struct UserPeripherals { - /// Chip ID. + /// Chip ID pub chip_id: Option<pac::CHIPID>, + /// Timer Counter 1 + pub timer_counter1: Option<pac::TC1>, + /// Timer Counter ...
```suggestion /// Chip ID. pub chip_id: Option<pac::CHIPID>, /// Timer Counter 1. pub timer_counter1: Option<pac::TC1>, /// Timer Counter 2. pub timer_counter2: Option<pac::TC2>, /// Timer Counter 3. pub timer_counter3: Option<pac::TC3>, ```
aerugo
github_2023
others
11
n7space
SteelPh0enix
@@ -9,50 +9,77 @@ pub(crate) use self::message_queue_storage::QueueData; use heapless::Vec; +use crate::aerugo::AERUGO; use crate::aerugo::{ error::{InitError, RuntimeError}, Aerugo, }; +use crate::api::SystemApi; use crate::arch::Mutex; use crate::data_provider::DataProvider; +use crate::internal_ce...
why?
aerugo
github_2023
others
11
n7space
SteelPh0enix
@@ -23,27 +24,136 @@ pub(crate) type QueueData<T, const N: usize> = heapless::spsc::Queue<T, N>; /// * `N` - Size of the queue. pub struct MessageQueueStorage<T, const N: usize> { /// Marks whether this storage has been initialized. - _initialized: InternalCell<bool>, + initialized: InternalCell<bool>, ...
```suggestion // SAFETY: This is safe because it is modified only here, and can't be externally ```
aerugo
github_2023
others
11
n7space
SteelPh0enix
@@ -23,27 +24,136 @@ pub(crate) type QueueData<T, const N: usize> = heapless::spsc::Queue<T, N>; /// * `N` - Size of the queue. pub struct MessageQueueStorage<T, const N: usize> { /// Marks whether this storage has been initialized. - _initialized: InternalCell<bool>, + initialized: InternalCell<bool>, ...
```suggestion /// Returns a reference to the stored MessageQueue structure. ```
aerugo
github_2023
others
11
n7space
SteelPh0enix
@@ -29,57 +30,54 @@ unsafe impl Sync for TaskletPtr {} unsafe impl Send for TaskletPtr {} impl TaskletPtr { - /// Creates new pointer + /// Creates new from tasklet referernce
```suggestion /// Creates new tasklet pointer from referernce ```
aerugo
github_2023
others
19
n7space
SteelPh0enix
@@ -0,0 +1,84 @@ +use super::*; + +struct MockDataProvider { + data_ready: bool, +} + +impl MockDataProvider { + const fn new() -> Self { + MockDataProvider { data_ready: false } + } + + fn set_data_ready(&mut self, data_ready: bool) { + self.data_ready = data_ready + } +} + +impl DataProvi...
In other projects we usually add comments for tests, explaining what they are testing (Given/When/Then formula). If you're going to use the same tools for requirement generation, maybe you also should add these comments?
aerugo
github_2023
others
21
n7space
SteelPh0enix
@@ -0,0 +1,26 @@ +use assert_cmd::Command; +use test_binary::build_test_binary; + +/// @SRS{ROS-FUN-RTOS-10} +/// @SRS{ROS-FUN-RTOS-90} +/// @SRS{ROS-FUN-RTOS-100} +/// @SRS{ROS-FUN-RTOS-110} +#[cfg_attr(not(doc), test)] +fn req_test_tasklet_priority() { + let test_bin_path = + build_test_binary("test-tasklet...
remove exit from TaskB and check if TaskC executes after TaskB finishes?
aerugo
github_2023
others
18
n7space
Glamhoth
@@ -72,6 +41,23 @@ impl Watchdog { } } + /// Converts duration to watchdog counter value
Parameter documentation is missing (here and in some other functions in this file)
aerugo
github_2023
others
18
n7space
Glamhoth
@@ -72,6 +41,23 @@ impl Watchdog { } } + /// Converts duration to watchdog counter value + fn convert_duration_to_counter_value(duration: MillisDurationU32) -> u16 {
I'd move free functions at the end of the `impl` block
aerugo
github_2023
others
18
n7space
Glamhoth
@@ -1,50 +1,109 @@ //! System HAL implementation for Cortex-M SAMV71 target. +use aerugo_cortex_m::Mutex; use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; use bare_metal::CriticalSection; -use crate::peripherals::Peripherals; +use crate::drivers::watchdog::config::WatchdogConfig; +use crate::driver...
Docs formatting
aerugo
github_2023
others
18
n7space
Glamhoth
@@ -1,50 +1,109 @@ //! System HAL implementation for Cortex-M SAMV71 target. +use aerugo_cortex_m::Mutex; use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; use bare_metal::CriticalSection; -use crate::peripherals::Peripherals; +use crate::drivers::watchdog::config::WatchdogConfig; +use crate::driver...
Lock should end here
aerugo
github_2023
others
18
n7space
Glamhoth
@@ -0,0 +1,155 @@ +//! Implementation of HAL Watchdog driver. +//! +//! Watchdog can be used to unconditionally reset or interrupt the MCU when program halts. +//! To indicate that program is running, watchdog needs to be "fed" periodically. +//! Minimal frequency of feeding can be adjusted by setting watchdog counter ...
`Parameters` to be inline with the rest of the docs
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,12 @@ +[package] +name = "internal-cell" +version = "1.0.0"
I'd keep the version same as the system, so `0.0.1` for now. `env-parser` has `1.0.0` because it's completely separate and most likely won't be changed anymore.
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -4,23 +4,41 @@ use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; use bare_metal::CriticalSection; use crate::peripherals::Peripherals; +use internal_cell::InternalCell; /// HAL implementation for Cortex-M SAMV71. pub struct Hal { /// Hardware peripherals. - _peripherals: Peripherals, + ...
Remove `_` as this field is now used.
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -4,23 +4,41 @@ use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; use bare_metal::CriticalSection; use crate::peripherals::Peripherals; +use internal_cell::InternalCell; /// HAL implementation for Cortex-M SAMV71. pub struct Hal { /// Hardware peripherals. - _peripherals: Peripherals, + ...
This should panic if peripherals are set twice, as this would clearly be an error, or at least return `Result`.
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -4,23 +4,41 @@ use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; use bare_metal::CriticalSection; use crate::peripherals::Peripherals; +use internal_cell::InternalCell; /// HAL implementation for Cortex-M SAMV71. pub struct Hal { /// Hardware peripherals. - _peripherals: Peripherals, + ...
Maybe `Hal` should be initialized with `Peripherals`, and then we move responsibility of initializing it at runtime upwards? Maybe `Aerugo` shall use `lazy_init` to initialize Hal at runtime?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -6,10 +6,14 @@ SAMV71 implementation of aerugo HAL. #![warn(clippy::missing_docs_in_private_items)] #![warn(rustdoc::missing_crate_level_docs)] +extern crate internal_cell; + pub(crate) use fugit as time; +pub(crate) use samv71q21_pac as pac; pub mod hal; pub mod peripherals; pub use self::hal::Hal; pub...
Just question: should our HAL do this `pub`?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,120 @@ +//! Implementation of HAL for Watchdog + +use embedded_hal::watchdog::WatchdogDisable; + +use crate::embedded_hal::watchdog; +use crate::pac::WDT; + +/// Structure representing a watchdog +pub struct Watchdog { + /// Watchdog instance + wdt: WDT, + /// Indicates whether the watchdog has been...
Move to a different file maybe? `src/peripherals/watchdog/watchdog_config.rs`? \+ We have `Config` in other places instead of `Configuration`
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,41 @@ +//! Access to the hardware peripherals. + +pub mod watchdog; + +use aerugo_cortex_m::Mutex; +use samv71q21_pac::CorePeripherals as cortex_peripherals; +use samv71q21_pac::Peripherals as samv71_peripherals; + +/// Mutex indicating whether the peripherals instance have already been taken. +static PERIPH...
Lock should end here.
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,120 @@ +//! Implementation of HAL for Watchdog + +use embedded_hal::watchdog::WatchdogDisable; + +use crate::embedded_hal::watchdog; +use crate::pac::WDT; + +/// Structure representing a watchdog +pub struct Watchdog { + /// Watchdog instance + wdt: WDT, + /// Indicates whether the watchdog has been...
This should return `Result` with an appriopriate error.
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,120 @@ +//! Implementation of HAL for Watchdog + +use embedded_hal::watchdog::WatchdogDisable; + +use crate::embedded_hal::watchdog; +use crate::pac::WDT; + +/// Structure representing a watchdog +pub struct Watchdog { + /// Watchdog instance + wdt: WDT, + /// Indicates whether the watchdog has been...
Shouldn't this set `self.configured`?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -15,19 +15,31 @@ static TIME_START: Lazy<SystemTime> = Lazy::new(SystemTime::now); /// HAL implementation for x86. pub struct Hal { /// Hardware peripherals. - _peripherals: Peripherals, + #[allow(dead_code)] + peripherals: Peripherals, } impl Hal { /// Frequency for the time types (TODO) ...
Shouldn't this use `Peripherals::new`?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -56,11 +56,21 @@ impl Aerugo { /// # Safety /// This shouldn't be called in more that [one place](crate::aerugo::AERUGO). const fn new() -> Self { - let peripherals = Peripherals {}; + Aerugo { hal: Hal::new() } + } - Aerugo { - hal: Hal::new(peripherals), - ...
Return `Option` to the user, so that he can handle it (user may want to do something else than `expect`).
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,137 @@ +//! Implementation of HAL for Watchdog +//! +//! Watchdog can be used to unconditionally reset or interrupt the MCU when program halts. +//! To indicate that program is running, watchdog needs to be "fed" periodically. +//! Minimal frequency of feeding can be adjusted by setting watchdog counter rese...
`was_configured`?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -0,0 +1,102 @@ +#![no_std] +#![no_main] + +extern crate cortex_m; +extern crate cortex_m_rt as rt; +extern crate panic_semihosting; + +use aerugo::hal::peripherals::watchdog::{Watchdog, WatchdogConfig}; +use aerugo::{ + InitApi, MessageQueueHandle, MessageQueueStorage, TaskletConfig, TaskletStorage, AERUGO, +}; +...
Rewrite this example to use cyclic tasklet
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -56,10 +58,30 @@ impl Aerugo { /// # Safety /// This shouldn't be called in more that [one place](crate::aerugo::AERUGO). const fn new() -> Self { - let peripherals = Peripherals {}; - Aerugo { - hal: Hal::new(peripherals), + hal: InternalCell::new(None), + ...
Return `Result`
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -346,7 +368,15 @@ impl RuntimeApi for Aerugo { type Duration = crate::time::TimerDurationU64<1_000_000>; fn get_system_time(&'static self) -> Self::Instant { - self.hal.get_system_time() + // SAFETY: This is safe, because it's a single-core environment, + // and no other references t...
Double `as_ref`?
aerugo
github_2023
others
16
n7space
Glamhoth
@@ -28,6 +28,10 @@ pub enum RuntimeError { ExecutorTaskletQueueFull, /// Enqueued data to a full data queue. DataQueueFull, + /// Tried to perform an operation before system initialization. + SystemNotInitialized, + /// Tried to initialize system more than once + SystemReinitialized,
`SystemAlreadyInitialized` to be in line with `StorageAlreadyInitialized`?
aerugo
github_2023
others
17
n7space
SteelPh0enix
@@ -328,12 +334,62 @@ impl InitApi for Aerugo { todo!() } - fn subscribe_tasklet_to_cyclic<T, C>( + /// Subscribes tasklet to the cyclic execution. + /// + /// Tasklet subscribes for cyclic execution. Tasklet will be executed in specified period, + /// or will be always ready for executio...
safety comment?
aerugo
github_2023
others
17
n7space
SteelPh0enix
@@ -0,0 +1,68 @@ +//! System time manager. +//! +//! This module contains a system time manager. It's responsibility is to keep track of tasklets +//! and events that are based on time. + +mod cyclic_execution; + +use self::cyclic_execution::CyclicExecution; + +use heapless::Vec; + +use crate::aerugo::{Aerugo, InitErro...
```suggestion /// This shoudln't be called more than once. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -55,30 +77,157 @@ impl Aerugo { impl InitApi for Aerugo { type Duration = crate::time::MillisDurationU32; + /// Creates new tasklet in the system. + /// + /// Tasklet is created in the passed `storage` memory. Storage has to be static to keep the stored + /// tasklet for the whole duration of sys...
```suggestion /// tasklet for the whole duration of system's life. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -55,30 +77,157 @@ impl Aerugo { impl InitApi for Aerugo { type Duration = crate::time::MillisDurationU32; + /// Creates new tasklet in the system. + /// + /// Tasklet is created in the passed `storage` memory. Storage has to be static to keep the stored + /// tasklet for the whole duration of sys...
```suggestion /// `()` if successful, `InitError` otherwise. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -55,30 +77,157 @@ impl Aerugo { impl InitApi for Aerugo { type Duration = crate::time::MillisDurationU32; + /// Creates new tasklet in the system. + /// + /// Tasklet is created in the passed `storage` memory. Storage has to be static to keep the stored + /// tasklet for the whole duration of sys...
```suggestion // SAFETY: This is safe, as long as this function is called only during system initialization. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -55,30 +77,157 @@ impl Aerugo { impl InitApi for Aerugo { type Duration = crate::time::MillisDurationU32; + /// Creates new tasklet in the system. + /// + /// Tasklet is created in the passed `storage` memory. Storage has to be static to keep the stored + /// tasklet for the whole duration of sys...
```suggestion // SAFETY: This is safe as long as this function is called only during system initialization. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -55,30 +77,157 @@ impl Aerugo { impl InitApi for Aerugo { type Duration = crate::time::MillisDurationU32; + /// Creates new tasklet in the system. + /// + /// Tasklet is created in the passed `storage` memory. Storage has to be static to keep the stored + /// tasklet for the whole duration of sys...
```suggestion // SAFETY: This is safe as long as this function is called only during system initialization. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -100,8 +303,11 @@ impl InitApi for Aerugo { let tasklet = tasklet_handle.tasklet(); let queue = queue_handle.queue(); - tasklet.subscribe(queue)?; - queue.register_tasklet(tasklet.ptr())?; + // SAFETY: This is safe, because this function can be called only during system initi...
```suggestion // SAFETY: This is safe as long as this function is called only during system initialization. ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -1,19 +1,26 @@ //! Trait with data provider functionality. //! -//! Data provider is a structure that provided some kind of data to the -//! [data receiver](crate::data_receiver::DataReceiver). +//! This module contains a trait for a data provider. In the system data providers are structures +//! that stores data ...
```suggestion //! This module contains a trait for a data provider. In the system, data providers are structures //! that store the data that can be then passed to a data receiver (currently only ```
aerugo
github_2023
others
14
n7space
SteelPh0enix
@@ -6,22 +6,27 @@ use crate::tasklet::TaskletPtr; /// Trait for generic queue that stores data of type `T`. /// +/// # Generic Parameters /// * `T` - Type of the stored data. pub(crate) trait Queue<T>: DataProvider<T> { /// Registers task to this queue. /// + /// # Parameters /// * `task` - Task...
safety comment?
aerugo
github_2023
others
12
n7space
Glamhoth
@@ -0,0 +1,11 @@ +#!/bin/bash + +aerugo_x86() { + cargo clippy -p aerugo -F use-aerugo-x86 -- -D warnings
add `--tests` too maybe?
aerugo
github_2023
others
9
n7space
SteelPh0enix
@@ -1,29 +1,32 @@ #![no_std] #![no_main] -#![allow(non_upper_case_globals)] extern crate panic_semihosting; use cortex_m::peripheral::syst::SystClkSource; use cortex_m_rt::{entry, exception}; -use aerugo::{AERUGO, InitApi, MessageQueueStorage, TaskletConfig, TaskletStorage}; +use aerugo::{InitApi, MessageQue...
I don't like the fact that storage has exactly the same name as function - add `_STORAGE` suffix?
aerugo
github_2023
others
7
n7space
SteelPh0enix
@@ -1,2 +1,70 @@ # aerugo -Safety-critical applications oriented Real-Time Operating System written in Rust +Safety-critical applications oriented Real-Time Operating System written in Rust. + +This project is developed as part of the European Space Agency activity +[Evaluation of Rust Usage in Space Applications by D...
```suggestion Tests can also be run using `cargo test` with `--features` and `--target` flags. ```
aerugo
github_2023
others
6
n7space
SteelPh0enix
@@ -6,6 +6,8 @@ Cortex-M specific implementation for Aerugo. #![warn(clippy::missing_docs_in_private_items)] #![warn(rustdoc::missing_crate_level_docs)] -pub mod mutex; +mod logger; +mod mutex; +pub use self::logger::logln;
I don't like `logln` name, why not just `log`? Assumed behavior is usually that it adds a full entry (line of text in this case i guess?) to log, no need the "line" suffix there
aerugo
github_2023
others
6
n7space
SteelPh0enix
@@ -0,0 +1,109 @@ +//! System scheduler. + +use heapless::binary_heap::{BinaryHeap, Max}; + +use crate::aerugo::{error::RuntimeError, Aerugo}; +use crate::api::RuntimeApi; +use crate::arch::Mutex; +use crate::task::TaskStatus; +use crate::tasklet::TaskletPtr; + +/// Type for the tasklet execution queue +type TaskletQue...
That `8` should probably be tailorable somehow, somewhere from the user code/config...
aerugo
github_2023
others
6
n7space
SteelPh0enix
@@ -0,0 +1,109 @@ +//! System scheduler. + +use heapless::binary_heap::{BinaryHeap, Max}; + +use crate::aerugo::{error::RuntimeError, Aerugo}; +use crate::api::RuntimeApi; +use crate::arch::Mutex; +use crate::task::TaskStatus; +use crate::tasklet::TaskletPtr; + +/// Type for the tasklet execution queue +type TaskletQue...
maybe split that into execution start and finish time? Or can we measuring this time some other way?
aerugo
github_2023
others
6
n7space
SteelPh0enix
@@ -0,0 +1,68 @@ +//! Handle to a tasklet. +//! +//! Tasklet handle is available to the user of the system to reference and interact with the +//! tasklet via handle interface. All system API functions shall use handles when a reference to +//! tasklet is required, for example in subscribing tasklet to some data source...
replace double-cast with single cast
aerugo
github_2023
others
6
n7space
SteelPh0enix
@@ -0,0 +1,178 @@ +//! Raw tasklet pointer. +//! +//! To hide generic parameters of the `Tasklet` we use `Task` trait. It's necessary for in example +//! storing tasklets that are ready for execution. But then using trait objects creates a dynamic +//! dispatching, which is unwanted in the embedded environment especial...
fix double-cast
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,57 @@ +//! System HAL. + +mod config; + +pub use self::config::SystemHardwareConfig; + +use bare_metal::CriticalSection; +use core::ops::{Add, Sub}; + +/// System HAL trait. +pub trait SystemHal { + /// Type for an instant in time. + type Instant: Ord + + Copy + + Add<Self::Duration, Outp...
Why no `Add<Self::Instant, Output = Self::Duration>`? Is it automatically generated somehow?
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,57 @@ +//! System HAL. + +mod config; + +pub use self::config::SystemHardwareConfig; + +use bare_metal::CriticalSection; +use core::ops::{Add, Sub}; + +/// System HAL trait. +pub trait SystemHal { + /// Type for an instant in time. + type Instant: Ord + + Copy + + Add<Self::Duration, Outp...
kill if not needed
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,57 @@ +//! System HAL. + +mod config; + +pub use self::config::SystemHardwareConfig; + +use bare_metal::CriticalSection; +use core::ops::{Add, Sub}; + +/// System HAL trait. +pub trait SystemHal { + /// Type for an instant in time. + type Instant: Ord + + Copy + + Add<Self::Duration, Outp...
kill if not needed
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,57 @@ +//! System HAL. + +mod config; + +pub use self::config::SystemHardwareConfig; + +use bare_metal::CriticalSection; +use core::ops::{Add, Sub}; + +/// System HAL trait. +pub trait SystemHal { + /// Type for an instant in time. + type Instant: Ord + + Copy + + Add<Self::Duration, Outp...
kill if not needed
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,60 @@ +//! System HAL implementation for x86 target. + +use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; +use bare_metal::CriticalSection; + +use crate::peripherals::Peripherals; + +/// HAL implementation for x86. +pub struct Hal { + /// Hardware peripherals. + _peripherals: Peripherals, ...
move magic number to named constant (if it's related to system clock or configuration, it should later be made tailorable via config or something like that)
aerugo
github_2023
others
4
n7space
SteelPh0enix
@@ -0,0 +1,75 @@ +//! System HAL implementation for x86 target. + +use std::convert::TryInto; +use std::time::SystemTime; + +use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; +use bare_metal::CriticalSection; +use once_cell::sync::Lazy; + +use crate::peripherals::Peripherals; + +/// Time when system was st...
same as in V71 HAL
aerugo
github_2023
others
4
n7space
Lurkerpas
@@ -0,0 +1,56 @@ +//! System HAL implementation for x86 target. + +use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; +use bare_metal::CriticalSection; + +use crate::peripherals::Peripherals; + +/// HAL implementation for x86.
in samv71-hal?
aerugo
github_2023
others
4
n7space
Lurkerpas
@@ -0,0 +1,71 @@ +//! System HAL implementation for x86 target. + +use std::convert::TryInto; +use std::time::SystemTime; + +use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; +use bare_metal::CriticalSection; +use once_cell::sync::Lazy; + +use crate::peripherals::Peripherals; + +/// Time when system was st...
Are we planning to implement watchdog on x86? We don't have HW, but we COULD have SW watchtog in another thread....
aerugo
github_2023
others
4
n7space
Lurkerpas
@@ -0,0 +1,56 @@ +//! System HAL implementation for x86 target. + +use aerugo_hal::system_hal::{SystemHal, SystemHardwareConfig}; +use bare_metal::CriticalSection; + +use crate::peripherals::Peripherals; + +/// HAL implementation for x86. +pub struct Hal { + /// Hardware peripherals. + _peripherals: Peripherals, ...
I assume master clock is part of the platform-specific SystemHardwareConfig?
aerugo
github_2023
others
2
n7space
SteelPh0enix
@@ -0,0 +1,114 @@ +//! System control and interface for the user to interact with it. + +pub mod error; + +mod configuration; + +pub use self::configuration::TaskletConfiguration; + +use crate::api::{InitApi, RuntimeApi}; +use crate::boolean_condition::{BooleanConditionSet, BooleanConditionStorage}; +use crate::event::...
Are you sure that hardware init will be possible via immutable ref to peripherals? I'm aware of the issues with passing mutable arguments to functions via arguments like that, so it'd be good to know if that signature will allow init (or not) right now
aerugo
github_2023
others
2
n7space
SteelPh0enix
@@ -0,0 +1,37 @@ +/// System runtime API. +/// +/// This API can be used by the user in tasklet functions to interact with the system. +use crate::execution_monitoring::ExecutionStats; +use crate::task::TaskId; + +/// System runtime API. +pub trait RuntimeApi: ErrorType { + /// Gets current system time timestamp. + ...
maybe `set_system_time` too? to set absolute time value directly? it should be possible to do via offset, so why not give an option to do this directly?