HRI board firmware  v2.1
Microcontroller firmware of the board used during the HRI labs.
dac.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __DAC_H
18 #define __DAC_H
19 
20 #include "../main.h"
21 
22 #define DAC1_Pin GPIO_Pin_4
23 #define DAC2_Pin GPIO_Pin_5
24 #define DAC_Port GPIOA
25 
26 #define DAC_FINAL_RANGE 9.0f // -9 to 9V after the op-amp.
27 #define DAC_MAX 4095 // 12-bits.
28 
44 void dac_Init(void);
45 void dac_SetVoltage1(float32_t voltage);
46 void dac_SetVoltage2(float32_t voltage);
47 float32_t dac_GetVoltage1(void);
48 float32_t dac_GetVoltage2(void);
49 
54 #endif
void dac_Init(void)
Setup a DAC with 2 channels.
Definition: dac.c:23
void dac_SetVoltage2(float32_t voltage)
Set the voltage of the channel 2 of the DAC.
Definition: dac.c:75
float32_t dac_GetVoltage1(void)
Get the current output voltage of the channel 1 of the DAC.
Definition: dac.c:89
float32_t dac_GetVoltage2(void)
Get the current output voltage of the channel 2 of the DAC.
Definition: dac.c:100
void dac_SetVoltage1(float32_t voltage)
Set the voltage of the channel 1 of the DAC.
Definition: dac.c:61