text: /**
    ******************************************************************************
    * File Name          : gpio.c
    * Description        : This file provides code for the configuration
    *                      of all used GPIO pins.
    ******************************************************************************
    ** This notice applies to any and all portions of this file
    * that are not between comment pairs USER CODE BEGIN and
    * USER CODE END. Other portions of this file, whether 
    * inserted by the user or by software development tools
    * are owned by their respective copyright owners.
    *
    * COPYRIGHT(c) 2019 STMicroelectronics
    *
    * Redistribution and use in source and binary forms, with or without modification,
    * are permitted provided that the following conditions are met:
    *   1. Redistributions of source code must retain the above copyright notice,
    *      this list of conditions and the following disclaimer.
    *   2. Redistributions in binary form must reproduce the above copyright notice,
    *      this list of conditions and the following disclaimer in the documentation
    *      and/or other materials provided with the distribution.
    *   3. Neither the name of STMicroelectronics nor the names of its contributors
    *      may be used to endorse or promote products derived from this software
    *      without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    ******************************************************************************
    */
  
  /* 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
       PE6   ------> S_TIM9_CH2
  */
  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, RAM_CS_Pin|M1_EN_Pin|M1_INB_Pin|M1_CS_Pin 
                            |M2_EN_Pin|M2_INA_Pin|M2_INB_Pin|M2_CS_Pin, GPIO_PIN_RESET);
  
    /*Configure GPIO pin Output Level */
    HAL_GPIO_WritePin(GPIOC, FLED_BLUE_Pin|FLED_GREEN_Pin|FLED_RED_Pin|CL_Pin 
                            |MVSIG1_Pin|MVSIG2_Pin|MVSIG3_Pin, GPIO_PIN_RESET);
  
    /*Configure GPIO pin Output Level */
    HAL_GPIO_WritePin(GPIOA, RAM_HOLD_Pin|DP1_Pin|DP2_Pin|LED_RST_Pin 
                            |BUZZER_Pin, GPIO_PIN_RESET);
  
    /*Configure GPIO pin Output Level */
    HAL_GPIO_WritePin(GPIOB, E1_Pin|E2_Pin|M1_INA_Pin|LCD_CS_Pin 
                            |LCD_RST_Pin|GATE_Pin|FET1_Pin|FET2_Pin, GPIO_PIN_RESET);
  
    /*Configure GPIO pin Output Level */
    HAL_GPIO_WritePin(GPIOD, ST_MOTOR_CH4_Pin|ST_MOTOR_CH3_Pin|ST_MOTOR_CH2_Pin|ST_MOTOR_CH1_Pin, GPIO_PIN_SET);
  
    /*Configure GPIO pin Output Level */
    HAL_GPIO_WritePin(GPIOD, RANGE_Pin|CK_Pin, GPIO_PIN_RESET);
  
    /*Configure GPIO pins : PEPin PEPin PEPin */
    GPIO_InitStruct.Pin = MVS3_Pin|MVS2_Pin|MVS1_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PEPin PEPin PEPin PEPin 
                             PEPin PEPin PEPin PEPin */
    GPIO_InitStruct.Pin = RAM_CS_Pin|M1_EN_Pin|M1_INB_Pin|M1_CS_Pin 
                            |M2_EN_Pin|M2_INA_Pin|M2_INB_Pin|M2_CS_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 : PtPin */
    GPIO_InitStruct.Pin = ESC_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF3_TIM9;
    HAL_GPIO_Init(ESC_GPIO_Port, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PCPin PCPin PCPin */
    GPIO_InitStruct.Pin = FLED_BLUE_Pin|FLED_GREEN_Pin|FLED_RED_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PCPin PCPin */
    GPIO_InitStruct.Pin = TOUCH1_Pin|TOUCH2_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF15_EVENTOUT;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PAPin PAPin PAPin PAPin 
                             PAPin */
    GPIO_InitStruct.Pin = RAM_HOLD_Pin|DP1_Pin|DP2_Pin|LED_RST_Pin 
                            |BUZZER_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 : PBPin PBPin PBPin PBPin 
                             PBPin PBPin PBPin PBPin */
    GPIO_InitStruct.Pin = E1_Pin|E2_Pin|M1_INA_Pin|LCD_CS_Pin 
                            |LCD_RST_Pin|GATE_Pin|FET1_Pin|FET2_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 : PDPin PDPin PDPin */
    GPIO_InitStruct.Pin = SW1_Pin|SW2_Pin|SW3_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF15_EVENTOUT;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PDPin PDPin PDPin PDPin 
                             PDPin PDPin */
    GPIO_InitStruct.Pin = ST_MOTOR_CH4_Pin|ST_MOTOR_CH3_Pin|ST_MOTOR_CH2_Pin|ST_MOTOR_CH1_Pin 
                            |RANGE_Pin|CK_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 : PtPin */
    GPIO_InitStruct.Pin = CL_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(CL_GPIO_Port, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PCPin PCPin PCPin */
    GPIO_InitStruct.Pin = MVSIG1_Pin|MVSIG2_Pin|MVSIG3_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
    /*Configure GPIO pins : PDPin PDPin PDPin PDPin 
                             PDPin PDPin */
    GPIO_InitStruct.Pin = PING1_Pin|PING2_Pin|PING3_Pin|PING4_Pin 
                            |PING5_Pin|PING6_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  
    /*Configure GPIO pin : PtPin */
    GPIO_InitStruct.Pin = DOUT_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(DOUT_GPIO_Port, &GPIO_InitStruct);
  
    /* EXTI interrupt init*/
    HAL_NVIC_SetPriority(EXTI2_IRQn, 1, 0);
    HAL_NVIC_EnableIRQ(EXTI2_IRQn);
  
    HAL_NVIC_SetPriority(EXTI3_IRQn, 1, 0);
    HAL_NVIC_EnableIRQ(EXTI3_IRQn);
  
    HAL_NVIC_SetPriority(EXTI4_IRQn, 1, 0);
    HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  
  }
  
  /* USER CODE BEGIN 2 */
  
  /* USER CODE END 2 */
  
  /**
    * @}
    */
  
  /**
    * @}
    */
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  