Skip to content

verify lifetimes in generated PeripheralManager methods #78

Open

Description

@suaviloquence

Macros no_enable_periph_rst_fn and similar

macro_rules! no_enable_rst_periph_fn {
($fn_name:ident, $p_type:ty, $field_name:ident) => {
/// Gets the specified peripheral if not already taken elsewhere. Otherwise,
/// returns [`BorrowMutError`].
pub fn $fn_name(&'a self) -> Result<PeripheralHandle<$p_type>, BorrowMutError> {
PeripheralHandle::new(&self.$field_name)
}
};
}

no_enable_rst_periph_fn!(timer_0, Clock<TMR>, timer_0);
no_enable_rst_periph_fn!(timer_1, Clock<TMR1>, timer_1);
no_enable_rst_periph_fn!(timer_2, Clock<TMR2>, timer_2);
no_enable_rst_periph_fn!(timer_3, Clock<TMR3>, timer_3);
no_enable_rst_periph_fn_no_handle!(gpio0, Gpio0, gpio0);
no_enable_rst_periph_fn_no_handle!(gpio1, Gpio1, gpio1);
no_enable_rst_periph_fn_no_handle!(gpio2, Gpio2, gpio2);

currently generate methods of the type &'a self -> &Periph<'a, 'a, ...>, where PeripheralManager stores all registers with the same lifetime 'a

pub struct PeripheralManager<'a> {

We need to verify that this is the correct behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions