ARM: bring in pinio.c.
This enables pinio_init(), power_on() and power_off(). Now one can turn on the power supply with M119 and turn it off with M2. Code changes were neccessary. Setting a pin first, then making it an output doesn't work on ARM. A pin has to be an output before it permanently accepts a given state. As I was never sure the former strategy actually worked on AVR, the order of these two steps was changed for both, AVR and ARM.
This commit is contained in:
parent
96f7dbd2b1
commit
4faa3cbf8f
|
|
@ -98,7 +98,7 @@ TARGET = $(PROGRAM).hex
|
|||
# Until the generic ARM port is completed, we'd have to wrap all sources
|
||||
# in #ifdef __AVR__. To avoid this, build only a selection for now:
|
||||
SOURCES = mendel.c cpu.c serial.c sermsg.c sersendf.c delay.c
|
||||
SOURCES += gcode_parse.c gcode_process.c
|
||||
SOURCES += gcode_parse.c gcode_process.c pinio.c
|
||||
ifeq ($(MCU), lpc1114)
|
||||
SOURCES += cmsis-system_lpc11xx.c
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -385,8 +385,8 @@ void process_gcode_command() {
|
|||
queue_wait();
|
||||
for (i = 0; i < NUM_HEATERS; i++)
|
||||
temp_set(i, 0);
|
||||
power_off();
|
||||
#endif /* __ARMEL_NOTYET__ */
|
||||
power_off();
|
||||
serial_writestr_P(PSTR("\nstop\n"));
|
||||
break;
|
||||
|
||||
|
|
@ -627,8 +627,10 @@ void process_gcode_command() {
|
|||
#ifndef __ARMEL_NOTYET__
|
||||
timer_stop();
|
||||
queue_flush();
|
||||
#endif /* __ARMEL_NOTYET__ */
|
||||
power_off();
|
||||
cli();
|
||||
#ifndef __ARMEL_NOTYET__
|
||||
for (;;)
|
||||
wd_reset();
|
||||
#endif /* __ARMEL_NOTYET__ */
|
||||
|
|
@ -708,9 +710,7 @@ void process_gcode_command() {
|
|||
//? --- M119: report endstop status ---
|
||||
//? Report the current status of the endstops configured in the
|
||||
//? firmware to the host.
|
||||
#ifndef __ARMEL_NOTYET__
|
||||
power_on();
|
||||
#endif /* __ARMEL_NOTYET__ */
|
||||
endstops_on();
|
||||
delay_ms(10); // allow the signal to stabilize
|
||||
{
|
||||
|
|
|
|||
2
mendel.c
2
mendel.c
|
|
@ -87,10 +87,10 @@ void init(void) {
|
|||
// set up G-code parsing
|
||||
gcode_init();
|
||||
|
||||
#ifndef __ARMEL_NOTYET__
|
||||
// set up inputs and outputs
|
||||
pinio_init();
|
||||
|
||||
#ifndef __ARMEL_NOTYET__
|
||||
#if defined TEMP_MAX6675 || defined SD
|
||||
spi_init();
|
||||
#endif
|
||||
|
|
|
|||
30
pinio.c
30
pinio.c
|
|
@ -12,8 +12,8 @@ volatile uint8_t psu_timeout = 0;
|
|||
*/
|
||||
void pinio_init(void) {
|
||||
/// X Stepper.
|
||||
WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN);
|
||||
WRITE(X_DIR_PIN, 0); SET_OUTPUT(X_DIR_PIN);
|
||||
SET_OUTPUT(X_STEP_PIN); WRITE(X_STEP_PIN, 0);
|
||||
SET_OUTPUT(X_DIR_PIN); WRITE(X_DIR_PIN, 0);
|
||||
#ifdef X_MIN_PIN
|
||||
SET_INPUT(X_MIN_PIN);
|
||||
PULLUP_OFF(X_MIN_PIN);
|
||||
|
|
@ -24,8 +24,8 @@ void pinio_init(void) {
|
|||
#endif
|
||||
|
||||
/// Y Stepper.
|
||||
WRITE(Y_STEP_PIN, 0); SET_OUTPUT(Y_STEP_PIN);
|
||||
WRITE(Y_DIR_PIN, 0); SET_OUTPUT(Y_DIR_PIN);
|
||||
SET_OUTPUT(Y_STEP_PIN); WRITE(Y_STEP_PIN, 0);
|
||||
SET_OUTPUT(Y_DIR_PIN); WRITE(Y_DIR_PIN, 0);
|
||||
#ifdef Y_MIN_PIN
|
||||
SET_INPUT(Y_MIN_PIN);
|
||||
PULLUP_OFF(Y_MIN_PIN);
|
||||
|
|
@ -37,8 +37,8 @@ void pinio_init(void) {
|
|||
|
||||
/// Z Stepper.
|
||||
#if defined Z_STEP_PIN && defined Z_DIR_PIN
|
||||
WRITE(Z_STEP_PIN, 0); SET_OUTPUT(Z_STEP_PIN);
|
||||
WRITE(Z_DIR_PIN, 0); SET_OUTPUT(Z_DIR_PIN);
|
||||
SET_OUTPUT(Z_STEP_PIN); WRITE(Z_STEP_PIN, 0);
|
||||
SET_OUTPUT(Z_DIR_PIN); WRITE(Z_DIR_PIN, 0);
|
||||
#endif
|
||||
#ifdef Z_MIN_PIN
|
||||
SET_INPUT(Z_MIN_PIN);
|
||||
|
|
@ -50,58 +50,58 @@ void pinio_init(void) {
|
|||
#endif
|
||||
|
||||
#if defined E_STEP_PIN && defined E_DIR_PIN
|
||||
WRITE(E_STEP_PIN, 0); SET_OUTPUT(E_STEP_PIN);
|
||||
WRITE(E_DIR_PIN, 0); SET_OUTPUT(E_DIR_PIN);
|
||||
SET_OUTPUT(E_STEP_PIN); WRITE(E_STEP_PIN, 0);
|
||||
SET_OUTPUT(E_DIR_PIN); WRITE(E_DIR_PIN, 0);
|
||||
#endif
|
||||
|
||||
/// Common Stepper Enable.
|
||||
#ifdef STEPPER_ENABLE_PIN
|
||||
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||
#ifdef STEPPER_INVERT_ENABLE
|
||||
WRITE(STEPPER_ENABLE_PIN, 0);
|
||||
#else
|
||||
WRITE(STEPPER_ENABLE_PIN, 1);
|
||||
#endif
|
||||
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
/// X Stepper Enable.
|
||||
#ifdef X_ENABLE_PIN
|
||||
SET_OUTPUT(X_ENABLE_PIN);
|
||||
#ifdef X_INVERT_ENABLE
|
||||
WRITE(X_ENABLE_PIN, 0);
|
||||
#else
|
||||
WRITE(X_ENABLE_PIN, 1);
|
||||
#endif
|
||||
SET_OUTPUT(X_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
/// Y Stepper Enable.
|
||||
#ifdef Y_ENABLE_PIN
|
||||
SET_OUTPUT(Y_ENABLE_PIN);
|
||||
#ifdef Y_INVERT_ENABLE
|
||||
WRITE(Y_ENABLE_PIN, 0);
|
||||
#else
|
||||
WRITE(Y_ENABLE_PIN, 1);
|
||||
#endif
|
||||
SET_OUTPUT(Y_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
/// Z Stepper Enable.
|
||||
#ifdef Z_ENABLE_PIN
|
||||
SET_OUTPUT(Z_ENABLE_PIN);
|
||||
#ifdef Z_INVERT_ENABLE
|
||||
WRITE(Z_ENABLE_PIN, 0);
|
||||
#else
|
||||
WRITE(Z_ENABLE_PIN, 1);
|
||||
#endif
|
||||
SET_OUTPUT(Z_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
/// E Stepper Enable.
|
||||
#ifdef E_ENABLE_PIN
|
||||
SET_OUTPUT(E_ENABLE_PIN);
|
||||
#ifdef E_INVERT_ENABLE
|
||||
WRITE(E_ENABLE_PIN, 0);
|
||||
#else
|
||||
WRITE(E_ENABLE_PIN, 1);
|
||||
#endif
|
||||
SET_OUTPUT(E_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
#ifdef STEPPER_ENABLE_PIN
|
||||
|
|
@ -109,8 +109,8 @@ void pinio_init(void) {
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG_LED_PIN
|
||||
WRITE(DEBUG_LED_PIN, 0);
|
||||
SET_OUTPUT(DEBUG_LED_PIN);
|
||||
WRITE(DEBUG_LED_PIN, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +118,8 @@ void power_on() {
|
|||
|
||||
if (ps_is_on == 0) {
|
||||
#ifdef PS_ON_PIN
|
||||
SET_OUTPUT(PS_ON_PIN);
|
||||
WRITE(PS_ON_PIN, 0);
|
||||
SET_OUTPUT(PS_ON_PIN);
|
||||
delay_ms(500);
|
||||
#endif
|
||||
#ifdef PS_MOSFET_PIN
|
||||
|
|
|
|||
Loading…
Reference in New Issue