Implementation of AD7798/AD7799 Driver.
More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "no_os_error.h"
#include "ad7799.h"
#include "no_os_alloc.h"
|
| int32_t | ad7799_read (struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data) |
| | Read device register.
|
| |
| int32_t | ad7799_write (struct ad7799_dev *device, uint8_t reg_addr, uint32_t reg_data) |
| | Write device register.
|
| |
| int32_t | ad7799_reset (struct ad7799_dev *device) |
| | Software reset of the device.
|
| |
| int32_t | ad7799_set_mode (struct ad7799_dev *device, uint8_t mode) |
| | Set the device mode.
|
| |
| int32_t | ad7799_set_channel (struct ad7799_dev *device, uint8_t ch) |
| | Select the ADC channel.
|
| |
| int32_t | ad7799_get_channel (struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data) |
| | Read specific ADC channel.
|
| |
| int32_t | ad7799_read_channel (struct ad7799_dev *device, uint8_t ch, int32_t *data_scaled) |
| | Read data from specific ADC channel with specified precision.
|
| |
| int32_t | ad7799_set_gain (struct ad7799_dev *device, uint8_t gain) |
| | Set the ADC gain.
|
| |
| int32_t | ad7799_get_gain (struct ad7799_dev *device, uint8_t *gain) |
| | Get the ADC gain.
|
| |
| int32_t | ad7799_set_refdet (struct ad7799_dev *device, uint8_t ref_en) |
| | Enable or disable the reference detect function.
|
| |
| int32_t | ad7799_set_polarity (struct ad7799_dev *device, uint8_t polarity) |
| | Set ADC polarity.
|
| |
| int32_t | ad7799_dev_ready (struct ad7799_dev *device) |
| | Read the /RDY bit of status register and check the status of the device.
|
| |
| int32_t | ad7799_init (struct ad7799_dev **device, const struct ad7799_init_param *init_param) |
| | Initialize the device.
|
| |
| int32_t | ad7799_remove (struct ad7799_dev *device) |
| | Remove the device and release resources.
|
| |
Implementation of AD7798/AD7799 Driver.
- Author
- Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)
Copyright 2020(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ ad7799_dev_ready()
| int32_t ad7799_dev_ready |
( |
struct ad7799_dev * | device | ) |
|
Read the /RDY bit of status register and check the status of the device.
- Parameters
-
| device | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_get_channel()
| int32_t ad7799_get_channel |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | ch, |
|
|
uint32_t * | reg_data ) |
Read specific ADC channel.
- Parameters
-
| device | - The device structure. |
| ch | - The ADC channel. |
| reg_data | - The content of the data register. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_get_gain()
| int32_t ad7799_get_gain |
( |
struct ad7799_dev * | device, |
|
|
uint8_t * | gain ) |
Get the ADC gain.
- Parameters
-
| device | - The device structure. |
| gain | - the gain value from the register. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_init()
Initialize the device.
- Parameters
-
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_read()
| int32_t ad7799_read |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | reg_addr, |
|
|
uint32_t * | reg_data ) |
Read device register.
- Parameters
-
| device | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The data read from the register. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_read_channel()
| int32_t ad7799_read_channel |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | ch, |
|
|
int32_t * | data_scaled ) |
Read data from specific ADC channel with specified precision.
- Parameters
-
| device | - The device structure. |
| ch | - The ADC channel. |
| data_scaled | - The content of the data in mV/uV. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_remove()
| int32_t ad7799_remove |
( |
struct ad7799_dev * | device | ) |
|
Remove the device and release resources.
- Parameters
-
| device | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_reset()
| int32_t ad7799_reset |
( |
struct ad7799_dev * | device | ) |
|
Software reset of the device.
- Parameters
-
| device | - The device structure. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_set_channel()
| int32_t ad7799_set_channel |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | ch ) |
Select the ADC channel.
- Parameters
-
| device | - The device structure. |
| ch | - The channel number. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_set_gain()
| int32_t ad7799_set_gain |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | gain ) |
Set the ADC gain.
- Parameters
-
| device | - The device structure. |
| gain | - the channel number. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_set_mode()
| int32_t ad7799_set_mode |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | mode ) |
Set the device mode.
- Parameters
-
| device | - The device structure. |
| mode | - The device mode. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_set_polarity()
| int32_t ad7799_set_polarity |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | polarity ) |
Set ADC polarity.
- Parameters
-
| device | - The device structure. |
| polarity | - set the device polarity: 0 - Bipolar coding 1 - Unipolar coding |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_set_refdet()
| int32_t ad7799_set_refdet |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | ref_en ) |
Enable or disable the reference detect function.
- Parameters
-
| device | - The device structure. |
| ref_en | - 1 reference detect enable.
- 0 reference detect disable.
|
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7799_write()
| int32_t ad7799_write |
( |
struct ad7799_dev * | device, |
|
|
uint8_t | reg_addr, |
|
|
uint32_t | reg_data ) |
Write device register.
- Parameters
-
| device | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The data to be written. |
- Returns
- 0 in case of success, negative error code otherwise.