Przeglądaj źródła

Clean up HAL ADC, old test scripts

Scott Lahteine 4 lat temu
rodzic
commit
a578749622

+ 5
- 5
Marlin/src/HAL/HAL_AVR/HAL.h Wyświetl plik

@@ -358,9 +358,9 @@ void TIMER0_COMPB_vect_bottom()
358 358
 
359 359
 // ADC
360 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 362
 #else
363
-  #define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
363
+  #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
364 364
 #endif
365 365
 
366 366
 inline void HAL_adc_init() {
@@ -371,11 +371,11 @@ inline void HAL_adc_init() {
371 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 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 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 379
 #endif
380 380
 
381 381
 #define HAL_ADC_RESOLUTION 10

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL.cpp Wyświetl plik

@@ -94,8 +94,8 @@ int freeMemory() {
94 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 101
 uint16_t HAL_adc_get_result() {

+ 3
- 3
Marlin/src/HAL/HAL_DUE/HAL.h Wyświetl plik

@@ -148,16 +148,16 @@ extern uint16_t HAL_adc_result;     // result of last ADC conversion
148 148
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
149 149
 #endif
150 150
 
151
-#define HAL_ANALOG_SELECT(pin)
151
+#define HAL_ANALOG_SELECT(ch)
152 152
 
153 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 156
 #define HAL_ADC_RESOLUTION  10
157 157
 #define HAL_READ_ADC()      HAL_adc_result
158 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 161
 uint16_t HAL_adc_get_result();
162 162
 
163 163
 //

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/HAL.cpp Wyświetl plik

@@ -191,7 +191,7 @@ void HAL_adc_init() {
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 195
   const adc1_channel_t chan = get_channel(adc_pin);
196 196
   uint32_t mv;
197 197
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/HAL.h Wyświetl plik

@@ -125,7 +125,7 @@ void HAL_adc_init();
125 125
 #define HAL_READ_ADC()      HAL_adc_result
126 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 130
 #define GET_PIN_MAP_PIN(index) index
131 131
 #define GET_PIN_MAP_INDEX(pin) pin

+ 1
- 1
Marlin/src/HAL/HAL_LINUX/HAL.cpp Wyświetl plik

@@ -55,7 +55,7 @@ void HAL_adc_init() {
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 Wyświetl plik

@@ -87,15 +87,15 @@ int freeMemory();
87 87
 #pragma GCC diagnostic pop
88 88
 
89 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 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 99
 uint16_t HAL_adc_get_result();
100 100
 
101 101
 // Reset source

+ 1
- 5
Marlin/src/HAL/HAL_SAMD51/HAL.cpp Wyświetl plik

@@ -426,7 +426,7 @@ void HAL_adc_init() {
426 426
     memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results));                 // Fill result with invalid values
427 427
 
428 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 431
     for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) {
432 432
       Adc* adc = ((Adc*[])ADC_INSTS)[ai];
@@ -471,8 +471,4 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
471 471
   HAL_adc_result = 0xFFFF;
472 472
 }
473 473
 
474
-uint16_t HAL_adc_get_result() {
475
-  return HAL_adc_result;
476
-}
477
-
478 474
 #endif // __SAMD51__

+ 1
- 1
Marlin/src/HAL/HAL_SAMD51/HAL.h Wyświetl plik

@@ -135,7 +135,7 @@ void HAL_adc_init();
135 135
 #define HAL_ADC_READY()     true
136 136
 
137 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 141
 // Pin Map

+ 1
- 1
Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp Wyświetl plik

@@ -94,7 +94,7 @@ extern "C" {
94 94
 }
95 95
 
96 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 98
   if (pin == 0xFF) {
99 99
     // Digital only
100 100
     HAL_adc_select = -1;

+ 0
- 7
buildroot/bin/backup_ramps Wyświetl plik

@@ -1,7 +0,0 @@
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 Wyświetl plik

@@ -1,8 +0,0 @@
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 Wyświetl plik

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

+ 0
- 3
buildroot/bin/build_marlin_pio Wyświetl plik

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

+ 0
- 3
buildroot/bin/build_marlin_teensy35 Wyświetl plik

@@ -1,3 +0,0 @@
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 Wyświetl plik

@@ -1,14 +0,0 @@
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 Wyświetl plik

@@ -1,12 +0,0 @@
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 Wyświetl plik

@@ -1,26 +0,0 @@
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 Wyświetl plik

@@ -1,17 +1,5 @@
1 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 Wyświetl plik

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

+ 0
- 2
buildroot/share/tests/DUE-tests Wyświetl plik

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

+ 4
- 11
buildroot/share/tests/run_tests Wyświetl plik

@@ -10,11 +10,11 @@ set -e
10 10
 
11 11
 exec_test () {
12 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 14
     printf "\033[0;32mPassed\033[0m\n"
15 15
     return 0
16 16
   else
17
-    env_restore
17
+    git reset --hard HEAD
18 18
     printf "\033[0;31mFailed!\033[0m\n"
19 19
     return 1
20 20
   fi
@@ -23,26 +23,19 @@ export -f exec_test
23 23
 
24 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 26
 if [[ $2 = "ALL" ]]; then
32 27
   dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
33 28
   declare -a tests=(${dir_list[@]/*run_tests/})
34 29
   for f in "${tests[@]}"; do
35
-    env_backup
36 30
     testenv=$(basename $f | cut -d"-" -f1)
37 31
     printf "Running \033[0;32m$f\033[0m Tests\n"
38 32
     exec_test $1 "$testenv --target clean" "Setup Build Environment"
39 33
     $f $1 $testenv
40
-    env_restore
34
+    git reset --hard HEAD
41 35
   done
42 36
 else
43
-  env_backup
44 37
   exec_test $1 "$2 --target clean" "Setup Build Environment"
45 38
   $2-tests $1 $2
46
-  env_restore
39
+  git reset --hard HEAD
47 40
 fi
48 41
 printf "\033[0;32mAll tests completed successfully\033[0m\n"

+ 0
- 2
buildroot/share/tests/teensy31-tests Wyświetl plik

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

+ 0
- 2
buildroot/share/tests/teensy35-tests Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz