@@ -51,19 +51,19 @@ void FastIO_init(); // Must be called before using fast io macros
5151
5252#if defined(STM32F0xx ) || defined(STM32F1xx ) || defined(STM32F3xx ) || defined(STM32L0xx ) || defined(STM32L4xx )
5353 #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(digitalPin[IO])]->BSRR = _BV32(digitalPinToPinName(IO) & 0x1F ) ; \
55+ else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(digitalPinToPinName(IO) & 0x1F ) ; \
5656 }while(0)
5757#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(digitalPin[IO])]->BSRR = _BV32(digitalPinToPinName(IO ) + ((V) ? 0 : 16)))
5959#endif
6060
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(digitalPin[IO])]->IDR, _BV32(digitalPinToPinName(IO) & 0x1F )))
62+ #define _TOGGLE (IO ) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(digitalPinToPinName(IO) & 0x1F ))
6363
6464#define _GET_MODE (IO )
6565#define _SET_MODE (IO ,M ) pinMode(IO, M)
66- #define _SET_OUTPUT (IO ) pinMode(IO, OUTPUT) /* !< Output Push Pull Mode & GPIO_NOPULL */
66+ #define _SET_OUTPUT (IO ) pinMode(IO, OUTPUT) // !< Output Push Pull Mode & GPIO_NOPULL
6767#define _SET_OUTPUT_OD (IO ) pinMode(IO, OUTPUT_OPEN_DRAIN)
6868
6969#define WRITE (IO ,V ) _WRITE(IO,V)
@@ -73,9 +73,9 @@ void FastIO_init(); // Must be called before using fast io macros
7373#define OUT_WRITE (IO ,V ) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
7474#define OUT_WRITE_OD (IO ,V ) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
7575
76- #define SET_INPUT (IO ) _SET_MODE(IO, INPUT) /* !< Input Floating Mode */
77- #define SET_INPUT_PULLUP (IO ) _SET_MODE(IO, INPUT_PULLUP) /* !< Input with Pull-up activation */
78- #define SET_INPUT_PULLDOWN (IO ) _SET_MODE(IO, INPUT_PULLDOWN) /* !< Input with Pull-down activation */
76+ #define SET_INPUT (IO ) _SET_MODE(IO, INPUT) // !< Input Floating Mode
77+ #define SET_INPUT_PULLUP (IO ) _SET_MODE(IO, INPUT_PULLUP) // !< Input with Pull-up activation
78+ #define SET_INPUT_PULLDOWN (IO ) _SET_MODE(IO, INPUT_PULLDOWN) // !< Input with Pull-down activation
7979#define SET_OUTPUT (IO ) OUT_WRITE(IO, LOW)
8080#define SET_PWM (IO ) _SET_MODE(IO, PWM)
8181
0 commit comments