Browse Source

Clean up HALs / FastIO (#14082)

Giuliano Zaro 5 years ago
parent
commit
a74aad3b4a

+ 1
- 5
Marlin/src/HAL/HAL_AVR/fastio_AVR.h View File

@@ -81,9 +81,8 @@
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 _IS_INPUT(IO)        !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
84
+#define _IS_INPUT(IO)         !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
85 85
 #define _IS_OUTPUT(IO)        TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
86
-#define _HAS_TIMER(IO)        bool(DIO ## IO ## _PWM)
87 86
 
88 87
 // digitalRead/Write wrappers
89 88
 #ifdef FASTIO_EXT_START
@@ -106,7 +105,6 @@
106 105
 
107 106
 #define IS_INPUT(IO)          _IS_INPUT(IO)
108 107
 #define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
109
-#define HAS_TIMER(IO)         _HAS_TIMER(IO)
110 108
 
111 109
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
112 110
 
@@ -353,5 +351,3 @@ enum ClockSource2 : char {
353 351
 #else
354 352
   #error "unknown CPU"
355 353
 #endif
356
-
357
-#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(P))

+ 0
- 15
Marlin/src/HAL/HAL_DUE/HAL.h View File

@@ -78,14 +78,6 @@
78 78
 #undef pgm_read_word
79 79
 #define pgm_read_word(addr) (*((uint16_t*)(addr)))
80 80
 
81
-#define RST_POWER_ON   1
82
-#define RST_EXTERNAL   2
83
-#define RST_BROWN_OUT  4
84
-#define RST_WATCHDOG   8
85
-#define RST_JTAG       16
86
-#define RST_SOFTWARE   32
87
-#define RST_BACKUP     64
88
-
89 81
 typedef int8_t pin_t;
90 82
 
91 83
 #define HAL_SERVO_LIB Servo
@@ -143,13 +135,6 @@ inline void HAL_adc_init(void) {}//todo
143 135
 
144 136
 void HAL_adc_start_conversion(const uint8_t adc_pin);
145 137
 uint16_t HAL_adc_get_result(void);
146
-uint16_t HAL_getAdcReading(uint8_t chan);
147
-void HAL_startAdcConversion(uint8_t chan);
148
-uint8_t HAL_pinToAdcChannel(int pin);
149
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
150
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
151
-void HAL_enable_AdcFreerun(void);
152
-//void HAL_disable_AdcFreerun(uint8_t chan);
153 138
 
154 139
 //
155 140
 // Pin Map

+ 0
- 3
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

@@ -46,7 +46,6 @@
46 46
 // Due has 12 PWMs assigned to logical pins 2-13.
47 47
 // 6, 7, 8 & 9 come from the PWM controller. The others come from the timers.
48 48
 #define PWM_PIN(P)              WITHIN(P, 2, 13)
49
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
50 49
 
51 50
 #ifndef MASK
52 51
   #define MASK(PIN) (1 << PIN)
@@ -180,8 +179,6 @@
180 179
 #define IS_INPUT(IO)         ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
181 180
 // Check if pin is an output
182 181
 #define IS_OUTPUT(IO)        ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
183
-// Check if pin is a timer - Must be a constexpr
184
-#define HAS_TIMER(IO)         ((IO) >= 2 && (IO) <= 13)
185 182
 
186 183
 // Shorthand
187 184
 #define OUT_WRITE(IO,V)       { SET_OUTPUT(IO); WRITE(IO,V); }

+ 0
- 1
Marlin/src/HAL/HAL_ESP32/fastio_ESP32.h View File

@@ -67,7 +67,6 @@
67 67
 
68 68
 // PWM outputs
69 69
 #define PWM_PIN(P)              (P < 34) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
70
-#define USEABLE_HARDWARE_PWM(P) (!IS_I2S_EXPANDER_PIN(P) && PWM_PIN(P))
71 70
 
72 71
 // Toggle pin value
73 72
 #define TOGGLE(IO)              WRITE(IO, !READ(IO))

+ 0
- 15
Marlin/src/HAL/HAL_LINUX/fastio.h View File

@@ -80,16 +80,6 @@
80 80
 /// check if pin is an output
81 81
 #define _IS_OUTPUT(IO)        (LPC1768_PIN_PIN(IO) >= 0)
82 82
 
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
85
-// hg42: instead use PWM bit from the #define
86
-
87
-/// check if pin is a timer
88
-#define _HAS_TIMER(IO)        true  // could be LPC1768_PIN_PWM(IO), but there
89
-// hg42: could be this:
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)
92
-
93 83
 /// Read a pin wrapper
94 84
 #define READ(IO)             _READ(IO)
95 85
 
@@ -116,14 +106,9 @@
116 106
 /// check if pin is an output wrapper
117 107
 #define IS_OUTPUT(IO)        _IS_OUTPUT(IO)
118 108
 
119
-/// check if pin is a timer (wrapper)
120
-#define HAS_TIMER(IO)        _HAS_TIMER(IO)
121
-
122 109
 // Shorthand
123 110
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
124 111
 
125 112
 // digitalRead/Write wrappers
126 113
 #define extDigitalRead(IO)    digitalRead(IO)
127 114
 #define extDigitalWrite(IO,V) digitalWrite(IO,V)
128
-
129
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)

+ 0
- 5
Marlin/src/HAL/HAL_LINUX/watchdog.h View File

@@ -21,11 +21,6 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#define RST_POWER_ON   1
25
-#define RST_EXTERNAL   2
26
-#define RST_BROWN_OUT  4
27
-#define RST_WATCHDOG   8
28
-
29 24
 #define WDT_TIMEOUT   4000000 // 4 second timeout
30 25
 
31 26
 void watchdog_init(void);

+ 1
- 9
Marlin/src/HAL/HAL_LPC1768/fastio.h View File

@@ -35,8 +35,7 @@
35 35
 
36 36
 #include "../shared/Marduino.h"
37 37
 
38
-#define PWM_PIN(P)              true // all pins are PWM capable
39
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
38
+#define PWM_PIN(P)            true // all pins are PWM capable
40 39
 
41 40
 #define LPC_PIN(pin)          gpio_pin(pin)
42 41
 #define LPC_GPIO(port)        gpio_port(port)
@@ -89,10 +88,6 @@
89 88
 /// check if pin is an output
90 89
 #define _IS_OUTPUT(IO)        (gpio_get_dir(IO))
91 90
 
92
-/// check if pin is a timer
93
-/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
94
-#define _HAS_TIMER(IO)        true
95
-
96 91
 /// Read a pin wrapper
97 92
 #define READ(IO)              _READ(IO)
98 93
 
@@ -119,9 +114,6 @@
119 114
 /// check if pin is an output wrapper
120 115
 #define IS_OUTPUT(IO)         _IS_OUTPUT(IO)
121 116
 
122
-/// check if pin is a timer (wrapper)
123
-#define HAS_TIMER(IO)         _HAS_TIMER(IO)
124
-
125 117
 // Shorthand
126 118
 #define OUT_WRITE(IO,V)       do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
127 119
 

+ 0
- 5
Marlin/src/HAL/HAL_LPC1768/watchdog.h View File

@@ -21,11 +21,6 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#define RST_POWER_ON   1
25
-#define RST_EXTERNAL   2
26
-#define RST_BROWN_OUT  4
27
-#define RST_WATCHDOG   8
28
-
29 24
 #define WDT_TIMEOUT   4000000 // 4 second timeout
30 25
 
31 26
 void watchdog_init(void);

+ 0
- 8
Marlin/src/HAL/HAL_STM32/HAL.h View File

@@ -127,14 +127,6 @@
127 127
 #undef pgm_read_ptr
128 128
 #define pgm_read_ptr(addr) (*(addr))
129 129
 
130
-#define RST_POWER_ON   1
131
-#define RST_EXTERNAL   2
132
-#define RST_BROWN_OUT  4
133
-#define RST_WATCHDOG   8
134
-#define RST_JTAG       16
135
-#define RST_SOFTWARE   32
136
-#define RST_BACKUP     64
137
-
138 130
 // --------------------------------------------------------------------------
139 131
 // Types
140 132
 // --------------------------------------------------------------------------

+ 1
- 3
Marlin/src/HAL/HAL_STM32/fastio_STM32.h View File

@@ -80,10 +80,8 @@ void FastIO_init(); // Must be called before using fast io macros
80 80
 
81 81
 #define IS_INPUT(IO)
82 82
 #define IS_OUTPUT(IO)
83
-#define HAS_TIMER(IO)           digitalPinHasPWM(IO)
84 83
 
85
-#define PWM_PIN(P)              HAS_TIMER(P)
86
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
84
+#define PWM_PIN(P)              digitalPinHasPWM(P)
87 85
 
88 86
 // digitalRead/Write wrappers
89 87
 #define extDigitalRead(IO)    digitalRead(IO)

+ 0
- 15
Marlin/src/HAL/HAL_STM32F1/HAL.h View File

@@ -253,23 +253,8 @@ void HAL_adc_init(void);
253 253
 #define HAL_ADC_READY()     true
254 254
 
255 255
 void HAL_adc_start_conversion(const uint8_t adc_pin);
256
-
257 256
 uint16_t HAL_adc_get_result(void);
258 257
 
259
-/* Todo: Confirm none of this is needed.
260
-uint16_t HAL_getAdcReading(uint8_t chan);
261
-
262
-void HAL_startAdcConversion(uint8_t chan);
263
-uint8_t HAL_pinToAdcChannel(int pin);
264
-
265
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
266
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
267
-
268
-void HAL_enable_AdcFreerun(void);
269
-//void HAL_disable_AdcFreerun(uint8_t chan);
270
-
271
-*/
272
-
273 258
 #define GET_PIN_MAP_PIN(index) index
274 259
 #define GET_PIN_MAP_INDEX(pin) pin
275 260
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

+ 1
- 3
Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h View File

@@ -50,10 +50,8 @@
50 50
 
51 51
 #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)
52 52
 #define IS_OUTPUT(IO)         (_GET_MODE(IO) == GPIO_OUTPUT_PP)
53
-#define HAS_TIMER(IO)         (PIN_MAP[IO].timer_device != nullptr)
54 53
 
55
-#define PWM_PIN(P)              HAS_TIMER(P)
56
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
54
+#define PWM_PIN(P)            (PIN_MAP[IO].timer_device != nullptr)
57 55
 
58 56
 // digitalRead/Write wrappers
59 57
 #define extDigitalRead(IO)    digitalRead(IO)

+ 0
- 23
Marlin/src/HAL/HAL_STM32F4/HAL.h View File

@@ -136,14 +136,6 @@
136 136
 #undef pgm_read_ptr
137 137
 #define pgm_read_ptr(addr) (*(addr))
138 138
 
139
-#define RST_POWER_ON   1
140
-#define RST_EXTERNAL   2
141
-#define RST_BROWN_OUT  4
142
-#define RST_WATCHDOG   8
143
-#define RST_JTAG       16
144
-#define RST_SOFTWARE   32
145
-#define RST_BACKUP     64
146
-
147 139
 // --------------------------------------------------------------------------
148 140
 // Types
149 141
 // --------------------------------------------------------------------------
@@ -232,23 +224,8 @@ inline void HAL_adc_init(void) {}
232 224
 #define HAL_ADC_READY()     true
233 225
 
234 226
 void HAL_adc_start_conversion(const uint8_t adc_pin);
235
-
236 227
 uint16_t HAL_adc_get_result(void);
237 228
 
238
-/* Todo: Confirm none of this is needed.
239
-uint16_t HAL_getAdcReading(uint8_t chan);
240
-
241
-void HAL_startAdcConversion(uint8_t chan);
242
-uint8_t HAL_pinToAdcChannel(int pin);
243
-
244
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
245
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
246
-
247
-void HAL_enable_AdcFreerun(void);
248
-//void HAL_disable_AdcFreerun(uint8_t chan);
249
-
250
-*/
251
-
252 229
 #define GET_PIN_MAP_PIN(index) index
253 230
 #define GET_PIN_MAP_INDEX(pin) pin
254 231
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

+ 1
- 3
Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h View File

@@ -50,10 +50,8 @@
50 50
 
51 51
 #define IS_INPUT(IO)
52 52
 #define IS_OUTPUT(IO)
53
-#define HAS_TIMER(IO)           true
54 53
 
55
-#define PWM_PIN(P)              HAS_TIMER(P)
56
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
54
+#define PWM_PIN(P)              true
57 55
 
58 56
 // digitalRead/Write wrappers
59 57
 #define extDigitalRead(IO)    digitalRead(IO)

+ 0
- 23
Marlin/src/HAL/HAL_STM32F7/HAL.h View File

@@ -125,14 +125,6 @@
125 125
 #undef pgm_read_ptr
126 126
 #define pgm_read_ptr(addr) (*(addr))
127 127
 
128
-#define RST_POWER_ON   1
129
-#define RST_EXTERNAL   2
130
-#define RST_BROWN_OUT  4
131
-#define RST_WATCHDOG   8
132
-#define RST_JTAG       16
133
-#define RST_SOFTWARE   32
134
-#define RST_BACKUP     64
135
-
136 128
 // --------------------------------------------------------------------------
137 129
 // Types
138 130
 // --------------------------------------------------------------------------
@@ -211,23 +203,8 @@ inline void HAL_adc_init(void) {}
211 203
 #define HAL_ADC_READY()     true
212 204
 
213 205
 void HAL_adc_start_conversion(const uint8_t adc_pin);
214
-
215 206
 uint16_t HAL_adc_get_result(void);
216 207
 
217
-/* Todo: Confirm none of this is needed.
218
-uint16_t HAL_getAdcReading(uint8_t chan);
219
-
220
-void HAL_startAdcConversion(uint8_t chan);
221
-uint8_t HAL_pinToAdcChannel(int pin);
222
-
223
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
224
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
225
-
226
-void HAL_enable_AdcFreerun(void);
227
-//void HAL_disable_AdcFreerun(uint8_t chan);
228
-
229
-*/
230
-
231 208
 #define GET_PIN_MAP_PIN(index) index
232 209
 #define GET_PIN_MAP_INDEX(pin) pin
233 210
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

+ 1
- 3
Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h View File

@@ -49,10 +49,8 @@
49 49
 
50 50
 #define IS_INPUT(IO)
51 51
 #define IS_OUTPUT(IO)
52
-#define HAS_TIMER(IO)           true
53 52
 
54
-#define PWM_PIN(P)              HAS_TIMER(P)
55
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
53
+#define PWM_PIN(P)              true
56 54
 
57 55
 // digitalRead/Write wrappers
58 56
 #define extDigitalRead(IO)    digitalRead(IO)

+ 1
- 23
Marlin/src/HAL/HAL_TEENSY31_32/HAL.h View File

@@ -89,14 +89,6 @@ typedef int8_t pin_t;
89 89
 #undef pgm_read_word
90 90
 #define pgm_read_word(addr) (*((uint16_t*)(addr)))
91 91
 
92
-#define RST_POWER_ON   1
93
-#define RST_EXTERNAL   2
94
-#define RST_BROWN_OUT  4
95
-#define RST_WATCHDOG   8
96
-#define RST_JTAG       16
97
-#define RST_SOFTWARE   32
98
-#define RST_BACKUP     64
99
-
100 92
 // Clear the reset reason
101 93
 void HAL_clear_reset_source(void);
102 94
 
@@ -128,25 +120,11 @@ void HAL_adc_init();
128 120
 #define HAL_READ_ADC()      HAL_adc_get_result()
129 121
 #define HAL_ADC_READY()     true
130 122
 
131
-#define HAL_ANALOG_SELECT(pin) NOOP;
123
+#define HAL_ANALOG_SELECT(pin)
132 124
 
133 125
 void HAL_adc_start_conversion(const uint8_t adc_pin);
134
-
135 126
 uint16_t HAL_adc_get_result(void);
136 127
 
137
-/*
138
-uint16_t HAL_getAdcReading(uint8_t chan);
139
-
140
-void HAL_startAdcConversion(uint8_t chan);
141
-uint8_t HAL_pinToAdcChannel(int pin);
142
-
143
-uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
144
-//uint16_t HAL_getAdcSuperSample(uint8_t chan);
145
-
146
-void HAL_enable_AdcFreerun(void);
147
-//void HAL_disable_AdcFreerun(uint8_t chan);
148
-*/
149
-
150 128
 #define GET_PIN_MAP_PIN(index) index
151 129
 #define GET_PIN_MAP_INDEX(pin) pin
152 130
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

+ 0
- 1
Marlin/src/HAL/HAL_TEENSY31_32/fastio_Teensy.h View File

@@ -91,7 +91,6 @@
91 91
 #define extDigitalWrite(IO,V) digitalWrite(IO,V)
92 92
 
93 93
 #define PWM_PIN(P)            digitalPinHasPWM(P)
94
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
95 94
 
96 95
 /**
97 96
  * Ports, functions, and pins

+ 1
- 23
Marlin/src/HAL/HAL_TEENSY35_36/HAL.h View File

@@ -97,14 +97,6 @@ typedef int8_t pin_t;
97 97
 #undef pgm_read_word
98 98
 #define pgm_read_word(addr) (*((uint16_t*)(addr)))
99 99
 
100
-#define RST_POWER_ON   1
101
-#define RST_EXTERNAL   2
102
-#define RST_BROWN_OUT  4
103
-#define RST_WATCHDOG   8
104
-#define RST_JTAG       16
105
-#define RST_SOFTWARE   32
106
-#define RST_BACKUP     64
107
-
108 100
 /** clear reset reason */
109 101
 void HAL_clear_reset_source(void);
110 102
 
@@ -133,25 +125,11 @@ void HAL_adc_init();
133 125
 #define HAL_READ_ADC()      HAL_adc_get_result()
134 126
 #define HAL_ADC_READY()     true
135 127
 
136
-#define HAL_ANALOG_SELECT(pin) NOOP;
128
+#define HAL_ANALOG_SELECT(pin)
137 129
 
138 130
 void HAL_adc_start_conversion(const uint8_t adc_pin);
139
-
140 131
 uint16_t HAL_adc_get_result(void);
141 132
 
142
-/*
143
-  uint16_t HAL_getAdcReading(uint8_t chan);
144
-
145
-  void HAL_startAdcConversion(uint8_t chan);
146
-  uint8_t HAL_pinToAdcChannel(int pin);
147
-
148
-  uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
149
-  //uint16_t HAL_getAdcSuperSample(uint8_t chan);
150
-
151
-  void HAL_enable_AdcFreerun(void);
152
-  //void HAL_disable_AdcFreerun(uint8_t chan);
153
-*/
154
-
155 133
 #define GET_PIN_MAP_PIN(index) index
156 134
 #define GET_PIN_MAP_INDEX(pin) pin
157 135
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)

+ 0
- 1
Marlin/src/HAL/HAL_TEENSY35_36/fastio_Teensy.h View File

@@ -90,7 +90,6 @@
90 90
 #define extDigitalWrite(IO,V) digitalWrite(IO,V)
91 91
 
92 92
 #define PWM_PIN(P)            digitalPinHasPWM(P)
93
-#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
94 93
 
95 94
 /**
96 95
  * Ports, functions, and pins

+ 9
- 0
Marlin/src/HAL/shared/Marduino.h View File

@@ -55,3 +55,12 @@
55 55
     //#define strchr_P(s,c) strchr(s,c)
56 56
   #endif
57 57
 #endif
58
+
59
+// Restart causes
60
+#define RST_POWER_ON    1
61
+#define RST_EXTERNAL    2
62
+#define RST_BROWN_OUT   4
63
+#define RST_WATCHDOG    8
64
+#define RST_JTAG       16
65
+#define RST_SOFTWARE   32
66
+#define RST_BACKUP     64

Loading…
Cancel
Save