Explorar el Código

Replace digitalPinHasPWM with HAS_TIMER (#13520)

Alexander Amelkin hace 5 años
padre
commit
e40636a7c1

+ 6
- 6
Marlin/src/HAL/HAL_AVR/fastio_AVR.h Ver fichero

@@ -81,9 +81,9 @@
81 81
 #define _SET_INPUT(IO)        CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
82 82
 #define _SET_OUTPUT(IO)       SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
83 83
 
84
-#define _GET_INPUT(IO)       !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
85
-#define _GET_OUTPUT(IO)       TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
86
-#define _GET_TIMER(IO)        DIO ## IO ## _PWM
84
+#define _IS_INPUT(IO)        !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
85
+#define _IS_OUTPUT(IO)        TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
86
+#define _HAS_TIMER(IO)        DIO ## IO ## _PWM
87 87
 
88 88
 // digitalRead/Write wrappers
89 89
 #ifdef FASTIO_EXT_START
@@ -104,9 +104,9 @@
104 104
 
105 105
 #define SET_PWM(IO)           SET_OUTPUT(IO)
106 106
 
107
-#define GET_INPUT(IO)         _GET_INPUT(IO)
108
-#define GET_OUTPUT(IO)        _GET_OUTPUT(IO)
109
-#define GET_TIMER(IO)         _GET_TIMER(IO)
107
+#define IS_INPUT(IO)          _IS_INPUT(IO)
108
+#define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
109
+#define HAS_TIMER(IO)         _HAS_TIMER(IO)
110 110
 
111 111
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
112 112
 

+ 3
- 3
Marlin/src/HAL/HAL_DUE/fastio_Due.h Ver fichero

@@ -177,11 +177,11 @@
177 177
 #define SET_PWM(IO)           SET_OUTPUT(IO)
178 178
 
179 179
 // Check if pin is an input
180
-#define GET_INPUT(IO)        ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
180
+#define IS_INPUT(IO)         ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
181 181
 // Check if pin is an output
182
-#define GET_OUTPUT(IO)       ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
182
+#define IS_OUTPUT(IO)        ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
183 183
 // Check if pin is a timer - Must be a constexpr
184
-#define GET_TIMER(IO)         ((IO) >= 2 && (IO) <= 13)
184
+#define HAS_TIMER(IO)         ((IO) >= 2 && (IO) <= 13)
185 185
 
186 186
 // Shorthand
187 187
 #define OUT_WRITE(IO,V)       { SET_OUTPUT(IO); WRITE(IO,V); }

+ 8
- 8
Marlin/src/HAL/HAL_LINUX/fastio.h Ver fichero

@@ -75,19 +75,19 @@
75 75
 // hg42: currently not used, but was used by pinsDebug
76 76
 
77 77
 /// check if pin is an input
78
-#define _GET_INPUT(IO)        (LPC1768_PIN_PIN(IO) >= 0)
78
+#define _IS_INPUT(IO)         (LPC1768_PIN_PIN(IO) >= 0)
79 79
 
80 80
 /// check if pin is an output
81
-#define _GET_OUTPUT(IO)       (LPC1768_PIN_PIN(IO) >= 0)
81
+#define _IS_OUTPUT(IO)        (LPC1768_PIN_PIN(IO) >= 0)
82 82
 
83
-// hg42: GET_TIMER is used only to check if it's a PWM pin
83
+// hg42: HAS_TIMER is used only to check if it's a PWM pin
84 84
 // hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
85 85
 // hg42: instead use PWM bit from the #define
86 86
 
87 87
 /// check if pin is a timer
88
-#define _GET_TIMER(IO)        true  // could be LPC1768_PIN_PWM(IO), but there
88
+#define _HAS_TIMER(IO)        true  // could be LPC1768_PIN_PWM(IO), but there
89 89
 // hg42: could be this:
90
-// #define _GET_TIMER(IO)        LPC1768_PIN_PWM(IO)
90
+// #define _HAS_TIMER(IO)        LPC1768_PIN_PWM(IO)
91 91
 // but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
92 92
 
93 93
 /// Read a pin wrapper
@@ -112,12 +112,12 @@
112 112
 #define SET_PWM(IO)           SET_OUTPUT(IO)
113 113
 
114 114
 /// check if pin is an input wrapper
115
-#define GET_INPUT(IO)        _GET_INPUT(IO)
115
+#define IS_INPUT(IO)         _IS_INPUT(IO)
116 116
 /// check if pin is an output wrapper
117
-#define GET_OUTPUT(IO)       _GET_OUTPUT(IO)
117
+#define IS_OUTPUT(IO)        _IS_OUTPUT(IO)
118 118
 
119 119
 /// check if pin is a timer (wrapper)
120
-#define GET_TIMER(IO)        _GET_TIMER(IO)
120
+#define HAS_TIMER(IO)        _HAS_TIMER(IO)
121 121
 
122 122
 // Shorthand
123 123
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)

+ 6
- 6
Marlin/src/HAL/HAL_LPC1768/fastio.h Ver fichero

@@ -84,14 +84,14 @@
84 84
 #define _PULLDOWN(IO,V)       pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
85 85
 
86 86
 /// check if pin is an input
87
-#define _GET_INPUT(IO)        (!gpio_get_dir(IO))
87
+#define _IS_INPUT(IO)         (!gpio_get_dir(IO))
88 88
 
89 89
 /// check if pin is an output
90
-#define _GET_OUTPUT(IO)       (gpio_get_dir(IO))
90
+#define _IS_OUTPUT(IO)        (gpio_get_dir(IO))
91 91
 
92 92
 /// check if pin is a timer
93 93
 /// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
94
-#define _GET_TIMER(IO)        true
94
+#define _HAS_TIMER(IO)        true
95 95
 
96 96
 /// Read a pin wrapper
97 97
 #define READ(IO)              _READ(IO)
@@ -115,12 +115,12 @@
115 115
 #define SET_PWM(IO)           SET_OUTPUT(IO)
116 116
 
117 117
 /// check if pin is an input wrapper
118
-#define GET_INPUT(IO)         _GET_INPUT(IO)
118
+#define IS_INPUT(IO)          _IS_INPUT(IO)
119 119
 /// check if pin is an output wrapper
120
-#define GET_OUTPUT(IO)        _GET_OUTPUT(IO)
120
+#define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
121 121
 
122 122
 /// check if pin is a timer (wrapper)
123
-#define GET_TIMER(IO)         _GET_TIMER(IO)
123
+#define HAS_TIMER(IO)         _HAS_TIMER(IO)
124 124
 
125 125
 // Shorthand
126 126
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)

+ 4
- 4
Marlin/src/HAL/HAL_STM32/fastio_STM32.h Ver fichero

@@ -78,11 +78,11 @@ void FastIO_init(); // Must be called before using fast io macros
78 78
 #define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
79 79
 #define SET_PWM(IO)             _SET_MODE(IO, PWM)
80 80
 
81
-#define GET_INPUT(IO)
82
-#define GET_OUTPUT(IO)
83
-#define GET_TIMER(IO)
81
+#define IS_INPUT(IO)
82
+#define IS_OUTPUT(IO)
83
+#define HAS_TIMER(IO)
84 84
 
85
-#define PWM_PIN(P)              digitalPinHasPWM(P)
85
+#define PWM_PIN(P)              HAS_TIMER(P)
86 86
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
87 87
 
88 88
 // digitalRead/Write wrappers

+ 4
- 4
Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h Ver fichero

@@ -45,11 +45,11 @@
45 45
 #define SET_OUTPUT(IO)        OUT_WRITE(IO, LOW)
46 46
 #define SET_PWM(IO)           pinMode(IO, PWM)    // do{ gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP); timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, TIMER_PWM); }while(0)
47 47
 
48
-#define GET_INPUT(IO)         (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
49
-#define GET_OUTPUT(IO)        (_GET_MODE(IO) == GPIO_OUTPUT_PP)
50
-#define GET_TIMER(IO)         (PIN_MAP[IO].timer_device != NULL)
48
+#define IS_INPUT(IO)          (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
49
+#define IS_OUTPUT(IO)         (_GET_MODE(IO) == GPIO_OUTPUT_PP)
50
+#define HAS_TIMER(IO)         (PIN_MAP[IO].timer_device != NULL)
51 51
 
52
-#define PWM_PIN(P)              digitalPinHasPWM(P)
52
+#define PWM_PIN(P)              HAS_TIMER(P)
53 53
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
54 54
 
55 55
 // digitalRead/Write wrappers

+ 3
- 3
Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h Ver fichero

@@ -48,9 +48,9 @@
48 48
 
49 49
 #define TOGGLE(IO)              OUT_WRITE(IO, !READ(IO))
50 50
 
51
-#define GET_INPUT(IO)
52
-#define GET_OUTPUT(IO)
53
-#define GET_TIMER(IO)
51
+#define IS_INPUT(IO)
52
+#define IS_OUTPUT(IO)
53
+#define HAS_TIMER(IO)
54 54
 
55 55
 #define PWM_PIN(P)              true
56 56
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)

+ 3
- 3
Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h Ver fichero

@@ -47,9 +47,9 @@
47 47
 
48 48
 #define TOGGLE(IO)              OUT_WRITE(IO, !READ(IO))
49 49
 
50
-#define GET_INPUT(IO)
51
-#define GET_OUTPUT(IO)
52
-#define GET_TIMER(IO)
50
+#define IS_INPUT(IO)
51
+#define IS_OUTPUT(IO)
52
+#define HAS_TIMER(IO)
53 53
 
54 54
 #define PWM_PIN(P)              true
55 55
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)

+ 4
- 4
Marlin/src/HAL/HAL_TEENSY31_32/fastio_Teensy.h Ver fichero

@@ -67,8 +67,8 @@
67 67
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
68 68
 }while(0)
69 69
 
70
-#define _GET_INPUT(P)   ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
71
-#define _GET_OUTPUT(P)  ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
70
+#define _IS_INPUT(P)    ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
71
+#define _IS_OUTPUT(P)   ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
72 72
 
73 73
 #define READ(IO)              _READ(IO)
74 74
 
@@ -81,8 +81,8 @@
81 81
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
82 82
 #define SET_PWM(IO)            SET_OUTPUT(IO)
83 83
 
84
-#define GET_INPUT(IO)         _GET_INPUT(IO)
85
-#define GET_OUTPUT(IO)        _GET_OUTPUT(IO)
84
+#define IS_INPUT(IO)          _IS_INPUT(IO)
85
+#define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
86 86
 
87 87
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
88 88
 

+ 4
- 4
Marlin/src/HAL/HAL_TEENSY35_36/fastio_Teensy.h Ver fichero

@@ -66,8 +66,8 @@
66 66
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
67 67
 }while(0)
68 68
 
69
-#define _GET_INPUT(P)   ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
70
-#define _GET_OUTPUT(P)  ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
69
+#define _IS_INPUT(P)    ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
70
+#define _IS_OUTPUT(P)   ((CORE_PIN ## P ## _DDRREG & CORE_PIN ## P ## _BITMASK) == 0)
71 71
 
72 72
 #define READ(IO)              _READ(IO)
73 73
 
@@ -80,8 +80,8 @@
80 80
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
81 81
 #define SET_PWM(IO)            SET_OUTPUT(IO)
82 82
 
83
-#define GET_INPUT(IO)         _GET_INPUT(IO)
84
-#define GET_OUTPUT(IO)        _GET_OUTPUT(IO)
83
+#define IS_INPUT(IO)          _IS_INPUT(IO)
84
+#define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
85 85
 
86 86
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
87 87
 

+ 4
- 4
Marlin/src/pins/pinsDebug.h Ver fichero

@@ -139,11 +139,11 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
139 139
           #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
140 140
             if (pin == 46 || pin == 47) {
141 141
               if (pin == 46) {
142
-                print_input_or_output(GET_OUTPUT(46));
142
+                print_input_or_output(IS_OUTPUT(46));
143 143
                 SERIAL_CHAR('0' + READ(46));
144 144
               }
145 145
               else if (pin == 47) {
146
-                print_input_or_output(GET_OUTPUT(47));
146
+                print_input_or_output(IS_OUTPUT(47));
147 147
                 SERIAL_CHAR('0' + READ(47));
148 148
               }
149 149
             }
@@ -195,11 +195,11 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
195 195
         if (pin == 46 || pin == 47) {
196 196
           SERIAL_ECHO_SP(12);
197 197
           if (pin == 46) {
198
-            print_input_or_output(GET_OUTPUT(46));
198
+            print_input_or_output(IS_OUTPUT(46));
199 199
             SERIAL_CHAR('0' + READ(46));
200 200
           }
201 201
           else {
202
-            print_input_or_output(GET_OUTPUT(47));
202
+            print_input_or_output(IS_OUTPUT(47));
203 203
             SERIAL_CHAR('0' + READ(47));
204 204
           }
205 205
         }

Loading…
Cancelar
Guardar