Advertisement
Guest User

Untitled

a guest
Jan 26th, 2022
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #[macro_use(singleton)]
  2. use core::cell::{Cell, RefCell};
  3. use cortex_m::singleton;
  4. use cortex_m::interrupt::free;
  5. use cortex_m::interrupt::Mutex;
  6. use cortex_m::peripheral::NVIC;
  7. use stm32_hal2::
  8. {
  9. low_power,
  10. clocks::Clocks,
  11. pac::{self, interrupt},
  12. gpio::{Pin, PinMode, Port},
  13. usart::{Usart, UsartConfig, UsartInterrupt},
  14. };
  15.  
  16. pub struct Board_debug
  17. {
  18. // LEDs
  19. red_led: Pin,
  20. green_led: Pin,
  21. orange_led: Pin,
  22. }
  23.  
  24. impl Board_debug
  25. {
  26. // public constructor method
  27. pub fn new() -> Self
  28. {
  29. let x: &'static mut bool = singleton!(: bool = false).unwrap();
  30. Self
  31. {
  32. red_led: Pin::new(Port::B, 14, PinMode::Output),
  33. green_led: Pin::new(Port::B, 0, PinMode::Output),
  34. orange_led: Pin::new(Port::B, 7, PinMode::Output),
  35. }
  36. }
  37.  
  38. // change green led state
  39. pub fn green_led_change(&mut self, level: bool)
  40. {
  41. if(level)
  42. {
  43. self.green_led.set_high();
  44. }
  45. else
  46. {
  47. self.green_led.set_low();
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement