won't compile
stm32f3348_discovery.c@0:b079fa4ed182, 2016-11-02 (annotated)
- Committer:
- richardv
- Date:
- Wed Nov 02 23:50:52 2016 +0000
- Revision:
- 0:b079fa4ed182
DMA RAM DAC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
richardv | 0:b079fa4ed182 | 1 | /** |
richardv | 0:b079fa4ed182 | 2 | ****************************************************************************** |
richardv | 0:b079fa4ed182 | 3 | * @file stm32f3348_discovery.c |
richardv | 0:b079fa4ed182 | 4 | * @author MCD Application Team |
richardv | 0:b079fa4ed182 | 5 | * @version V1.0.0 |
richardv | 0:b079fa4ed182 | 6 | * @date 20-June-2014 |
richardv | 0:b079fa4ed182 | 7 | * @brief This file provides set of firmware functions to manage Leds, |
richardv | 0:b079fa4ed182 | 8 | * push-button for STM32F3348 DISCO. |
richardv | 0:b079fa4ed182 | 9 | ****************************************************************************** |
richardv | 0:b079fa4ed182 | 10 | * @attention |
richardv | 0:b079fa4ed182 | 11 | * |
richardv | 0:b079fa4ed182 | 12 | * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
richardv | 0:b079fa4ed182 | 13 | * |
richardv | 0:b079fa4ed182 | 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
richardv | 0:b079fa4ed182 | 15 | * You may not use this file except in compliance with the License. |
richardv | 0:b079fa4ed182 | 16 | * You may obtain a copy of the License at: |
richardv | 0:b079fa4ed182 | 17 | * |
richardv | 0:b079fa4ed182 | 18 | * http://www.st.com/software_license_agreement_liberty_v2 |
richardv | 0:b079fa4ed182 | 19 | * |
richardv | 0:b079fa4ed182 | 20 | * Unless required by applicable law or agreed to in writing, software |
richardv | 0:b079fa4ed182 | 21 | * distributed under the License is distributed on an "AS IS" BASIS, |
richardv | 0:b079fa4ed182 | 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
richardv | 0:b079fa4ed182 | 23 | * See the License for the specific language governing permissions and |
richardv | 0:b079fa4ed182 | 24 | * limitations under the License. |
richardv | 0:b079fa4ed182 | 25 | * |
richardv | 0:b079fa4ed182 | 26 | ****************************************************************************** |
richardv | 0:b079fa4ed182 | 27 | */ |
richardv | 0:b079fa4ed182 | 28 | |
richardv | 0:b079fa4ed182 | 29 | /* Includes ------------------------------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 30 | #include "stm32f3348_discovery.h" |
richardv | 0:b079fa4ed182 | 31 | |
richardv | 0:b079fa4ed182 | 32 | /** @addtogroup Utilities |
richardv | 0:b079fa4ed182 | 33 | * @{ |
richardv | 0:b079fa4ed182 | 34 | */ |
richardv | 0:b079fa4ed182 | 35 | |
richardv | 0:b079fa4ed182 | 36 | /** @addtogroup STM32F3348_DISCOVERY |
richardv | 0:b079fa4ed182 | 37 | * @{ |
richardv | 0:b079fa4ed182 | 38 | */ |
richardv | 0:b079fa4ed182 | 39 | |
richardv | 0:b079fa4ed182 | 40 | /** @defgroup STM32F3348_DISCOVERY_LOW_LEVEL |
richardv | 0:b079fa4ed182 | 41 | * @brief This file provides firmware functions to manage Leds and push-button |
richardv | 0:b079fa4ed182 | 42 | * available on STM32F3348-DISCO board from STMicroelectronics. |
richardv | 0:b079fa4ed182 | 43 | * @{ |
richardv | 0:b079fa4ed182 | 44 | */ |
richardv | 0:b079fa4ed182 | 45 | |
richardv | 0:b079fa4ed182 | 46 | |
richardv | 0:b079fa4ed182 | 47 | /* Private typedef -----------------------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 48 | /* Private define ------------------------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 49 | /* Private macro -------------------------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 50 | /* Private variables ---------------------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 51 | |
richardv | 0:b079fa4ed182 | 52 | GPIO_TypeDef* GPIO_PORT[LEDn] = {LED3_GPIO_PORT, LED4_GPIO_PORT, |
richardv | 0:b079fa4ed182 | 53 | LED5_GPIO_PORT, LED6_GPIO_PORT}; |
richardv | 0:b079fa4ed182 | 54 | |
richardv | 0:b079fa4ed182 | 55 | const uint16_t GPIO_PIN[LEDn] = {LED3_PIN, LED4_PIN, |
richardv | 0:b079fa4ed182 | 56 | LED5_PIN, LED6_PIN}; |
richardv | 0:b079fa4ed182 | 57 | |
richardv | 0:b079fa4ed182 | 58 | const uint32_t GPIO_CLK[LEDn] = {LED3_GPIO_CLK, LED4_GPIO_CLK, |
richardv | 0:b079fa4ed182 | 59 | LED5_GPIO_CLK, LED6_GPIO_CLK}; |
richardv | 0:b079fa4ed182 | 60 | |
richardv | 0:b079fa4ed182 | 61 | GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT}; |
richardv | 0:b079fa4ed182 | 62 | |
richardv | 0:b079fa4ed182 | 63 | const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN}; |
richardv | 0:b079fa4ed182 | 64 | |
richardv | 0:b079fa4ed182 | 65 | const uint32_t BUTTON_CLK[BUTTONn] = {USER_BUTTON_GPIO_CLK}; |
richardv | 0:b079fa4ed182 | 66 | |
richardv | 0:b079fa4ed182 | 67 | const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE}; |
richardv | 0:b079fa4ed182 | 68 | |
richardv | 0:b079fa4ed182 | 69 | const uint8_t BUTTON_PORT_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PORT_SOURCE}; |
richardv | 0:b079fa4ed182 | 70 | |
richardv | 0:b079fa4ed182 | 71 | const uint8_t BUTTON_PIN_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PIN_SOURCE}; |
richardv | 0:b079fa4ed182 | 72 | |
richardv | 0:b079fa4ed182 | 73 | const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn}; |
richardv | 0:b079fa4ed182 | 74 | |
richardv | 0:b079fa4ed182 | 75 | |
richardv | 0:b079fa4ed182 | 76 | /* Private function prototypes -----------------------------------------------*/ |
richardv | 0:b079fa4ed182 | 77 | |
richardv | 0:b079fa4ed182 | 78 | /** |
richardv | 0:b079fa4ed182 | 79 | * @brief Configures LED GPIO. |
richardv | 0:b079fa4ed182 | 80 | * @param Led: Specifies the Led to be configured. |
richardv | 0:b079fa4ed182 | 81 | * This parameter can be one of following parameters: |
richardv | 0:b079fa4ed182 | 82 | * @arg LED3 |
richardv | 0:b079fa4ed182 | 83 | * @arg LED4 |
richardv | 0:b079fa4ed182 | 84 | * @arg LED5 |
richardv | 0:b079fa4ed182 | 85 | * @arg LED6 |
richardv | 0:b079fa4ed182 | 86 | * @retval None |
richardv | 0:b079fa4ed182 | 87 | */ |
richardv | 0:b079fa4ed182 | 88 | void STM_EVAL_LEDInit(Led_TypeDef Led) |
richardv | 0:b079fa4ed182 | 89 | { |
richardv | 0:b079fa4ed182 | 90 | GPIO_InitTypeDef GPIO_InitStructure; |
richardv | 0:b079fa4ed182 | 91 | |
richardv | 0:b079fa4ed182 | 92 | /* Enable the GPIO_LED Clock */ |
richardv | 0:b079fa4ed182 | 93 | RCC_AHBPeriphClockCmd(GPIO_CLK[Led], ENABLE); |
richardv | 0:b079fa4ed182 | 94 | |
richardv | 0:b079fa4ed182 | 95 | /* Configure the GPIO_LED pin */ |
richardv | 0:b079fa4ed182 | 96 | GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led]; |
richardv | 0:b079fa4ed182 | 97 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; |
richardv | 0:b079fa4ed182 | 98 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; |
richardv | 0:b079fa4ed182 | 99 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; |
richardv | 0:b079fa4ed182 | 100 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
richardv | 0:b079fa4ed182 | 101 | GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure); |
richardv | 0:b079fa4ed182 | 102 | } |
richardv | 0:b079fa4ed182 | 103 | |
richardv | 0:b079fa4ed182 | 104 | /** |
richardv | 0:b079fa4ed182 | 105 | * @brief Turns selected LED On. |
richardv | 0:b079fa4ed182 | 106 | * @param Led: Specifies the Led to be set on. |
richardv | 0:b079fa4ed182 | 107 | * This parameter can be one of following parameters: |
richardv | 0:b079fa4ed182 | 108 | * @arg LED3 |
richardv | 0:b079fa4ed182 | 109 | * @arg LED4 |
richardv | 0:b079fa4ed182 | 110 | * @arg LED5 |
richardv | 0:b079fa4ed182 | 111 | * @arg LED6 |
richardv | 0:b079fa4ed182 | 112 | * @retval None |
richardv | 0:b079fa4ed182 | 113 | */ |
richardv | 0:b079fa4ed182 | 114 | void STM_EVAL_LEDOn(Led_TypeDef Led) |
richardv | 0:b079fa4ed182 | 115 | { |
richardv | 0:b079fa4ed182 | 116 | GPIO_PORT[Led]->BSRR = GPIO_PIN[Led]; |
richardv | 0:b079fa4ed182 | 117 | } |
richardv | 0:b079fa4ed182 | 118 | |
richardv | 0:b079fa4ed182 | 119 | /** |
richardv | 0:b079fa4ed182 | 120 | * @brief Turns selected LED Off. |
richardv | 0:b079fa4ed182 | 121 | * @param Led: Specifies the Led to be set off. |
richardv | 0:b079fa4ed182 | 122 | * This parameter can be one of following parameters: |
richardv | 0:b079fa4ed182 | 123 | * @arg LED3 |
richardv | 0:b079fa4ed182 | 124 | * @arg LED4 |
richardv | 0:b079fa4ed182 | 125 | * @arg LED5 |
richardv | 0:b079fa4ed182 | 126 | * @arg LED6 |
richardv | 0:b079fa4ed182 | 127 | * @retval None |
richardv | 0:b079fa4ed182 | 128 | */ |
richardv | 0:b079fa4ed182 | 129 | void STM_EVAL_LEDOff(Led_TypeDef Led) |
richardv | 0:b079fa4ed182 | 130 | { |
richardv | 0:b079fa4ed182 | 131 | GPIO_PORT[Led]->BRR = GPIO_PIN[Led]; |
richardv | 0:b079fa4ed182 | 132 | } |
richardv | 0:b079fa4ed182 | 133 | |
richardv | 0:b079fa4ed182 | 134 | /** |
richardv | 0:b079fa4ed182 | 135 | * @brief Toggles the selected LED. |
richardv | 0:b079fa4ed182 | 136 | * @param Led: Specifies the Led to be toggled. |
richardv | 0:b079fa4ed182 | 137 | * This parameter can be one of following parameters: |
richardv | 0:b079fa4ed182 | 138 | * @arg LED3 |
richardv | 0:b079fa4ed182 | 139 | * @arg LED4 |
richardv | 0:b079fa4ed182 | 140 | * @arg LED5 |
richardv | 0:b079fa4ed182 | 141 | * @arg LED6 |
richardv | 0:b079fa4ed182 | 142 | * @retval None |
richardv | 0:b079fa4ed182 | 143 | */ |
richardv | 0:b079fa4ed182 | 144 | void STM_EVAL_LEDToggle(Led_TypeDef Led) |
richardv | 0:b079fa4ed182 | 145 | { |
richardv | 0:b079fa4ed182 | 146 | GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led]; |
richardv | 0:b079fa4ed182 | 147 | } |
richardv | 0:b079fa4ed182 | 148 | |
richardv | 0:b079fa4ed182 | 149 | /** |
richardv | 0:b079fa4ed182 | 150 | * @brief Configures Button GPIO and EXTI Line. |
richardv | 0:b079fa4ed182 | 151 | * @param Button: Specifies the Button to be configured. |
richardv | 0:b079fa4ed182 | 152 | * This parameter should be: BUTTON_USER |
richardv | 0:b079fa4ed182 | 153 | * @param Button_Mode: Specifies Button mode. |
richardv | 0:b079fa4ed182 | 154 | * This parameter can be one of following parameters: |
richardv | 0:b079fa4ed182 | 155 | * @arg BUTTON_MODE_GPIO: Button will be used as simple IO |
richardv | 0:b079fa4ed182 | 156 | * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt |
richardv | 0:b079fa4ed182 | 157 | * generation capability |
richardv | 0:b079fa4ed182 | 158 | * @retval None |
richardv | 0:b079fa4ed182 | 159 | */ |
richardv | 0:b079fa4ed182 | 160 | void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) |
richardv | 0:b079fa4ed182 | 161 | { |
richardv | 0:b079fa4ed182 | 162 | GPIO_InitTypeDef GPIO_InitStructure; |
richardv | 0:b079fa4ed182 | 163 | EXTI_InitTypeDef EXTI_InitStructure; |
richardv | 0:b079fa4ed182 | 164 | NVIC_InitTypeDef NVIC_InitStructure; |
richardv | 0:b079fa4ed182 | 165 | |
richardv | 0:b079fa4ed182 | 166 | /* Enable the BUTTON Clock */ |
richardv | 0:b079fa4ed182 | 167 | RCC_AHBPeriphClockCmd(BUTTON_CLK[Button], ENABLE); |
richardv | 0:b079fa4ed182 | 168 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
richardv | 0:b079fa4ed182 | 169 | |
richardv | 0:b079fa4ed182 | 170 | /* Configure Button pin as input */ |
richardv | 0:b079fa4ed182 | 171 | GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button]; |
richardv | 0:b079fa4ed182 | 172 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; |
richardv | 0:b079fa4ed182 | 173 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; |
richardv | 0:b079fa4ed182 | 174 | |
richardv | 0:b079fa4ed182 | 175 | GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure); |
richardv | 0:b079fa4ed182 | 176 | |
richardv | 0:b079fa4ed182 | 177 | if (Button_Mode == BUTTON_MODE_EXTI) |
richardv | 0:b079fa4ed182 | 178 | { |
richardv | 0:b079fa4ed182 | 179 | /* Connect Button EXTI Line to Button GPIO Pin */ |
richardv | 0:b079fa4ed182 | 180 | SYSCFG_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]); |
richardv | 0:b079fa4ed182 | 181 | |
richardv | 0:b079fa4ed182 | 182 | /* Configure Button EXTI line */ |
richardv | 0:b079fa4ed182 | 183 | EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button]; |
richardv | 0:b079fa4ed182 | 184 | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
richardv | 0:b079fa4ed182 | 185 | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; |
richardv | 0:b079fa4ed182 | 186 | EXTI_InitStructure.EXTI_LineCmd = ENABLE; |
richardv | 0:b079fa4ed182 | 187 | EXTI_Init(&EXTI_InitStructure); |
richardv | 0:b079fa4ed182 | 188 | |
richardv | 0:b079fa4ed182 | 189 | /* Enable and set Button EXTI Interrupt to the lowest priority */ |
richardv | 0:b079fa4ed182 | 190 | NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button]; |
richardv | 0:b079fa4ed182 | 191 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; |
richardv | 0:b079fa4ed182 | 192 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; |
richardv | 0:b079fa4ed182 | 193 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; |
richardv | 0:b079fa4ed182 | 194 | |
richardv | 0:b079fa4ed182 | 195 | NVIC_Init(&NVIC_InitStructure); |
richardv | 0:b079fa4ed182 | 196 | |
richardv | 0:b079fa4ed182 | 197 | } |
richardv | 0:b079fa4ed182 | 198 | } |
richardv | 0:b079fa4ed182 | 199 | |
richardv | 0:b079fa4ed182 | 200 | /** |
richardv | 0:b079fa4ed182 | 201 | * @brief Returns the selected Button state. |
richardv | 0:b079fa4ed182 | 202 | * @param Button: Specifies the Button to be checked. |
richardv | 0:b079fa4ed182 | 203 | * This parameter should be: BUTTON_USER |
richardv | 0:b079fa4ed182 | 204 | * @retval The Button GPIO pin value. |
richardv | 0:b079fa4ed182 | 205 | */ |
richardv | 0:b079fa4ed182 | 206 | uint32_t STM_EVAL_PBGetState(Button_TypeDef Button) |
richardv | 0:b079fa4ed182 | 207 | { |
richardv | 0:b079fa4ed182 | 208 | return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]); |
richardv | 0:b079fa4ed182 | 209 | } |
richardv | 0:b079fa4ed182 | 210 | |
richardv | 0:b079fa4ed182 | 211 | /** |
richardv | 0:b079fa4ed182 | 212 | * @} |
richardv | 0:b079fa4ed182 | 213 | */ |
richardv | 0:b079fa4ed182 | 214 | |
richardv | 0:b079fa4ed182 | 215 | /** |
richardv | 0:b079fa4ed182 | 216 | * @} |
richardv | 0:b079fa4ed182 | 217 | */ |
richardv | 0:b079fa4ed182 | 218 | |
richardv | 0:b079fa4ed182 | 219 | /** |
richardv | 0:b079fa4ed182 | 220 | * @} |
richardv | 0:b079fa4ed182 | 221 | */ |
richardv | 0:b079fa4ed182 | 222 | |
richardv | 0:b079fa4ed182 | 223 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |