From 644efa7122fff843fe9c5882256c0538c4e994c8 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 8 Apr 2020 14:23:13 -0500 Subject: [PATCH] Test cleanups --- firmware/asdf/src/Arch/asdf_arch_atmega328p.c | 2 +- firmware/asdf/src/Arch/asdf_arch_test.c | 132 +++++++++++++++--- firmware/asdf/src/Arch/asdf_arch_test.h | 56 ++++++-- .../asdf/src/Keymaps/asdf_keymap_defs_test.h | 2 +- .../asdf/src/Keymaps/asdf_keymap_defs_test2.h | 2 +- firmware/asdf/src/Makefile.test | 2 +- firmware/asdf/test/test_asdf_virtual.c | 4 +- 7 files changed, 163 insertions(+), 37 deletions(-) diff --git a/firmware/asdf/src/Arch/asdf_arch_atmega328p.c b/firmware/asdf/src/Arch/asdf_arch_atmega328p.c index bf7eb0e..ec86579 100644 --- a/firmware/asdf/src/Arch/asdf_arch_atmega328p.c +++ b/firmware/asdf/src/Arch/asdf_arch_atmega328p.c @@ -386,7 +386,7 @@ void asdf_arch_out1_open_lo_set(uint8_t value) // // NOTES: OUT2 is inverted by the 7404 buffer, so clearing the bit sets the output high. OUT2 // cannot be high impedance. -// +/ // SCOPE: public // // COMPLEXITY: 2 diff --git a/firmware/asdf/src/Arch/asdf_arch_test.c b/firmware/asdf/src/Arch/asdf_arch_test.c index 257d6c0..0ac6489 100644 --- a/firmware/asdf/src/Arch/asdf_arch_test.c +++ b/firmware/asdf/src/Arch/asdf_arch_test.c @@ -252,11 +252,12 @@ void asdf_arch_out1_set(uint8_t value) set_output(PHYSICAL_OUT1, value); } -// PROCEDURE: asdf_arch_out1_hi_z_set +// PROCEDURE: asdf_arch_out1_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none // -// DESCRIPTION: Sets the OUT1 bit to hi-z if value is true, and low if value is false. +// DESCRIPTION: Emulates setting the OUT1 bit to hi-z if value is true, and low +// if value is false. For testing, set PHYSICAL_OUT1_OPEN_HI to the value. // // SIDE EFFECTS: See above. // @@ -266,9 +267,27 @@ void asdf_arch_out1_set(uint8_t value) // // COMPLEXITY: 1 // -void asdf_arch_out1_hi_z_set(uint8_t value) -{ - set_output(PHYSICAL_OUT1_OC, value); +void asdf_arch_out1_open_hi_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); +} + +// PROCEDURE: asdf_arch_out1_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// +// DESCRIPTION: Emulates setting the OUT1 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT1_OPEN_LO to the value. +// +// SIDE EFFECTS: See above. +// +// NOTES: +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_out1_open_lo_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); } // PROCEDURE: asdf_arch_out2_set @@ -289,11 +308,12 @@ void asdf_arch_out2_set(uint8_t value) } -// PROCEDURE: asdf_arch_out2_hi_z_set +// PROCEDURE: asdf_arch_out2_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none // -// DESCRIPTION: Sets the OUT2 bit to hi-z if value is true, and low if value is false. +// DESCRIPTION: Emulates setting the OUT2 bit to hi-z if value is true, and low +// if value is false. For testing, set PHYSICAL_OUT2_OPEN_HI to the value. // // SIDE EFFECTS: See above. // @@ -303,9 +323,27 @@ void asdf_arch_out2_set(uint8_t value) // // COMPLEXITY: 1 // -void asdf_arch_out2_hi_z_set(uint8_t value) -{ - set_output(PHYSICAL_OUT2_OC, value); +void asdf_arch_out2_open_hi_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); +} + +// PROCEDURE: asdf_arch_out2_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// +// DESCRIPTION: Emulates setting the OUT2 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT2_OPEN_LO to the value. +// +// SIDE EFFECTS: See above. +// +// NOTES: +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_out2_open_lo_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); } // PROCEDURE: asdf_arch_out3_set @@ -327,12 +365,12 @@ void asdf_arch_out3_set(uint8_t value) set_output(PHYSICAL_OUT3, value); } - -// PROCEDURE: asdf_arch_out3_hi_z_set +// PROCEDURE: asdf_arch_out3_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none // -// DESCRIPTION: Sets the OUT3 bit to hi-z if value is true, and low if value is false. +// DESCRIPTION: Emulates setting the OUT3 bit to hi-z if value is true, and low +// if value is false. For testing, set PHYSICAL_OUT3_OPEN_HI to the value. // // SIDE EFFECTS: See above. // @@ -342,9 +380,27 @@ void asdf_arch_out3_set(uint8_t value) // // COMPLEXITY: 1 // -void asdf_arch_out3_hi_z_set(uint8_t value) -{ - set_output(PHYSICAL_OUT3_OC, value); +void asdf_arch_out3_open_hi_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); +} + +// PROCEDURE: asdf_arch_out3_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// +// DESCRIPTION: Emulates setting the OUT3 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT3_OPEN_LO to the value. +// +// SIDE EFFECTS: See above. +// +// NOTES: +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_out3_open_lo_set(uint8_t value) +{set_output(PHYSICAL_OUT1_OPEN_HI, value); } // PROCEDURE: asdf_arch_check_output @@ -396,9 +452,9 @@ uint8_t asdf_arch_check_pulse(asdf_physical_dev_t device) // // NOTES: Set ASDF_PULSE_DELAY_US in asdf_config.h // -// SCOPE: public +// SCOPE: private // -// COMPLEXITY: 1 +// COMPLEXITY: 2 // void asdf_arch_pulse_delay(void) { @@ -407,6 +463,46 @@ void asdf_arch_pulse_delay(void) } } +// PROCEDURE: asdf_arch_pulse_delay_long +// INPUTS: none +// OUTPUTS: none +// +// DESCRIPTION: Emulates a long delay by advancing the pulse detector state machine +// for each output. +// +// SIDE EFFECTS: see above. +// +// NOTES: Set ASDF_PULSE_DELAY_US in asdf_config.h +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_pulse_delay_long(void) +{ + asdf_arch_pulse_delay(); +} + +// PROCEDURE: asdf_arch_pulse_delay_short +// INPUTS: none +// OUTPUTS: none +// +// DESCRIPTION: Emulates a short delay by advancing the pulse detector state machine +// for each output. +// +// SIDE EFFECTS: see above. +// +// NOTES: Set ASDF_PULSE_DELAY_US in asdf_config.h +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_pulse_delay_short(void) +{ + asdf_arch_pulse_delay(); +} + // PROCEDURE: asdf_arch_init // INPUTS: none // OUTPUTS: none diff --git a/firmware/asdf/src/Arch/asdf_arch_test.h b/firmware/asdf/src/Arch/asdf_arch_test.h index 27a9d00..6f1eaab 100644 --- a/firmware/asdf/src/Arch/asdf_arch_test.h +++ b/firmware/asdf/src/Arch/asdf_arch_test.h @@ -95,7 +95,6 @@ typedef enum { PD_ST_ERROR_PULSE_FROM_INITIAL_STATE = 15, } pulse_state_t; - // PROCEDURE: asdf_arch_null_output // INPUTS: (uint8_t) value - ignored // OUTPUTS: none @@ -126,11 +125,19 @@ void asdf_arch_led3_set(uint8_t value); // DESCRIPTION: Sets the OUT1 bit if value is true, and clear OUT1 if value is false. void asdf_arch_out1_set(uint8_t value); -// PROCEDURE: asdf_arch_out1_hi_z_set +// PROCEDURE: asdf_arch_out1_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none -// DESCRIPTION: Sets the OUT1 bit to hi-z if value is true, and low if value is false. -void asdf_arch_out1_hi_z_set(uint8_t value); +// DESCRIPTION: Emulates setting the OUT1 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT1_OPEN_LO to the value. +void asdf_arch_out1_open_hi_set(uint8_t value); + +// PROCEDURE: asdf_arch_out1_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// DESCRIPTION: Emulates setting the OUT1 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT1_OPEN_LO to the value. +void asdf_arch_out1_open_lo_set(uint8_t value); // PROCEDURE: asdf_arch_out2_set // INPUTS: (uint8_t) value @@ -138,11 +145,19 @@ void asdf_arch_out1_hi_z_set(uint8_t value); // DESCRIPTION: Sets the OUT2 bit if value is true, and clear OUT2 if value is false. void asdf_arch_out2_set(uint8_t value); -// PROCEDURE: asdf_arch_out2_hi_z_set +// PROCEDURE: asdf_arch_out2_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none -// DESCRIPTION: Sets the OUT2 bit to hi-z if value is true, and low if value is false. -void asdf_arch_out2_hi_z_set(uint8_t value); +// DESCRIPTION: Emulates setting the OUT2 bit to hi-z if value is true, and low +// if value is false. For testing, set PHYSICAL_OUT2_OPEN_HI to the value. +void asdf_arch_out2_open_hi_set(uint8_t value); + +// PROCEDURE: asdf_arch_out2_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// DESCRIPTION: Emulates setting the OUT2 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT2_OPEN_LO to the value. +void asdf_arch_out2_open_lo_set(uint8_t value); // PROCEDURE: asdf_arch_out3_set // INPUTS: (uint8_t) value @@ -150,11 +165,19 @@ void asdf_arch_out2_hi_z_set(uint8_t value); // DESCRIPTION: Sets the OUT3 bit if value is true, and clear OUT3 if value is false. void asdf_arch_out3_set(uint8_t value); -// PROCEDURE: asdf_arch_out3_hi_z_set +// PROCEDURE: asdf_arch_out3_open_hi_set // INPUTS: (uint8_t) value // OUTPUTS: none -// DESCRIPTION: Sets the OUT3 bit to hi-z if value is true, and low if value is false. -void asdf_arch_out3_hi_z_set(uint8_t value); +// DESCRIPTION: Emulates setting the OUT3 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT3_OPEN_LO to the value. +void asdf_arch_out3_open_hi_set(uint8_t value); + +// PROCEDURE: asdf_arch_out3_open_lo_set +// INPUTS: (uint8_t) value +// OUTPUTS: none +// DESCRIPTION: Emulates setting the OUT3 bit to high if value is true, and hi-z +// if value is false. For testing, set PHYSICAL_OUT3_OPEN_LO to the value. +void asdf_arch_out3_open_lo_set(uint8_t value); // PROCEDURE: asdf_arch_check_output // INPUTS:(asdf_physical_dev_t) device - which device to check @@ -168,12 +191,19 @@ uint8_t asdf_arch_check_output(asdf_physical_dev_t device); // DESCRIPTION: For a given real device, return the state of the pulse detector uint8_t asdf_arch_check_pulse(asdf_physical_dev_t device); -// PROCEDURE: asdf_arch_pulse_delay +// PROCEDURE: asdf_arch_pulse_delay_short // INPUTS: none // OUTPUTS: none -// DESCRIPTION: Emulates a delay by advancing the pulse detector state machine +// DESCRIPTION: Emulates a short delay by advancing the pulse detector state machine // for each output. -void asdf_arch_pulse_delay(void); +void asdf_arch_pulse_delay_short(void); + +// PROCEDURE: asdf_arch_pulse_delay_long +// INPUTS: none +// OUTPUTS: none +// DESCRIPTION: Emulates a long delay by advancing the pulse detector state machine +// for each output. +void asdf_arch_pulse_delay_long(void); // PROCEDURE: asdf_arch_read_row // INPUTS: (uint8_t) row: the row number to be scanned diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h index 0ec6eb7..4f88072 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h @@ -173,7 +173,7 @@ /* single pulse */ \ .virtual_device = VOUT3, \ .physical_device = PHYSICAL_OUT3, \ - .function = V_PULSE, \ + .function = V_PULSE_SHORT, \ .initial_value = 0, \ }, \ { /* first of double assignment attempt */ \ diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_defs_test2.h b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test2.h index e884195..2e142d2 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_defs_test2.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test2.h @@ -110,7 +110,7 @@ ACTION_NOTHING, ASCII_ESC, ACTION_CTRL, 0x1c }, \ { ACTION_NOTHING, ASCII_CTRL_P, ACTION_NOTHING, ACTION_NOTHING, \ ASCII_SPACE, ASCII_CTRL_Z, ASCII_CTRL_A, ASCII_CTRL_Q }, \ - { ACTION_NOTHING, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, \ + { ACTION_NOTHING, ASCII_COMMA, ASCII_CTRL_M, ASCII_CTRL_N, \ ASCII_CTRL_B, ASCII_CTRL_V, ASCII_CTRL_C, ASCII_CTRL_X }, \ { ACTION_NOTHING, ASCII_CTRL_K, ASCII_CTRL_J, ASCII_CTRL_H, \ ASCII_CTRL_G, ASCII_CTRL_F, ASCII_CTRL_D, ASCII_CTRL_S }, \ diff --git a/firmware/asdf/src/Makefile.test b/firmware/asdf/src/Makefile.test index 805b266..dd56cdd 100644 --- a/firmware/asdf/src/Makefile.test +++ b/firmware/asdf/src/Makefile.test @@ -55,7 +55,7 @@ TEST2_BUILD = $(BUILD_DIR)/test_$(TEST2) TEST3 = asdf_keymaps TEST3_SRC = $(TEST_DIR)/test_$(TEST3).c -TEST3_DEPS = ./$(TEST3).c $(UNITY_DIR)/unity.c ./asdf_physical.c ./asdf_virtual.c ./asdf_arch.c +TEST3_DEPS = ./$(TEST3).c $(UNITY_DIR)/unity.c ./asdf_physical.c ./asdf_virtual.c ./asdf_modifiers.c ./asdf_arch.c TEST3_BUILD = $(BUILD_DIR)/test_$(TEST3) TEST4 = asdf_buffer diff --git a/firmware/asdf/test/test_asdf_virtual.c b/firmware/asdf/test/test_asdf_virtual.c index b47f241..32cf7fb 100644 --- a/firmware/asdf/test/test_asdf_virtual.c +++ b/firmware/asdf/test/test_asdf_virtual.c @@ -80,7 +80,7 @@ void test_pulse_high_virtual_output(void) TEST_ASSERT_EQUAL_INT32(PD_ST_STABLE_LOW, asdf_arch_check_pulse(PHYSICAL_OUT1)); TEST_ASSERT_EQUAL_INT32(0, asdf_arch_check_output(PHYSICAL_OUT1)); - asdf_virtual_action(VOUT1, V_PULSE); + asdf_virtual_action(VOUT1, V_PULSE_SHORT); // output should be low TEST_ASSERT_EQUAL_INT32(0, asdf_arch_check_output(PHYSICAL_OUT1)); @@ -95,7 +95,7 @@ void test_pulse_low_virtual_output(void) TEST_ASSERT_EQUAL_INT32(PD_ST_STABLE_HIGH, asdf_arch_check_pulse(PHYSICAL_OUT1)); TEST_ASSERT_EQUAL_INT32(1, asdf_arch_check_output(PHYSICAL_OUT1)); - asdf_virtual_action(VOUT1, V_PULSE); + asdf_virtual_action(VOUT1, V_PULSE_SHORT); // output should be high TEST_ASSERT_EQUAL_INT32(1, asdf_arch_check_output(PHYSICAL_OUT1));