173 lines
6.2 KiB
C
173 lines
6.2 KiB
C
/**
|
|
******************************************************************************
|
|
* File Name : gpio.c
|
|
* Description : This file provides code for the configuration
|
|
* of all used GPIO pins.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2020 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)
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOE, LED5_Pin|LED2_Pin|LED1_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOE, SENSOR_EN_Pin|GPS_RST_Pin|NB_RST_Pin|NB_WKUP_Pin
|
|
|NB_EN_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOB, GPS_ON_Pin|BD_EN_Pin|OLED_RST_Pin|OLED_EN_Pin
|
|
|LED3_Pin|IR_OUT_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOD, AU_CTR_Pin|AU_RST_Pin|AU_EN_Pin|CARD_END5_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(CARD_EN_GPIO_Port, CARD_EN_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(PCIE_RST_GPIO_Port, PCIE_RST_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(PCIE_EN_GPIO_Port, PCIE_EN_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pins : KEY1_Pin SEL1_Pin SEL2_Pin SEL3_Pin
|
|
KEY4_Pin */
|
|
GPIO_InitStruct.Pin = KEY1_Pin|SEL1_Pin|SEL2_Pin|SEL3_Pin
|
|
|KEY4_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : LED5_Pin SENSOR_EN_Pin GPS_RST_Pin NB_RST_Pin
|
|
NB_WKUP_Pin NB_EN_Pin LED2_Pin LED1_Pin */
|
|
GPIO_InitStruct.Pin = LED5_Pin|SENSOR_EN_Pin|GPS_RST_Pin|NB_RST_Pin
|
|
|NB_WKUP_Pin|NB_EN_Pin|LED2_Pin|LED1_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : SENSOR_INT1_Pin */
|
|
GPIO_InitStruct.Pin = SENSOR_INT1_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(SENSOR_INT1_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : SENSOR_INT2_Pin */
|
|
GPIO_InitStruct.Pin = SENSOR_INT2_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(SENSOR_INT2_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PA5 PA6 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PB0 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : GPS_ON_Pin BD_EN_Pin OLED_RST_Pin OLED_EN_Pin
|
|
LED4_Pin LED3_Pin IR_OUT_Pin */
|
|
GPIO_InitStruct.Pin = GPS_ON_Pin|BD_EN_Pin|OLED_RST_Pin|OLED_EN_Pin
|
|
|LED4_Pin|LED3_Pin|IR_OUT_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : AU_CTR_Pin AU_RST_Pin AU_EN_Pin CARD_END5_Pin */
|
|
GPIO_InitStruct.Pin = AU_CTR_Pin|AU_RST_Pin|AU_EN_Pin|CARD_END5_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : CHARGE_STATE_Pin */
|
|
GPIO_InitStruct.Pin = CHARGE_STATE_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(CHARGE_STATE_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : CARD_EN_Pin */
|
|
GPIO_InitStruct.Pin = CARD_EN_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(CARD_EN_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PCIE_RST_Pin PCIE_EN_Pin */
|
|
GPIO_InitStruct.Pin = PCIE_RST_Pin|PCIE_EN_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : KEY3_Pin KEY2_Pin */
|
|
GPIO_InitStruct.Pin = KEY3_Pin|KEY2_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|