Skip to content

Sync with latest cortex-m version #27

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

Closed
sbechet opened this issue Feb 19, 2020 · 0 comments
Closed

Sync with latest cortex-m version #27

sbechet opened this issue Feb 19, 2020 · 0 comments

Comments

@sbechet
Copy link
Contributor

sbechet commented Feb 19, 2020

It's not really a bug, but I can't do this synchronization. There is currently something that I did not understand in the functioning of rust

I tried to replace init() with:

use core::borrow::BorrowMut;
use core::ops::DerefMut;
use cortex_m::interrupt::Mutex;
use linked_list_allocator::Heap;
// ...
pub struct CortexMHeap {
    heap: Mutex<Heap>,
}
// ...

    pub unsafe fn init(&self, start_addr: usize, size: usize) {
        cortex_m::interrupt::free(|cs| {
               self.heap
                    .borrow(cs)
                    .borrow_mut()
                    .deref_mut()
                    .init(start_addr, size);
            });
    }
}

but answer is:

error[E0596]: cannot borrow data in a `&` reference as mutable
   --> src/lib.rs:103:17
    |
103 | /                 self.heap
104 | |                     .borrow(cs)
105 | |                     .borrow_mut()
106 | |                     .deref_mut()
    | |________________________________^ cannot borrow as mutable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant