/**
  ******************************************************************************
  * @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   GpioInitStruct; 
  
  MS32_GPIO_StructInit(&GpioInitStruct);
  GpioInitStruct.Pin = MS32_GPIO_PIN_5 | MS32_GPIO_PIN_7;  // OPAMP1,INP OUT
  GpioInitStruct.Mode = MS32_GPIO_MODE_ANALOG;
  GpioInitStruct.Pull = MS32_GPIO_PULL_NO;
  MS32_GPIO_Init(GPIOB,&GpioInitStruct);                   // init function had enable clock
}

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

  opamp_pin_init();
 
  MS32_OP_StructInit(&OpampInitStruct);
  OpampInitStruct.OutputEn = MS32_OP_OUT_EN;    
  OpampInitStruct.NegitiveInputSel = MS32_OP_NEGINPUT_GAIN; 
  OpampInitStruct.GAIN = MS32_OP_GAIN2; 
  MS32_OP_Init(MS32_OP1,&OpampInitStruct);                 // init function had enable syscfg clock  
}

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