no-OS
ad7780.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef __AD7780_H__
40 #define __AD7780_H__
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_gpio.h"
47 #include "no_os_spi.h"
48 
49 /******************************************************************************/
50 /************************** AD7780 Definitions ********************************/
51 /******************************************************************************/
52 
53 /* DOUT/RDY pin */
54 #define AD7780_RDY_STATE(value) no_os_gpio_get_value(dev->gpio_miso, \
55  &value)
56 
57 /* PDRST pin */
58 #define AD7780_PDRST_PIN_OUT no_os_gpio_direction_output(dev->gpio_pdrst, \
59  NO_OS_GPIO_HIGH);
60 #define AD7780_PDRST_HIGH no_os_gpio_set_value(dev->gpio_pdrst, \
61  NO_OS_GPIO_HIGH)
62 #define AD7780_PDRST_LOW no_os_gpio_set_value(dev->gpio_pdrst, \
63  NO_OS_GPIO_LOW)
64 
65 /* FILTER pin */
66 #define AD7780_FILTER_PIN_OUT no_os_gpio_direction_output(dev->gpio_filter, \
67  NO_OS_GPIO_HIGH);
68 #define AD7780_FILTER_HIGH no_os_gpio_set_value(dev->gpio_filter, \
69  NO_OS_GPIO_HIGH)
70 #define AD7780_FILTER_LOW no_os_gpio_set_value(dev->gpio_filter, \
71  NO_OS_GPIO_LOW)
72 
73 /* GAIN pin */
74 #define AD7780_GAIN_PIN_OUT no_os_gpio_direction_output(dev->gpio_gain, \
75  NO_OS_GPIO_HIGH);
76 #define AD7780_GAIN_HIGH no_os_gpio_set_value(dev->gpio_gain, \
77  NO_OS_GPIO_HIGH)
78 #define AD7780_GAIN_LOW no_os_gpio_set_value(dev->gpio_gain, \
79  NO_OS_GPIO_LOW)
80 
81 /* Status bits */
82 #define AD7780_STAT_RDY (1 << 7) // Ready bit.
83 #define AD7780_STAT_FILTER (1 << 6) // Filter bit.
84 #define AD7780_STAT_ERR (1 << 5) // Error bit.
85 #define AD7780_STAT_ID1 (1 << 4) // ID bits.
86 #define AD7780_STAT_ID0 (1 << 3) // ID bits.
87 #define AD7780_STAT_GAIN (1 << 2) // Gain bit.
88 #define AD7780_STAT_PAT1 (1 << 1) // Status pattern bits.
89 #define AD7780_STAT_PAT0 (1 << 0) // Status pattern bits.
90 
91 #define AD7780_ID_NUMBER 0x08
92 
93 /******************************************************************************/
94 /*************************** Types Declarations *******************************/
95 /******************************************************************************/
96 
97 struct ad7780_dev {
98  /* SPI */
100  /* GPIO */
105 };
106 
108  /* SPI */
110  /* GPIO */
115 };
116 
117 /******************************************************************************/
118 /************************ Functions Declarations ******************************/
119 /******************************************************************************/
120 
123 int8_t ad7780_init(struct ad7780_dev **device,
125 
127 int32_t ad7780_remove(struct ad7780_dev *dev);
128 
130 int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev);
131 
133 int32_t ad7780_read_sample(struct ad7780_dev *dev,
134  uint8_t* p_status);
135 
137 float ad7780_convert_to_voltage(uint32_t raw_sample,
138  float v_ref,
139  uint8_t gain);
140 
141 #endif /* __AD7780_H__ */
AD7780_PDRST_HIGH
#define AD7780_PDRST_HIGH
Definition: ad7780.h:60
ad7780_init_param::gpio_filter
struct no_os_gpio_init_param gpio_filter
Definition: ad7780.h:113
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
AD7780_FILTER_PIN_OUT
#define AD7780_FILTER_PIN_OUT
Definition: ad7780.h:66
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:82
no_os_spi.h
Header file of SPI Interface.
ad7780_read_sample
int32_t ad7780_read_sample(struct ad7780_dev *dev, uint8_t *p_status)
Reads a 24-bit sample from the ADC.
Definition: ad7780.c:168
ad7780_init_param::gpio_gain
struct no_os_gpio_init_param gpio_gain
Definition: ad7780.h:114
AD7780_RDY_STATE
#define AD7780_RDY_STATE(value)
Definition: ad7780.h:54
device
Definition: ad9361_util.h:75
ad7780_init
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:64
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:108
ad7780_wait_rdy_go_low
int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev)
Waits for DOUT/RDY pin to go low.
Definition: ad7780.c:144
AD7780_STAT_ID1
#define AD7780_STAT_ID1
Definition: ad7780.h:85
ad7780_init_param::gpio_pdrst
struct no_os_gpio_init_param gpio_pdrst
Definition: ad7780.h:111
ad7780_init
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:64
AD7780_GAIN_PIN_OUT
#define AD7780_GAIN_PIN_OUT
Definition: ad7780.h:74
ad7780_remove
int32_t ad7780_remove(struct ad7780_dev *dev)
Free the resources allocated by ad7780_init().
Definition: ad7780.c:119
ad7780_init_param::spi_init
no_os_spi_init_param spi_init
Definition: ad7780.h:109
ad7780.h
AD7780 header file.
ad7780_dev::gpio_pdrst
struct no_os_gpio_desc * gpio_pdrst
Definition: ad7780.h:101
ad7780_init_param
Definition: ad7780.h:107
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:95
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
ad7780_remove
int32_t ad7780_remove(struct ad7780_dev *dev)
Free the resources allocated by ad7780_init().
Definition: ad7780.c:119
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
ad7780_dev
Definition: ad7780.h:97
AD7780_FILTER_LOW
#define AD7780_FILTER_LOW
Definition: ad7780.h:70
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:55
AD7780_ID_NUMBER
#define AD7780_ID_NUMBER
Definition: ad7780.h:91
ad7780_read_sample
int32_t ad7780_read_sample(struct ad7780_dev *dev, uint8_t *p_status)
Reads a 24-bit sample from the ADC.
Definition: ad7780.c:168
ad7780_dev::gpio_gain
struct no_os_gpio_desc * gpio_gain
Definition: ad7780.h:104
AD7780_PDRST_LOW
#define AD7780_PDRST_LOW
Definition: ad7780.h:62
ad7780_convert_to_voltage
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:194
AD7780_STAT_ID0
#define AD7780_STAT_ID0
Definition: ad7780.h:86
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
ad7780_wait_rdy_go_low
int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev)
Waits for DOUT/RDY pin to go low.
Definition: ad7780.c:144
ad7780_init_param::gpio_miso
struct no_os_gpio_init_param gpio_miso
Definition: ad7780.h:112
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:70
ad7780_convert_to_voltage
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:194
no_os_gpio.h
Header file of GPIO Interface.
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:51
AD7780_PDRST_PIN_OUT
#define AD7780_PDRST_PIN_OUT
Definition: ad7780.h:58
ad7780_dev::gpio_filter
struct no_os_gpio_desc * gpio_filter
Definition: ad7780.h:103
ad7780_dev::spi_desc
no_os_spi_desc * spi_desc
Definition: ad7780.h:99
ad7780_dev::gpio_miso
struct no_os_gpio_desc * gpio_miso
Definition: ad7780.h:102
AD7780_GAIN_HIGH
#define AD7780_GAIN_HIGH
Definition: ad7780.h:76
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112