Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed. (modified for use opendrain in stm32)

Dependents:   hctl2032_encoder

Fork of FastIO by Erik -

Files at this revision

API Documentation at this revision

Comitter:
c128
Date:
Fri Sep 05 04:48:50 2014 +0000
Parent:
8:b0d725519c4f
Commit message:
changes to make opendrain working in stm32

Changed in this revision

Devices/FastIO_NUCLEO_F401.h Show annotated file Show diff for this revision Revisions of this file
FastIO.h Show annotated file Show diff for this revision Revisions of this file
diff -r b0d725519c4f -r 6e0f24f71081 Devices/FastIO_NUCLEO_F401.h
--- a/Devices/FastIO_NUCLEO_F401.h	Tue Aug 12 07:15:20 2014 +0000
+++ b/Devices/FastIO_NUCLEO_F401.h	Fri Sep 05 04:48:50 2014 +0000
@@ -16,6 +16,32 @@
 #define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_DIR_OUTPUT      (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_MODE(pull)      pin_mode(pin, pull);
+#define SET_FUNCTION        pin_function(pin, STM_PIN_DATA(2, GPIO_NOPULL, GPIO_AF10_OTG_FS));
+
+//pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP));
+//void pin_function(PinName pin, int data) {
+//    MBED_ASSERT(pin != (PinName)NC);
+//    // Get the pin informations
+//    uint32_t mode  = STM_PIN_MODE(data);
+//    uint32_t pupd  = STM_PIN_PUPD(data);
+//    uint32_t afnum = STM_PIN_AFNUM(data);
+
+//    uint32_t port_index = STM_PORT(pin);
+//    uint32_t pin_index  = STM_PIN(pin);
+
+    // Enable GPIO clock
+//    uint32_t gpio_add = Set_GPIO_Clock(port_index);
+//    GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
+
+    // Configure GPIO
+//    GPIO_InitTypeDef GPIO_InitStructure;
+//   GPIO_InitStructure.Pin       = (uint32_t)(1 << pin_index);
+//    GPIO_InitStructure.Mode      = gpio_mode[mode];
+//    GPIO_InitStructure.Pull      = pupd;
+//    GPIO_InitStructure.Speed     = GPIO_SPEED_HIGH;
+//    GPIO_InitStructure.Alternate = afnum;
+//    HAL_GPIO_Init(gpio, &GPIO_InitStructure);
+
 
 #define WRITE_PIN_SET       (PORT->BSRRL = PINMASK)
 #define WRITE_PIN_CLR       (PORT->BSRRH = PINMASK)
@@ -23,3 +49,4 @@
 #define READ_PIN            ((PORT->IDR & container.mask) ? 1 : 0)
 
 #endif
+
diff -r b0d725519c4f -r 6e0f24f71081 FastIO.h
--- a/FastIO.h	Tue Aug 12 07:15:20 2014 +0000
+++ b/FastIO.h	Fri Sep 05 04:48:50 2014 +0000
@@ -108,6 +108,8 @@
         FastInOut<pin>::FastInOut();
         write(initial);
         SET_DIR_OUTPUT;
+        SET_FUNCTION;
+
     }
 
     FastOut& operator= (int value) {