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
|
# 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:
|
# 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 = 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)
|
ifeq ($(MCU), lpc1114)
|
||||||
SOURCES += cmsis-system_lpc11xx.c
|
SOURCES += cmsis-system_lpc11xx.c
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -385,8 +385,8 @@ void process_gcode_command() {
|
||||||
queue_wait();
|
queue_wait();
|
||||||
for (i = 0; i < NUM_HEATERS; i++)
|
for (i = 0; i < NUM_HEATERS; i++)
|
||||||
temp_set(i, 0);
|
temp_set(i, 0);
|
||||||
power_off();
|
|
||||||
#endif /* __ARMEL_NOTYET__ */
|
#endif /* __ARMEL_NOTYET__ */
|
||||||
|
power_off();
|
||||||
serial_writestr_P(PSTR("\nstop\n"));
|
serial_writestr_P(PSTR("\nstop\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -627,8 +627,10 @@ void process_gcode_command() {
|
||||||
#ifndef __ARMEL_NOTYET__
|
#ifndef __ARMEL_NOTYET__
|
||||||
timer_stop();
|
timer_stop();
|
||||||
queue_flush();
|
queue_flush();
|
||||||
|
#endif /* __ARMEL_NOTYET__ */
|
||||||
power_off();
|
power_off();
|
||||||
cli();
|
cli();
|
||||||
|
#ifndef __ARMEL_NOTYET__
|
||||||
for (;;)
|
for (;;)
|
||||||
wd_reset();
|
wd_reset();
|
||||||
#endif /* __ARMEL_NOTYET__ */
|
#endif /* __ARMEL_NOTYET__ */
|
||||||
|
|
@ -708,9 +710,7 @@ void process_gcode_command() {
|
||||||
//? --- M119: report endstop status ---
|
//? --- M119: report endstop status ---
|
||||||
//? Report the current status of the endstops configured in the
|
//? Report the current status of the endstops configured in the
|
||||||
//? firmware to the host.
|
//? firmware to the host.
|
||||||
#ifndef __ARMEL_NOTYET__
|
|
||||||
power_on();
|
power_on();
|
||||||
#endif /* __ARMEL_NOTYET__ */
|
|
||||||
endstops_on();
|
endstops_on();
|
||||||
delay_ms(10); // allow the signal to stabilize
|
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
|
// set up G-code parsing
|
||||||
gcode_init();
|
gcode_init();
|
||||||
|
|
||||||
#ifndef __ARMEL_NOTYET__
|
|
||||||
// set up inputs and outputs
|
// set up inputs and outputs
|
||||||
pinio_init();
|
pinio_init();
|
||||||
|
|
||||||
|
#ifndef __ARMEL_NOTYET__
|
||||||
#if defined TEMP_MAX6675 || defined SD
|
#if defined TEMP_MAX6675 || defined SD
|
||||||
spi_init();
|
spi_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
30
pinio.c
30
pinio.c
|
|
@ -12,8 +12,8 @@ volatile uint8_t psu_timeout = 0;
|
||||||
*/
|
*/
|
||||||
void pinio_init(void) {
|
void pinio_init(void) {
|
||||||
/// X Stepper.
|
/// X Stepper.
|
||||||
WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN);
|
SET_OUTPUT(X_STEP_PIN); WRITE(X_STEP_PIN, 0);
|
||||||
WRITE(X_DIR_PIN, 0); SET_OUTPUT(X_DIR_PIN);
|
SET_OUTPUT(X_DIR_PIN); WRITE(X_DIR_PIN, 0);
|
||||||
#ifdef X_MIN_PIN
|
#ifdef X_MIN_PIN
|
||||||
SET_INPUT(X_MIN_PIN);
|
SET_INPUT(X_MIN_PIN);
|
||||||
PULLUP_OFF(X_MIN_PIN);
|
PULLUP_OFF(X_MIN_PIN);
|
||||||
|
|
@ -24,8 +24,8 @@ void pinio_init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Y Stepper.
|
/// Y Stepper.
|
||||||
WRITE(Y_STEP_PIN, 0); SET_OUTPUT(Y_STEP_PIN);
|
SET_OUTPUT(Y_STEP_PIN); WRITE(Y_STEP_PIN, 0);
|
||||||
WRITE(Y_DIR_PIN, 0); SET_OUTPUT(Y_DIR_PIN);
|
SET_OUTPUT(Y_DIR_PIN); WRITE(Y_DIR_PIN, 0);
|
||||||
#ifdef Y_MIN_PIN
|
#ifdef Y_MIN_PIN
|
||||||
SET_INPUT(Y_MIN_PIN);
|
SET_INPUT(Y_MIN_PIN);
|
||||||
PULLUP_OFF(Y_MIN_PIN);
|
PULLUP_OFF(Y_MIN_PIN);
|
||||||
|
|
@ -37,8 +37,8 @@ void pinio_init(void) {
|
||||||
|
|
||||||
/// Z Stepper.
|
/// Z Stepper.
|
||||||
#if defined Z_STEP_PIN && defined Z_DIR_PIN
|
#if defined Z_STEP_PIN && defined Z_DIR_PIN
|
||||||
WRITE(Z_STEP_PIN, 0); SET_OUTPUT(Z_STEP_PIN);
|
SET_OUTPUT(Z_STEP_PIN); WRITE(Z_STEP_PIN, 0);
|
||||||
WRITE(Z_DIR_PIN, 0); SET_OUTPUT(Z_DIR_PIN);
|
SET_OUTPUT(Z_DIR_PIN); WRITE(Z_DIR_PIN, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Z_MIN_PIN
|
#ifdef Z_MIN_PIN
|
||||||
SET_INPUT(Z_MIN_PIN);
|
SET_INPUT(Z_MIN_PIN);
|
||||||
|
|
@ -50,58 +50,58 @@ void pinio_init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined E_STEP_PIN && defined E_DIR_PIN
|
#if defined E_STEP_PIN && defined E_DIR_PIN
|
||||||
WRITE(E_STEP_PIN, 0); SET_OUTPUT(E_STEP_PIN);
|
SET_OUTPUT(E_STEP_PIN); WRITE(E_STEP_PIN, 0);
|
||||||
WRITE(E_DIR_PIN, 0); SET_OUTPUT(E_DIR_PIN);
|
SET_OUTPUT(E_DIR_PIN); WRITE(E_DIR_PIN, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Common Stepper Enable.
|
/// Common Stepper Enable.
|
||||||
#ifdef STEPPER_ENABLE_PIN
|
#ifdef STEPPER_ENABLE_PIN
|
||||||
|
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||||
#ifdef STEPPER_INVERT_ENABLE
|
#ifdef STEPPER_INVERT_ENABLE
|
||||||
WRITE(STEPPER_ENABLE_PIN, 0);
|
WRITE(STEPPER_ENABLE_PIN, 0);
|
||||||
#else
|
#else
|
||||||
WRITE(STEPPER_ENABLE_PIN, 1);
|
WRITE(STEPPER_ENABLE_PIN, 1);
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// X Stepper Enable.
|
/// X Stepper Enable.
|
||||||
#ifdef X_ENABLE_PIN
|
#ifdef X_ENABLE_PIN
|
||||||
|
SET_OUTPUT(X_ENABLE_PIN);
|
||||||
#ifdef X_INVERT_ENABLE
|
#ifdef X_INVERT_ENABLE
|
||||||
WRITE(X_ENABLE_PIN, 0);
|
WRITE(X_ENABLE_PIN, 0);
|
||||||
#else
|
#else
|
||||||
WRITE(X_ENABLE_PIN, 1);
|
WRITE(X_ENABLE_PIN, 1);
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(X_ENABLE_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Y Stepper Enable.
|
/// Y Stepper Enable.
|
||||||
#ifdef Y_ENABLE_PIN
|
#ifdef Y_ENABLE_PIN
|
||||||
|
SET_OUTPUT(Y_ENABLE_PIN);
|
||||||
#ifdef Y_INVERT_ENABLE
|
#ifdef Y_INVERT_ENABLE
|
||||||
WRITE(Y_ENABLE_PIN, 0);
|
WRITE(Y_ENABLE_PIN, 0);
|
||||||
#else
|
#else
|
||||||
WRITE(Y_ENABLE_PIN, 1);
|
WRITE(Y_ENABLE_PIN, 1);
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(Y_ENABLE_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Z Stepper Enable.
|
/// Z Stepper Enable.
|
||||||
#ifdef Z_ENABLE_PIN
|
#ifdef Z_ENABLE_PIN
|
||||||
|
SET_OUTPUT(Z_ENABLE_PIN);
|
||||||
#ifdef Z_INVERT_ENABLE
|
#ifdef Z_INVERT_ENABLE
|
||||||
WRITE(Z_ENABLE_PIN, 0);
|
WRITE(Z_ENABLE_PIN, 0);
|
||||||
#else
|
#else
|
||||||
WRITE(Z_ENABLE_PIN, 1);
|
WRITE(Z_ENABLE_PIN, 1);
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(Z_ENABLE_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// E Stepper Enable.
|
/// E Stepper Enable.
|
||||||
#ifdef E_ENABLE_PIN
|
#ifdef E_ENABLE_PIN
|
||||||
|
SET_OUTPUT(E_ENABLE_PIN);
|
||||||
#ifdef E_INVERT_ENABLE
|
#ifdef E_INVERT_ENABLE
|
||||||
WRITE(E_ENABLE_PIN, 0);
|
WRITE(E_ENABLE_PIN, 0);
|
||||||
#else
|
#else
|
||||||
WRITE(E_ENABLE_PIN, 1);
|
WRITE(E_ENABLE_PIN, 1);
|
||||||
#endif
|
#endif
|
||||||
SET_OUTPUT(E_ENABLE_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STEPPER_ENABLE_PIN
|
#ifdef STEPPER_ENABLE_PIN
|
||||||
|
|
@ -109,8 +109,8 @@ void pinio_init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_LED_PIN
|
#ifdef DEBUG_LED_PIN
|
||||||
WRITE(DEBUG_LED_PIN, 0);
|
|
||||||
SET_OUTPUT(DEBUG_LED_PIN);
|
SET_OUTPUT(DEBUG_LED_PIN);
|
||||||
|
WRITE(DEBUG_LED_PIN, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,8 +118,8 @@ void power_on() {
|
||||||
|
|
||||||
if (ps_is_on == 0) {
|
if (ps_is_on == 0) {
|
||||||
#ifdef PS_ON_PIN
|
#ifdef PS_ON_PIN
|
||||||
|
SET_OUTPUT(PS_ON_PIN);
|
||||||
WRITE(PS_ON_PIN, 0);
|
WRITE(PS_ON_PIN, 0);
|
||||||
SET_OUTPUT(PS_ON_PIN);
|
|
||||||
delay_ms(500);
|
delay_ms(500);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PS_MOSFET_PIN
|
#ifdef PS_MOSFET_PIN
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue