123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * @file gpio.c
- * @brief This file provides code for the configuration
- * of all used GPIO pins.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2024 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
- /* USER CODE END Header */
- /* 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)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOE_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOE, EN_4G_Pin|RST_4G_Pin, GPIO_PIN_SET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOD, LED_R_Pin|LED_G_Pin|LED_Y_Pin|BEEP_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(OneWireCommuation_GPIO_Port, OneWireCommuation_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
- /*Configure GPIO pins : PEPin PEPin */
- GPIO_InitStruct.Pin = EN_4G_Pin|RST_4G_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
- /*Configure GPIO pins : PDPin PDPin PDPin PDPin */
- GPIO_InitStruct.Pin = LED_R_Pin|LED_G_Pin|LED_Y_Pin|BEEP_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
- /*Configure GPIO pin : PtPin */
- GPIO_InitStruct.Pin = OneWireCommuation_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(OneWireCommuation_GPIO_Port, &GPIO_InitStruct);
- /*Configure GPIO pin : PtPin */
- GPIO_InitStruct.Pin = LED_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
- }
- /* USER CODE BEGIN 2 */
- // 运行灯翻转
- void LED0_TOGGLE(void)
- {
- // HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
- HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
- HAL_GPIO_TogglePin(LED_G_GPIO_Port, LED_G_Pin);
- HAL_GPIO_TogglePin(LED_Y_GPIO_Port, LED_Y_Pin);
- // HAL_GPIO_TogglePin(BEEP_GPIO_Port, BEEP_Pin);
- }
- /**
- * @brief 4G_EN 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note 使能电源 拉低关闭
- * @retval 无
- */
- void GPIO_EN_For_4G(GPIO_PinState pinState){
- HAL_GPIO_WritePin(EN_4G_GPIO_Port, EN_4G_Pin, pinState);
- }
- /**
- * @brief 4G_RST 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note 模块RESET/POWERKEY
- * @retval 无
- */
- void GPIO_RST_For_4G(GPIO_PinState pinState){
- HAL_GPIO_WritePin(RST_4G_GPIO_Port, RST_4G_Pin, pinState);
- }
- /**
- * @brief LED_R 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note
- * @retval 无
- */
- void GPIO_LED_R (GPIO_PinState pinState){
- HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, pinState);
- }
- /**
- * @brief LED_G 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note
- * @retval 无
- */
- void GPIO_LED_G (GPIO_PinState pinState){
- HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, pinState);
- }
- /**
- * @brief LED_Y 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note
- * @retval 无
- */
- void GPIO_LED_Y (GPIO_PinState pinState){
- HAL_GPIO_WritePin(LED_Y_GPIO_Port, LED_Y_Pin, pinState);
- }
- /**
- * @brief OneWireCommuation 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note
- * @retval 无
- */
- void GPIO_OneWireCommuation (GPIO_PinState pinState){
- HAL_GPIO_WritePin(OneWireCommuation_GPIO_Port, OneWireCommuation_Pin, pinState);
- }
- /**
- * @brief BEEP 引脚操作
- * @param pinState:GPIO_PIN_RESET
- GPIO_PIN_SET
- * @note
- * @retval 无
- */
- void GPIO_BEEP (GPIO_PinState pinState){
- HAL_GPIO_WritePin(BEEP_GPIO_Port, BEEP_Pin, pinState);
- }
- /* USER CODE END 2 */
|