yarf 0.1
Yet Another RepRap Firmware
src/hardware/endstops.h
Go to the documentation of this file.
00001 /*
00002  * endstops.h
00003  *
00004  * Copyright 2011 Pieter Agten
00005  *
00006  * This file is part of Yarf.
00007  *
00008  * Yarf is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * Yarf is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00029 #ifndef ENDSTOPS_H
00030 #define ENDSTOPS_H
00031 
00032 #include "yarf.h"
00033 #include "fastio.h"
00034 
00035 #include <stdbool.h>
00036 
00040 #define endstop_x_min() (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTED)
00041 
00044 #define endstop_y_min() (READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTED)
00045 
00048 #define endstop_z_min() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTED)
00049 
00054 #if (SOFTWARE_MAX_ENDSTOPS || X_MAX_PIN == -1)
00055 #define endstop_x_max() (false)
00056 #else
00057 #define endstop_x_max() (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTED)
00058 #endif
00059 
00064 #if (SOFTWARE_MAX_ENDSTOPS || Y_MAX_PIN == -1)
00065 #define endstop_y_max() (false)
00066 #else
00067 #define endstop_y_max() (READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTED)
00068 #endif
00069 
00070 
00075 #if (SOFTWARE_MAX_ENDSTOPS || Z_MAX_PIN == -1)
00076 #define endstop_z_max() (false)
00077 #else
00078 #define endstop_z_max() (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTED)
00079 #endif
00080 
00081 
00088 static inline bool
00089 endstop_min(unsigned char axis) {
00090   switch(axis) {
00091     case X_AXIS:
00092       return endstop_x_min();
00093     case Y_AXIS:
00094       return endstop_y_min();
00095     case Z_AXIS:
00096       return endstop_z_min();
00097     case E_AXIS:
00098       return false;
00099     default:
00100       return true;
00101   }
00102 }
00103 
00111 static inline bool
00112 endstop_max(unsigned char axis) {
00113   switch(axis) {
00114     case X_AXIS:
00115       return endstop_x_max();
00116     case Y_AXIS:
00117       return endstop_y_max();
00118     case Z_AXIS:
00119       return endstop_z_max();
00120     case E_AXIS:
00121       return false;
00122     default:
00123       return true;
00124   }
00125 }
00126 
00127 #endif //ENDSTOPS_H
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines