/**
  ******************************************************************************
  * @file     OPAMP_CFG.c
  * @author   SINOMCU-AE
  * @brief    OPAMP1 config
  *    
  *          This file provides functions to OPAMP1 config:
  *              INP PB5,OUT PB7,2 Gain
  *         
  ******************************************************************************
  * @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>
  *
  ******************************************************************************
  */
  
/* Includes ------------------------------------------------------------------*/
#include "OPAMP_CFG.h"

/**
  * @brief  OPAMP1 pin Initialization Function
  *    PB5   <-- OMAMP1_INP
  *    PB7   --> OPAM1_OUT 
  * @param  None
  * @retval None
  */
void OPAMP_Pin_Init(void)
{
  MS32_GPIO_InitTypeDef   GPIO_InitStruct; 
  
  MS32_AHB1_GRP1_EnableClock(MS32_AHB1_GRP1_PERIPH_GPIOB);

  MS32_GPIO_StructInit(&GPIO_InitStruct);
  GPIO_InitStruct.Pin = MS32_GPIO_PIN_5 | MS32_GPIO_PIN_7; // OPAMP1,INP OUT
  GPIO_InitStruct.Mode = MS32_GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = MS32_GPIO_PULL_NO;
  MS32_GPIO_Init(GPIOB,&GPIO_InitStruct); 
}

/**
  * @brief  OPAMP1 Initialization Function,¬2 Gain
  * @param  None
  * @retval None
  */
void OPAMP_Init(void)
{
  MS32_OP_InitTypeDef  OPAMP_InitStruct;

  OPAMP_Pin_Init();
  
  MS32_APB1_GRP2_EnableClock(MS32_APB1_GRP2_PERIPH_SYSCFG);
 
  MS32_OP_StructInit(&OPAMP_InitStruct);
  OPAMP_InitStruct.OutputEn = MS32_OP_OUT_EN;    
  OPAMP_InitStruct.NegitiveInputSel = MS32_OP_NEGINPUT_GAIN; 
  OPAMP_InitStruct.GAIN = MS32_OP_GAIN2; 
  MS32_OP_Init(MS32_OP1,&OPAMP_InitStruct);   
}

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