chiark / gitweb /
force inline
authorBernhard <bkubicek@x201.(none)>
Sun, 27 Nov 2011 15:04:58 +0000 (16:04 +0100)
committerBernhard <bkubicek@x201.(none)>
Sun, 27 Nov 2011 15:04:58 +0000 (16:04 +0100)
Marlin/EEPROMwrite.h
Marlin/Marlin.h
Marlin/cardreader.h
Marlin/planner.cpp
Marlin/planner.h
Marlin/temperature.h
Marlin/ultralcd.h
Marlin/watchdog.h

index 3d559c0269846847a0c5b0564f7ab43feb427ce8..08b344af6307ac50e61943802b32b0ed461c392d 100644 (file)
@@ -38,7 +38,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
 #define EEPROM_VERSION "V04"  
 
-inline void StoreSettings() 
+FORCE_INLINE void StoreSettings() 
 {
 #ifdef EEPROM_SETTINGS
   char ver[4]= "000";
@@ -71,7 +71,7 @@ inline void StoreSettings()
 #endif //EEPROM_SETTINGS
 }
 
-inline void RetrieveSettings(bool def=false)
+FORCE_INLINE void RetrieveSettings(bool def=false)
 {  // if def=true, the default values will be used
   #ifdef EEPROM_SETTINGS
     int i=EEPROM_OFFSET;
index acfc3c2fa6ef16ecc90a1aeb4eb51c5208946ac5..20032a685c27ca0997ff03b3938ede599676b2f2 100644 (file)
@@ -8,6 +8,8 @@
 #include <avr/pgmspace.h>
 #include "Configuration.h"
 
+
+#define  FORCE_INLINE __attribute__((always_inline)) inline
 //#define SERIAL_ECHO(x) Serial << "echo: " << x;
 //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
 //#define SERIAL_ERROR(x) Serial << "Error: " << x;
@@ -41,7 +43,7 @@ const char echomagic[] PROGMEM ="echo:";
 
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
 #define SerialprintPGM(x) serialprintPGM(PSTR(x))
-inline void serialprintPGM(const char *str)
+FORCE_INLINE void serialprintPGM(const char *str)
 {
   char ch=pgm_read_byte(str);
   while(ch)
index 4530e4e206b73204acb3fb41f32f9a388f13e7ac..c8ef9dbb434991858c33696f6ca44ed1eee0d046 100644 (file)
@@ -32,11 +32,11 @@ public:
   void chdir(const char * relpath);
   void updir();
 
-  inline bool eof() { return sdpos>=filesize ;};
-  inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
-  inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
-  inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
-  inline char* getWorkDirName(){workDir.getFilename(filename);return filename;};
+  FORCE_INLINE bool eof() { return sdpos>=filesize ;};
+  FORCE_INLINE int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
+  FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
+  FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
+  FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
 
 public:
   bool saving;
@@ -69,31 +69,31 @@ private:
 class CardReader
 {
 public:
-  inline CardReader(){};
+  FORCE_INLINE CardReader(){};
   
-  inline static void initsd(){};
-  inline static void write_command(char *buf){};
+  FORCE_INLINE static void initsd(){};
+  FORCE_INLINE static void write_command(char *buf){};
   
-  inline static void checkautostart(bool x) {}; 
+  FORCE_INLINE static void checkautostart(bool x) {}; 
   
-  inline static void openFile(char* name,bool read){};
-  inline static void closefile() {};
-  inline static void release(){};
-  inline static void startFileprint(){};
-  inline static void startFilewrite(char *name){};
-  inline static void pauseSDPrint(){};
-  inline static void getStatus(){};
+  FORCE_INLINE static void openFile(char* name,bool read){};
+  FORCE_INLINE static void closefile() {};
+  FORCE_INLINE static void release(){};
+  FORCE_INLINE static void startFileprint(){};
+  FORCE_INLINE static void startFilewrite(char *name){};
+  FORCE_INLINE static void pauseSDPrint(){};
+  FORCE_INLINE static void getStatus(){};
   
-  inline static void selectFile(char* name){};
-  inline static void getfilename(const uint8_t nr){};
-  inline static uint8_t getnrfilenames(){return 0;};
+  FORCE_INLINE static void selectFile(char* name){};
+  FORCE_INLINE static void getfilename(const uint8_t nr){};
+  FORCE_INLINE static uint8_t getnrfilenames(){return 0;};
   
 
-  inline static void ls() {};
-  inline static bool eof() {return true;};
-  inline static char get() {return 0;};
-  inline static void setIndex(){};
-  inline uint8_t percentDone(){return 0;};
+  FORCE_INLINE static void ls() {};
+  FORCE_INLINE static bool eof() {return true;};
+  FORCE_INLINE static char get() {return 0;};
+  FORCE_INLINE static void setIndex(){};
+  FORCE_INLINE uint8_t percentDone(){return 0;};
 };
 #endif //SDSUPPORT
 #endif
\ No newline at end of file
index 2367e313a03830406dff36437b49723cf660cde0..2c2ba3f77b93eb5ab42ff860b666be2c4f6cf365 100644 (file)
@@ -132,7 +132,8 @@ static int8_t prev_block_index(int8_t block_index) {
 
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 
 // given acceleration:
-inline float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
+FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
+{
   if (acceleration!=0) {
   return((target_rate*target_rate-initial_rate*initial_rate)/
          (2.0*acceleration));
@@ -147,7 +148,8 @@ inline float estimate_acceleration_distance(float initial_rate, float target_rat
 // a total travel of distance. This can be used to compute the intersection point between acceleration and
 // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
 
-inline float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
+FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) 
+{
  if (acceleration!=0) {
   return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
          (4.0*acceleration) );
@@ -211,7 +213,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
 
 // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the 
 // acceleration within the allotted distance.
-inline float max_allowable_speed(float acceleration, float target_velocity, float distance) {
+FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
   return  sqrt(target_velocity*target_velocity-2*acceleration*distance);
 }
 
index 7bae9a1c92bfe34f84e3e478f13bf98d3a38bc40..e17580dad7c6bb7ba34c09f090794a706f9da6ca 100644 (file)
@@ -25,6 +25,7 @@
 #define planner_h
 
 #include "Configuration.h"
+#include "Marlin.h"
 
 // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in 
 // the source g-code and may never actually be reached if acceleration management is active.
@@ -106,14 +107,16 @@ extern volatile unsigned char block_buffer_head;           // Index of the next
 extern volatile unsigned char block_buffer_tail; 
 // Called when the current block is no longer needed. Discards the block and makes the memory
 // availible for new blocks.    
-inline void plan_discard_current_block() {
+FORCE_INLINE void plan_discard_current_block()  
+{
   if (block_buffer_head != block_buffer_tail) {
     block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);  
   }
 }
 
 // Gets the current block. Returns NULL if buffer empty
-inline block_t *plan_get_current_block() {
+FORCE_INLINE block_t *plan_get_current_block() 
+{
   if (block_buffer_head == block_buffer_tail) { 
     return(NULL); 
   }
index 0f0de985f4e3ad3429a54d887fa1c2f89deab48f..9057c1c90b1641375d2582c63102e2829c462de0 100644 (file)
@@ -59,31 +59,31 @@ extern float Kp,Ki,Kd,Kc;
 //inline so that there is no performance decrease.\r
 //deg=degreeCelsius\r
 \r
-inline float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};\r
-inline float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};\r
-inline float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};\r
+FORCE_INLINE float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};\r
+FORCE_INLINE float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};\r
+FORCE_INLINE float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};\r
 \r
-inline float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};\r
-inline float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};\r
-inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};\r
+FORCE_INLINE float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};\r
+FORCE_INLINE float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};\r
+FORCE_INLINE float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};\r
 \r
-inline void setTargetHotend0(const float &celsius) \r
+FORCE_INLINE void setTargetHotend0(const float &celsius) \r
 {  \r
   target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);\r
   #ifdef PIDTEMP\r
     pid_setpoint = celsius;\r
   #endif //PIDTEMP\r
 };\r
-inline void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};\r
-inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};\r
+FORCE_INLINE void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};\r
+FORCE_INLINE void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};\r
 \r
-inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};\r
-inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};\r
-inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};\r
+FORCE_INLINE bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};\r
+FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};\r
+FORCE_INLINE bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};\r
 \r
-inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};\r
-inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};\r
-inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};\r
+FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};\r
+FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};\r
+FORCE_INLINE bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};\r
 \r
 void disable_heater();\r
 void setWatch();\r
index 85a8df74c5b3e835f19b1ae092dbd9020f3e595f..887dc04f251fd8581d807ea972f49110cb1f3f0e 100644 (file)
@@ -79,7 +79,7 @@
     bool tune;
     
   private:
-    inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
+    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
     {
       if(linechanging) return; // an item is changint its value, do not switch lines hence
       lastlineoffset=lineoffset; 
       } 
     }
     
-    inline void clearIfNecessary()
+    FORCE_INLINE void clearIfNecessary()
     {
       if(lastlineoffset!=lineoffset ||force_lcd_update)
       {
   #define LCD_STATUS
   #define LCD_MESSAGE(x)
   #define LCD_MESSAGEPGM(x)
-  inline void lcd_status() {};
+  FORCE_INLINE void lcd_status() {};
 #endif
   
 #ifndef ULTIPANEL  
index 44ee9de35d927d22edbb92a0ed0447177f7e9589..1d4148827176c5a433a80f60064fa725cdc43f9b 100644 (file)
@@ -9,8 +9,8 @@
   void wd_reset();
 
 #else
-  inline void wd_init() {};
-  inline void wd_reset() {};
+  FORCE_INLINE void wd_init() {};
+  FORCE_INLINE void wd_reset() {};
 #endif
 
 #endif