Browse Source

Implement more fastio_Due macros (#11165)

Scott Lahteine 7 years ago
parent
commit
8a8eae8d97
No account linked to committer's email address
2 changed files with 17 additions and 17 deletions
  1. 3
    1
      .travis.yml
  2. 14
    16
      Marlin/src/HAL/HAL_DUE/fastio_Due.h

+ 3
- 1
.travis.yml View File

451
   - export TEST_PLATFORM="-e DUE"
451
   - export TEST_PLATFORM="-e DUE"
452
   - restore_configs
452
   - restore_configs
453
   - opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB
453
   - opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB
454
-  - opt_set S_CURVE_ACCELERATION
454
+  - opt_enable S_CURVE_ACCELERATION
455
+  - opt_set E0_AUTO_FAN_PIN 8
456
+  - opt_set EXTRUDER_AUTO_FAN_SPEED 100
455
   - update_defaults
457
   - update_defaults
456
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
458
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
457
 
459
 

+ 14
- 16
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

39
 #ifndef _FASTIO_DUE_H
39
 #ifndef _FASTIO_DUE_H
40
 #define _FASTIO_DUE_H
40
 #define _FASTIO_DUE_H
41
 
41
 
42
+#include <pins_arduino.h>
43
+
42
 /**
44
 /**
43
  * Utility functions
45
  * Utility functions
44
  */
46
  */
64
 
66
 
65
 // Write to a pin
67
 // Write to a pin
66
 #define _WRITE_VAR(IO,V) do { \
68
 #define _WRITE_VAR(IO,V) do { \
67
-  volatile Pio* port = g_APinDescription[IO].pPort; \
69
+  volatile Pio* port = digitalPinToPort(IO); \
68
   uint32_t mask = g_APinDescription[IO].ulPin; \
70
   uint32_t mask = g_APinDescription[IO].ulPin; \
69
   if (V) port->PIO_SODR = mask; \
71
   if (V) port->PIO_SODR = mask; \
70
   else port->PIO_CODR = mask; \
72
   else port->PIO_CODR = mask; \
84
 // Set pin as input
86
 // Set pin as input
85
 #define _SET_INPUT(IO) do{ \
87
 #define _SET_INPUT(IO) do{ \
86
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
88
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
87
-  PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0); \
89
+  PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, digitalPinToBitMask(IO), 0); \
88
 }while(0)
90
 }while(0)
89
 
91
 
90
 // Set pin as output
92
 // Set pin as output
91
 #define _SET_OUTPUT(IO) do{ \
93
 #define _SET_OUTPUT(IO) do{ \
92
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
94
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
93
-  PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
95
+  PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, digitalPinToBitMask(IO), g_APinDescription[IO].ulPinConfiguration); \
94
   g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
96
   g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
95
 }while(0)
97
 }while(0)
96
 
98
 
97
 // Set pin as input with pullup mode
99
 // Set pin as input with pullup mode
98
 #define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
100
 #define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
99
 
101
 
100
-// Check if pin is an input
101
-#define _GET_INPUT(IO)
102
-// Check if pin is an output
103
-#define _GET_OUTPUT(IO)
104
-// Check if pin is a timer
105
-#define _GET_TIMER(IO)
106
-
107
 // Read a pin (wrapper)
102
 // Read a pin (wrapper)
108
 #define READ(IO) _READ(IO)
103
 #define READ(IO) _READ(IO)
109
 
104
 
120
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
115
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
121
 // Set pin as output (wrapper) -  reads the pin and sets the output to that value
116
 // Set pin as output (wrapper) -  reads the pin and sets the output to that value
122
 #define SET_OUTPUT(IO) _SET_OUTPUT(IO)
117
 #define SET_OUTPUT(IO) _SET_OUTPUT(IO)
123
-// Check if pin is an input (wrapper)
124
-#define GET_INPUT(IO) _GET_INPUT(IO)
125
-// Check if pin is an output (wrapper)
126
-#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
127
 
118
 
128
-// Check if pin is a timer (wrapper)
129
-#define GET_TIMER(IO) _GET_TIMER(IO)
119
+// Check if pin is an input
120
+#define GET_INPUT(IO) !(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
121
+// Check if pin is an output
122
+#define GET_OUTPUT(IO) !!(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
123
+// Check if pin is a timer
124
+#define GET_TIMER(IO) ( \
125
+     (g_APinDescription[IO].ulPinAttribute & PIN_ATTR_TIMER) == PIN_ATTR_TIMER \
126
+  || (g_APinDescription[IO].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM \
127
+)
130
 
128
 
131
 // Shorthand
129
 // Shorthand
132
 #define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
130
 #define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }

Loading…
Cancel
Save