Permalink
Browse files

Move pin into it's own file. vtable errors for mb24.

  • Loading branch information...
1 parent 9ec3432 commit 3b920919d0ed4e0f966e29fb39caf515188d8050 Matt Mets committed Aug 20, 2011
Showing with 297 additions and 226 deletions.
  1. +0 −2 v2/src/Extruder/boards/ecv22/Configuration.hh
  2. +1 −0 v2/src/Extruder/boards/ecv22/ExtruderMotor.cc
  3. +0 −1 v2/src/Extruder/boards/ecv34/Configuration.cc
  4. +0 −4 v2/src/Extruder/boards/ecv34/Configuration.hh
  5. +1 −0 v2/src/Extruder/boards/ecv34/ExtruderMotor.cc
  6. +1 −1 v2/src/Extruder/boards/ecv34/SoftwareServo.hh
  7. +2 −0 v2/src/Motherboard/Command.hh
  8. +1 −0 v2/src/Motherboard/EepromMap.cc
  9. +12 −10 v2/src/Motherboard/EepromMap.hh
  10. +11 −13 v2/src/Motherboard/Errors.hh
  11. +0 −1 v2/src/Motherboard/Host.cc
  12. +23 −11 v2/src/Motherboard/Host.hh
  13. +1 −1 v2/src/Motherboard/Main.cc
  14. +2 −2 v2/src/Motherboard/Main.hh
  15. +33 −0 v2/src/Motherboard/Point.cc
  16. +12 −46 v2/src/Motherboard/{Types.hh → Point.hh}
  17. +65 −64 v2/src/Motherboard/Steppers.hh
  18. +0 −1 v2/src/Motherboard/boards/mb24/Configuration.hh
  19. +0 −1 v2/src/Motherboard/boards/rrmbv12/Configuration.hh
  20. +1 −0 v2/src/Motherboard/lib_sd/sd_raw_config.h
  21. +67 −11 v2/src/shared/AvrPort.cc
  22. +31 −47 v2/src/shared/AvrPort.hh
  23. +1 −1 v2/src/shared/Heater.hh
  24. +0 −1 v2/src/shared/InterfaceBoard.cc
  25. +1 −1 v2/src/shared/InterfaceBoard.hh
  26. +1 −1 v2/src/shared/LiquidCrystal.hh
  27. +1 −1 v2/src/shared/PSU.hh
  28. +2 −0 v2/src/shared/Pin.cc
  29. +22 −0 v2/src/shared/Pin.hh
  30. +1 −2 v2/src/shared/ProtocolDocumentation.hh
  31. +1 −1 v2/src/shared/StepperInterface.hh
  32. +0 −1 v2/src/shared/Thermistor.hh
  33. +1 −1 v2/src/shared/Thermocouple.hh
  34. 0 v2/src/{Extruder → shared}/Types.hh
  35. +2 −0 v2/src/shared/UART.cc
@@ -22,8 +22,6 @@
// for different motherboards, as well as available
// features.
-#include "AvrPort.hh"
-
// TODO: Ditch this in favor of a unified board.hh, or something.
#define IS_EXTRUDER_BOARD
@@ -22,6 +22,7 @@
#include "ExtruderMotor.hh"
#include "Eeprom.hh"
#include "EepromMap.hh"
+#include "Pin.hh"
using namespace eeprom;
@@ -1,2 +1 @@
#include "Configuration.hh"
-#include "AvrPort.hh"
@@ -22,7 +22,6 @@
// for different motherboards, as well as available
// features.
-#include "AvrPort.hh"
// TODO: Ditch this in favor of a unified board.hh, or something.
#define IS_EXTRUDER_BOARD
@@ -39,9 +38,6 @@
// Host RS485 UART configuration
#define HAS_SLAVE_UART 0
-extern Pin TX_ENABLE_PIN;
-extern Pin RX_ENABLE_PIN;
-
// Extrusion head heater configuration
#define HAS_HEATER 1
@@ -18,6 +18,7 @@
#include <avr/io.h>
#include <util/atomic.h>
#include "Configuration.hh"
+#include "Pin.hh"
// Enable pin D5 is also OC0B.
@@ -18,7 +18,7 @@
#ifndef SOFTWARE_SERVO_HH_
#define SOFTWARE_SERVO_HH_
-#include "AvrPort.hh"
+#include "Pin.hh"
/// Software implementation of a hobby servo driver. Though module is implemented
/// purely in software, it does require periodic servicing from a microsecond
@@ -20,6 +20,8 @@
#include <stdint.h>
+/// The command namespace contains functions that handle the incoming command
+/// queue, for both SD and serial jobs.
namespace command {
/// Reset the entire command queue. Clears out any remaining queued
@@ -21,6 +21,7 @@
namespace eeprom {
+// TODO: Shouldn't this just reset everything to an uninitialized state?
void setDefaults() {
// Initialize eeprom map
// Default: enstops inverted, Y axis inverted
@@ -30,24 +30,26 @@ const static uint16_t VERSION_LOW = 0x0000;
/// Version, high byte: 1 byte
const static uint16_t VERSION_HIGH = 0x0001;
-// Axis inversion flags: 1 byte.
-// Axis N (where X=0, Y=1, etc.) is inverted if the Nth bit is set.
+/// Axis inversion flags: 1 byte.
+/// Axis N (where X=0, Y=1, etc.) is inverted if the Nth bit is set.
const static uint16_t AXIS_INVERSION = 0x0002;
-// Endstop inversion flags: 1 byte.
-// The endstops for axis N (where X=0, Y=1, etc.) are considered
-// to be logically inverted if the Nth bit is set.
-// Bit 7 is set to indicate endstops are present; it is zero to indicate
-// that endstops are not present.
-// Ordinary endstops (H21LOB et. al.) are inverted.
+/// Endstop inversion flags: 1 byte.
+/// The endstops for axis N (where X=0, Y=1, etc.) are considered
+/// to be logically inverted if the Nth bit is set.
+/// Bit 7 is set to indicate endstops are present; it is zero to indicate
+/// that endstops are not present.
+/// Ordinary endstops (H21LOB et. al.) are inverted.
const static uint16_t ENDSTOP_INVERSION = 0x0003;
-// Name of this machine: 32 bytes.
+/// Name of this machine: 32 bytes.
const static uint16_t MACHINE_NAME = 0x0020;
-// Default locations for the axis: 5 x 32 bit = 20 bytes
+/// Default locations for the axis: 5 x 32 bit = 20 bytes
const static uint16_t AXIS_HOME_POSITIONS = 0x0060;
+
+/// Reset all data in the EEPROM to a default.
void setDefaults();
} // namespace eeprom
@@ -18,20 +18,18 @@
#ifndef ERRORS_HH_
#define ERRORS_HH_
-///
-/// Canonical definition of blink codes for error conditions.
-///
-/// Explicit definitions instead of an enum to make it easy
-/// to lookup blink codes until we write the doc.
+/// Definition of blink codes for error conditions.
-#define NO_ERROR 0
-#define ERR_SLAVE_PACKET_TIMEOUT 1
-#define ERR_SLAVE_LOCK_TIMEOUT 2
-#define ERR_SLAVE_PACKET_MISC 3
-#define ERR_HOST_PACKET_TIMEOUT 4
-#define ERR_HOST_PACKET_MISC 5
-#define ERR_WDT_TIMEOUT 6
+// TODO: Add these to the main documentation page.
-#define ERR_HOST_TRUNCATED_CMD 8
+#define NO_ERROR 0
+#define ERR_SLAVE_PACKET_TIMEOUT 1
+#define ERR_SLAVE_LOCK_TIMEOUT 2
+#define ERR_SLAVE_PACKET_MISC 3
+#define ERR_HOST_PACKET_TIMEOUT 4
+#define ERR_HOST_PACKET_MISC 5
+#define ERR_WDT_TIMEOUT 6
+
+#define ERR_HOST_TRUNCATED_CMD 8
#endif /* ERRORS_HH_ */
@@ -535,7 +535,6 @@ HostState getHostState() {
return currentState;
}
-// Start a build from SD, if possible.
sdcard::SdErrorCode startBuildFromSD() {
sdcard::SdErrorCode e;
View
@@ -21,34 +21,46 @@
#include "Packet.hh"
#include "SDCard.hh"
+// TODO: Make this a class.
+/// Functions in the host namespace deal with communications to the host
+/// computer. The host also implents a simple state machine, because it is
+/// also responsable for handling prints from SD card.
namespace host {
const int MAX_MACHINE_NAME_LEN = 32;
const int MAX_FILE_LEN = MAX_PACKET_PAYLOAD-1;
-void runHostSlice();
-
+/// The host can be in any of these four states.
enum HostState {
- HOST_STATE_READY = 0,
- HOST_STATE_BUILDING = 1,
+ HOST_STATE_READY = 0,
+ HOST_STATE_BUILDING = 1,
HOST_STATE_BUILDING_FROM_SD = 2,
- HOST_STATE_ERROR = 3,
+ HOST_STATE_ERROR = 3
};
-// Returns the name of the current machine
+/// Run the host slice. This function handles incoming packets and host resets.
+void runHostSlice();
+
+/// Returns the name of the current machine
+/// \return Pointer to a character string containing the machine name.
char* getMachineName();
-//Returns the name of the current build, if any.
+/// Returns the name of the current build, if any.
+/// \return Pointer to a character string containing the build name.
char* getBuildName();
-// Returns the current host state
+/// Returns the current host state. The host implements a very simple
+/// state machine, which is used to determine what information should be
+/// displayed on the interface board.
+/// \return Current host state.
HostState getHostState();
-// Start a build from SD, if possible.
-// Returns true if build started successfully, false otherwise
+/// Start a build from SD card. The build name should be set by overwriting
+/// the value of buildName, provided by #getBuildName().
+/// \return True if build started successfully.
sdcard::SdErrorCode startBuildFromSD();
-// Stop the current build, if any
+/// Stop the current build
void stopBuild();
}
@@ -33,7 +33,7 @@ void reset(bool hard_reset) {
ATOMIC_BLOCK(ATOMIC_FORCEON) {
Motherboard& board = Motherboard::getBoard();
sdcard::reset();
- steppers::abort();
+ steppers::abort();
command::reset();
eeprom::init();
board.reset();
@@ -18,8 +18,8 @@
#ifndef MAIN_HH_
#define MAIN_HH_
-/// Reset the machine. Pass in true if this is a power-up reset; false
-/// otherwise.
+/// Reset the machine.
+/// \param[in] hard_reset Pass in true if this is a power-up reset
void reset(bool hard_reset);
#endif // MAIN_HH_
@@ -0,0 +1,33 @@
+#include "Point.hh"
+
+Point::Point()
+{
+}
+
+Point::Point(int32_t x, int32_t y, int32_t z, int32_t a, int32_t b) {
+ coordinates[0] = x;
+ coordinates[1] = y;
+ coordinates[2] = z;
+#if AXIS_COUNT > 3
+ coordinates[3] = a;
+ coordinates[4] = b;
+#endif
+}
+
+Point::Point(int32_t x, int32_t y, int32_t z) {
+ coordinates[0] = x;
+ coordinates[1] = y;
+ coordinates[2] = z;
+#if AXIS_COUNT > 3
+ coordinates[3] = 0;
+ coordinates[4] = 0;
+#endif
+}
+
+const int32_t& Point::operator[](unsigned int index) const {
+ return coordinates[index];
+}
+
+int32_t& Point::operator[](unsigned int index) {
+ return coordinates[index];
+}
@@ -1,26 +1,9 @@
-/*
- * Copyright 2010 by Adam Mayer <adam@makerbot.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- */
-
-#ifndef TYPES_HH_
-#define TYPES_HH_
+#ifndef POINT_HH
+#define POINT_HH
#include "Configuration.hh"
+#include <stdint.h>
-typedef uint32_t micros_t;
#define AXIS_COUNT STEPPER_COUNT
@@ -31,7 +14,7 @@ private:
int32_t coordinates[AXIS_COUNT]; ///< n-dimensional coordinate
public:
/// Default point constructor
- Point() {}
+ Point();
/// Construct a point with the given cooridnates. Coordinates are in
/// stepper steps.
@@ -40,15 +23,8 @@ public:
/// \param[in] z Z axis position
/// \param[in] a (if supported) A axis position
/// \param[in] b (if supported) B axis position
- Point(int32_t x, int32_t y, int32_t z, int32_t a, int32_t b) {
- coordinates[0] = x;
- coordinates[1] = y;
- coordinates[2] = z;
-#if AXIS_COUNT > 3
- coordinates[3] = a;
- coordinates[4] = b;
-#endif
- }
+ Point(int32_t x, int32_t y, int32_t z, int32_t a, int32_t b);
+
// TODO: Can this be removed by giving the 5-dimensional function
// some initial values?
@@ -58,31 +34,21 @@ public:
/// \param[in] x X axis position
/// \param[in] y Y axis position
/// \param[in] z Z axis position
- Point(int32_t x, int32_t y, int32_t z) {
- coordinates[0] = x;
- coordinates[1] = y;
- coordinates[2] = z;
-#if AXIS_COUNT > 3
- coordinates[3] = 0;
- coordinates[4] = 0;
-#endif
- }
+ Point(int32_t x, int32_t y, int32_t z);
+
/// Constant array accessor.
/// \param[in] index Axis to look up
/// \return Axis position, in steps
- const int32_t& operator[](unsigned int index) const {
- return coordinates[index];
- }
+ const int32_t& operator[](unsigned int index) const;
+
/// Array accessor.
/// \param[in] index Axis to look up
/// \return Reference to the variable containing the axis' position.
- int32_t& operator[](unsigned int index) {
- return coordinates[index];
- }
+ int32_t& operator[](unsigned int index);
} __attribute__ ((__packed__));
-#endif // TYPES_HH_
+#endif // POINT_HH
Oops, something went wrong.

0 comments on commit 3b92091

Please sign in to comment.