Browse Source

force inline

Bernhard 13 years ago
parent
commit
26a1de1e44
8 changed files with 59 additions and 52 deletions
  1. 2
    2
      Marlin/EEPROMwrite.h
  2. 3
    1
      Marlin/Marlin.h
  3. 24
    24
      Marlin/cardreader.h
  4. 5
    3
      Marlin/planner.cpp
  5. 5
    2
      Marlin/planner.h
  6. 15
    15
      Marlin/temperature.h
  7. 3
    3
      Marlin/ultralcd.h
  8. 2
    2
      Marlin/watchdog.h

+ 2
- 2
Marlin/EEPROMwrite.h View File

38
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
38
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
39
 #define EEPROM_VERSION "V04"  
39
 #define EEPROM_VERSION "V04"  
40
 
40
 
41
-inline void StoreSettings() 
41
+FORCE_INLINE void StoreSettings() 
42
 {
42
 {
43
 #ifdef EEPROM_SETTINGS
43
 #ifdef EEPROM_SETTINGS
44
   char ver[4]= "000";
44
   char ver[4]= "000";
71
 #endif //EEPROM_SETTINGS
71
 #endif //EEPROM_SETTINGS
72
 }
72
 }
73
 
73
 
74
-inline void RetrieveSettings(bool def=false)
74
+FORCE_INLINE void RetrieveSettings(bool def=false)
75
 {  // if def=true, the default values will be used
75
 {  // if def=true, the default values will be used
76
   #ifdef EEPROM_SETTINGS
76
   #ifdef EEPROM_SETTINGS
77
     int i=EEPROM_OFFSET;
77
     int i=EEPROM_OFFSET;

+ 3
- 1
Marlin/Marlin.h View File

8
 #include <avr/pgmspace.h>
8
 #include <avr/pgmspace.h>
9
 #include "Configuration.h"
9
 #include "Configuration.h"
10
 
10
 
11
+
12
+#define  FORCE_INLINE __attribute__((always_inline)) inline
11
 //#define SERIAL_ECHO(x) Serial << "echo: " << x;
13
 //#define SERIAL_ECHO(x) Serial << "echo: " << x;
12
 //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
14
 //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
13
 //#define SERIAL_ERROR(x) Serial << "Error: " << x;
15
 //#define SERIAL_ERROR(x) Serial << "Error: " << x;
41
 
43
 
42
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
44
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
43
 #define SerialprintPGM(x) serialprintPGM(PSTR(x))
45
 #define SerialprintPGM(x) serialprintPGM(PSTR(x))
44
-inline void serialprintPGM(const char *str)
46
+FORCE_INLINE void serialprintPGM(const char *str)
45
 {
47
 {
46
   char ch=pgm_read_byte(str);
48
   char ch=pgm_read_byte(str);
47
   while(ch)
49
   while(ch)

+ 24
- 24
Marlin/cardreader.h View File

32
   void chdir(const char * relpath);
32
   void chdir(const char * relpath);
33
   void updir();
33
   void updir();
34
 
34
 
35
-  inline bool eof() { return sdpos>=filesize ;};
36
-  inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
37
-  inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
38
-  inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
39
-  inline char* getWorkDirName(){workDir.getFilename(filename);return filename;};
35
+  FORCE_INLINE bool eof() { return sdpos>=filesize ;};
36
+  FORCE_INLINE int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
37
+  FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
38
+  FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
39
+  FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
40
 
40
 
41
 public:
41
 public:
42
   bool saving;
42
   bool saving;
69
 class CardReader
69
 class CardReader
70
 {
70
 {
71
 public:
71
 public:
72
-  inline CardReader(){};
72
+  FORCE_INLINE CardReader(){};
73
   
73
   
74
-  inline static void initsd(){};
75
-  inline static void write_command(char *buf){};
74
+  FORCE_INLINE static void initsd(){};
75
+  FORCE_INLINE static void write_command(char *buf){};
76
   
76
   
77
-  inline static void checkautostart(bool x) {}; 
77
+  FORCE_INLINE static void checkautostart(bool x) {}; 
78
   
78
   
79
-  inline static void openFile(char* name,bool read){};
80
-  inline static void closefile() {};
81
-  inline static void release(){};
82
-  inline static void startFileprint(){};
83
-  inline static void startFilewrite(char *name){};
84
-  inline static void pauseSDPrint(){};
85
-  inline static void getStatus(){};
79
+  FORCE_INLINE static void openFile(char* name,bool read){};
80
+  FORCE_INLINE static void closefile() {};
81
+  FORCE_INLINE static void release(){};
82
+  FORCE_INLINE static void startFileprint(){};
83
+  FORCE_INLINE static void startFilewrite(char *name){};
84
+  FORCE_INLINE static void pauseSDPrint(){};
85
+  FORCE_INLINE static void getStatus(){};
86
   
86
   
87
-  inline static void selectFile(char* name){};
88
-  inline static void getfilename(const uint8_t nr){};
89
-  inline static uint8_t getnrfilenames(){return 0;};
87
+  FORCE_INLINE static void selectFile(char* name){};
88
+  FORCE_INLINE static void getfilename(const uint8_t nr){};
89
+  FORCE_INLINE static uint8_t getnrfilenames(){return 0;};
90
   
90
   
91
 
91
 
92
-  inline static void ls() {};
93
-  inline static bool eof() {return true;};
94
-  inline static char get() {return 0;};
95
-  inline static void setIndex(){};
96
-  inline uint8_t percentDone(){return 0;};
92
+  FORCE_INLINE static void ls() {};
93
+  FORCE_INLINE static bool eof() {return true;};
94
+  FORCE_INLINE static char get() {return 0;};
95
+  FORCE_INLINE static void setIndex(){};
96
+  FORCE_INLINE uint8_t percentDone(){return 0;};
97
 };
97
 };
98
 #endif //SDSUPPORT
98
 #endif //SDSUPPORT
99
 #endif
99
 #endif

+ 5
- 3
Marlin/planner.cpp View File

132
 
132
 
133
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 
133
 // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the 
134
 // given acceleration:
134
 // given acceleration:
135
-inline float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
135
+FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
136
+{
136
   if (acceleration!=0) {
137
   if (acceleration!=0) {
137
   return((target_rate*target_rate-initial_rate*initial_rate)/
138
   return((target_rate*target_rate-initial_rate*initial_rate)/
138
          (2.0*acceleration));
139
          (2.0*acceleration));
147
 // a total travel of distance. This can be used to compute the intersection point between acceleration and
148
 // a total travel of distance. This can be used to compute the intersection point between acceleration and
148
 // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
149
 // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
149
 
150
 
150
-inline float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
151
+FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) 
152
+{
151
  if (acceleration!=0) {
153
  if (acceleration!=0) {
152
   return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
154
   return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
153
          (4.0*acceleration) );
155
          (4.0*acceleration) );
211
 
213
 
212
 // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the 
214
 // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the 
213
 // acceleration within the allotted distance.
215
 // acceleration within the allotted distance.
214
-inline float max_allowable_speed(float acceleration, float target_velocity, float distance) {
216
+FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
215
   return  sqrt(target_velocity*target_velocity-2*acceleration*distance);
217
   return  sqrt(target_velocity*target_velocity-2*acceleration*distance);
216
 }
218
 }
217
 
219
 

+ 5
- 2
Marlin/planner.h View File

25
 #define planner_h
25
 #define planner_h
26
 
26
 
27
 #include "Configuration.h"
27
 #include "Configuration.h"
28
+#include "Marlin.h"
28
 
29
 
29
 // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in 
30
 // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in 
30
 // the source g-code and may never actually be reached if acceleration management is active.
31
 // the source g-code and may never actually be reached if acceleration management is active.
106
 extern volatile unsigned char block_buffer_tail; 
107
 extern volatile unsigned char block_buffer_tail; 
107
 // Called when the current block is no longer needed. Discards the block and makes the memory
108
 // Called when the current block is no longer needed. Discards the block and makes the memory
108
 // availible for new blocks.    
109
 // availible for new blocks.    
109
-inline void plan_discard_current_block() {
110
+FORCE_INLINE void plan_discard_current_block()  
111
+{
110
   if (block_buffer_head != block_buffer_tail) {
112
   if (block_buffer_head != block_buffer_tail) {
111
     block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);  
113
     block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);  
112
   }
114
   }
113
 }
115
 }
114
 
116
 
115
 // Gets the current block. Returns NULL if buffer empty
117
 // Gets the current block. Returns NULL if buffer empty
116
-inline block_t *plan_get_current_block() {
118
+FORCE_INLINE block_t *plan_get_current_block() 
119
+{
117
   if (block_buffer_head == block_buffer_tail) { 
120
   if (block_buffer_head == block_buffer_tail) { 
118
     return(NULL); 
121
     return(NULL); 
119
   }
122
   }

+ 15
- 15
Marlin/temperature.h View File

59
 //inline so that there is no performance decrease.
59
 //inline so that there is no performance decrease.
60
 //deg=degreeCelsius
60
 //deg=degreeCelsius
61
 
61
 
62
-inline float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
63
-inline float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
64
-inline float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
62
+FORCE_INLINE float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
63
+FORCE_INLINE float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
64
+FORCE_INLINE float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
65
 
65
 
66
-inline float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
67
-inline float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
68
-inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
66
+FORCE_INLINE float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
67
+FORCE_INLINE float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
68
+FORCE_INLINE float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
69
 
69
 
70
-inline void setTargetHotend0(const float &celsius) 
70
+FORCE_INLINE void setTargetHotend0(const float &celsius) 
71
 {  
71
 {  
72
   target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
72
   target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
73
   #ifdef PIDTEMP
73
   #ifdef PIDTEMP
74
     pid_setpoint = celsius;
74
     pid_setpoint = celsius;
75
   #endif //PIDTEMP
75
   #endif //PIDTEMP
76
 };
76
 };
77
-inline void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
78
-inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
77
+FORCE_INLINE void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
78
+FORCE_INLINE void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
79
 
79
 
80
-inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
81
-inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
82
-inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
80
+FORCE_INLINE bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
81
+FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
82
+FORCE_INLINE bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
83
 
83
 
84
-inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
85
-inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
86
-inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
84
+FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
85
+FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
86
+FORCE_INLINE bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
87
 
87
 
88
 void disable_heater();
88
 void disable_heater();
89
 void setWatch();
89
 void setWatch();

+ 3
- 3
Marlin/ultralcd.h View File

79
     bool tune;
79
     bool tune;
80
     
80
     
81
   private:
81
   private:
82
-    inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
82
+    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
83
     {
83
     {
84
       if(linechanging) return; // an item is changint its value, do not switch lines hence
84
       if(linechanging) return; // an item is changint its value, do not switch lines hence
85
       lastlineoffset=lineoffset; 
85
       lastlineoffset=lineoffset; 
119
       } 
119
       } 
120
     }
120
     }
121
     
121
     
122
-    inline void clearIfNecessary()
122
+    FORCE_INLINE void clearIfNecessary()
123
     {
123
     {
124
       if(lastlineoffset!=lineoffset ||force_lcd_update)
124
       if(lastlineoffset!=lineoffset ||force_lcd_update)
125
       {
125
       {
143
   #define LCD_STATUS
143
   #define LCD_STATUS
144
   #define LCD_MESSAGE(x)
144
   #define LCD_MESSAGE(x)
145
   #define LCD_MESSAGEPGM(x)
145
   #define LCD_MESSAGEPGM(x)
146
-  inline void lcd_status() {};
146
+  FORCE_INLINE void lcd_status() {};
147
 #endif
147
 #endif
148
   
148
   
149
 #ifndef ULTIPANEL  
149
 #ifndef ULTIPANEL  

+ 2
- 2
Marlin/watchdog.h View File

9
   void wd_reset();
9
   void wd_reset();
10
 
10
 
11
 #else
11
 #else
12
-  inline void wd_init() {};
13
-  inline void wd_reset() {};
12
+  FORCE_INLINE void wd_init() {};
13
+  FORCE_INLINE void wd_reset() {};
14
 #endif
14
 #endif
15
 
15
 
16
 #endif
16
 #endif

Loading…
Cancel
Save