bs_bcu_app/drv/drv_gpio.c

59 lines
2.5 KiB
C
Raw Permalink Normal View History

2024-11-13 18:11:22 +08:00
#include "drv_sys.h"
#include "drv_gpio.h"
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>GPIO<49><4F><EFBFBD><EFBFBD>
GPIOConfig gpio_config[] = {
// <20>߱<EFBFBD><DFB1><EFBFBD><EFBFBD><EFBFBD>
{GPIOG, GPIO_PIN_4, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOG, GPIO_PIN_5, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOG, GPIO_PIN_6, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOG, GPIO_PIN_7, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOD, GPIO_PIN_10, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOD, GPIO_PIN_11, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOD, GPIO_PIN_12, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOD, GPIO_PIN_13, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
// <20>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>
{GPIOG, GPIO_PIN_8, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOA, GPIO_PIN_8, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, 0},
// <20>߱߷<DFB1><DFB7><EFBFBD>
{GPIOD, GPIO_PIN_14, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOD, GPIO_PIN_15, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOG, GPIO_PIN_2, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOG, GPIO_PIN_3, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
// <20>ͱ߷<CDB1><DFB7><EFBFBD>
{GPIOC, GPIO_PIN_6, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
{GPIOC, GPIO_PIN_7, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_FREQ_VERY_HIGH, 0},
};
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>GPIO<49><4F><EFBFBD><EFBFBD>
void InitGPIOs(void) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIOʱ<4F><CAB1>
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO<49>˿ڣ<CBBF><DAA3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ʱ<EFBFBD><CAB1>
GPIO_InitTypeDef GPIO_InitStruct;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B2A2>ʼ<EFBFBD><CABC>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < sizeof(gpio_config) / sizeof(GPIOConfig); i++)
{
// <20><><EFBFBD><EFBFBD>GPIO<49><4F>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><E1B9B9>
GPIO_InitStruct.Pin = gpio_config[i].pin;
GPIO_InitStruct.Mode = gpio_config[i].mode;
GPIO_InitStruct.Pull = gpio_config[i].pull;
GPIO_InitStruct.Speed = gpio_config[i].speed;
GPIO_InitStruct.Alternate = gpio_config[i].alternate;
// <20><>ʼ<EFBFBD><CABC>GPIO<49><4F><EFBFBD><EFBFBD>
HAL_GPIO_Init(gpio_config[i].port, &GPIO_InitStruct);
}
2024-11-21 10:06:36 +08:00
}