mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
489:119543c9f674
Parent:
382:ee426a420dbb
--- a/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_gpio.c	Thu Mar 05 13:15:07 2015 +0000
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_gpio.c	Thu Mar 12 14:30:49 2015 +0000
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32l0xx_hal_gpio.c
   * @author  MCD Application Team
-  * @version V1.1.0
-  * @date    18-June-2014
+  * @version V1.2.0
+  * @date    06-February-2015
   * @brief   GPIO HAL module driver.  
   *          This file provides firmware functions to manage the following 
   *          functionalities of the General Purpose Input/Output (GPIO) peripheral:
@@ -41,7 +41,7 @@
   lines, the port must be configured in input mode. All available GPIO pins are 
   connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
   
-    (+) The external interrupt/event controller consists of up to 23 edge detectors 
+    (+) The external interrupt/event controller consists of up to 28 edge detectors
   (16 lines are connected to GPIO) for generating event/interrupt requests (each 
   input line can be independently configured to select the type (interrupt or event) 
   and the corresponding trigger event (rising or falling or both). Each line can 
@@ -50,11 +50,8 @@
                      ##### How to use this driver #####
   ==============================================================================  
   [..]             
-    (#) Enable the GPIO IOPORT clock using the following function: __GPIOx_CLK_ENABLE(). 
-  
-    (#) In case of external interrupt/event mode selection, enable the SYSCFG clock 
-       using the following function  __SYSCFG_CLK_ENABLE().  
-             
+    (#) Enable the GPIO IOPORT clock using the following function: __HAL_RCC_GPIOx_CLK_ENABLE(). 
+
     (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
         (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
         (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef 
@@ -73,11 +70,18 @@
         mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
         HAL_NVIC_EnableIRQ().
          
+   (#) HAL_GPIO_DeInit allows to set register values to their reset value. This function
+       is also to be used when unconfiguring pin which was used as an external interrupt
+       or in event mode. That is the only way to reset the corresponding bit in
+       EXTI & SYSCFG registers.
+
     (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
             
     (#) To set/reset the level of a pin configured in output mode use 
         HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
-                 
+
+    (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
+
     (#) During and just after reset, the alternate functions are not 
         active and the GPIO pins are configured in input floating mode (except JTAG
         pins).
@@ -94,7 +98,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -128,7 +132,7 @@
   * @{
   */
 
-/** @defgroup GPIO
+/** @addtogroup GPIO
   * @brief GPIO HAL module driver
   * @{
   */
@@ -138,12 +142,6 @@
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
 /* Private macro -------------------------------------------------------------*/
-#define GET_GPIO_SOURCE(__GPIOx__) \
-(((uint32_t)(__GPIOx__) == ((uint32_t)GPIOA_BASE))? 0 :\
- ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0400)))? (uint32_t)1 :\
- ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0800)))? (uint32_t)2 :\
- ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0C00)))? (uint32_t)3 :\
- ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1C00)))? (uint32_t)4 : (uint32_t)5)
 
  
 #define GPIO_MODE             ((uint32_t)0x00000003)
@@ -159,12 +157,12 @@
 /* Private function prototypes -----------------------------------------------*/
 /* Private functions ---------------------------------------------------------*/
 
-/** @defgroup GPIO_Private_Functions
+/** @addtogroup GPIO_Exported_Functions
   * @{
   */
 
-/** @defgroup GPIO_Group1 Initialization and de-initialization functions 
- *  @brief    Initialization and Configuration functions 
+/** @addtogroup GPIO_Exported_Functions_Group1
+ *  @brief    Initialization and de-initialization functions
  *
 @verbatim
  ===============================================================================
@@ -177,23 +175,24 @@
 
 /**
   * @brief  Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
-  * @param  GPIOx: where x can be (A..D and H) to select the GPIO peripheral for STM32L0XX family devices.
+  * @param  GPIOx: where x can be (A..E and H) to select the GPIO peripheral for STM32L0XX family devices.
+  *                Note that GPIOE is not available on all devices.
   * @param  GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains
-  *         the configuration information for the specified GPIO peripheral.
+  *                    the configuration information for the specified GPIO peripheral.
   * @retval None
   */
 void HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)
 {
-  uint32_t position;
+  uint32_t position = 0x00;
   uint32_t ioposition = 0x00;
   uint32_t iocurrent = 0x00;
   uint32_t temp = 0x00;
-  
+ 
   /* Check the parameters */
-  assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
   assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
-  assert_param(IS_GPIO_PULL(GPIO_Init->Pull)); 
-  
+  assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
+  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,(GPIO_Init->Pin)));
+
   /* Configure the port pins */
   for(position = 0; position < GPIO_NUMBER; position++)
   {
@@ -210,6 +209,8 @@
       {
         /* Check the Alternate function parameter */
         assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
+        /* Check if the Alternate function is compliant with the GPIO in use */
+        assert_param(IS_GPIO_AF_AVAILABLE(GPIOx,(GPIO_Init->Alternate)));
         /* Configure Alternate function mapped with the current IO */ 
         temp = GPIOx->AFR[position >> 3];
         temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
@@ -253,11 +254,11 @@
       if((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE) 
       {
         /* Enable SYSCFG Clock */
-        __SYSCFG_CLK_ENABLE();
+        __HAL_RCC_SYSCFG_CLK_ENABLE();
 
         temp = SYSCFG->EXTICR[position >> 2];
-        temp &= ~((uint32_t)0x0F) << (4 * (position & 0x03));
-        temp |= ((uint32_t)(GET_GPIO_SOURCE(GPIOx)) << (4 * (position & 0x03)));
+        temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03)));
+        temp |= ((uint32_t)(GPIO_GET_INDEX(GPIOx)) << (4 * (position & 0x03)));
         SYSCFG->EXTICR[position >> 2] = temp;
 
         /* Clear EXTI line configuration */
@@ -300,18 +301,23 @@
 
 /**
   * @brief  De-initializes the GPIOx peripheral registers to their default reset values.
-  * @param  GPIOx: where x can be (A..D and H) to select the GPIO peripheral for STM32L0XX family devices. 
+  * @param  GPIOx: where x can be (A..E and H) to select the GPIO peripheral for STM32L0XX family devices.
+  *                Note that GPIOE is not available on all devices.
   * @param  GPIO_Pin: specifies the port bit to be written.
-  *          This parameter can be one of GPIO_PIN_x where x can be (0..15) except for GPIOD(2) and GPIOH(1:0).
+  *                   This parameter can be one of GPIO_PIN_x where x can be (0..15).
+  *                   All port bits are not necessarily available on all GPIOs.
   * @retval None
   */
 void HAL_GPIO_DeInit(GPIO_TypeDef  *GPIOx, uint32_t GPIO_Pin)
 { 
-  uint32_t position;
+  uint32_t position = 0x00;
   uint32_t ioposition = 0x00;
   uint32_t iocurrent = 0x00;
   uint32_t tmp = 0x00;
-  
+
+  /* Check the parameters */
+   assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,GPIO_Pin));
+
   /* Configure the port pins */
   for(position = 0; position < GPIO_NUMBER; position++)
   {
@@ -359,7 +365,7 @@
   * @}
   */
 
-/** @defgroup GPIO_Group2 IO operation functions 
+/** @addtogroup GPIO_Exported_Functions_Group2
  *  @brief   GPIO Read and Write
  *
 @verbatim
@@ -373,9 +379,11 @@
 
 /**
   * @brief  Reads the specified input port pin.
-  * @param  GPIOx: where x can be (A..D and H) to select the GPIO peripheral for STM32L0xx family devices. 
+  * @param  GPIOx: where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
+  *                Note that GPIOE is not available on all devices.
   * @param  GPIO_Pin: specifies the port bit to read.
-  *         This parameter can be GPIO_PIN_x where x can be (0..15) except for GPIOD(2) and GPIOH(1:0).
+  *                   This parameter can be GPIO_PIN_x where x can be (0..15).
+  *                   All port bits are not necessarily available on all GPIOs.
   * @retval The input port pin value.
   */
 GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
@@ -383,7 +391,7 @@
   GPIO_PinState bitstatus;
   
   /* Check the parameters */
-  assert_param(IS_GPIO_PIN(GPIO_Pin));
+  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,GPIO_Pin));
   
   if((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
   {
@@ -403,19 +411,21 @@
   *         accesses. In this way, there is no risk of an IRQ occurring between
   *         the read and the modify access.
   *               
-  * @param  GPIOx: where x can be (A..D and H) to select the GPIO peripheral for STM32L0xx family devices. 
+  * @param  GPIOx: where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
+  *                Note that GPIOE is not available on all devices.
   * @param  GPIO_Pin: specifies the port bit to be written.
-  *          This parameter can be one of GPIO_PIN_x where x can be (0..15) except for GPIOD(2) and GPIOH(1:0).
+  *                   This parameter can be one of GPIO_PIN_x where x can be (0..15).
+  *                   All port bits are not necessarily available on all GPIOs.
   * @param  PinState: specifies the value to be written to the selected bit.
-  *          This parameter can be one of the GPIO_PinState enum values:
-  *            GPIO_PIN_RESET: to clear the port pin
-  *            GPIO_PIN_SET: to set the port pin
+  *                   This parameter can be one of the GPIO_PinState enum values:
+  *                        GPIO_PIN_RESET: to clear the port pin
+  *                        GPIO_PIN_SET: to set the port pin
   * @retval None
   */
 void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
 {
   /* Check the parameters */
-  assert_param(IS_GPIO_PIN(GPIO_Pin));
+  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,GPIO_Pin));
   assert_param(IS_GPIO_PIN_ACTION(PinState));
   
   if(PinState != GPIO_PIN_RESET)
@@ -430,14 +440,16 @@
 
 /**
   * @brief  Toggles the specified GPIO pins.
-  * @param  GPIOx: Where x can be (A..D and H) to select the GPIO peripheral for STM32L0xx family devices.  
+  * @param  GPIOx: Where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
+  *                Note that GPIOE is not available on all devices.
+  *                All port bits are not necessarily available on all GPIOs.
   * @param  GPIO_Pin: Specifies the pins to be toggled.
   * @retval None
   */
 void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
 {
   /* Check the parameters */
-  assert_param(IS_GPIO_PIN(GPIO_Pin));
+  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,GPIO_Pin));
 
   GPIOx->ODR ^= GPIO_Pin;
 }
@@ -448,9 +460,11 @@
 *         GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
 * @note   The configuration of the locked GPIO pins can no longer be modified
 *         until the next reset.
-* @param  GPIOx: where x can be (A..D and H) to select the GPIO peripheral for STM32F3 family
+* @param  GPIOx: where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family.
+*                Note that GPIOE is not available on all devices.
 * @param  GPIO_Pin: specifies the port bit to be locked.
 *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
+*         All port bits are not necessarily available on all GPIOs.
 * @retval None
 */
 HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
@@ -458,7 +472,7 @@
   __IO uint32_t tmp = GPIO_LCKR_LCKK;
 
   /* Check the parameters */
-  assert_param(IS_GPIO_PIN(GPIO_Pin));
+  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx,GPIO_Pin));
 
   /* Apply lock key write sequence */
   tmp |= GPIO_Pin;
@@ -482,7 +496,7 @@
 }
 /**
   * @brief  This function handles EXTI interrupt request.
-  * @param  GPIO_Pin: Specifies the pins connected EXTI line
+  * @param  GPIO_Pin: Specifies the pins connected to the EXTI line.
   * @retval None
   */
 void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
@@ -497,7 +511,7 @@
 
 /**
   * @brief  EXTI line detection callbacks.
-  * @param  GPIO_Pin: Specifies the pins connected EXTI line
+  * @param  GPIO_Pin: Specifies the pins connected to the EXTI line.
   * @retval None
   */
 __weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
@@ -526,3 +540,4 @@
   */
 
 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+