Restructure libs source to support multi platform
[fw/stlink] / example / libs_stm / src / stm32l1xx / stm32l1xx_dbgmcu.c
diff --git a/example/libs_stm/src/stm32l1xx/stm32l1xx_dbgmcu.c b/example/libs_stm/src/stm32l1xx/stm32l1xx_dbgmcu.c
new file mode 100644 (file)
index 0000000..f6b5712
--- /dev/null
@@ -0,0 +1,170 @@
+/**\r
+  ******************************************************************************\r
+  * @file    stm32l1xx_dbgmcu.c\r
+  * @author  MCD Application Team\r
+  * @version V1.0.0\r
+  * @date    31-December-2010\r
+  * @brief   This file provides all the DBGMCU firmware functions.\r
+  ******************************************************************************\r
+  * @attention\r
+  *\r
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
+  *\r
+  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
+  ******************************************************************************  \r
+  */ \r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32l1xx_dbgmcu.h"\r
+\r
+/** @addtogroup STM32L1xx_StdPeriph_Driver\r
+  * @{\r
+  */\r
+\r
+/** @defgroup DBGMCU \r
+  * @brief DBGMCU driver modules\r
+  * @{\r
+  */ \r
+\r
+/* Private typedef -----------------------------------------------------------*/\r
+/* Private define ------------------------------------------------------------*/\r
+#define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)\r
+\r
+/* Private macro -------------------------------------------------------------*/\r
+/* Private variables ---------------------------------------------------------*/\r
+/* Private function prototypes -----------------------------------------------*/\r
+/* Private functions ---------------------------------------------------------*/\r
+\r
+/** @defgroup DBGMCU_Private_Functions\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @brief  Returns the device revision identifier.\r
+  * @param  None\r
+  * @retval Device revision identifier\r
+  */\r
+uint32_t DBGMCU_GetREVID(void)\r
+{\r
+   return(DBGMCU->IDCODE >> 16);\r
+}\r
+\r
+/**\r
+  * @brief  Returns the device identifier.\r
+  * @param  None\r
+  * @retval Device identifier\r
+  */\r
+uint32_t DBGMCU_GetDEVID(void)\r
+{\r
+   return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);\r
+}\r
+\r
+/**\r
+  * @brief  Configures low power mode behavior when the MCU is in Debug mode.\r
+  * @param  DBGMCU_Periph: specifies the low power mode.\r
+  *   This parameter can be any combination of the following values:\r
+  *     @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode              \r
+  *     @arg DBGMCU_STOP: Keep debugger connection during STOP mode               \r
+  *     @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode                    \r
+  * @param  NewState: new state of the specified low power mode in Debug mode.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  if (NewState != DISABLE)\r
+  {\r
+    DBGMCU->CR |= DBGMCU_Periph;\r
+  }\r
+  else\r
+  {\r
+    DBGMCU->CR &= ~DBGMCU_Periph;\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  * @brief  Configures APB1 peripheral behavior when the MCU is in Debug mode.\r
+  * @param  DBGMCU_Periph: specifies the APB1 peripheral.\r
+  *   This parameter can be any combination of the following values:\r
+  *     @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted              \r
+  *     @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted               \r
+  *     @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted\r
+  *     @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted\r
+  *     @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted\r
+  *     @arg DBGMCU_RTC_STOP: RTC Wakeup counter stopped when Core is halted  \r
+  *     @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted\r
+  *     @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted\r
+  *     @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is \r
+  *                                     halted\r
+  *     @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is \r
+  *                                     halted                               \r
+  * @param  NewState: new state of the specified APB1 peripheral in Debug mode.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  if (NewState != DISABLE)\r
+  {\r
+    DBGMCU->APB1FZ |= DBGMCU_Periph;\r
+  }\r
+  else\r
+  {\r
+    DBGMCU->APB1FZ &= ~DBGMCU_Periph;\r
+  }\r
+}\r
+\r
+/**\r
+  * @brief  Configures APB2 peripheral behavior when the MCU is in Debug mode.\r
+  * @param  DBGMCU_Periph: specifies the APB2 peripheral.\r
+  *   This parameter can be any combination of the following values:\r
+  *     @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted              \r
+  *     @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted               \r
+  *     @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted                              \r
+  * @param  NewState: new state of the specified APB2 peripheral in Debug mode.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  if (NewState != DISABLE)\r
+  {\r
+    DBGMCU->APB2FZ |= DBGMCU_Periph;\r
+  }\r
+  else\r
+  {\r
+    DBGMCU->APB2FZ &= ~DBGMCU_Periph;\r
+  }\r
+}\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r