Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Libre Solar Technologies GmbH
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_DAC_H_
13#define ZEPHYR_INCLUDE_DRIVERS_DAC_H_
14
15#include <zephyr/device.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
42 bool buffered: 1;
47 bool internal: 1;
48};
49
56/*
57 * Type definition of DAC API function for configuring a channel.
58 * See dac_channel_setup() for argument descriptions.
59 */
60typedef int (*dac_api_channel_setup)(const struct device *dev,
61 const struct dac_channel_cfg *channel_cfg);
62
63/*
64 * Type definition of DAC API function for setting a write request.
65 * See dac_write_value() for argument descriptions.
66 */
67typedef int (*dac_api_write_value)(const struct device *dev,
68 uint8_t channel, uint32_t value);
69
70/*
71 * DAC driver API
72 *
73 * This is the mandatory API any DAC driver needs to expose.
74 */
75__subsystem struct dac_driver_api {
76 dac_api_channel_setup channel_setup;
77 dac_api_write_value write_value;
78};
79
97__syscall int dac_channel_setup(const struct device *dev,
98 const struct dac_channel_cfg *channel_cfg);
99
100static inline int z_impl_dac_channel_setup(const struct device *dev,
101 const struct dac_channel_cfg *channel_cfg)
102{
103 const struct dac_driver_api *api =
104 (const struct dac_driver_api *)dev->api;
105
106 return api->channel_setup(dev, channel_cfg);
107}
108
119__syscall int dac_write_value(const struct device *dev, uint8_t channel,
120 uint32_t value);
121
122static inline int z_impl_dac_write_value(const struct device *dev,
123 uint8_t channel, uint32_t value)
124{
125 const struct dac_driver_api *api =
126 (const struct dac_driver_api *)dev->api;
127
128 return api->write_value(dev, channel, value);
129}
130
135#ifdef __cplusplus
136}
137#endif
138
139#include <zephyr/syscalls/dac.h>
140
141#endif /* ZEPHYR_INCLUDE_DRIVERS_DAC_H_ */
int dac_write_value(const struct device *dev, uint8_t channel, uint32_t value)
Write a single value to a DAC channel.
int dac_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg)
Configure a DAC channel.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Structure for specifying the configuration of a DAC channel.
Definition dac.h:33
bool buffered
Enable output buffer for this channel.
Definition dac.h:42
uint8_t channel_id
Channel identifier of the DAC that should be configured.
Definition dac.h:35
uint8_t resolution
Desired resolution of the DAC (depends on device capabilities).
Definition dac.h:37
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409