no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad7780.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef __AD7780_H__
34#define __AD7780_H__
35
36#include <stdint.h>
37#include "no_os_gpio.h"
38#include "no_os_spi.h"
39
40/* DOUT/RDY pin */
41#define AD7780_RDY_STATE(value) no_os_gpio_get_value(dev->gpio_miso, \
42 &value)
43
44/* PDRST pin */
45#define AD7780_PDRST_PIN_OUT no_os_gpio_direction_output(dev->gpio_pdrst, \
46 NO_OS_GPIO_HIGH);
47#define AD7780_PDRST_HIGH no_os_gpio_set_value(dev->gpio_pdrst, \
48 NO_OS_GPIO_HIGH)
49#define AD7780_PDRST_LOW no_os_gpio_set_value(dev->gpio_pdrst, \
50 NO_OS_GPIO_LOW)
51
52/* FILTER pin */
53#define AD7780_FILTER_PIN_OUT no_os_gpio_direction_output(dev->gpio_filter, \
54 NO_OS_GPIO_HIGH);
55#define AD7780_FILTER_HIGH no_os_gpio_set_value(dev->gpio_filter, \
56 NO_OS_GPIO_HIGH)
57#define AD7780_FILTER_LOW no_os_gpio_set_value(dev->gpio_filter, \
58 NO_OS_GPIO_LOW)
59
60/* GAIN pin */
61#define AD7780_GAIN_PIN_OUT no_os_gpio_direction_output(dev->gpio_gain, \
62 NO_OS_GPIO_HIGH);
63#define AD7780_GAIN_HIGH no_os_gpio_set_value(dev->gpio_gain, \
64 NO_OS_GPIO_HIGH)
65#define AD7780_GAIN_LOW no_os_gpio_set_value(dev->gpio_gain, \
66 NO_OS_GPIO_LOW)
67
68/* Status bits */
69#define AD7780_STAT_RDY (1 << 7) // Ready bit.
70#define AD7780_STAT_FILTER (1 << 6) // Filter bit.
71#define AD7780_STAT_ERR (1 << 5) // Error bit.
72#define AD7780_STAT_ID1 (1 << 4) // ID bits.
73#define AD7780_STAT_ID0 (1 << 3) // ID bits.
74#define AD7780_STAT_GAIN (1 << 2) // Gain bit.
75#define AD7780_STAT_PAT1 (1 << 1) // Status pattern bits.
76#define AD7780_STAT_PAT0 (1 << 0) // Status pattern bits.
77
78#define AD7780_ID_NUMBER 0x08
79
89
99
102int8_t ad7780_init(struct ad7780_dev **device,
104
106int32_t ad7780_remove(struct ad7780_dev *dev);
107
109int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev);
110
112int32_t ad7780_read_sample(struct ad7780_dev *dev,
113 uint8_t* p_status);
114
116float ad7780_convert_to_voltage(uint32_t raw_sample,
117 float v_ref,
118 uint8_t gain);
119
120#endif /* __AD7780_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int32_t ad7780_read_sample(struct ad7780_dev *dev, uint8_t *p_status)
Reads a 24-bit sample from the ADC.
Definition ad7780.c:156
float ad7780_convert_to_voltage(uint32_t raw_sample, float v_ref, uint8_t gain)
Converts the 24-bit raw value to milivolts.
Definition ad7780.c:182
int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev)
Waits for DOUT/RDY pin to go low.
Definition ad7780.c:132
int8_t ad7780_init(struct ad7780_dev **device, struct ad7780_init_param init_param)
Initializes the communication peripheral and the initial Values for AD7780 Board and checks if the de...
Definition ad7780.c:52
int32_t ad7780_remove(struct ad7780_dev *dev)
Free the resources allocated by ad7780_init().
Definition ad7780.c:107
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad7780.h:80
struct no_os_spi_desc * spi_desc
Definition ad7780.h:82
struct no_os_gpio_desc * gpio_filter
Definition ad7780.h:86
struct no_os_gpio_desc * gpio_gain
Definition ad7780.h:87
struct no_os_gpio_desc * gpio_miso
Definition ad7780.h:85
struct no_os_gpio_desc * gpio_pdrst
Definition ad7780.h:84
Definition ad7780.h:90
struct no_os_gpio_init_param gpio_miso
Definition ad7780.h:95
struct no_os_spi_init_param spi_init
Definition ad7780.h:92
struct no_os_gpio_init_param gpio_filter
Definition ad7780.h:96
struct no_os_gpio_init_param gpio_pdrst
Definition ad7780.h:94
struct no_os_gpio_init_param gpio_gain
Definition ad7780.h:97
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128