Browse Source

Clean up HAL ADC, old test scripts

pull/1/head
Scott Lahteine 5 years ago
parent
commit
a578749622
  1. 10
      Marlin/src/HAL/HAL_AVR/HAL.h
  2. 4
      Marlin/src/HAL/HAL_DUE/HAL.cpp
  3. 6
      Marlin/src/HAL/HAL_DUE/HAL.h
  4. 2
      Marlin/src/HAL/HAL_ESP32/HAL.cpp
  5. 2
      Marlin/src/HAL/HAL_ESP32/HAL.h
  6. 2
      Marlin/src/HAL/HAL_LINUX/HAL.cpp
  7. 8
      Marlin/src/HAL/HAL_LINUX/HAL.h
  8. 4
      Marlin/src/HAL/HAL_SAMD51/HAL.cpp
  9. 2
      Marlin/src/HAL/HAL_SAMD51/HAL.h
  10. 2
      Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp
  11. 7
      buildroot/bin/backup_ramps
  12. 8
      buildroot/bin/build_marlin
  13. 4
      buildroot/bin/build_marlin_fail
  14. 3
      buildroot/bin/build_marlin_pio
  15. 3
      buildroot/bin/build_marlin_teensy35
  16. 14
      buildroot/bin/env_backup
  17. 12
      buildroot/bin/env_clean
  18. 26
      buildroot/bin/env_restore
  19. 18
      buildroot/bin/restore_configs
  20. 3
      buildroot/bin/update_defaults
  21. 2
      buildroot/share/tests/DUE-tests
  22. 15
      buildroot/share/tests/run_tests
  23. 2
      buildroot/share/tests/teensy31-tests
  24. 2
      buildroot/share/tests/teensy35-tests

10
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

4
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() {

6
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();
//

2
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);

2
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

2
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) {
}

8
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_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

4
Marlin/src/HAL/HAL_SAMD51/HAL.cpp

@ -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__

2
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

2
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;

7
buildroot/bin/backup_ramps

@ -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"

8
buildroot/bin/build_marlin

@ -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

4
buildroot/bin/build_marlin_fail

@ -1,4 +0,0 @@
#!/usr/bin/env bash
build_marlin $@ && exit 0
exit 1

3
buildroot/bin/build_marlin_pio

@ -1,3 +0,0 @@
#!/usr/bin/env bash
platformio run --project-dir $@ --silent

3
buildroot/bin/build_marlin_teensy35

@ -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

14
buildroot/bin/env_backup

@ -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

12
buildroot/bin/env_clean

@ -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

26
buildroot/bin/env_restore

@ -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

18
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

3
buildroot/bin/update_defaults

@ -1,3 +0,0 @@
#!/usr/bin/env bash
cp Marlin/Configuration*.h config/default

2
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

15
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"

2
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"

2
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"

Loading…
Cancel
Save