mmu2_power.cpp 843 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "mmu2_power.h"
  2. #include "Configuration_prusa.h"
  3. #include "pins.h"
  4. #include "fastio.h"
  5. #include <util/delay.h>
  6. #include "mmu2.h"
  7. #include "eeprom.h"
  8. namespace MMU2 {
  9. // sadly, on MK3 we cannot do actual power cycle on HW...
  10. // so we just block the MMU via EEPROM var instead.
  11. void power_on()
  12. {
  13. if (!eeprom_read_byte((uint8_t *)EEPROM_MMU_ENABLED))
  14. {
  15. eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, true);
  16. }
  17. }
  18. void power_off()
  19. {
  20. if (eeprom_read_byte((uint8_t *)EEPROM_MMU_ENABLED))
  21. {
  22. eeprom_update_byte((uint8_t *)EEPROM_MMU_ENABLED, false);
  23. }
  24. }
  25. void reset() {
  26. #ifdef MMU_HWRESET // HW - pulse reset pin
  27. WRITE(MMU_RST_PIN, 0);
  28. _delay_us(100);
  29. WRITE(MMU_RST_PIN, 1);
  30. #else
  31. MMU2::Reset(MMU2::Software);
  32. #endif
  33. // otherwise HW reset is not available
  34. }
  35. } // namespace MMU2