From a578749622883af652b1c085a1322a2f33341793 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Jan 2020 02:39:22 -0600 Subject: [PATCH] Clean up HAL ADC, old test scripts --- Marlin/src/HAL/HAL_AVR/HAL.h | 10 +++++----- Marlin/src/HAL/HAL_DUE/HAL.cpp | 4 ++-- Marlin/src/HAL/HAL_DUE/HAL.h | 6 +++--- Marlin/src/HAL/HAL_ESP32/HAL.cpp | 2 +- Marlin/src/HAL/HAL_ESP32/HAL.h | 2 +- Marlin/src/HAL/HAL_LINUX/HAL.cpp | 2 +- Marlin/src/HAL/HAL_LINUX/HAL.h | 14 +++++++------- Marlin/src/HAL/HAL_SAMD51/HAL.cpp | 6 +----- Marlin/src/HAL/HAL_SAMD51/HAL.h | 2 +- Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp | 2 +- buildroot/bin/backup_ramps | 7 ------- buildroot/bin/build_marlin | 8 -------- buildroot/bin/build_marlin_fail | 4 ---- buildroot/bin/build_marlin_pio | 3 --- buildroot/bin/build_marlin_teensy35 | 3 --- buildroot/bin/env_backup | 14 -------------- buildroot/bin/env_clean | 12 ------------ buildroot/bin/env_restore | 26 -------------------------- buildroot/bin/restore_configs | 18 +++--------------- buildroot/bin/update_defaults | 3 --- buildroot/share/tests/DUE-tests | 2 -- buildroot/share/tests/run_tests | 15 ++++----------- buildroot/share/tests/teensy31-tests | 2 -- buildroot/share/tests/teensy35-tests | 2 -- 24 files changed, 30 insertions(+), 139 deletions(-) delete mode 100755 buildroot/bin/backup_ramps delete mode 100755 buildroot/bin/build_marlin delete mode 100755 buildroot/bin/build_marlin_fail delete mode 100755 buildroot/bin/build_marlin_pio delete mode 100755 buildroot/bin/build_marlin_teensy35 delete mode 100755 buildroot/bin/env_backup delete mode 100755 buildroot/bin/env_clean delete mode 100755 buildroot/bin/env_restore delete mode 100755 buildroot/bin/update_defaults diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index fb664878bb..5c10ad08e4 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -358,9 +358,9 @@ void TIMER0_COMPB_vect_bottom() // ADC #ifdef DIDR2 - #define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0) + #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0) #else - #define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0) + #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind); #endif inline void HAL_adc_init() { @@ -371,11 +371,11 @@ inline void HAL_adc_init() { #endif } -#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC) +#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC) #ifdef MUX5 - #define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin) + #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch) #else - #define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin) + #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) #endif #define HAL_ADC_RESOLUTION 10 diff --git a/Marlin/src/HAL/HAL_DUE/HAL.cpp b/Marlin/src/HAL/HAL_DUE/HAL.cpp index 130779896d..2d2eb3b9ff 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.cpp +++ b/Marlin/src/HAL/HAL_DUE/HAL.cpp @@ -94,8 +94,8 @@ int freeMemory() { // ADC // ------------------------ -void HAL_adc_start_conversion(const uint8_t adc_pin) { - HAL_adc_result = analogRead(adc_pin); +void HAL_adc_start_conversion(const uint8_t ch) { + HAL_adc_result = analogRead(ch); } uint16_t HAL_adc_get_result() { diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h index 20016ef183..b5bac89568 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.h +++ b/Marlin/src/HAL/HAL_DUE/HAL.h @@ -148,16 +148,16 @@ extern uint16_t HAL_adc_result; // result of last ADC conversion #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) #endif -#define HAL_ANALOG_SELECT(pin) +#define HAL_ANALOG_SELECT(ch) inline void HAL_adc_init() {}//todo -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) +#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) #define HAL_ADC_RESOLUTION 10 #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true -void HAL_adc_start_conversion(const uint8_t adc_pin); +void HAL_adc_start_conversion(const uint8_t ch); uint16_t HAL_adc_get_result(); // diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.cpp b/Marlin/src/HAL/HAL_ESP32/HAL.cpp index a188d4fb9a..73e60c1780 100644 --- a/Marlin/src/HAL/HAL_ESP32/HAL.cpp +++ b/Marlin/src/HAL/HAL_ESP32/HAL.cpp @@ -191,7 +191,7 @@ void HAL_adc_init() { } } -void HAL_adc_start_conversion(uint8_t adc_pin) { +void HAL_adc_start_conversion(const uint8_t adc_pin) { const adc1_channel_t chan = get_channel(adc_pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.h b/Marlin/src/HAL/HAL_ESP32/HAL.h index 2c6858ba9c..c4528f7520 100644 --- a/Marlin/src/HAL/HAL_ESP32/HAL.h +++ b/Marlin/src/HAL/HAL_ESP32/HAL.h @@ -125,7 +125,7 @@ void HAL_adc_init(); #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true -void HAL_adc_start_conversion(uint8_t adc_pin); +void HAL_adc_start_conversion(const uint8_t adc_pin); #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.cpp b/Marlin/src/HAL/HAL_LINUX/HAL.cpp index 316f6b452a..a10b1629a0 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.cpp +++ b/Marlin/src/HAL/HAL_LINUX/HAL.cpp @@ -55,7 +55,7 @@ void HAL_adc_init() { } -void HAL_adc_enable_channel(int ch) { +void HAL_adc_enable_channel(const uint8_t ch) { } diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/HAL_LINUX/HAL.h index 37b3b479bc..63aa8fa11f 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.h +++ b/Marlin/src/HAL/HAL_LINUX/HAL.h @@ -87,15 +87,15 @@ int freeMemory(); #pragma GCC diagnostic pop // ADC -#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin) -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_ADC_RESOLUTION 10 -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true +#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) +#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) +#define HAL_ADC_RESOLUTION 10 +#define HAL_READ_ADC() HAL_adc_get_result() +#define HAL_ADC_READY() true void HAL_adc_init(); -void HAL_adc_enable_channel(int pin); -void HAL_adc_start_conversion(const uint8_t adc_pin); +void HAL_adc_enable_channel(const uint8_t ch); +void HAL_adc_start_conversion(const uint8_t ch); uint16_t HAL_adc_get_result(); // Reset source diff --git a/Marlin/src/HAL/HAL_SAMD51/HAL.cpp b/Marlin/src/HAL/HAL_SAMD51/HAL.cpp index 1c53042f8d..1894f6c7a2 100644 --- a/Marlin/src/HAL/HAL_SAMD51/HAL.cpp +++ b/Marlin/src/HAL/HAL_SAMD51/HAL.cpp @@ -426,7 +426,7 @@ void HAL_adc_init() { memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi) - pinPeripheral(adc_pins[pi], PIO_ANALOG); + pinPeripheral(adc_pins[pi], PIO_ANALOG); for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) { Adc* adc = ((Adc*[])ADC_INSTS)[ai]; @@ -471,8 +471,4 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = 0xFFFF; } -uint16_t HAL_adc_get_result() { - return HAL_adc_result; -} - #endif // __SAMD51__ diff --git a/Marlin/src/HAL/HAL_SAMD51/HAL.h b/Marlin/src/HAL/HAL_SAMD51/HAL.h index d193e58694..37437cb758 100644 --- a/Marlin/src/HAL/HAL_SAMD51/HAL.h +++ b/Marlin/src/HAL/HAL_SAMD51/HAL.h @@ -135,7 +135,7 @@ void HAL_adc_init(); #define HAL_ADC_READY() true void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); +inline uint16_t HAL_adc_get_result() { return HAL_adc_result; } // // Pin Map diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp index 5848944792..34d2354637 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp @@ -94,7 +94,7 @@ extern "C" { } void HAL_adc_start_conversion(const uint8_t adc_pin) { - uint16_t pin = pin2sc1a[adc_pin]; + const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { // Digital only HAL_adc_select = -1; diff --git a/buildroot/bin/backup_ramps b/buildroot/bin/backup_ramps deleted file mode 100755 index b376bb74b8..0000000000 --- a/buildroot/bin/backup_ramps +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -PINS="Marlin/src/pins" -RAMPS="$PINS/ramps/pins_RAMPS.h" -BKUP="$PINS/ramps/pins_RAMPS.backup.h" - -[[ -f $RAMPS ]] && cp "$RAMPS" "$BKUP" diff --git a/buildroot/bin/build_marlin b/buildroot/bin/build_marlin deleted file mode 100755 index 3255346291..0000000000 --- a/buildroot/bin/build_marlin +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -case "$#" in - 0 ) BOARD=arduino:avr:mega:cpu=atmega2560 ;; - * ) BOARD=arduino:avr:$1 ;; -esac - -arduino --verify --board $BOARD Marlin/Marlin.ino diff --git a/buildroot/bin/build_marlin_fail b/buildroot/bin/build_marlin_fail deleted file mode 100755 index e18105cdd4..0000000000 --- a/buildroot/bin/build_marlin_fail +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -build_marlin $@ && exit 0 -exit 1 diff --git a/buildroot/bin/build_marlin_pio b/buildroot/bin/build_marlin_pio deleted file mode 100755 index b3c113c2f6..0000000000 --- a/buildroot/bin/build_marlin_pio +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -platformio run --project-dir $@ --silent diff --git a/buildroot/bin/build_marlin_teensy35 b/buildroot/bin/build_marlin_teensy35 deleted file mode 100755 index ed6e95cd23..0000000000 --- a/buildroot/bin/build_marlin_teensy35 +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -arduino --verify --board teensy:avr:teensy35:usb=serial,speed=120,opt=o1std,keys=en-us Marlin/Marlin.ino diff --git a/buildroot/bin/env_backup b/buildroot/bin/env_backup deleted file mode 100755 index 164582de60..0000000000 --- a/buildroot/bin/env_backup +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -[ -z "$1" ] || cd $1 - -if [ -d ".test" ]; then - printf "\033[0;31mEnvironment backup already exists!\033[0m\n" -else - mkdir .test - cp Marlin/Configuration*.h .test/ - [ -f Marlin/_Bootscreen.h ] && cp Marlin/_Bootscreen.h .test/ - [ -f Marlin/_Statusscreen.h ] && cp Marlin/_Statusscreen.h .test/ - cp -r Marlin/src/pins .test/pins - printf "\033[0;32mEnvironment Backup created\033[0m\n" -fi diff --git a/buildroot/bin/env_clean b/buildroot/bin/env_clean deleted file mode 100755 index 721aa762df..0000000000 --- a/buildroot/bin/env_clean +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -rm -rf .pioenvs -rm -rf .piolibdeps -rm -rf .piolib -rm -rf .pio - -if [[ $1 = "--deep" ]]; then - rm -rf ~/.platformio/packages/* - rm -rf ~/.platformio/platforms/* - rm -rf ~/.platformio/.cache/* -fi diff --git a/buildroot/bin/env_restore b/buildroot/bin/env_restore deleted file mode 100755 index defc6d8431..0000000000 --- a/buildroot/bin/env_restore +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -[ -z "$1" ] || cd $1 - -if [ -d ".test" ]; then - cp .test/Configuration*.h Marlin/ - rm .test/Configuration*.h - - if [ -f .test/_Bootscreen.h ]; then - cp .test/_Bootscreen.h Marlin/ - rm .test/_Bootscreen.h - fi - - if [ -f .test/_Statusscreen.h ]; then - cp .test/_Statusscreen.h Marlin/ - rm .test/_Statusscreen.h - fi - - cp -r .test/pins Marlin/src - rm -r .test/pins - - rmdir .test - printf "\033[0;32mEnvironment Restored\033[0m\n" -else - printf "\033[0;31mEnvironment Backup not available!\033[0m\n" -fi diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs index 5e24d8d7cc..b2d0ea19ac 100755 --- a/buildroot/bin/restore_configs +++ b/buildroot/bin/restore_configs @@ -1,17 +1,5 @@ #!/usr/bin/env bash -RESTORE="https://raw.githubusercontent.com/MarlinFirmware/Configurations/master/config/default" - -cd Marlin - -rm -f Conf*.h _*screen.h - -PINS="src/pins" -RAMPS="$PINS/ramps/pins_RAMPS.h" -BKUP="$PINS/ramps/pins_RAMPS.backup.h" -[ -f $BKUP ] && { cp "$BKUP" "$RAMPS" ; rm -f $BKUP ; } - -wget -q "$RESTORE/Configuration.h" -O Configuration.h -wget -q "$RESTORE/Configuration_adv.h" -O Configuration_adv.h - -cd - >/dev/null +git checkout Marlin/Configuration*.h 2>/dev/null +git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null +rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h diff --git a/buildroot/bin/update_defaults b/buildroot/bin/update_defaults deleted file mode 100755 index 4442a54e4d..0000000000 --- a/buildroot/bin/update_defaults +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -cp Marlin/Configuration*.h config/default diff --git a/buildroot/share/tests/DUE-tests b/buildroot/share/tests/DUE-tests index 756e7a9492..b130f75044 100755 --- a/buildroot/share/tests/DUE-tests +++ b/buildroot/share/tests/DUE-tests @@ -6,8 +6,6 @@ # exit on first failure set -e -backup_ramps # pins_set is used below... - restore_configs opt_set LCD_LANGUAGE bg opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB diff --git a/buildroot/share/tests/run_tests b/buildroot/share/tests/run_tests index 229cfb588a..d4ea8925eb 100755 --- a/buildroot/share/tests/run_tests +++ b/buildroot/share/tests/run_tests @@ -10,11 +10,11 @@ set -e exec_test () { printf "\n\033[0;32m[Test $2] \033[0m$3...\n" - if build_marlin_pio $1 "-e $2"; then + if platformio run --project-dir $1 "-e $2" --silent; then printf "\033[0;32mPassed\033[0m\n" return 0 else - env_restore + git reset --hard HEAD printf "\033[0;31mFailed!\033[0m\n" return 1 fi @@ -23,26 +23,19 @@ export -f exec_test printf "Running \033[0;32m$2\033[0m Tests\n" -if [[ $3 = "--deep-clean" ]]; then - echo "Deleting all PlatformIO caches, downloads and installed packages..." - env_clean --deep -fi - if [[ $2 = "ALL" ]]; then dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*) declare -a tests=(${dir_list[@]/*run_tests/}) for f in "${tests[@]}"; do - env_backup testenv=$(basename $f | cut -d"-" -f1) printf "Running \033[0;32m$f\033[0m Tests\n" exec_test $1 "$testenv --target clean" "Setup Build Environment" $f $1 $testenv - env_restore + git reset --hard HEAD done else - env_backup exec_test $1 "$2 --target clean" "Setup Build Environment" $2-tests $1 $2 - env_restore + git reset --hard HEAD fi printf "\033[0;32mAll tests completed successfully\033[0m\n" diff --git a/buildroot/share/tests/teensy31-tests b/buildroot/share/tests/teensy31-tests index a847d6f572..be377b15af 100755 --- a/buildroot/share/tests/teensy31-tests +++ b/buildroot/share/tests/teensy31-tests @@ -6,8 +6,6 @@ # exit on first failure set -e -backup_ramps - restore_configs opt_set MOTHERBOARD BOARD_TEENSY31_32 exec_test $1 $2 "Teensy3.1 with default config" diff --git a/buildroot/share/tests/teensy35-tests b/buildroot/share/tests/teensy35-tests index 9661666c4a..f72840873e 100755 --- a/buildroot/share/tests/teensy35-tests +++ b/buildroot/share/tests/teensy35-tests @@ -6,8 +6,6 @@ # exit on first failure set -e -backup_ramps - restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 exec_test $1 $2 "Teensy3.5 with default config"