From 313e37c0b282de83a58e9934b48bdfbf43dde326 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Tue, 10 Nov 2015 18:07:18 +0100 Subject: [PATCH] STM32F411: implement SET_INPUT() and READ(). --- pinio.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pinio.h b/pinio.h index 21b373a..93ab237 100644 --- a/pinio.h +++ b/pinio.h @@ -116,7 +116,11 @@ #elif defined __ARM_STM32F411__ /** + Modified mbed-system of BSRR. Originally it is 32bit. Now we have low/high-bit + splitted in 2x16bit. Much easier to handle. Low-bit for HIGH and high-bit for LOW. */ + /// Read a pin. + #define _READ(IO) (IO ## _PORT->IDR & MASK(IO ## _PIN)) /// Write to a pin. #define _WRITE(IO, v) \ do { \ @@ -126,6 +130,19 @@ IO ## _PORT->BSRR = MASK((IO ## _PIN + 16)); \ } while (0) + /** + Set pins as input/output. Standard is input. MODER ist 32bit. 2bits for every pin. + */ + /** Set pin as input. + - reset pullup + - set input mode + */ + #define _SET_INPUT(IO) \ + do { \ + IO ## _PORT->PUPDR &= ~(3 << ((IO ## _PIN) << 1)); \ + IO ## _PORT->MODER &= ~(3 << ((IO ## _PIN) << 1)); \ + } while (0) + /** Set pin as output. - reset Pullup - reset direction mode