瀏覽代碼

force inline

Bernhard 13 年之前
父節點
當前提交
b19c8b74b9
共有 3 個檔案被更改,包括 19 行新增16 行删除
  1. 2
    1
      Marlin/MarlinSerial.cpp
  2. 9
    7
      Marlin/MarlinSerial.h
  3. 8
    8
      Marlin/temperature.h

+ 2
- 1
Marlin/MarlinSerial.cpp 查看文件

32
 #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
32
 #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
33
 
33
 
34
 #include "MarlinSerial.h"
34
 #include "MarlinSerial.h"
35
+#include "Marlin.h"
35
 
36
 
36
 
37
 
37
 
38
 
41
 #endif
42
 #endif
42
 
43
 
43
 
44
 
44
-inline void store_char(unsigned char c)
45
+FORCE_INLINE void store_char(unsigned char c)
45
 {
46
 {
46
   int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
47
   int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
47
 
48
 

+ 9
- 7
Marlin/MarlinSerial.h 查看文件

24
 
24
 
25
 #include <inttypes.h>
25
 #include <inttypes.h>
26
 #include <Stream.h>
26
 #include <Stream.h>
27
+#define  FORCE_INLINE __attribute__((always_inline)) inline
28
+
27
 
29
 
28
 
30
 
29
 // Define constants and variables for buffering incoming serial data.  We're
31
 // Define constants and variables for buffering incoming serial data.  We're
55
     int read(void);
57
     int read(void);
56
     void flush(void);
58
     void flush(void);
57
     
59
     
58
-    inline int available(void)
60
+    FORCE_INLINE int available(void)
59
     {
61
     {
60
       return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
62
       return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
61
     }
63
     }
62
     
64
     
63
-    inline void write(uint8_t c)
65
+    FORCE_INLINE void write(uint8_t c)
64
     {
66
     {
65
       while (!((UCSR0A) & (1 << UDRE0)))
67
       while (!((UCSR0A) & (1 << UDRE0)))
66
         ;
68
         ;
69
     }
71
     }
70
     
72
     
71
     
73
     
72
-    inline void checkRx(void)
74
+    FORCE_INLINE void checkRx(void)
73
     {
75
     {
74
       if((UCSR0A & (1<<RXC0)) != 0) {
76
       if((UCSR0A & (1<<RXC0)) != 0) {
75
         unsigned char c  =  UDR0;
77
         unsigned char c  =  UDR0;
94
     
96
     
95
   public:
97
   public:
96
     
98
     
97
-    inline void write(const char *str)
99
+    FORCE_INLINE void write(const char *str)
98
     {
100
     {
99
       while (*str)
101
       while (*str)
100
         write(*str++);
102
         write(*str++);
101
     }
103
     }
102
 
104
 
103
 
105
 
104
-    inline void write(const uint8_t *buffer, size_t size)
106
+    FORCE_INLINE void write(const uint8_t *buffer, size_t size)
105
     {
107
     {
106
       while (size--)
108
       while (size--)
107
         write(*buffer++);
109
         write(*buffer++);
108
     }
110
     }
109
 
111
 
110
-    inline void print(const String &s)
112
+    FORCE_INLINE void print(const String &s)
111
     {
113
     {
112
       for (int i = 0; i < s.length(); i++) {
114
       for (int i = 0; i < s.length(); i++) {
113
         write(s[i]);
115
         write(s[i]);
114
       }
116
       }
115
     }
117
     }
116
     
118
     
117
-    inline void print(const char *str)
119
+    FORCE_INLINE void print(const char *str)
118
     {
120
     {
119
       write(str);
121
       write(str);
120
     }
122
     }

+ 8
- 8
Marlin/temperature.h 查看文件

62
 FORCE_INLINE float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
62
 FORCE_INLINE float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
63
 FORCE_INLINE float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
63
 FORCE_INLINE float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
64
 FORCE_INLINE float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
64
 FORCE_INLINE float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
65
-inline float degHotend(uint8_t extruder){  
65
+FORCE_INLINE float degHotend(uint8_t extruder){  
66
   if(extruder == 0) return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
66
   if(extruder == 0) return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
67
   if(extruder == 1) return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);
67
   if(extruder == 1) return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);
68
 };
68
 };
74
   if(extruder == 1) return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);
74
   if(extruder == 1) return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);
75
 };
75
 };
76
 
76
 
77
-inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
77
+FORCE_INLINE float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
78
 
78
 
79
 FORCE_INLINE void setTargetHotend0(const float &celsius) 
79
 FORCE_INLINE void setTargetHotend0(const float &celsius) 
80
 {  
80
 {  
84
   #endif //PIDTEMP
84
   #endif //PIDTEMP
85
 };
85
 };
86
 FORCE_INLINE void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
86
 FORCE_INLINE void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
87
-inline float setTargetHotend(const float &celcius, uint8_t extruder){  
87
+FORCE_INLINE float setTargetHotend(const float &celcius, uint8_t extruder){  
88
   if(extruder == 0) setTargetHotend0(celcius);
88
   if(extruder == 0) setTargetHotend0(celcius);
89
   if(extruder == 1) setTargetHotend1(celcius);
89
   if(extruder == 1) setTargetHotend1(celcius);
90
 };
90
 };
91
-inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
91
+FORCE_INLINE void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
92
 
92
 
93
 FORCE_INLINE bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
93
 FORCE_INLINE bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
94
 FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
94
 FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
95
-inline float isHeatingHotend(uint8_t extruder){  
95
+FORCE_INLINE float isHeatingHotend(uint8_t extruder){  
96
   if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];
96
   if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];
97
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];
97
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];
98
 };
98
 };
99
-inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
99
+FORCE_INLINE bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
100
 
100
 
101
 FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
101
 FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
102
 FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
102
 FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
103
-inline float isCoolingHotend(uint8_t extruder){  
103
+FORCE_INLINE float isCoolingHotend(uint8_t extruder){  
104
   if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];
104
   if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];
105
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];
105
   if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];
106
 };
106
 };
107
-inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
107
+FORCE_INLINE bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
108
 
108
 
109
 void disable_heater();
109
 void disable_heater();
110
 void setWatch();
110
 void setWatch();

Loading…
取消
儲存