PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/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
18#ifndef BOARDS_RRMBV12_MOTHERBOARD_HH_
19#define BOARDS_RRMBV12_MOTHERBOARD_HH_
20
21
22#include "UART.hh"
23#include "StepperInterface.hh"
24#include "Types.hh"
25#include "PSU.hh"
26#include "Configuration.hh"
27
28/// Main class for Motherboard version 1.2 (Gen3 electronics)
29/// \ingroup HardwareLibraries
30/// \ingroup MBv12
31class Motherboard {
32private:
33	const static int STEPPERS = STEPPER_COUNT;
34
35	StepperInterface stepper[STEPPERS];
36
37	PSU psu;
38
39	/// Microseconds since board initialization
40	volatile micros_t micros;
41
42        /// Private constructor; use the singleton
43        Motherboard(const Pin& psu_pin);
44
45	static Motherboard motherboard;
46public:
47	/// Reset the motherboard to its initial state.
48	/// This only resets the board, and does not send a reset
49	/// to any attached toolheads.
50	void reset();
51
52	void runMotherboardSlice();
53
54	/// Count the number of steppers available on this board.
55	const int getStepperCount() const { return STEPPERS; }
56
57        /// Get the stepper interface for the nth stepper.
58	StepperInterface& getStepperInterface(int n)
59	{
60		return stepper[n];
61	}
62
63	/// Get the number of microseconds that have passed since
64	/// the board was initialized.  This value will wrap after
65	/// 2**16 microseconds; callers should compensate for this.
66	micros_t getCurrentMicros();
67
68	/// Write an error code to the debug pin.
69	void indicateError(int errorCode);
70
71        /// Get the current error being displayed.
72	uint8_t getCurrentError();
73
74	/// Get the motherboard instance.
75	static Motherboard& getBoard() { return motherboard; }
76
77	/// Perform the timer interrupt routine.
78	void doInterrupt();
79};
80
81#endif // BOARDS_RRMBV12_MOTHERBOARD_HH_