Parcourir la source

Fix HAL/STM32 FastIO for analog pins (#19735)

Serhiy-K il y a 3 ans
Parent
révision
cc7fbabc96
2 fichiers modifiés avec 9 ajouts et 11 suppressions
  1. 5
    5
      Marlin/src/HAL/STM32/fastio.h
  2. 4
    6
      Marlin/src/HAL/STM32/pinsDebug_STM32duino.h

+ 5
- 5
Marlin/src/HAL/STM32/fastio.h Voir le fichier

51
 
51
 
52
 #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx)
52
 #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx)
53
   #define _WRITE(IO, V) do { \
53
   #define _WRITE(IO, V) do { \
54
-    if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \
55
-    else   FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR  = _BV32(STM_PIN(digitalPin[IO])) ; \
54
+    if (V) FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \
55
+    else   FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BRR  = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \
56
   }while(0)
56
   }while(0)
57
 #else
57
 #else
58
-  #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO]) + ((V) ? 0 : 16)))
58
+  #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO)) + ((V) ? 0 : 16)))
59
 #endif
59
 #endif
60
 
60
 
61
-#define _READ(IO)               bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPin[IO])]->IDR, _BV32(STM_PIN(digitalPin[IO]))))
62
-#define _TOGGLE(IO)             (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(STM_PIN(digitalPin[IO])))
61
+#define _READ(IO)               bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO)))))
62
+#define _TOGGLE(IO)             (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO))))
63
 
63
 
64
 #define _GET_MODE(IO)
64
 #define _GET_MODE(IO)
65
 #define _SET_MODE(IO,M)         pinMode(IO, M)
65
 #define _SET_MODE(IO,M)         pinMode(IO, M)

+ 4
- 6
Marlin/src/HAL/STM32/pinsDebug_STM32duino.h Voir le fichier

51
  *  It contains:
51
  *  It contains:
52
  *    - name of the signal
52
  *    - name of the signal
53
  *    - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines.
53
  *    - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines.
54
- *        EXAMPLE:  "#define KILL_PIN  PB1" results in Ard_num of 57.  57 is then used as an
55
- *                  index into digitalPin[] to get the Port_pin number
54
+ *        EXAMPLE:  "#define KILL_PIN  PB1" results in Ard_num of 57.  57 is then used as the
55
+ *                  argument to digitalPinToPinName(IO) to get the Port_pin number
56
  *    - if it is a digital or analog signal.  PWMs are considered digital here.
56
  *    - if it is a digital or analog signal.  PWMs are considered digital here.
57
  *
57
  *
58
  *  pin_xref is a structure generated by this header file.  It is generated by the
58
  *  pin_xref is a structure generated by this header file.  It is generated by the
68
  *          signal.  The Arduino pin number is listed by the M43 I command.
68
  *          signal.  The Arduino pin number is listed by the M43 I command.
69
  */
69
  */
70
 
70
 
71
-extern const PinName digitalPin[];  // provided by the platform
72
-
73
 ////////////////////////////////////////////////////////
71
 ////////////////////////////////////////////////////////
74
 //
72
 //
75
 // make a list of the Arduino pin numbers in the Port/Pin order
73
 // make a list of the Arduino pin numbers in the Port/Pin order
137
 
135
 
138
 uint8_t get_pin_mode(const pin_t Ard_num) {
136
 uint8_t get_pin_mode(const pin_t Ard_num) {
139
   uint32_t mode_all = 0;
137
   uint32_t mode_all = 0;
140
-  const PinName dp = digitalPin[Ard_num];
138
+  const PinName dp = digitalPinToPinName(Ard_num);
141
   switch (PORT_ALPHA(dp)) {
139
   switch (PORT_ALPHA(dp)) {
142
     case 'A' : mode_all = GPIOA->MODER; break;
140
     case 'A' : mode_all = GPIOA->MODER; break;
143
     case 'B' : mode_all = GPIOB->MODER; break;
141
     case 'B' : mode_all = GPIOB->MODER; break;
218
 void pwm_details(const pin_t Ard_num) {
216
 void pwm_details(const pin_t Ard_num) {
219
   if (pwm_status(Ard_num)) {
217
   if (pwm_status(Ard_num)) {
220
     uint32_t alt_all = 0;
218
     uint32_t alt_all = 0;
221
-    const PinName dp = digitalPin[Ard_num];
219
+    const PinName dp = digitalPinToPinName(Ard_num);
222
     pin_t pin_number = uint8_t(PIN_NUM(dp));
220
     pin_t pin_number = uint8_t(PIN_NUM(dp));
223
     const bool over_7 = pin_number >= 8;
221
     const bool over_7 = pin_number >= 8;
224
     const uint8_t ind = over_7 ? 1 : 0;
222
     const uint8_t ind = over_7 ? 1 : 0;

Chargement…
Annuler
Enregistrer