@@ -223,6 +223,65 @@ void st_wake_up()
223223 // Initialize stepper output bits to ensure first ISR call does not step.
224224 st .step_outbits = step_port_invert_mask ;
225225
226+ // Set any ports configured as open drain here
227+ // https://sites.google.com/site/johnkneenmicrocontrollers/input_output/io_1768
228+ // https://sites.google.com/site/johnkneenmicrocontrollers/18b-i2c/i2c_lpc1768#linkC1768
229+ #ifdef OPEN_DRAIN_X
230+ LPC_PINCON -> PINMODE_OD2 |= 1 <<0 ; // Bit P2.0 is open drain Step
231+ LPC_PINCON -> PINMODE4 &= ~(3 <<0 );
232+ LPC_PINCON -> PINMODE4 |= (2 <<0 ); // P2.0 has no pull up/down resistor
233+
234+ LPC_PINCON -> PINMODE_OD0 |= 1 <<5 ; // Bit P0.5 is open drain Dir
235+ LPC_PINCON -> PINMODE0 &= ~(3 <<10 );
236+ LPC_PINCON -> PINMODE0 |= (2 <<10 ); // P0.5 has no pull up/down resistor
237+
238+ LPC_PINCON -> PINMODE_OD0 |= 1 <<4 ; // Bit P0.4 is open drain Enable
239+ LPC_PINCON -> PINMODE0 &= ~(3 <<8 );
240+ LPC_PINCON -> PINMODE0 |= (2 <<8 ); // P0.4 has no pull up/down resistor
241+ #endif
242+
243+ #ifdef OPEN_DRAIN_Y
244+ LPC_PINCON -> PINMODE_OD2 |= 1 <<1 ; // Bit P2.1 is open drain Step
245+ LPC_PINCON -> PINMODE4 &= ~(3 <<2 );
246+ LPC_PINCON -> PINMODE4 |= (2 <<2 ); // P2.1 has no pull up/down resistor
247+
248+ LPC_PINCON -> PINMODE_OD0 |= 1 <<11 ; // Bit P0.11 is open drain Dir
249+ LPC_PINCON -> PINMODE0 &= ~(3 <<22 );
250+ LPC_PINCON -> PINMODE0 |= (2 <<22 ); // P0.11 has no pull up/down resistor
251+
252+ LPC_PINCON -> PINMODE_OD0 |= 1 <<10 ; // Bit P0.10 is open drain Enable
253+ LPC_PINCON -> PINMODE0 &= ~(3 <<20 );
254+ LPC_PINCON -> PINMODE0 |= (2 <<20 ); // P0.10 has no pull up/down resistor
255+ #endif
256+
257+ #ifdef OPEN_DRAIN_Z
258+ LPC_PINCON -> PINMODE_OD2 |= 1 <<2 ; // Bit P2.2 is open drain Step
259+ LPC_PINCON -> PINMODE4 &= ~(3 <<4 );
260+ LPC_PINCON -> PINMODE4 |= (2 <<4 ); // P2.2 has no pull up/down resistor
261+
262+ LPC_PINCON -> PINMODE_OD0 |= 1 <<20 ; // Bit P0.20 is open drain Dir
263+ LPC_PINCON -> PINMODE1 &= ~(3 <<8 );
264+ LPC_PINCON -> PINMODE1 |= (2 <<8 ); // P0.20 has no pull up/down resistor
265+
266+ LPC_PINCON -> PINMODE_OD0 |= 1 <<19 ; // Bit P0.19 is open drain Enable
267+ LPC_PINCON -> PINMODE1 &= ~(3 <<6 );
268+ LPC_PINCON -> PINMODE1 |= (2 <<6 ); // P0.19 has no pull up/down resistor
269+ #endif
270+
271+ #ifdef OPEN_DRAIN_A
272+ LPC_PINCON -> PINMODE_OD2 |= 1 <<3 ; // Bit P2.3 is open drain Step
273+ LPC_PINCON -> PINMODE4 &= ~(3 <<6 );
274+ LPC_PINCON -> PINMODE4 |= (2 <<6 ); // P2.2 has no pull up/down resistor
275+
276+ LPC_PINCON -> PINMODE_OD0 |= 1 <<22 ; // Bit P0.22 is open drain Dir
277+ LPC_PINCON -> PINMODE1 &= ~(3 <<12 );
278+ LPC_PINCON -> PINMODE1 |= (2 <<12 ); // P0.22 has no pull up/down resistor
279+
280+ LPC_PINCON -> PINMODE_OD0 |= 1 <<21 ; // Bit P0.21 is open drain Enable
281+ LPC_PINCON -> PINMODE1 &= ~(3 <<10 );
282+ LPC_PINCON -> PINMODE1 |= (2 <<10 ); // P0.21 has no pull up/down resistor
283+ #endif
284+
226285 // Initialize step pulse timing from settings. Here to ensure updating after re-writing.
227286 #ifdef STEP_PULSE_DELAY
228287 // Set total step pulse time after direction pin set. Ad hoc computation from oscilloscope.
0 commit comments