Skip to content

Commit

Permalink
Move pin into it's own file. vtable errors for mb24.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Mets committed Aug 20, 2011
1 parent 9ec3432 commit 3b92091
Show file tree
Hide file tree
Showing 35 changed files with 297 additions and 226 deletions.
2 changes: 0 additions & 2 deletions v2/src/Extruder/boards/ecv22/Configuration.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
// for different motherboards, as well as available // for different motherboards, as well as available
// features. // features.


#include "AvrPort.hh"

// TODO: Ditch this in favor of a unified board.hh, or something. // TODO: Ditch this in favor of a unified board.hh, or something.
#define IS_EXTRUDER_BOARD #define IS_EXTRUDER_BOARD


Expand Down
1 change: 1 addition & 0 deletions v2/src/Extruder/boards/ecv22/ExtruderMotor.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "ExtruderMotor.hh" #include "ExtruderMotor.hh"
#include "Eeprom.hh" #include "Eeprom.hh"
#include "EepromMap.hh" #include "EepromMap.hh"
#include "Pin.hh"


using namespace eeprom; using namespace eeprom;


Expand Down
1 change: 0 additions & 1 deletion v2/src/Extruder/boards/ecv34/Configuration.cc
Original file line number Original file line Diff line number Diff line change
@@ -1,2 +1 @@
#include "Configuration.hh" #include "Configuration.hh"
#include "AvrPort.hh"
4 changes: 0 additions & 4 deletions v2/src/Extruder/boards/ecv34/Configuration.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// for different motherboards, as well as available // for different motherboards, as well as available
// features. // features.


#include "AvrPort.hh"


// TODO: Ditch this in favor of a unified board.hh, or something. // TODO: Ditch this in favor of a unified board.hh, or something.
#define IS_EXTRUDER_BOARD #define IS_EXTRUDER_BOARD
Expand All @@ -39,9 +38,6 @@
// Host RS485 UART configuration // Host RS485 UART configuration
#define HAS_SLAVE_UART 0 #define HAS_SLAVE_UART 0


extern Pin TX_ENABLE_PIN;
extern Pin RX_ENABLE_PIN;

// Extrusion head heater configuration // Extrusion head heater configuration
#define HAS_HEATER 1 #define HAS_HEATER 1


Expand Down
1 change: 1 addition & 0 deletions v2/src/Extruder/boards/ecv34/ExtruderMotor.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <util/atomic.h> #include <util/atomic.h>
#include "Configuration.hh" #include "Configuration.hh"
#include "Pin.hh"


// Enable pin D5 is also OC0B. // Enable pin D5 is also OC0B.


Expand Down
2 changes: 1 addition & 1 deletion v2/src/Extruder/boards/ecv34/SoftwareServo.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef SOFTWARE_SERVO_HH_ #ifndef SOFTWARE_SERVO_HH_
#define SOFTWARE_SERVO_HH_ #define SOFTWARE_SERVO_HH_


#include "AvrPort.hh" #include "Pin.hh"


/// Software implementation of a hobby servo driver. Though module is implemented /// Software implementation of a hobby servo driver. Though module is implemented
/// purely in software, it does require periodic servicing from a microsecond /// purely in software, it does require periodic servicing from a microsecond
Expand Down
2 changes: 2 additions & 0 deletions v2/src/Motherboard/Command.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


#include <stdint.h> #include <stdint.h>


/// The command namespace contains functions that handle the incoming command
/// queue, for both SD and serial jobs.
namespace command { namespace command {


/// Reset the entire command queue. Clears out any remaining queued /// Reset the entire command queue. Clears out any remaining queued
Expand Down
1 change: 1 addition & 0 deletions v2/src/Motherboard/EepromMap.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


namespace eeprom { namespace eeprom {


// TODO: Shouldn't this just reset everything to an uninitialized state?
void setDefaults() { void setDefaults() {
// Initialize eeprom map // Initialize eeprom map
// Default: enstops inverted, Y axis inverted // Default: enstops inverted, Y axis inverted
Expand Down
22 changes: 12 additions & 10 deletions v2/src/Motherboard/EepromMap.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,24 +30,26 @@ const static uint16_t VERSION_LOW = 0x0000;
/// Version, high byte: 1 byte /// Version, high byte: 1 byte
const static uint16_t VERSION_HIGH = 0x0001; const static uint16_t VERSION_HIGH = 0x0001;


// Axis inversion flags: 1 byte. /// Axis inversion flags: 1 byte.
// Axis N (where X=0, Y=1, etc.) is inverted if the Nth bit is set. /// Axis N (where X=0, Y=1, etc.) is inverted if the Nth bit is set.
const static uint16_t AXIS_INVERSION = 0x0002; const static uint16_t AXIS_INVERSION = 0x0002;


// Endstop inversion flags: 1 byte. /// Endstop inversion flags: 1 byte.
// The endstops for axis N (where X=0, Y=1, etc.) are considered /// The endstops for axis N (where X=0, Y=1, etc.) are considered
// to be logically inverted if the Nth bit is set. /// to be logically inverted if the Nth bit is set.
// Bit 7 is set to indicate endstops are present; it is zero to indicate /// Bit 7 is set to indicate endstops are present; it is zero to indicate
// that endstops are not present. /// that endstops are not present.
// Ordinary endstops (H21LOB et. al.) are inverted. /// Ordinary endstops (H21LOB et. al.) are inverted.
const static uint16_t ENDSTOP_INVERSION = 0x0003; 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; 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; const static uint16_t AXIS_HOME_POSITIONS = 0x0060;



/// Reset all data in the EEPROM to a default.
void setDefaults(); void setDefaults();


} // namespace eeprom } // namespace eeprom
Expand Down
24 changes: 11 additions & 13 deletions v2/src/Motherboard/Errors.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@
#ifndef ERRORS_HH_ #ifndef ERRORS_HH_
#define ERRORS_HH_ #define ERRORS_HH_


/// /// Definition of blink codes for error conditions.
/// 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.


#define NO_ERROR 0 // TODO: Add these to the main documentation page.
#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 #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_ */ #endif /* ERRORS_HH_ */
1 change: 0 additions & 1 deletion v2/src/Motherboard/Host.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ HostState getHostState() {
return currentState; return currentState;
} }


// Start a build from SD, if possible.
sdcard::SdErrorCode startBuildFromSD() { sdcard::SdErrorCode startBuildFromSD() {
sdcard::SdErrorCode e; sdcard::SdErrorCode e;


Expand Down
34 changes: 23 additions & 11 deletions v2/src/Motherboard/Host.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,34 +21,46 @@
#include "Packet.hh" #include "Packet.hh"
#include "SDCard.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 { namespace host {


const int MAX_MACHINE_NAME_LEN = 32; const int MAX_MACHINE_NAME_LEN = 32;
const int MAX_FILE_LEN = MAX_PACKET_PAYLOAD-1; const int MAX_FILE_LEN = MAX_PACKET_PAYLOAD-1;


void runHostSlice(); /// The host can be in any of these four states.

enum HostState { enum HostState {
HOST_STATE_READY = 0, HOST_STATE_READY = 0,
HOST_STATE_BUILDING = 1, HOST_STATE_BUILDING = 1,
HOST_STATE_BUILDING_FROM_SD = 2, 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(); 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(); 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(); HostState getHostState();


// Start a build from SD, if possible. /// Start a build from SD card. The build name should be set by overwriting
// Returns true if build started successfully, false otherwise /// the value of buildName, provided by #getBuildName().
/// \return True if build started successfully.
sdcard::SdErrorCode startBuildFromSD(); sdcard::SdErrorCode startBuildFromSD();


// Stop the current build, if any /// Stop the current build
void stopBuild(); void stopBuild();


} }
Expand Down
2 changes: 1 addition & 1 deletion v2/src/Motherboard/Main.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void reset(bool hard_reset) {
ATOMIC_BLOCK(ATOMIC_FORCEON) { ATOMIC_BLOCK(ATOMIC_FORCEON) {
Motherboard& board = Motherboard::getBoard(); Motherboard& board = Motherboard::getBoard();
sdcard::reset(); sdcard::reset();
steppers::abort(); steppers::abort();
command::reset(); command::reset();
eeprom::init(); eeprom::init();
board.reset(); board.reset();
Expand Down
4 changes: 2 additions & 2 deletions v2/src/Motherboard/Main.hh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#ifndef MAIN_HH_ #ifndef MAIN_HH_
#define MAIN_HH_ #define MAIN_HH_


/// Reset the machine. Pass in true if this is a power-up reset; false /// Reset the machine.
/// otherwise. /// \param[in] hard_reset Pass in true if this is a power-up reset
void reset(bool hard_reset); void reset(bool hard_reset);


#endif // MAIN_HH_ #endif // MAIN_HH_
33 changes: 33 additions & 0 deletions v2/src/Motherboard/Point.cc
Original file line number Original file line Diff line number Diff line change
@@ -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];
}
58 changes: 12 additions & 46 deletions v2/src/Motherboard/Types.hh → v2/src/Motherboard/Point.hh
Original file line number Original file line Diff line number Diff line change
@@ -1,26 +1,9 @@
/* #ifndef POINT_HH
* Copyright 2010 by Adam Mayer <adam@makerbot.com> #define POINT_HH
*
* 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_


#include "Configuration.hh" #include "Configuration.hh"
#include <stdint.h>


typedef uint32_t micros_t;


#define AXIS_COUNT STEPPER_COUNT #define AXIS_COUNT STEPPER_COUNT


Expand All @@ -31,7 +14,7 @@ private:
int32_t coordinates[AXIS_COUNT]; ///< n-dimensional coordinate int32_t coordinates[AXIS_COUNT]; ///< n-dimensional coordinate
public: public:
/// Default point constructor /// Default point constructor
Point() {} Point();


/// Construct a point with the given cooridnates. Coordinates are in /// Construct a point with the given cooridnates. Coordinates are in
/// stepper steps. /// stepper steps.
Expand All @@ -40,15 +23,8 @@ public:
/// \param[in] z Z axis position /// \param[in] z Z axis position
/// \param[in] a (if supported) A axis position /// \param[in] a (if supported) A axis position
/// \param[in] b (if supported) B 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) { 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
}


// TODO: Can this be removed by giving the 5-dimensional function // TODO: Can this be removed by giving the 5-dimensional function
// some initial values? // some initial values?
Expand All @@ -58,31 +34,21 @@ public:
/// \param[in] x X axis position /// \param[in] x X axis position
/// \param[in] y Y axis position /// \param[in] y Y axis position
/// \param[in] z Z axis position /// \param[in] z Z axis position
Point(int32_t x, int32_t y, int32_t z) { 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
}


/// Constant array accessor. /// Constant array accessor.
/// \param[in] index Axis to look up /// \param[in] index Axis to look up
/// \return Axis position, in steps /// \return Axis position, in steps
const int32_t& operator[](unsigned int index) const { const int32_t& operator[](unsigned int index) const;
return coordinates[index];
}


/// Array accessor. /// Array accessor.
/// \param[in] index Axis to look up /// \param[in] index Axis to look up
/// \return Reference to the variable containing the axis' position. /// \return Reference to the variable containing the axis' position.
int32_t& operator[](unsigned int index) { int32_t& operator[](unsigned int index);
return coordinates[index];
}


} __attribute__ ((__packed__)); } __attribute__ ((__packed__));




#endif // TYPES_HH_ #endif // POINT_HH
Loading

0 comments on commit 3b92091

Please sign in to comment.