/firmware/src/Motherboard/boards/rrmbv12/Motherboard.hh

http://github.com/makerbot/G3Firmware · C++ Header · 81 lines · 30 code · 18 blank · 33 comment · 0 complexity · 78de65cde7edd3b5549ce527ceb110ef MD5 · raw file

  1. /*
  2. * Copyright 2010 by Adam Mayer <adam@makerbot.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>
  16. */
  17. #ifndef BOARDS_RRMBV12_MOTHERBOARD_HH_
  18. #define BOARDS_RRMBV12_MOTHERBOARD_HH_
  19. #include "UART.hh"
  20. #include "StepperInterface.hh"
  21. #include "Types.hh"
  22. #include "PSU.hh"
  23. #include "Configuration.hh"
  24. /// Main class for Motherboard version 1.2 (Gen3 electronics)
  25. /// \ingroup HardwareLibraries
  26. /// \ingroup MBv12
  27. class Motherboard {
  28. private:
  29. const static int STEPPERS = STEPPER_COUNT;
  30. StepperInterface stepper[STEPPERS];
  31. PSU psu;
  32. /// Microseconds since board initialization
  33. volatile micros_t micros;
  34. /// Private constructor; use the singleton
  35. Motherboard(const Pin& psu_pin);
  36. static Motherboard motherboard;
  37. public:
  38. /// Reset the motherboard to its initial state.
  39. /// This only resets the board, and does not send a reset
  40. /// to any attached toolheads.
  41. void reset();
  42. void runMotherboardSlice();
  43. /// Count the number of steppers available on this board.
  44. const int getStepperCount() const { return STEPPERS; }
  45. /// Get the stepper interface for the nth stepper.
  46. StepperInterface& getStepperInterface(int n)
  47. {
  48. return stepper[n];
  49. }
  50. /// Get the number of microseconds that have passed since
  51. /// the board was initialized. This value will wrap after
  52. /// 2**16 microseconds; callers should compensate for this.
  53. micros_t getCurrentMicros();
  54. /// Write an error code to the debug pin.
  55. void indicateError(int errorCode);
  56. /// Get the current error being displayed.
  57. uint8_t getCurrentError();
  58. /// Get the motherboard instance.
  59. static Motherboard& getBoard() { return motherboard; }
  60. /// Perform the timer interrupt routine.
  61. void doInterrupt();
  62. };
  63. #endif // BOARDS_RRMBV12_MOTHERBOARD_HH_