/**
  ******************************************************************************
  * @file     GPIO_CFG.c
  * @author   SINOMCU-AE
  * @brief    GPIO config
  *    
  *          This file provides functions to GPIO config:
  *              LED1 pin pushpull,output,pull down
  *         
  ******************************************************************************
  * @attention 
  *                           DISCLAIMER
  * The present firmware which is for guidance only aims at providing customers
  * with coding information regarding their products in order for them to save
  * time. As a result, SinoMCU shall not be held liable for any direct,indirect
  * or consequential damages with respect to any claims arising from the content 
  * of such firmware and/or the use made by customers of the coding information 
  * contained herein in connection with their products.
  *
  * <h2><center>&copy; Copyright (c) 2021 sinomcu All rights reserved.</center></h2>
  *
  ******************************************************************************
  */

#include "GPIO_CFG.h"

/**
  * @brief  LED1 on,pin out high level
  * @param  None
  * @retval None
  */
void LED1_ON(void) {
  MS32_GPIO_SetOutputPin(LED_Port,LED1_Pin); 
} 

/**
  * @brief  LED1 off,pin out low level
  * @param  None
  * @retval None
  */
void LED1_OFF(void) {
  MS32_GPIO_ResetOutputPin(LED_Port,LED1_Pin);
}

/**
  * @brief  LED1 toggle
  * @param  None
  * @retval None
  */
void LED1_TOGGLE(void) {
  MS32_GPIO_TogglePin(LED_Port,LED1_Pin);
}

/**
  * @brief  GPIO Initialization Function
  * @param  None
  * @retval None
  */
void gpio_init(void) {
  MS32_GPIO_InitTypeDef  GpioInitStruct;
  
  MS32_AHB1_GRP1_EnableClock(LED1_AHB_PERIPH_Port);

  // LED GPIO out pulldown
  MS32_GPIO_StructInit(&GpioInitStruct);  
  GpioInitStruct.Pin = LED1_Pin;
  GpioInitStruct.Mode = MS32_GPIO_MODE_OUTPUT;
  GpioInitStruct.OutputType = MS32_GPIO_OUTPUT_PUSHPULL;
  GpioInitStruct.Speed = MS32_GPIO_SPEED_HIGH;
  GpioInitStruct.Pull = MS32_GPIO_PULL_DOWN;
  GpioInitStruct.Alternate = MS32_GPIO_AF_0;
  MS32_GPIO_Init(LED_Port,&GpioInitStruct);
}

/******************************** END OF FILE *********************************/
