-
Notifications
You must be signed in to change notification settings - Fork 152
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
Need some help with interrupts #154
Comments
Hi @josephpenafiel
This feature is going to be enabled by default some time in the future: see #153 . As for the embedded-rust book, the appropriate update is on review at the moment: see PR#196. Regards, |
thank you that worked, but now I have a new problem. I want to do something simple. Toggle a led everytime a timer interrupt occurs. The compiler tells me this: what's the correct way of doing what I want? |
I would suggest to try the following approach: make both TIM2 and GPIO (or LED pin) global shared resources. Then use them in TIM2 handler under interrupt::free mutex. |
when i do that I get a similar error |
Here is an example for BluePill that converts both TIM2 and PC13 into shared resources and uses them in a safe way: safe LED blink from TIM2 irq. Regards, |
not helpful |
Hello everyone,
I'm trying to test some interrupts in a stm32f302 nucleo board, but I'm having some trouble with the Mutex. When I define one, I get this error:
"calls in statics are limited to constant functions, tuple structs and tuple variants rustc (E0015)"
here's the code I'm trying to test:
`
#![no_main]
#![no_std]
#[allow(unused_extern_crates)]
extern crate panic_halt;
extern crate stm32f30x;
use core::cell::RefCell;
use cortex_m_rt::entry;
// use cortex_m::interrupt::{Mutex, self};
use stm32f30x::{interrupt,Interrupt};
#[entry]
fn main() -> ! {
let p = cortex_m::Peripherals::take().unwrap();
let cp = stm32f30x::Peripherals::take().unwrap();
let rcc = &cp.RCC;
let gpiob = &cp.GPIOB;
let tim2 = &cp.TIM2;
}
#[interrupt]
fn TIM2() {
cortex_m::interrupt::free(|cs| {
let tim2 = MY_TIM2.borrow(cs).borrow();
if tim2.as_ref().unwrap().sr.read().uif().bit_is_set() {
unsafe { TOOGLE = !TOOGLE };
tim2.as_ref().unwrap().sr.write(|w| w.uif().clear_bit());
}
});
}
`
I followed the example from the Rust embedded book in the concurrency section.
thanks in advance
The text was updated successfully, but these errors were encountered: