adc
gpio.cpp@3:1d62b3be52e8, 2020-10-28 (annotated)
- Committer:
- yuliyasm
- Date:
- Wed Oct 28 15:35:08 2020 +0000
- Revision:
- 3:1d62b3be52e8
new
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yuliyasm | 3:1d62b3be52e8 | 1 | /** |
yuliyasm | 3:1d62b3be52e8 | 2 | ****************************************************************************** |
yuliyasm | 3:1d62b3be52e8 | 3 | * File Name : gpio.c |
yuliyasm | 3:1d62b3be52e8 | 4 | * Description : This file provides code for the configuration |
yuliyasm | 3:1d62b3be52e8 | 5 | * of all used GPIO pins. |
yuliyasm | 3:1d62b3be52e8 | 6 | ****************************************************************************** |
yuliyasm | 3:1d62b3be52e8 | 7 | * @attention |
yuliyasm | 3:1d62b3be52e8 | 8 | * |
yuliyasm | 3:1d62b3be52e8 | 9 | * <h2><center>© Copyright (c) 2020 STMicroelectronics. |
yuliyasm | 3:1d62b3be52e8 | 10 | * All rights reserved.</center></h2> |
yuliyasm | 3:1d62b3be52e8 | 11 | * |
yuliyasm | 3:1d62b3be52e8 | 12 | * This software component is licensed by ST under Ultimate Liberty license |
yuliyasm | 3:1d62b3be52e8 | 13 | * SLA0044, the "License"; You may not use this file except in compliance with |
yuliyasm | 3:1d62b3be52e8 | 14 | * the License. You may obtain a copy of the License at: |
yuliyasm | 3:1d62b3be52e8 | 15 | * www.st.com/SLA0044 |
yuliyasm | 3:1d62b3be52e8 | 16 | * |
yuliyasm | 3:1d62b3be52e8 | 17 | ****************************************************************************** |
yuliyasm | 3:1d62b3be52e8 | 18 | */ |
yuliyasm | 3:1d62b3be52e8 | 19 | |
yuliyasm | 3:1d62b3be52e8 | 20 | /* Includes ------------------------------------------------------------------*/ |
yuliyasm | 3:1d62b3be52e8 | 21 | #include "gpio.h" |
yuliyasm | 3:1d62b3be52e8 | 22 | /* USER CODE BEGIN 0 */ |
yuliyasm | 3:1d62b3be52e8 | 23 | |
yuliyasm | 3:1d62b3be52e8 | 24 | /* USER CODE END 0 */ |
yuliyasm | 3:1d62b3be52e8 | 25 | |
yuliyasm | 3:1d62b3be52e8 | 26 | /*----------------------------------------------------------------------------*/ |
yuliyasm | 3:1d62b3be52e8 | 27 | /* Configure GPIO */ |
yuliyasm | 3:1d62b3be52e8 | 28 | /*----------------------------------------------------------------------------*/ |
yuliyasm | 3:1d62b3be52e8 | 29 | /* USER CODE BEGIN 1 */ |
yuliyasm | 3:1d62b3be52e8 | 30 | |
yuliyasm | 3:1d62b3be52e8 | 31 | /* USER CODE END 1 */ |
yuliyasm | 3:1d62b3be52e8 | 32 | |
yuliyasm | 3:1d62b3be52e8 | 33 | /** Configure pins |
yuliyasm | 3:1d62b3be52e8 | 34 | PC14-OSC32_IN (OSC32_IN) ------> RCC_OSC32_IN |
yuliyasm | 3:1d62b3be52e8 | 35 | PC15-OSC32_OUT (OSC32_OUT) ------> RCC_OSC32_OUT |
yuliyasm | 3:1d62b3be52e8 | 36 | PH0-OSC_IN (PH0) ------> RCC_OSC_IN |
yuliyasm | 3:1d62b3be52e8 | 37 | PH1-OSC_OUT (PH1) ------> RCC_OSC_OUT |
yuliyasm | 3:1d62b3be52e8 | 38 | */ |
yuliyasm | 3:1d62b3be52e8 | 39 | void MX_GPIO_Init(void) |
yuliyasm | 3:1d62b3be52e8 | 40 | { |
yuliyasm | 3:1d62b3be52e8 | 41 | |
yuliyasm | 3:1d62b3be52e8 | 42 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
yuliyasm | 3:1d62b3be52e8 | 43 | |
yuliyasm | 3:1d62b3be52e8 | 44 | /* GPIO Ports Clock Enable */ |
yuliyasm | 3:1d62b3be52e8 | 45 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 46 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 47 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 48 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 49 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 50 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 51 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
yuliyasm | 3:1d62b3be52e8 | 52 | |
yuliyasm | 3:1d62b3be52e8 | 53 | /*Configure GPIO pin Output Level */ |
yuliyasm | 3:1d62b3be52e8 | 54 | HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin, GPIO_PIN_RESET); |
yuliyasm | 3:1d62b3be52e8 | 55 | |
yuliyasm | 3:1d62b3be52e8 | 56 | /*Configure GPIO pin Output Level */ |
yuliyasm | 3:1d62b3be52e8 | 57 | HAL_GPIO_WritePin(GPIOD, USB_OTG_FS_PWR_EN_Pin|PHASE_A_CS_Pin|PHASE_B_CS_Pin, GPIO_PIN_RESET); |
yuliyasm | 3:1d62b3be52e8 | 58 | |
yuliyasm | 3:1d62b3be52e8 | 59 | /*Configure GPIO pin Output Level */ |
yuliyasm | 3:1d62b3be52e8 | 60 | HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); |
yuliyasm | 3:1d62b3be52e8 | 61 | |
yuliyasm | 3:1d62b3be52e8 | 62 | /*Configure GPIO pin : PtPin */ |
yuliyasm | 3:1d62b3be52e8 | 63 | GPIO_InitStruct.Pin = B1_Pin; |
yuliyasm | 3:1d62b3be52e8 | 64 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
yuliyasm | 3:1d62b3be52e8 | 65 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
yuliyasm | 3:1d62b3be52e8 | 66 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); |
yuliyasm | 3:1d62b3be52e8 | 67 | |
yuliyasm | 3:1d62b3be52e8 | 68 | /*Configure GPIO pins : PBPin PBPin */ |
yuliyasm | 3:1d62b3be52e8 | 69 | GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin; |
yuliyasm | 3:1d62b3be52e8 | 70 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
yuliyasm | 3:1d62b3be52e8 | 71 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
yuliyasm | 3:1d62b3be52e8 | 72 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
yuliyasm | 3:1d62b3be52e8 | 73 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
yuliyasm | 3:1d62b3be52e8 | 74 | |
yuliyasm | 3:1d62b3be52e8 | 75 | /*Configure GPIO pins : PDPin PDPin PDPin */ |
yuliyasm | 3:1d62b3be52e8 | 76 | GPIO_InitStruct.Pin = USB_OTG_FS_PWR_EN_Pin|PHASE_A_CS_Pin|PHASE_B_CS_Pin; |
yuliyasm | 3:1d62b3be52e8 | 77 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
yuliyasm | 3:1d62b3be52e8 | 78 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
yuliyasm | 3:1d62b3be52e8 | 79 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
yuliyasm | 3:1d62b3be52e8 | 80 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
yuliyasm | 3:1d62b3be52e8 | 81 | |
yuliyasm | 3:1d62b3be52e8 | 82 | /*Configure GPIO pin : PtPin */ |
yuliyasm | 3:1d62b3be52e8 | 83 | GPIO_InitStruct.Pin = USB_OTG_FS_OVCR_Pin; |
yuliyasm | 3:1d62b3be52e8 | 84 | GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; |
yuliyasm | 3:1d62b3be52e8 | 85 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
yuliyasm | 3:1d62b3be52e8 | 86 | HAL_GPIO_Init(USB_OTG_FS_OVCR_GPIO_Port, &GPIO_InitStruct); |
yuliyasm | 3:1d62b3be52e8 | 87 | |
yuliyasm | 3:1d62b3be52e8 | 88 | /*Configure GPIO pin : PtPin */ |
yuliyasm | 3:1d62b3be52e8 | 89 | GPIO_InitStruct.Pin = LD2_Pin; |
yuliyasm | 3:1d62b3be52e8 | 90 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
yuliyasm | 3:1d62b3be52e8 | 91 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
yuliyasm | 3:1d62b3be52e8 | 92 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
yuliyasm | 3:1d62b3be52e8 | 93 | HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); |
yuliyasm | 3:1d62b3be52e8 | 94 | |
yuliyasm | 3:1d62b3be52e8 | 95 | } |
yuliyasm | 3:1d62b3be52e8 | 96 | |
yuliyasm | 3:1d62b3be52e8 | 97 | /* USER CODE BEGIN 2 */ |
yuliyasm | 3:1d62b3be52e8 | 98 | |
yuliyasm | 3:1d62b3be52e8 | 99 | /* USER CODE END 2 */ |
yuliyasm | 3:1d62b3be52e8 | 100 | |
yuliyasm | 3:1d62b3be52e8 | 101 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
yuliyasm | 3:1d62b3be52e8 | 102 |