zephyr/include/drivers/dac.h
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00

132 lines
3.1 KiB
C

/*
* Copyright (c) 2020 Libre Solar Technologies GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief DAC public API header file.
*/
#ifndef ZEPHYR_INCLUDE_DRIVERS_DAC_H_
#define ZEPHYR_INCLUDE_DRIVERS_DAC_H_
#include <device.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief DAC driver APIs
* @defgroup dac_interface DAC driver APIs
* @ingroup io_interfaces
* @{
*/
/**
* @struct dac_channel_cfg
* @brief Structure for specifying the configuration of a DAC channel.
*
* @param channel_id Channel identifier of the DAC that should be configured.
* @param resolution Desired resolution of the DAC (depends on device
* capabilities).
*/
struct dac_channel_cfg {
uint8_t channel_id;
uint8_t resolution;
};
/**
* @cond INTERNAL_HIDDEN
*
* For internal use only, skip these in public documentation.
*/
/*
* Type definition of DAC API function for configuring a channel.
* See dac_channel_setup() for argument descriptions.
*/
typedef int (*dac_api_channel_setup)(struct device *dev,
const struct dac_channel_cfg *channel_cfg);
/*
* Type definition of DAC API function for setting a write request.
* See dac_write_value() for argument descriptions.
*/
typedef int (*dac_api_write_value)(struct device *dev,
uint8_t channel, uint32_t value);
/*
* DAC driver API
*
* This is the mandatory API any DAC driver needs to expose.
*/
__subsystem struct dac_driver_api {
dac_api_channel_setup channel_setup;
dac_api_write_value write_value;
};
/**
* @endcond
*/
/**
* @brief Configure a DAC channel.
*
* It is required to call this function and configure each channel before it is
* selected for a write request.
*
* @param dev Pointer to the device structure for the driver instance.
* @param channel_cfg Channel configuration.
*
* @retval 0 On success.
* @retval -EINVAL If a parameter with an invalid value has been provided.
* @retval -ENOTSUP If the requested resolution is not supported.
*/
__syscall int dac_channel_setup(struct device *dev,
const struct dac_channel_cfg *channel_cfg);
static inline int z_impl_dac_channel_setup(struct device *dev,
const struct dac_channel_cfg *channel_cfg)
{
const struct dac_driver_api *api =
(const struct dac_driver_api *)dev->api;
return api->channel_setup(dev, channel_cfg);
}
/**
* @brief Write a single value to a DAC channel
*
* @param dev Pointer to the device structure for the driver instance.
* @param channel Number of the channel to be used.
* @param value Data to be written to DAC output registers.
*
* @retval 0 On success.
* @retval -EINVAL If a parameter with an invalid value has been provided.
*/
__syscall int dac_write_value(struct device *dev, uint8_t channel, uint32_t value);
static inline int z_impl_dac_write_value(struct device *dev,
uint8_t channel, uint32_t value)
{
const struct dac_driver_api *api =
(const struct dac_driver_api *)dev->api;
return api->write_value(dev, channel, value);
}
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#include <syscalls/dac.h>
#endif /* ZEPHYR_INCLUDE_DRIVERS_DAC_H_ */