Added TEST output pin
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 9 Oct 2018 20:19:40 +0000 (13:19 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 9 Oct 2018 20:21:22 +0000 (13:21 -0700)
src/avr/src/config.h
src/avr/src/outputs.c
src/avr/src/outputs.h
src/avr/src/vars.def

index 97570c2bfd344c626f1c44ca68479cc73e9f888a..d8bb92dd2a6b3a0e2576261e5d804ace1b443f73 100644 (file)
@@ -87,7 +87,7 @@ enum {
   ESTOP_PIN,
   MOTOR_FAULT_PIN,
   MOTOR_ENABLE_PIN,
-  NC_0_PIN,
+  TEST_PIN,
   PROBE_PIN,
 };
 
@@ -96,7 +96,7 @@ enum {
 
 #define AXES                     6 // number of axes
 #define MOTORS                   4 // number of motors on the board
-#define OUTS                     5 // number of supported pin outputs
+#define OUTS                     6 // number of supported pin outputs
 #define ANALOG                   2 // number of supported analog inputs
 #define VFDREG                  32 // number of supported VFD modbus registers
 
@@ -115,6 +115,7 @@ enum {
  *    LO    Segment execution SW interrupt       (set in stepper.h)
  *   MED    Serial RX                            (set in usart.c)
  *   MED    Serial TX                            (set in usart.c) (* see note)
+ *   MED    I2C Slave                            (set in i2c.c)
  *    LO    Real time clock interrupt            (set in rtc.h)
  *
  *    (*) The TX cannot run at LO level or exception reports and other prints
index c8d1491f16ea2ac191a5d6fe4cdb90a1dda8c6ad..f989ec790151f13323b95efb61935fa76a88a9c2 100644 (file)
@@ -43,6 +43,7 @@ output_t outputs[OUTS] = {
   {SWITCH_1_PIN},
   {SWITCH_2_PIN},
   {FAULT_PIN},
+  {TEST_PIN},
 };
 
 
@@ -53,6 +54,7 @@ static output_t *_get_output(uint8_t pin) {
   case SWITCH_1_PIN:    return &outputs[2];
   case SWITCH_2_PIN:    return &outputs[3];
   case FAULT_PIN:       return &outputs[4];
+  case TEST_PIN:        return &outputs[5];
   }
 
   return 0;
@@ -62,18 +64,18 @@ static output_t *_get_output(uint8_t pin) {
 static void _update_state(output_t *output) {
   switch (output->mode) {
   case OUT_DISABLED: output->state = OUT_TRI; break;
-  case OUT_LO_HI: output->state = output->active ? OUT_HI : OUT_LO; break;
-  case OUT_HI_LO: output->state = output->active ? OUT_LO : OUT_HI; break;
-  case OUT_TRI_LO: output->state = output->active ? OUT_LO : OUT_TRI; break;
-  case OUT_TRI_HI: output->state = output->active ? OUT_HI : OUT_TRI; break;
-  case OUT_LO_TRI: output->state = output->active ? OUT_TRI : OUT_LO; break;
-  case OUT_HI_TRI: output->state = output->active ? OUT_TRI : OUT_HI; break;
+  case OUT_LO_HI:  output->state = output->active ? OUT_HI  : OUT_LO;  break;
+  case OUT_HI_LO:  output->state = output->active ? OUT_LO  : OUT_HI;  break;
+  case OUT_TRI_LO: output->state = output->active ? OUT_LO  : OUT_TRI; break;
+  case OUT_TRI_HI: output->state = output->active ? OUT_HI  : OUT_TRI; break;
+  case OUT_LO_TRI: output->state = output->active ? OUT_TRI : OUT_LO;  break;
+  case OUT_HI_TRI: output->state = output->active ? OUT_TRI : OUT_HI;  break;
   }
 
   switch (output->state) {
   case OUT_TRI: DIRCLR_PIN(output->pin); break;
-  case OUT_HI: OUTSET_PIN(output->pin); DIRSET_PIN(output->pin); break;
-  case OUT_LO: OUTCLR_PIN(output->pin); DIRSET_PIN(output->pin); break;
+  case OUT_HI:  OUTSET_PIN(output->pin); DIRSET_PIN(output->pin); break;
+  case OUT_LO:  OUTCLR_PIN(output->pin); DIRSET_PIN(output->pin); break;
   }
 }
 
@@ -98,6 +100,16 @@ void outputs_set_active(uint8_t pin, bool active) {
 }
 
 
+bool outputs_toggle(uint8_t pin) {
+  output_t *output = _get_output(pin);
+  if (!output) return false;
+
+  output->active = !output->active;
+  _update_state(output);
+  return output->active;
+}
+
+
 void outputs_set_mode(uint8_t pin, output_mode_t mode) {
   output_t *output = _get_output(pin);
   if (!output) return;
index 086f4809d40465ce500f43e8efc998bd5401ee18..e0f6636c95e8910af272c8a87b8dd39e5acedd5f 100644 (file)
@@ -53,6 +53,7 @@ typedef enum {
 void outputs_init();
 bool outputs_is_active(uint8_t pin);
 void outputs_set_active(uint8_t pin, bool active);
+bool outputs_toggle(uint8_t pin);
 void outputs_set_mode(uint8_t pin, output_mode_t mode);
 output_state_t outputs_get_state(uint8_t pin);
 void outputs_stop();
index dd163927ac806dca3e4d194021ddf7d846319e80..8b4e99be5ed058557d4d301c9f2b060f767de190 100644 (file)
@@ -27,7 +27,7 @@
 
 #define AXES_LABEL   "xyzabc"
 #define MOTORS_LABEL "0123"
-#define OUTS_LABEL   "ed12f"
+#define OUTS_LABEL   "ed12ft"
 #define ANALOG_LABEL "12"
 #define VFDREG_LABEL "0123456789abcdefghijklmnopqrstuv"