Clean up HAL ADC, old test scripts

This commit is contained in:
Scott Lahteine 2020-01-17 02:39:22 -06:00
parent 0d0dfba203
commit a578749622
24 changed files with 30 additions and 139 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -55,7 +55,7 @@ void HAL_adc_init() {
}
void HAL_adc_enable_channel(int ch) {
void HAL_adc_enable_channel(const uint8_t ch) {
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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