source: S-port/trunk/Core/Src/gpio.c

Last change on this file was 1, checked in by AlexLir, 3 years ago
File size: 4.4 KB
Line 
1/**
2 ******************************************************************************
3 * @file gpio.c
4 * @brief This file provides code for the configuration
5 * of all used GPIO pins.
6 ******************************************************************************
7 * @attention
8 *
9 * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
10 * All rights reserved.</center></h2>
11 *
12 * This software component is licensed by ST under Ultimate Liberty license
13 * SLA0044, the "License"; You may not use this file except in compliance with
14 * the License. You may obtain a copy of the License at:
15 * www.st.com/SLA0044
16 *
17 ******************************************************************************
18 */
19
20/* Includes ------------------------------------------------------------------*/
21#include "gpio.h"
22
23/* USER CODE BEGIN 0 */
24
25/* USER CODE END 0 */
26
27/*----------------------------------------------------------------------------*/
28/* Configure GPIO */
29/*----------------------------------------------------------------------------*/
30/* USER CODE BEGIN 1 */
31
32/* USER CODE END 1 */
33
34/** Configure pins as
35 * Analog
36 * Input
37 * Output
38 * EVENT_OUT
39 * EXTI
40 PC9 ------> RCC_MCO_2
41*/
42void MX_GPIO_Init(void)
43{
44
45 GPIO_InitTypeDef GPIO_InitStruct = {0};
46
47 /* GPIO Ports Clock Enable */
48 __HAL_RCC_GPIOH_CLK_ENABLE();
49 __HAL_RCC_GPIOC_CLK_ENABLE();
50 __HAL_RCC_GPIOA_CLK_ENABLE();
51 __HAL_RCC_GPIOE_CLK_ENABLE();
52 __HAL_RCC_GPIOB_CLK_ENABLE();
53 __HAL_RCC_GPIOD_CLK_ENABLE();
54
55 /*Configure GPIO pin Output Level */
56 HAL_GPIO_WritePin(GPIOA, PHY_nRST_Pin|PHY_LEDy_Pin, GPIO_PIN_RESET);
57
58 /*Configure GPIO pin Output Level */
59 HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_SET);
60 HAL_GPIO_WritePin(FL_RES_GPIO_Port, FL_RES_Pin, GPIO_PIN_RESET);
61
62 /*Configure GPIO pins : PAPin PAPin PAPin */
63 GPIO_InitStruct.Pin = PHY_nRST_Pin|PHY_LEDy_Pin;
64 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
65 GPIO_InitStruct.Pull = GPIO_NOPULL;
66 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
67 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
68
69 /*Configure GPIO pins: execution, 3V, 5V, 12V; óòå÷êà íà ðåçèñòîðå ïðèìåðíî 700uV*/
70 GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5;
71 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
72 GPIO_InitStruct.Pull = GPIO_PULLUP;
73 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
74 HAL_GPIO_Init(EXECUTION_GPIO_Port, &GPIO_InitStruct);
75
76 /*Configure GPIO pins: version, 1,2,3,4,5 ; óòå÷êà íà ðåçèñòîðå ïðèìåðíî 700uV*/
77 GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
78 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
79 GPIO_InitStruct.Pull = GPIO_PULLUP;
80 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
81 HAL_GPIO_Init(VERSION_GPIO_Port, &GPIO_InitStruct);
82
83 /*Configure GPIO pin : PtPin */
84 GPIO_InitStruct.Pin = PHY_INT_Pin;
85 GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
86 GPIO_InitStruct.Pull = GPIO_NOPULL;
87 HAL_GPIO_Init(PHY_INT_GPIO_Port, &GPIO_InitStruct);
88
89 /*Configure GPIO pin : RES IP */
90 GPIO_InitStruct.Pin = RES_IP_Pin;
91 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
92 GPIO_InitStruct.Pull = GPIO_PULLUP;
93 HAL_GPIO_Init(RES_IP_GPIO_Port, &GPIO_InitStruct);
94
95 /*Configure GPIO pin : PtPin */
96 GPIO_InitStruct.Pin = USART_TX_EN_Pin;
97 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
98 GPIO_InitStruct.Pull = GPIO_NOPULL;
99 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
100 HAL_GPIO_Init(USART_TX_EN_GPIO_Port, &GPIO_InitStruct);
101
102 /*Configure GPIO pin : PC9 */
103 GPIO_InitStruct.Pin = GPIO_PIN_9;
104 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
105 GPIO_InitStruct.Pull = GPIO_NOPULL;
106 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
107 GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
108 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
109
110 /*Configure GPIO pin : PtPin */
111 GPIO_InitStruct.Pin = SPI3_CS_Pin | FL_RES_Pin;
112 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
113 GPIO_InitStruct.Pull = GPIO_PULLUP;
114 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
115 HAL_GPIO_Init(SPI3_CS_GPIO_Port, &GPIO_InitStruct);
116
117 /* EXTI interrupt init*/
118 HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0);
119 HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
120}
121
122/* USER CODE BEGIN 2 */
123
124/* USER CODE END 2 */
125
126/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.