Browse Source

Clean up HAL ADC, old test scripts

Scott Lahteine 4 years ago
parent
commit
a578749622

+ 5
- 5
Marlin/src/HAL/HAL_AVR/HAL.h View File

358
 
358
 
359
 // ADC
359
 // ADC
360
 #ifdef DIDR2
360
 #ifdef DIDR2
361
-  #define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0)
361
+  #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
362
 #else
362
 #else
363
-  #define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
363
+  #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
364
 #endif
364
 #endif
365
 
365
 
366
 inline void HAL_adc_init() {
366
 inline void HAL_adc_init() {
371
   #endif
371
   #endif
372
 }
372
 }
373
 
373
 
374
-#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
374
+#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
375
 #ifdef MUX5
375
 #ifdef MUX5
376
-  #define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
376
+  #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
377
 #else
377
 #else
378
-  #define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
378
+  #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
379
 #endif
379
 #endif
380
 
380
 
381
 #define HAL_ADC_RESOLUTION 10
381
 #define HAL_ADC_RESOLUTION 10

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL.cpp View File

94
 // ADC
94
 // ADC
95
 // ------------------------
95
 // ------------------------
96
 
96
 
97
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
98
-  HAL_adc_result = analogRead(adc_pin);
97
+void HAL_adc_start_conversion(const uint8_t ch) {
98
+  HAL_adc_result = analogRead(ch);
99
 }
99
 }
100
 
100
 
101
 uint16_t HAL_adc_get_result() {
101
 uint16_t HAL_adc_get_result() {

+ 3
- 3
Marlin/src/HAL/HAL_DUE/HAL.h View File

148
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
148
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
149
 #endif
149
 #endif
150
 
150
 
151
-#define HAL_ANALOG_SELECT(pin)
151
+#define HAL_ANALOG_SELECT(ch)
152
 
152
 
153
 inline void HAL_adc_init() {}//todo
153
 inline void HAL_adc_init() {}//todo
154
 
154
 
155
-#define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
155
+#define HAL_START_ADC(ch)   HAL_adc_start_conversion(ch)
156
 #define HAL_ADC_RESOLUTION  10
156
 #define HAL_ADC_RESOLUTION  10
157
 #define HAL_READ_ADC()      HAL_adc_result
157
 #define HAL_READ_ADC()      HAL_adc_result
158
 #define HAL_ADC_READY()     true
158
 #define HAL_ADC_READY()     true
159
 
159
 
160
-void HAL_adc_start_conversion(const uint8_t adc_pin);
160
+void HAL_adc_start_conversion(const uint8_t ch);
161
 uint16_t HAL_adc_get_result();
161
 uint16_t HAL_adc_get_result();
162
 
162
 
163
 //
163
 //

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/HAL.cpp View File

191
   }
191
   }
192
 }
192
 }
193
 
193
 
194
-void HAL_adc_start_conversion(uint8_t adc_pin) {
194
+void HAL_adc_start_conversion(const uint8_t adc_pin) {
195
   const adc1_channel_t chan = get_channel(adc_pin);
195
   const adc1_channel_t chan = get_channel(adc_pin);
196
   uint32_t mv;
196
   uint32_t mv;
197
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
197
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/HAL.h View File

125
 #define HAL_READ_ADC()      HAL_adc_result
125
 #define HAL_READ_ADC()      HAL_adc_result
126
 #define HAL_ADC_READY()     true
126
 #define HAL_ADC_READY()     true
127
 
127
 
128
-void HAL_adc_start_conversion(uint8_t adc_pin);
128
+void HAL_adc_start_conversion(const uint8_t adc_pin);
129
 
129
 
130
 #define GET_PIN_MAP_PIN(index) index
130
 #define GET_PIN_MAP_PIN(index) index
131
 #define GET_PIN_MAP_INDEX(pin) pin
131
 #define GET_PIN_MAP_INDEX(pin) pin

+ 1
- 1
Marlin/src/HAL/HAL_LINUX/HAL.cpp View File

55
 
55
 
56
 }
56
 }
57
 
57
 
58
-void HAL_adc_enable_channel(int ch) {
58
+void HAL_adc_enable_channel(const uint8_t ch) {
59
 
59
 
60
 }
60
 }
61
 
61
 

+ 7
- 7
Marlin/src/HAL/HAL_LINUX/HAL.h View File

87
 #pragma GCC diagnostic pop
87
 #pragma GCC diagnostic pop
88
 
88
 
89
 // ADC
89
 // ADC
90
-#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
91
-#define HAL_START_ADC(pin)     HAL_adc_start_conversion(pin)
92
-#define HAL_ADC_RESOLUTION     10
93
-#define HAL_READ_ADC()         HAL_adc_get_result()
94
-#define HAL_ADC_READY()        true
90
+#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
91
+#define HAL_START_ADC(ch)     HAL_adc_start_conversion(ch)
92
+#define HAL_ADC_RESOLUTION    10
93
+#define HAL_READ_ADC()        HAL_adc_get_result()
94
+#define HAL_ADC_READY()       true
95
 
95
 
96
 void HAL_adc_init();
96
 void HAL_adc_init();
97
-void HAL_adc_enable_channel(int pin);
98
-void HAL_adc_start_conversion(const uint8_t adc_pin);
97
+void HAL_adc_enable_channel(const uint8_t ch);
98
+void HAL_adc_start_conversion(const uint8_t ch);
99
 uint16_t HAL_adc_get_result();
99
 uint16_t HAL_adc_get_result();
100
 
100
 
101
 // Reset source
101
 // Reset source

+ 1
- 5
Marlin/src/HAL/HAL_SAMD51/HAL.cpp View File

426
     memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results));                 // Fill result with invalid values
426
     memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results));                 // Fill result with invalid values
427
 
427
 
428
     for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi)
428
     for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi)
429
-        pinPeripheral(adc_pins[pi], PIO_ANALOG);
429
+      pinPeripheral(adc_pins[pi], PIO_ANALOG);
430
 
430
 
431
     for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) {
431
     for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) {
432
       Adc* adc = ((Adc*[])ADC_INSTS)[ai];
432
       Adc* adc = ((Adc*[])ADC_INSTS)[ai];
471
   HAL_adc_result = 0xFFFF;
471
   HAL_adc_result = 0xFFFF;
472
 }
472
 }
473
 
473
 
474
-uint16_t HAL_adc_get_result() {
475
-  return HAL_adc_result;
476
-}
477
-
478
 #endif // __SAMD51__
474
 #endif // __SAMD51__

+ 1
- 1
Marlin/src/HAL/HAL_SAMD51/HAL.h View File

135
 #define HAL_ADC_READY()     true
135
 #define HAL_ADC_READY()     true
136
 
136
 
137
 void HAL_adc_start_conversion(const uint8_t adc_pin);
137
 void HAL_adc_start_conversion(const uint8_t adc_pin);
138
-uint16_t HAL_adc_get_result();
138
+inline uint16_t HAL_adc_get_result() { return HAL_adc_result; }
139
 
139
 
140
 //
140
 //
141
 // Pin Map
141
 // Pin Map

+ 1
- 1
Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp View File

94
 }
94
 }
95
 
95
 
96
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
96
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
97
-  uint16_t pin = pin2sc1a[adc_pin];
97
+  const uint16_t pin = pin2sc1a[adc_pin];
98
   if (pin == 0xFF) {
98
   if (pin == 0xFF) {
99
     // Digital only
99
     // Digital only
100
     HAL_adc_select = -1;
100
     HAL_adc_select = -1;

+ 0
- 7
buildroot/bin/backup_ramps View File

1
-#!/usr/bin/env bash
2
-
3
-PINS="Marlin/src/pins"
4
-RAMPS="$PINS/ramps/pins_RAMPS.h"
5
-BKUP="$PINS/ramps/pins_RAMPS.backup.h"
6
-
7
-[[ -f $RAMPS ]] && cp "$RAMPS" "$BKUP"

+ 0
- 8
buildroot/bin/build_marlin View File

1
-#!/usr/bin/env bash
2
-
3
-case "$#" in
4
-  0 ) BOARD=arduino:avr:mega:cpu=atmega2560 ;;
5
-  * ) BOARD=arduino:avr:$1 ;;
6
-esac
7
-
8
-arduino --verify --board $BOARD Marlin/Marlin.ino

+ 0
- 4
buildroot/bin/build_marlin_fail View File

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

+ 0
- 3
buildroot/bin/build_marlin_pio View File

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

+ 0
- 3
buildroot/bin/build_marlin_teensy35 View File

1
-#!/usr/bin/env bash
2
-
3
-arduino --verify --board teensy:avr:teensy35:usb=serial,speed=120,opt=o1std,keys=en-us Marlin/Marlin.ino

+ 0
- 14
buildroot/bin/env_backup View File

1
-#!/usr/bin/env bash
2
-
3
-[ -z "$1" ] || cd $1
4
-
5
-if [ -d ".test" ]; then
6
-  printf "\033[0;31mEnvironment backup already exists!\033[0m\n"
7
-else
8
-  mkdir .test
9
-  cp Marlin/Configuration*.h .test/
10
-  [ -f Marlin/_Bootscreen.h ] && cp Marlin/_Bootscreen.h .test/
11
-  [ -f Marlin/_Statusscreen.h ] && cp Marlin/_Statusscreen.h .test/
12
-  cp -r Marlin/src/pins .test/pins
13
-  printf "\033[0;32mEnvironment Backup created\033[0m\n"
14
-fi

+ 0
- 12
buildroot/bin/env_clean View File

1
-#!/usr/bin/env bash
2
-
3
-rm -rf .pioenvs
4
-rm -rf .piolibdeps
5
-rm -rf .piolib
6
-rm -rf .pio
7
-
8
-if [[ $1 = "--deep" ]]; then
9
-  rm -rf ~/.platformio/packages/*
10
-  rm -rf ~/.platformio/platforms/*
11
-  rm -rf ~/.platformio/.cache/*
12
-fi

+ 0
- 26
buildroot/bin/env_restore View File

1
-#!/usr/bin/env bash
2
-
3
-[ -z "$1" ] || cd $1
4
-
5
-if [ -d ".test" ]; then
6
-  cp .test/Configuration*.h Marlin/
7
-  rm .test/Configuration*.h
8
-
9
-  if [ -f .test/_Bootscreen.h ]; then
10
-    cp .test/_Bootscreen.h Marlin/
11
-    rm .test/_Bootscreen.h
12
-  fi
13
-
14
-  if [ -f .test/_Statusscreen.h ]; then
15
-    cp .test/_Statusscreen.h Marlin/
16
-    rm .test/_Statusscreen.h
17
-  fi
18
-
19
-  cp -r .test/pins Marlin/src
20
-  rm -r .test/pins
21
-
22
-  rmdir .test
23
-  printf "\033[0;32mEnvironment Restored\033[0m\n"
24
-else
25
-  printf "\033[0;31mEnvironment Backup not available!\033[0m\n"
26
-fi

+ 3
- 15
buildroot/bin/restore_configs View File

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 
2
 
3
-RESTORE="https://raw.githubusercontent.com/MarlinFirmware/Configurations/master/config/default"
4
-
5
-cd Marlin
6
-
7
-rm -f Conf*.h _*screen.h
8
-
9
-PINS="src/pins"
10
-RAMPS="$PINS/ramps/pins_RAMPS.h"
11
-BKUP="$PINS/ramps/pins_RAMPS.backup.h"
12
-[ -f $BKUP ] && { cp "$BKUP" "$RAMPS" ; rm -f $BKUP ; }
13
-
14
-wget -q "$RESTORE/Configuration.h" -O Configuration.h
15
-wget -q "$RESTORE/Configuration_adv.h" -O Configuration_adv.h
16
-
17
-cd - >/dev/null
3
+git checkout Marlin/Configuration*.h 2>/dev/null
4
+git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
5
+rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h

+ 0
- 3
buildroot/bin/update_defaults View File

1
-#!/usr/bin/env bash
2
-
3
-cp Marlin/Configuration*.h config/default

+ 0
- 2
buildroot/share/tests/DUE-tests View File

6
 # exit on first failure
6
 # exit on first failure
7
 set -e
7
 set -e
8
 
8
 
9
-backup_ramps     # pins_set is used below...
10
-
11
 restore_configs
9
 restore_configs
12
 opt_set LCD_LANGUAGE bg
10
 opt_set LCD_LANGUAGE bg
13
 opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB
11
 opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB

+ 4
- 11
buildroot/share/tests/run_tests View File

10
 
10
 
11
 exec_test () {
11
 exec_test () {
12
   printf "\n\033[0;32m[Test $2] \033[0m$3...\n"
12
   printf "\n\033[0;32m[Test $2] \033[0m$3...\n"
13
-  if build_marlin_pio $1 "-e $2"; then
13
+  if platformio run --project-dir $1 "-e $2" --silent; then
14
     printf "\033[0;32mPassed\033[0m\n"
14
     printf "\033[0;32mPassed\033[0m\n"
15
     return 0
15
     return 0
16
   else
16
   else
17
-    env_restore
17
+    git reset --hard HEAD
18
     printf "\033[0;31mFailed!\033[0m\n"
18
     printf "\033[0;31mFailed!\033[0m\n"
19
     return 1
19
     return 1
20
   fi
20
   fi
23
 
23
 
24
 printf "Running \033[0;32m$2\033[0m Tests\n"
24
 printf "Running \033[0;32m$2\033[0m Tests\n"
25
 
25
 
26
-if [[ $3 = "--deep-clean" ]]; then
27
-  echo "Deleting all PlatformIO caches, downloads and installed packages..."
28
-  env_clean --deep
29
-fi
30
-
31
 if [[ $2 = "ALL" ]]; then
26
 if [[ $2 = "ALL" ]]; then
32
   dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
27
   dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
33
   declare -a tests=(${dir_list[@]/*run_tests/})
28
   declare -a tests=(${dir_list[@]/*run_tests/})
34
   for f in "${tests[@]}"; do
29
   for f in "${tests[@]}"; do
35
-    env_backup
36
     testenv=$(basename $f | cut -d"-" -f1)
30
     testenv=$(basename $f | cut -d"-" -f1)
37
     printf "Running \033[0;32m$f\033[0m Tests\n"
31
     printf "Running \033[0;32m$f\033[0m Tests\n"
38
     exec_test $1 "$testenv --target clean" "Setup Build Environment"
32
     exec_test $1 "$testenv --target clean" "Setup Build Environment"
39
     $f $1 $testenv
33
     $f $1 $testenv
40
-    env_restore
34
+    git reset --hard HEAD
41
   done
35
   done
42
 else
36
 else
43
-  env_backup
44
   exec_test $1 "$2 --target clean" "Setup Build Environment"
37
   exec_test $1 "$2 --target clean" "Setup Build Environment"
45
   $2-tests $1 $2
38
   $2-tests $1 $2
46
-  env_restore
39
+  git reset --hard HEAD
47
 fi
40
 fi
48
 printf "\033[0;32mAll tests completed successfully\033[0m\n"
41
 printf "\033[0;32mAll tests completed successfully\033[0m\n"

+ 0
- 2
buildroot/share/tests/teensy31-tests View File

6
 # exit on first failure
6
 # exit on first failure
7
 set -e
7
 set -e
8
 
8
 
9
-backup_ramps
10
-
11
 restore_configs
9
 restore_configs
12
 opt_set MOTHERBOARD BOARD_TEENSY31_32
10
 opt_set MOTHERBOARD BOARD_TEENSY31_32
13
 exec_test $1 $2 "Teensy3.1 with default config"
11
 exec_test $1 $2 "Teensy3.1 with default config"

+ 0
- 2
buildroot/share/tests/teensy35-tests View File

6
 # exit on first failure
6
 # exit on first failure
7
 set -e
7
 set -e
8
 
8
 
9
-backup_ramps
10
-
11
 restore_configs
9
 restore_configs
12
 opt_set MOTHERBOARD BOARD_TEENSY35_36
10
 opt_set MOTHERBOARD BOARD_TEENSY35_36
13
 exec_test $1 $2 "Teensy3.5 with default config"
11
 exec_test $1 $2 "Teensy3.5 with default config"

Loading…
Cancel
Save