Pārlūkot izejas kodu

Replace digitalPinHasPWM with HAS_TIMER (#13520)

Alexander Amelkin 6 gadus atpakaļ
vecāks
revīzija
e40636a7c1

+ 6
- 6
Marlin/src/HAL/HAL_AVR/fastio_AVR.h Parādīt failu

81
 #define _SET_INPUT(IO)        CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
81
 #define _SET_INPUT(IO)        CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
82
 #define _SET_OUTPUT(IO)       SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
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
 // digitalRead/Write wrappers
88
 // digitalRead/Write wrappers
89
 #ifdef FASTIO_EXT_START
89
 #ifdef FASTIO_EXT_START
104
 
104
 
105
 #define SET_PWM(IO)           SET_OUTPUT(IO)
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
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
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 Parādīt failu

177
 #define SET_PWM(IO)           SET_OUTPUT(IO)
177
 #define SET_PWM(IO)           SET_OUTPUT(IO)
178
 
178
 
179
 // Check if pin is an input
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
 // Check if pin is an output
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
 // Check if pin is a timer - Must be a constexpr
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
 // Shorthand
186
 // Shorthand
187
 #define OUT_WRITE(IO,V)       { SET_OUTPUT(IO); WRITE(IO,V); }
187
 #define OUT_WRITE(IO,V)       { SET_OUTPUT(IO); WRITE(IO,V); }

+ 8
- 8
Marlin/src/HAL/HAL_LINUX/fastio.h Parādīt failu

75
 // hg42: currently not used, but was used by pinsDebug
75
 // hg42: currently not used, but was used by pinsDebug
76
 
76
 
77
 /// check if pin is an input
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
 /// check if pin is an output
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
 // hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
84
 // hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
85
 // hg42: instead use PWM bit from the #define
85
 // hg42: instead use PWM bit from the #define
86
 
86
 
87
 /// check if pin is a timer
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
 // hg42: could be this:
89
 // hg42: could be this:
90
-// #define _GET_TIMER(IO)        LPC1768_PIN_PWM(IO)
90
+// #define _HAS_TIMER(IO)        LPC1768_PIN_PWM(IO)
91
 // but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
91
 // but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
92
 
92
 
93
 /// Read a pin wrapper
93
 /// Read a pin wrapper
112
 #define SET_PWM(IO)           SET_OUTPUT(IO)
112
 #define SET_PWM(IO)           SET_OUTPUT(IO)
113
 
113
 
114
 /// check if pin is an input wrapper
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
 /// check if pin is an output wrapper
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
 /// check if pin is a timer (wrapper)
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
 // Shorthand
122
 // Shorthand
123
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
123
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)

+ 6
- 6
Marlin/src/HAL/HAL_LPC1768/fastio.h Parādīt failu

84
 #define _PULLDOWN(IO,V)       pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
84
 #define _PULLDOWN(IO,V)       pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
85
 
85
 
86
 /// check if pin is an input
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
 /// check if pin is an output
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
 /// check if pin is a timer
92
 /// check if pin is a timer
93
 /// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
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
 /// Read a pin wrapper
96
 /// Read a pin wrapper
97
 #define READ(IO)              _READ(IO)
97
 #define READ(IO)              _READ(IO)
115
 #define SET_PWM(IO)           SET_OUTPUT(IO)
115
 #define SET_PWM(IO)           SET_OUTPUT(IO)
116
 
116
 
117
 /// check if pin is an input wrapper
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
 /// check if pin is an output wrapper
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
 /// check if pin is a timer (wrapper)
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
 // Shorthand
125
 // Shorthand
126
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
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 Parādīt failu

78
 #define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
78
 #define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
79
 #define SET_PWM(IO)             _SET_MODE(IO, PWM)
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
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
86
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
87
 
87
 
88
 // digitalRead/Write wrappers
88
 // digitalRead/Write wrappers

+ 4
- 4
Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h Parādīt failu

45
 #define SET_OUTPUT(IO)        OUT_WRITE(IO, LOW)
45
 #define SET_OUTPUT(IO)        OUT_WRITE(IO, LOW)
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)
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
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
53
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
54
 
54
 
55
 // digitalRead/Write wrappers
55
 // digitalRead/Write wrappers

+ 3
- 3
Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h Parādīt failu

48
 
48
 
49
 #define TOGGLE(IO)              OUT_WRITE(IO, !READ(IO))
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
 #define PWM_PIN(P)              true
55
 #define PWM_PIN(P)              true
56
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
56
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)

+ 3
- 3
Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h Parādīt failu

47
 
47
 
48
 #define TOGGLE(IO)              OUT_WRITE(IO, !READ(IO))
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
 #define PWM_PIN(P)              true
54
 #define PWM_PIN(P)              true
55
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
55
 #define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)

+ 4
- 4
Marlin/src/HAL/HAL_TEENSY31_32/fastio_Teensy.h Parādīt failu

67
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
67
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
68
 }while(0)
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
 #define READ(IO)              _READ(IO)
73
 #define READ(IO)              _READ(IO)
74
 
74
 
81
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
81
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
82
 #define SET_PWM(IO)            SET_OUTPUT(IO)
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
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
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 Parādīt failu

66
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
66
   GPIO_BITBAND(CORE_PIN ## P ## _DDRREG , CORE_PIN ## P ## _BIT) = 0; \
67
 }while(0)
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
 #define READ(IO)              _READ(IO)
72
 #define READ(IO)              _READ(IO)
73
 
73
 
80
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
80
 #define SET_OUTPUT(IO)        _SET_OUTPUT(IO)
81
 #define SET_PWM(IO)            SET_OUTPUT(IO)
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
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
86
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
87
 
87
 

+ 4
- 4
Marlin/src/pins/pinsDebug.h Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt