EL4121 Embedded System / mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

UserRevisionLine numberNew contents of line
be_bryan 0:b74591d5ab33 1 /* mbed Microcontroller Library
be_bryan 0:b74591d5ab33 2 *******************************************************************************
be_bryan 0:b74591d5ab33 3 * Copyright (c) 2016, STMicroelectronics
be_bryan 0:b74591d5ab33 4 * All rights reserved.
be_bryan 0:b74591d5ab33 5 *
be_bryan 0:b74591d5ab33 6 * Redistribution and use in source and binary forms, with or without
be_bryan 0:b74591d5ab33 7 * modification, are permitted provided that the following conditions are met:
be_bryan 0:b74591d5ab33 8 *
be_bryan 0:b74591d5ab33 9 * 1. Redistributions of source code must retain the above copyright notice,
be_bryan 0:b74591d5ab33 10 * this list of conditions and the following disclaimer.
be_bryan 0:b74591d5ab33 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
be_bryan 0:b74591d5ab33 12 * this list of conditions and the following disclaimer in the documentation
be_bryan 0:b74591d5ab33 13 * and/or other materials provided with the distribution.
be_bryan 0:b74591d5ab33 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
be_bryan 0:b74591d5ab33 15 * may be used to endorse or promote products derived from this software
be_bryan 0:b74591d5ab33 16 * without specific prior written permission.
be_bryan 0:b74591d5ab33 17 *
be_bryan 0:b74591d5ab33 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
be_bryan 0:b74591d5ab33 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
be_bryan 0:b74591d5ab33 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
be_bryan 0:b74591d5ab33 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
be_bryan 0:b74591d5ab33 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
be_bryan 0:b74591d5ab33 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
be_bryan 0:b74591d5ab33 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
be_bryan 0:b74591d5ab33 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
be_bryan 0:b74591d5ab33 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
be_bryan 0:b74591d5ab33 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
be_bryan 0:b74591d5ab33 28 *******************************************************************************
be_bryan 0:b74591d5ab33 29 */
be_bryan 0:b74591d5ab33 30 #ifndef MBED_PIN_DEVICE_H
be_bryan 0:b74591d5ab33 31 #define MBED_PIN_DEVICE_H
be_bryan 0:b74591d5ab33 32
be_bryan 0:b74591d5ab33 33 #include "cmsis.h"
be_bryan 0:b74591d5ab33 34 #include "stm32l4xx_ll_gpio.h"
be_bryan 0:b74591d5ab33 35
be_bryan 0:b74591d5ab33 36 extern const uint32_t ll_pin_defines[16];
be_bryan 0:b74591d5ab33 37
be_bryan 0:b74591d5ab33 38 /* Family specific implementations */
be_bryan 0:b74591d5ab33 39 static inline void stm_pin_DisconnectDebug(PinName pin)
be_bryan 0:b74591d5ab33 40 {
be_bryan 0:b74591d5ab33 41 /* empty for now */
be_bryan 0:b74591d5ab33 42 }
be_bryan 0:b74591d5ab33 43
be_bryan 0:b74591d5ab33 44 static inline void stm_pin_PullConfig(GPIO_TypeDef *gpio, uint32_t ll_pin, uint32_t pull_config)
be_bryan 0:b74591d5ab33 45 {
be_bryan 0:b74591d5ab33 46 switch (pull_config) {
be_bryan 0:b74591d5ab33 47 case GPIO_PULLUP:
be_bryan 0:b74591d5ab33 48 LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_UP);
be_bryan 0:b74591d5ab33 49 break;
be_bryan 0:b74591d5ab33 50 case GPIO_PULLDOWN:
be_bryan 0:b74591d5ab33 51 LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN);
be_bryan 0:b74591d5ab33 52 break;
be_bryan 0:b74591d5ab33 53 default:
be_bryan 0:b74591d5ab33 54 LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_NO);
be_bryan 0:b74591d5ab33 55 break;
be_bryan 0:b74591d5ab33 56 }
be_bryan 0:b74591d5ab33 57 }
be_bryan 0:b74591d5ab33 58
be_bryan 0:b74591d5ab33 59 static inline void stm_pin_SetAFPin( GPIO_TypeDef *gpio, PinName pin, uint32_t afnum)
be_bryan 0:b74591d5ab33 60 {
be_bryan 0:b74591d5ab33 61 uint32_t ll_pin = ll_pin_defines[STM_PIN(pin)];
be_bryan 0:b74591d5ab33 62
be_bryan 0:b74591d5ab33 63 if (STM_PIN(pin) > 7)
be_bryan 0:b74591d5ab33 64 LL_GPIO_SetAFPin_8_15(gpio, ll_pin, afnum);
be_bryan 0:b74591d5ab33 65 else
be_bryan 0:b74591d5ab33 66 LL_GPIO_SetAFPin_0_7(gpio, ll_pin, afnum);
be_bryan 0:b74591d5ab33 67 }
be_bryan 0:b74591d5ab33 68
be_bryan 0:b74591d5ab33 69 #endif