ECE 486 Support Libraries
opamp486.c
Go to the documentation of this file.
1 /*!
2  * @file
3  *
4  * @brief Setup L4 opamp1 to buffer DAC Channel 1 in order to drive pin PA3
5  *
6  * @author Don Hummels
7  *
8  * @date Jan 2016
9  *
10  */
11 
12 #include "stm32l4xx_hal.h"
13 #include "opamp486.h"
14 
15 static OPAMP_HandleTypeDef OpampHandle;
16 
17 // Setup L4 opamp1 to buffer the dac1 output1 in order to drive pin PA3
18 
19 void opamp_init(void)
20 {
21  OpampHandle.Instance = OPAMP1;
22  OpampHandle.Init.Mode = OPAMP_FOLLOWER_MODE; // follower mode
23  OpampHandle.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_DAC_CH;
24  OpampHandle.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
25  HAL_OPAMP_Init(&OpampHandle);
26 
27  HAL_OPAMP_Start(&OpampHandle);
28  return;
29 }
30 
31 
32 void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef * opamp)
33 {
34  GPIO_InitTypeDef GPIO_InitStruct;
35 
36  __HAL_RCC_GPIOA_CLK_ENABLE();
37  __HAL_RCC_OPAMP_CLK_ENABLE();
38 
39  GPIO_InitStruct.Pin = GPIO_PIN_3;
40  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
41  GPIO_InitStruct.Pull = GPIO_NOPULL;
42  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
43 
44 }
void opamp_init(void)
Set up OPAMP1 to buffer DAC Channel 1 to drive PA3.
Definition: opamp486.c:19
void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef *opamp)
Definition: opamp486.c:32
static OPAMP_HandleTypeDef OpampHandle
Definition: opamp486.c:15
Initialization of OPAMP1 to buffer DAC Ch 1 to an output pin.