Martin Johnson / STM32F3-Discovery

Dependents:   Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more

Committer:
MartinJohnson
Date:
Thu Apr 26 03:11:18 2018 +0000
Revision:
1:f8e3e71af478
Parent:
0:404f5a4f1385
Add stdio.h serial I/O support for the version D discovery board.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MartinJohnson 0:404f5a4f1385 1 /**
MartinJohnson 0:404f5a4f1385 2 ******************************************************************************
MartinJohnson 0:404f5a4f1385 3 * @file stm32f30x_dbgmcu.c
MartinJohnson 0:404f5a4f1385 4 * @author MCD Application Team
MartinJohnson 0:404f5a4f1385 5 * @version V1.2.3
MartinJohnson 0:404f5a4f1385 6 * @date 10-July-2015
MartinJohnson 0:404f5a4f1385 7 * @brief This file provides firmware functions to manage the following
MartinJohnson 0:404f5a4f1385 8 * functionalities of the Debug MCU (DBGMCU) peripheral:
MartinJohnson 0:404f5a4f1385 9 * + Device and Revision ID management
MartinJohnson 0:404f5a4f1385 10 * + Peripherals Configuration
MartinJohnson 0:404f5a4f1385 11 ******************************************************************************
MartinJohnson 0:404f5a4f1385 12 * @attention
MartinJohnson 0:404f5a4f1385 13 *
MartinJohnson 0:404f5a4f1385 14 * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
MartinJohnson 0:404f5a4f1385 15 *
MartinJohnson 0:404f5a4f1385 16 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
MartinJohnson 0:404f5a4f1385 17 * You may not use this file except in compliance with the License.
MartinJohnson 0:404f5a4f1385 18 * You may obtain a copy of the License at:
MartinJohnson 0:404f5a4f1385 19 *
MartinJohnson 0:404f5a4f1385 20 * http://www.st.com/software_license_agreement_liberty_v2
MartinJohnson 0:404f5a4f1385 21 *
MartinJohnson 0:404f5a4f1385 22 * Unless required by applicable law or agreed to in writing, software
MartinJohnson 0:404f5a4f1385 23 * distributed under the License is distributed on an "AS IS" BASIS,
MartinJohnson 0:404f5a4f1385 24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MartinJohnson 0:404f5a4f1385 25 * See the License for the specific language governing permissions and
MartinJohnson 0:404f5a4f1385 26 * limitations under the License.
MartinJohnson 0:404f5a4f1385 27 *
MartinJohnson 0:404f5a4f1385 28 ******************************************************************************
MartinJohnson 0:404f5a4f1385 29 */
MartinJohnson 0:404f5a4f1385 30
MartinJohnson 0:404f5a4f1385 31 /* Includes ------------------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 32 #include "stm32f30x_dbgmcu.h"
MartinJohnson 0:404f5a4f1385 33
MartinJohnson 0:404f5a4f1385 34 /** @addtogroup STM32F30x_StdPeriph_Driver
MartinJohnson 0:404f5a4f1385 35 * @{
MartinJohnson 0:404f5a4f1385 36 */
MartinJohnson 0:404f5a4f1385 37
MartinJohnson 0:404f5a4f1385 38 /** @defgroup DBGMCU
MartinJohnson 0:404f5a4f1385 39 * @brief DBGMCU driver modules
MartinJohnson 0:404f5a4f1385 40 * @{
MartinJohnson 0:404f5a4f1385 41 */
MartinJohnson 0:404f5a4f1385 42
MartinJohnson 0:404f5a4f1385 43 /* Private typedef -----------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 44 /* Private define ------------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 45 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
MartinJohnson 0:404f5a4f1385 46
MartinJohnson 0:404f5a4f1385 47 /* Private macro -------------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 48 /* Private variables ---------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 49 /* Private function prototypes -----------------------------------------------*/
MartinJohnson 0:404f5a4f1385 50 /* Private functions ---------------------------------------------------------*/
MartinJohnson 0:404f5a4f1385 51
MartinJohnson 0:404f5a4f1385 52 /** @defgroup DBGMCU_Private_Functions
MartinJohnson 0:404f5a4f1385 53 * @{
MartinJohnson 0:404f5a4f1385 54 */
MartinJohnson 0:404f5a4f1385 55
MartinJohnson 0:404f5a4f1385 56 /** @defgroup DBGMCU_Group1 Device and Revision ID management functions
MartinJohnson 0:404f5a4f1385 57 * @brief Device and Revision ID management functions
MartinJohnson 0:404f5a4f1385 58 *
MartinJohnson 0:404f5a4f1385 59 @verbatim
MartinJohnson 0:404f5a4f1385 60 ==============================================================================
MartinJohnson 0:404f5a4f1385 61 ##### Device and Revision ID management functions #####
MartinJohnson 0:404f5a4f1385 62 ==============================================================================
MartinJohnson 0:404f5a4f1385 63
MartinJohnson 0:404f5a4f1385 64 @endverbatim
MartinJohnson 0:404f5a4f1385 65 * @{
MartinJohnson 0:404f5a4f1385 66 */
MartinJohnson 0:404f5a4f1385 67
MartinJohnson 0:404f5a4f1385 68 /**
MartinJohnson 0:404f5a4f1385 69 * @brief Returns the device revision identifier.
MartinJohnson 0:404f5a4f1385 70 * @param None
MartinJohnson 0:404f5a4f1385 71 * @retval Device revision identifier
MartinJohnson 0:404f5a4f1385 72 */
MartinJohnson 0:404f5a4f1385 73 uint32_t DBGMCU_GetREVID(void)
MartinJohnson 0:404f5a4f1385 74 {
MartinJohnson 0:404f5a4f1385 75 return(DBGMCU->IDCODE >> 16);
MartinJohnson 0:404f5a4f1385 76 }
MartinJohnson 0:404f5a4f1385 77
MartinJohnson 0:404f5a4f1385 78 /**
MartinJohnson 0:404f5a4f1385 79 * @brief Returns the device identifier.
MartinJohnson 0:404f5a4f1385 80 * @param None
MartinJohnson 0:404f5a4f1385 81 * @retval Device identifier
MartinJohnson 0:404f5a4f1385 82 */
MartinJohnson 0:404f5a4f1385 83 uint32_t DBGMCU_GetDEVID(void)
MartinJohnson 0:404f5a4f1385 84 {
MartinJohnson 0:404f5a4f1385 85 return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
MartinJohnson 0:404f5a4f1385 86 }
MartinJohnson 0:404f5a4f1385 87
MartinJohnson 0:404f5a4f1385 88 /**
MartinJohnson 0:404f5a4f1385 89 * @}
MartinJohnson 0:404f5a4f1385 90 */
MartinJohnson 0:404f5a4f1385 91
MartinJohnson 0:404f5a4f1385 92 /** @defgroup DBGMCU_Group2 Peripherals Configuration functions
MartinJohnson 0:404f5a4f1385 93 * @brief Peripherals Configuration
MartinJohnson 0:404f5a4f1385 94 *
MartinJohnson 0:404f5a4f1385 95 @verbatim
MartinJohnson 0:404f5a4f1385 96 ==============================================================================
MartinJohnson 0:404f5a4f1385 97 ##### Peripherals Configuration functions #####
MartinJohnson 0:404f5a4f1385 98 ==============================================================================
MartinJohnson 0:404f5a4f1385 99
MartinJohnson 0:404f5a4f1385 100 @endverbatim
MartinJohnson 0:404f5a4f1385 101 * @{
MartinJohnson 0:404f5a4f1385 102 */
MartinJohnson 0:404f5a4f1385 103
MartinJohnson 0:404f5a4f1385 104 /**
MartinJohnson 0:404f5a4f1385 105 * @brief Configures low power mode behavior when the MCU is in Debug mode.
MartinJohnson 0:404f5a4f1385 106 * @param DBGMCU_Periph: specifies the low power mode.
MartinJohnson 0:404f5a4f1385 107 * This parameter can be any combination of the following values:
MartinJohnson 0:404f5a4f1385 108 * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode.
MartinJohnson 0:404f5a4f1385 109 * @arg DBGMCU_STOP: Keep debugger connection during STOP mode.
MartinJohnson 0:404f5a4f1385 110 * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode.
MartinJohnson 0:404f5a4f1385 111 * @param NewState: new state of the specified low power mode in Debug mode.
MartinJohnson 0:404f5a4f1385 112 * This parameter can be: ENABLE or DISABLE.
MartinJohnson 0:404f5a4f1385 113 * @retval None
MartinJohnson 0:404f5a4f1385 114 */
MartinJohnson 0:404f5a4f1385 115 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
MartinJohnson 0:404f5a4f1385 116 {
MartinJohnson 0:404f5a4f1385 117 /* Check the parameters */
MartinJohnson 0:404f5a4f1385 118 assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
MartinJohnson 0:404f5a4f1385 119 assert_param(IS_FUNCTIONAL_STATE(NewState));
MartinJohnson 0:404f5a4f1385 120 if (NewState != DISABLE)
MartinJohnson 0:404f5a4f1385 121 {
MartinJohnson 0:404f5a4f1385 122 DBGMCU->CR |= DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 123 }
MartinJohnson 0:404f5a4f1385 124 else
MartinJohnson 0:404f5a4f1385 125 {
MartinJohnson 0:404f5a4f1385 126 DBGMCU->CR &= ~DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 127 }
MartinJohnson 0:404f5a4f1385 128 }
MartinJohnson 0:404f5a4f1385 129
MartinJohnson 0:404f5a4f1385 130 /**
MartinJohnson 0:404f5a4f1385 131 * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
MartinJohnson 0:404f5a4f1385 132 * @param DBGMCU_Periph: specifies the APB1 peripheral.
MartinJohnson 0:404f5a4f1385 133 * This parameter can be any combination of the following values:
MartinJohnson 0:404f5a4f1385 134 * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 135 * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 136 * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 137 * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 138 * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 139 * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter are stopped when
MartinJohnson 0:404f5a4f1385 140 * Core is halted.
MartinJohnson 0:404f5a4f1385 141 * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 142 * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 143 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when
MartinJohnson 0:404f5a4f1385 144 * Core is halted.
MartinJohnson 0:404f5a4f1385 145 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when
MartinJohnson 0:404f5a4f1385 146 * Core is halted.
MartinJohnson 0:404f5a4f1385 147 * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 148 * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when
MartinJohnson 0:404f5a4f1385 149 * Core is halted.
MartinJohnson 0:404f5a4f1385 150 * @param NewState: new state of the specified APB1 peripheral in Debug mode.
MartinJohnson 0:404f5a4f1385 151 * This parameter can be: ENABLE or DISABLE.
MartinJohnson 0:404f5a4f1385 152 * @retval None
MartinJohnson 0:404f5a4f1385 153 */
MartinJohnson 0:404f5a4f1385 154 void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
MartinJohnson 0:404f5a4f1385 155 {
MartinJohnson 0:404f5a4f1385 156 /* Check the parameters */
MartinJohnson 0:404f5a4f1385 157 assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
MartinJohnson 0:404f5a4f1385 158 assert_param(IS_FUNCTIONAL_STATE(NewState));
MartinJohnson 0:404f5a4f1385 159
MartinJohnson 0:404f5a4f1385 160 if (NewState != DISABLE)
MartinJohnson 0:404f5a4f1385 161 {
MartinJohnson 0:404f5a4f1385 162 DBGMCU->APB1FZ |= DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 163 }
MartinJohnson 0:404f5a4f1385 164 else
MartinJohnson 0:404f5a4f1385 165 {
MartinJohnson 0:404f5a4f1385 166 DBGMCU->APB1FZ &= ~DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 167 }
MartinJohnson 0:404f5a4f1385 168 }
MartinJohnson 0:404f5a4f1385 169
MartinJohnson 0:404f5a4f1385 170 /**
MartinJohnson 0:404f5a4f1385 171 * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
MartinJohnson 0:404f5a4f1385 172 * @param DBGMCU_Periph: specifies the APB2 peripheral.
MartinJohnson 0:404f5a4f1385 173 * This parameter can be any combination of the following values:
MartinJohnson 0:404f5a4f1385 174 * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 175 * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 176 * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 177 * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 178 * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 179 * @arg DBGMCU_TIM20_STOP: TIM20 counter stopped when Core is halted.
MartinJohnson 0:404f5a4f1385 180 * @param NewState: new state of the specified APB2 peripheral in Debug mode.
MartinJohnson 0:404f5a4f1385 181 * This parameter can be: ENABLE or DISABLE.
MartinJohnson 0:404f5a4f1385 182 * @retval None
MartinJohnson 0:404f5a4f1385 183 */
MartinJohnson 0:404f5a4f1385 184 void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
MartinJohnson 0:404f5a4f1385 185 {
MartinJohnson 0:404f5a4f1385 186 /* Check the parameters */
MartinJohnson 0:404f5a4f1385 187 assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
MartinJohnson 0:404f5a4f1385 188 assert_param(IS_FUNCTIONAL_STATE(NewState));
MartinJohnson 0:404f5a4f1385 189
MartinJohnson 0:404f5a4f1385 190 if (NewState != DISABLE)
MartinJohnson 0:404f5a4f1385 191 {
MartinJohnson 0:404f5a4f1385 192 DBGMCU->APB2FZ |= DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 193 }
MartinJohnson 0:404f5a4f1385 194 else
MartinJohnson 0:404f5a4f1385 195 {
MartinJohnson 0:404f5a4f1385 196 DBGMCU->APB2FZ &= ~DBGMCU_Periph;
MartinJohnson 0:404f5a4f1385 197 }
MartinJohnson 0:404f5a4f1385 198 }
MartinJohnson 0:404f5a4f1385 199
MartinJohnson 0:404f5a4f1385 200 /**
MartinJohnson 0:404f5a4f1385 201 * @}
MartinJohnson 0:404f5a4f1385 202 */
MartinJohnson 0:404f5a4f1385 203
MartinJohnson 0:404f5a4f1385 204 /**
MartinJohnson 0:404f5a4f1385 205 * @}
MartinJohnson 0:404f5a4f1385 206 */
MartinJohnson 0:404f5a4f1385 207
MartinJohnson 0:404f5a4f1385 208 /**
MartinJohnson 0:404f5a4f1385 209 * @}
MartinJohnson 0:404f5a4f1385 210 */
MartinJohnson 0:404f5a4f1385 211
MartinJohnson 0:404f5a4f1385 212 /**
MartinJohnson 0:404f5a4f1385 213 * @}
MartinJohnson 0:404f5a4f1385 214 */
MartinJohnson 0:404f5a4f1385 215
MartinJohnson 0:404f5a4f1385 216 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/