stm32_dac_driver.h 1.85 KB
Newer Older
Clément Foucher's avatar
Clément Foucher committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (c) 2021 LAAS-CNRS
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: LGLPV2.1
 */

/**
 * @author  Clément Foucher <clement.foucher@laas.fr>
 */

#ifndef STM32_DAC_DRIVER_H_
#define STM32_DAC_DRIVER_H_

// Zephyr
#include <device.h>

// Public API
#include "dac.h"

#ifdef __cplusplus
extern "C" {
#endif


#define DAC1_NODELABEL DT_NODELABEL(dac1)
#define DAC2_NODELABEL DT_NODELABEL(dac2)
#define DAC3_NODELABEL DT_NODELABEL(dac3)

typedef enum
{
	dac_mode_unset,
	dac_mode_constant,
	dac_mode_function
} dac_mode_t;


struct stm32_dac_driver_data
{
	DAC_TypeDef* dac_struct;
	dac_mode_t   dac_mode;
};



static int  dac_stm32_init(const struct device* dev);
static void dac_stm32_set_const_value(const struct device* dev, uint8_t channel, uint32_t value);
static void dac_stm32_set_function(const struct device* dev, uint8_t channel, const dac_function_config_t* function_config);
static void dac_stm32_pin_configure(const struct device* dev, uint8_t channel, const dac_pin_config_t* pin_config);
static void dac_stm32_start(const struct device* dev, uint8_t channel);
static void dac_stm32_stop(const struct device* dev, uint8_t channel);


#ifdef __cplusplus
}
#endif

#endif // STM32_DAC_DRIVER_H_