no-OS
ad7780.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __AD7780_H__
34 #define __AD7780_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include "no_os_gpio.h"
41 #include "no_os_spi.h"
42 
43 /******************************************************************************/
44 /************************** AD7780 Definitions ********************************/
45 /******************************************************************************/
46 
47 /* DOUT/RDY pin */
48 #define AD7780_RDY_STATE(value) no_os_gpio_get_value(dev->gpio_miso, \
49  &value)
50 
51 /* PDRST pin */
52 #define AD7780_PDRST_PIN_OUT no_os_gpio_direction_output(dev->gpio_pdrst, \
53  NO_OS_GPIO_HIGH);
54 #define AD7780_PDRST_HIGH no_os_gpio_set_value(dev->gpio_pdrst, \
55  NO_OS_GPIO_HIGH)
56 #define AD7780_PDRST_LOW no_os_gpio_set_value(dev->gpio_pdrst, \
57  NO_OS_GPIO_LOW)
58 
59 /* FILTER pin */
60 #define AD7780_FILTER_PIN_OUT no_os_gpio_direction_output(dev->gpio_filter, \
61  NO_OS_GPIO_HIGH);
62 #define AD7780_FILTER_HIGH no_os_gpio_set_value(dev->gpio_filter, \
63  NO_OS_GPIO_HIGH)
64 #define AD7780_FILTER_LOW no_os_gpio_set_value(dev->gpio_filter, \
65  NO_OS_GPIO_LOW)
66 
67 /* GAIN pin */
68 #define AD7780_GAIN_PIN_OUT no_os_gpio_direction_output(dev->gpio_gain, \
69  NO_OS_GPIO_HIGH);
70 #define AD7780_GAIN_HIGH no_os_gpio_set_value(dev->gpio_gain, \
71  NO_OS_GPIO_HIGH)
72 #define AD7780_GAIN_LOW no_os_gpio_set_value(dev->gpio_gain, \
73  NO_OS_GPIO_LOW)
74 
75 /* Status bits */
76 #define AD7780_STAT_RDY (1 << 7) // Ready bit.
77 #define AD7780_STAT_FILTER (1 << 6) // Filter bit.
78 #define AD7780_STAT_ERR (1 << 5) // Error bit.
79 #define AD7780_STAT_ID1 (1 << 4) // ID bits.
80 #define AD7780_STAT_ID0 (1 << 3) // ID bits.
81 #define AD7780_STAT_GAIN (1 << 2) // Gain bit.
82 #define AD7780_STAT_PAT1 (1 << 1) // Status pattern bits.
83 #define AD7780_STAT_PAT0 (1 << 0) // Status pattern bits.
84 
85 #define AD7780_ID_NUMBER 0x08
86 
87 /******************************************************************************/
88 /*************************** Types Declarations *******************************/
89 /******************************************************************************/
90 
91 struct ad7780_dev {
92  /* SPI */
94  /* GPIO */
99 };
100 
102  /* SPI */
104  /* GPIO */
109 };
110 
111 /******************************************************************************/
112 /************************ Functions Declarations ******************************/
113 /******************************************************************************/
114 
117 int8_t ad7780_init(struct ad7780_dev **device,
119 
121 int32_t ad7780_remove(struct ad7780_dev *dev);
122 
124 int8_t ad7780_wait_rdy_go_low(struct ad7780_dev *dev);
125 
127 int32_t ad7780_read_sample(struct ad7780_dev *dev,
128  uint8_t* p_status);
129 
131 float ad7780_convert_to_voltage(uint32_t raw_sample,
132  float v_ref,
133  uint8_t gain);
134 
135 #endif /* __AD7780_H__ */
AD7780_PDRST_HIGH
#define AD7780_PDRST_HIGH
Definition: ad7780.h:54
ad7780_init_param::gpio_filter
struct no_os_gpio_init_param gpio_filter
Definition: ad7780.h:107
timeout
uint32_t timeout
Definition: ad413x.c:49
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
AD7780_FILTER_PIN_OUT
#define AD7780_FILTER_PIN_OUT
Definition: ad7780.h:60
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:159
no_os_spi.h
Header file of SPI Interface.
ad7780_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad7780.h:103
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:163
ad7780_init_param::gpio_gain
struct no_os_gpio_init_param gpio_gain
Definition: ad7780.h:108
AD7780_RDY_STATE
#define AD7780_RDY_STATE(value)
Definition: ad7780.h:48
device
Definition: ad9361_util.h:69
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:59
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:124
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:139
AD7780_STAT_ID1
#define AD7780_STAT_ID1
Definition: ad7780.h:79
ad7780_init_param::gpio_pdrst
struct no_os_gpio_init_param gpio_pdrst
Definition: ad7780.h:105
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:59
AD7780_GAIN_PIN_OUT
#define AD7780_GAIN_PIN_OUT
Definition: ad7780.h:68
ad7780_remove
int32_t ad7780_remove(struct ad7780_dev *dev)
Free the resources allocated by ad7780_init().
Definition: ad7780.c:114
ad7780.h
AD7780 header file.
ad7780_dev::gpio_pdrst
struct no_os_gpio_desc * gpio_pdrst
Definition: ad7780.h:95
ad7780_init_param
Definition: ad7780.h:101
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:104
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
ad7780_remove
int32_t ad7780_remove(struct ad7780_dev *dev)
Free the resources allocated by ad7780_init().
Definition: ad7780.c:114
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ad7780_dev
Definition: ad7780.h:91
AD7780_FILTER_LOW
#define AD7780_FILTER_LOW
Definition: ad7780.h:64
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:49
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
AD7780_ID_NUMBER
#define AD7780_ID_NUMBER
Definition: ad7780.h:85
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:163
ad7780_dev::gpio_gain
struct no_os_gpio_desc * gpio_gain
Definition: ad7780.h:98
AD7780_PDRST_LOW
#define AD7780_PDRST_LOW
Definition: ad7780.h:56
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:189
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
ad7780_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7780.h:93
AD7780_STAT_ID0
#define AD7780_STAT_ID0
Definition: ad7780.h:80
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
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:139
ad7780_init_param::gpio_miso
struct no_os_gpio_init_param gpio_miso
Definition: ad7780.h:106
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:116
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:189
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:52
AD7780_PDRST_PIN_OUT
#define AD7780_PDRST_PIN_OUT
Definition: ad7780.h:52
ad7780_dev::gpio_filter
struct no_os_gpio_desc * gpio_filter
Definition: ad7780.h:97
ad7780_dev::gpio_miso
struct no_os_gpio_desc * gpio_miso
Definition: ad7780.h:96
AD7780_GAIN_HIGH
#define AD7780_GAIN_HIGH
Definition: ad7780.h:70
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140