mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 142:7f2b6c44bbe3
- Child:
- 242:7074e42da0b2
diff -r b062af740e40 -r 7bd0639b8911 targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c --- a/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/pinmap.c Wed Jun 11 16:00:09 2014 +0100 @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ +#include "mbed_assert.h" #include "device.h" #include "pinmap.h" #include "error.h" @@ -74,7 +75,7 @@ break; default: error("Pinmap error: wrong port number."); - break; + break; } return gpio_add; } @@ -83,8 +84,7 @@ * Configure pin (mode, speed, output type and pull-up/pull-down) */ void pin_function(PinName pin, int data) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); // Get the pin informations uint32_t mode = STM_PIN_MODE(data); uint32_t pupd = STM_PIN_PUPD(data); @@ -113,15 +113,14 @@ //} //if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) { // - //} + //} } /** * Configure pin pull-up/pull-down */ void pin_mode(PinName pin, PinMode mode) { - if (pin == NC) return; - + MBED_ASSERT(pin != (PinName)NC); uint32_t port_index = STM_PORT(pin); uint32_t pin_index = STM_PIN(pin); @@ -131,7 +130,8 @@ // Configure pull-up/pull-down resistors uint32_t pupd = (uint32_t)mode; - if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down + if (pupd > 2) + pupd = 0; // Open-drain = No pull-up/No pull-down gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2))); gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2));