173 lines
5.4 KiB
C
173 lines
5.4 KiB
C
/**
|
|
******************************************************************************
|
|
* @file gpio.c
|
|
* @brief This file provides code for the configuration
|
|
* of all used GPIO pins.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2024 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
* the "License"; You may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at:
|
|
* opensource.org/licenses/BSD-3-Clause
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "gpio.h"
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Configure GPIO */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/** Configure pins as
|
|
* Analog
|
|
* Input
|
|
* Output
|
|
* EVENT_OUT
|
|
* EXTI
|
|
*/
|
|
void MX_GPIO_Init(void)
|
|
{
|
|
|
|
LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
|
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
|
|
|
|
/**/
|
|
LL_GPIO_ResetOutputPin(GPIOC, ERR_LED_Pin|SYS_LED_Pin);
|
|
|
|
/**/
|
|
LL_GPIO_ResetOutputPin(GPIOA, RS485_2_EN_Pin|MT_DIR_Pin|MT_STEP_Pin|MT_SON_Pin);
|
|
|
|
/**/
|
|
LL_GPIO_ResetOutputPin(RS485_EN_GPIO_Port, RS485_EN_Pin);
|
|
|
|
/**/
|
|
LL_GPIO_SetOutputPin(GPIOA, OUTPWM2_Pin|OUTPUT1_Pin);
|
|
|
|
/**/
|
|
LL_GPIO_SetOutputPin(GPIOC, OUTPUT2_Pin|OUTPUT3_Pin|OUTPWM1_Pin);
|
|
|
|
/**/
|
|
LL_GPIO_SetOutputPin(GPIOB, OUTPUT4_Pin|OUTPUT5_Pin|OUTPUT6_Pin|OUTPUT7_Pin
|
|
|OUTPUT8_Pin);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = ERR_LED_Pin|SYS_LED_Pin|OUTPUT2_Pin|OUTPUT3_Pin
|
|
|OUTPWM1_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = CAN_MP_Pin|SW1_Pin|SW2_Pin|SW3_Pin
|
|
|INPUT7_Pin|INPUT6_Pin|INPUT5_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = OUTPWM2_Pin|RS485_2_EN_Pin|MT_DIR_Pin|MT_STEP_Pin
|
|
|MT_SON_Pin|OUTPUT1_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = OUTPUT4_Pin|RS485_EN_Pin|OUTPUT5_Pin|OUTPUT6_Pin
|
|
|OUTPUT7_Pin|OUTPUT8_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = INPUT8_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
|
LL_GPIO_Init(INPUT8_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = INPUT4_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
|
LL_GPIO_Init(INPUT4_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
GPIO_InitStruct.Pin = INPUT3_Pin|INPUT2_Pin|INPUT1_Pin|SW4_Pin
|
|
|CAN_ZP_Pin;
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
|
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/**/
|
|
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE8);
|
|
|
|
/**/
|
|
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE9);
|
|
|
|
/**/
|
|
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE10);
|
|
|
|
/**/
|
|
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_8;
|
|
EXTI_InitStruct.LineCommand = ENABLE;
|
|
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
|
|
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
|
|
LL_EXTI_Init(&EXTI_InitStruct);
|
|
|
|
/**/
|
|
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_9;
|
|
EXTI_InitStruct.LineCommand = ENABLE;
|
|
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
|
|
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
|
|
LL_EXTI_Init(&EXTI_InitStruct);
|
|
|
|
/**/
|
|
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_10;
|
|
EXTI_InitStruct.LineCommand = ENABLE;
|
|
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
|
|
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
|
|
LL_EXTI_Init(&EXTI_InitStruct);
|
|
|
|
/**/
|
|
LL_GPIO_SetPinMode(AP_GPIO_Port, AP_Pin, LL_GPIO_MODE_FLOATING);
|
|
|
|
/**/
|
|
LL_GPIO_SetPinMode(BP_GPIO_Port, BP_Pin, LL_GPIO_MODE_FLOATING);
|
|
|
|
/**/
|
|
LL_GPIO_SetPinMode(ZP_GPIO_Port, ZP_Pin, LL_GPIO_MODE_FLOATING);
|
|
|
|
/* EXTI interrupt init*/
|
|
NVIC_SetPriority(EXTI9_5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
|
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
|
NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
|
NVIC_EnableIRQ(EXTI15_10_IRQn);
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|