no-OS
ad5628.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef __AD5628_H__
41 #define __AD5628_H__
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 #include <stdint.h>
47 #include "no_os_spi.h"
48 
49 /******************************************************************************/
50 /******************************** AD5628 **************************************/
51 /******************************************************************************/
52 /* AD5628 Input Register */
53 #define AD5628_CMD(x) ((0x000F & (int32_t)(x)) << 24)
54 #define AD5628_ADDR(x) ((0x000F & (int32_t)(x)) << 20)
55 #define AD5628_DATA_BITS(x) ((0x0FFF & (int32_t)(x)) << 8)
56 
57 /* Command Definitions (AD5628_COMMAND(x) options) */
58 #define AD5628_CMD_WRITE_INPUT_N 0 // Write to Input Register n.
59 #define AD5628_CMD_UPDATE_DAC_N 1 // Update DAC Register n.
60 #define AD5628_CMD_WRITE_INPUT_N_UPDATE_ALL 2 // Write to Input Register n, update all.
61 #define AD5628_CMD_WRITE_INPUT_N_UPDATE_N 3 // Write to and update DAC Channel n.
62 #define AD5628_CMD_POWERDOWN 4 // Power down/power up DAC.
63 #define AD5628_CMD_LOAD_CLEAR_CODE 5 // Load clear code register.
64 #define AD5628_CMD_LOAD_LDAC_REG 6 // Load LDAC register.
65 #define AD5628_CMD_RESET 7 // Reset (power-on reset)
66 #define AD5628_CMD_SET_INT_REF 8 // Set up internal REF register.
67 
68 /* Address Commands (AD5628_ADDRESS(x) options) */
69 #define AD5628_ADDR_DAC_A 0x00 //DAC A
70 #define AD5628_ADDR_DAC_B 0x01 //DAC B
71 #define AD5628_ADDR_DAC_C 0x02 //DAC C
72 #define AD5628_ADDR_DAC_D 0x03 //DAC D
73 #define AD5628_ADDR_DAC_E 0x04 //DAC E
74 #define AD5628_ADDR_DAC_F 0x05 //DAC F
75 #define AD5628_ADDR_DAC_G 0x06 //DAC G
76 #define AD5628_ADDR_DAC_H 0x07 //DAC H
77 #define AD5628_ADDR_DAC_ALL 0x0F //All DACs
78 
79 /* Internal Reference Register */
80 #define AD5628_INT_REF_OFF 0
81 #define AD5628_INT_REF_ON 1
82 
83 /* Power-Down Modes of Operation */
84 #define AD5628_POWER_MODE(x) ((0x03 & (uint16_t) (x)) << 8)
85 
86 #define AD5628_PWRDN_NONE 0 // Normal operation
87 #define AD5628_PWRDN_1K 1 // 1 KOhm to GND (Power-down mode)
88 #define AD5628_PWRDN_100K 2 // 100 KOhm to GND (Power-down mode)
89 #define AD5628_PWRDN_3STATE 3 // Three-state (Power-down mode)
90 
91 /* Clear Code Function */
92 #define AD5628_CODE_0X0000 0
93 #define AD5628_CODE_0X8000 1
94 #define AD5628_CODE_0XFFFF 2
95 #define AD5628_CODE_NOP 3
96 
97 /******************************************************************************/
98 /*************************** Types Declarations *******************************/
99 /******************************************************************************/
100 
101 struct ad5628_dev {
102  /* SPI */
104 };
105 
107  /* SPI */
109 };
110 
111 /******************************************************************************/
112 /************************ Functions Declarations ******************************/
113 /******************************************************************************/
114 
116 int32_t ad5628_init(struct ad5628_dev **device,
118 
120 int32_t ad5628_remove(struct ad5628_dev *dev);
121 
123 void ad5628_power_mode(struct ad5628_dev *dev,
124  uint8_t pwr_mode,
125  uint8_t channel);
126 
128 void ad5628_reset(struct ad5628_dev *dev);
129 
131 void ad5628_set_input_register(struct ad5628_dev *dev,
132  uint32_t register_value);
133 
134 #endif /* __AD5628_H__ */
AD5628_INT_REF_ON
#define AD5628_INT_REF_ON
Definition: ad5628.h:81
ad5628_init
int32_t ad5628_init(struct ad5628_dev **device, struct ad5628_init_param init_param)
Initializes the communication peripheral and the initial Values for AD5628 Board and resets the devic...
Definition: ad5628.c:60
AD5628_CMD
#define AD5628_CMD(x)
Definition: ad5628.h:53
ad5628_init
int32_t ad5628_init(struct ad5628_dev **device, struct ad5628_init_param init_param)
Initializes the communication peripheral and the initial Values for AD5628 Board and resets the devic...
Definition: ad5628.c: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:82
no_os_spi.h
Header file of SPI Interface.
ad5628_reset
void ad5628_reset(struct ad5628_dev *dev)
Resets the device.
Definition: ad5628.c:151
ad5628_dev
Definition: ad5628.h:101
ad5628.h
Header file of AD5628 Driver.
device
Definition: ad9361_util.h:75
ad5628_remove
int32_t ad5628_remove(struct ad5628_dev *dev)
Free the resources allocated by ad5628_init().
Definition: ad5628.c:95
AD5628_CMD_POWERDOWN
#define AD5628_CMD_POWERDOWN
Definition: ad5628.h:62
ad5628_remove
int32_t ad5628_remove(struct ad5628_dev *dev)
Free the resources allocated by ad5628_init().
Definition: ad5628.c:95
ad5628_set_input_register
void ad5628_set_input_register(struct ad5628_dev *dev, uint32_t register_value)
Writes a 32-bit data-word to the Input Register of the device.
Definition: ad5628.c:165
AD5628_POWER_MODE
#define AD5628_POWER_MODE(x)
Definition: ad5628.h:84
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
AD5628_CMD_SET_INT_REF
#define AD5628_CMD_SET_INT_REF
Definition: ad5628.h:66
ad5628_set_input_register
void ad5628_set_input_register(struct ad5628_dev *dev, uint32_t register_value)
Writes a 32-bit data-word to the Input Register of the device.
Definition: ad5628.c:165
AD5628_CMD_LOAD_CLEAR_CODE
#define AD5628_CMD_LOAD_CLEAR_CODE
Definition: ad5628.h:63
AD5628_ADDR_DAC_ALL
#define AD5628_ADDR_DAC_ALL
Definition: ad5628.h:77
ad5628_init_param::spi_init
no_os_spi_init_param spi_init
Definition: ad5628.h:108
ad5628_init_param
Definition: ad5628.h:106
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
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
ad5628_dev::spi_desc
no_os_spi_desc * spi_desc
Definition: ad5628.h:103
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
ad5628_reset
void ad5628_reset(struct ad5628_dev *dev)
Resets the device.
Definition: ad5628.c:151
ad5628_power_mode
void ad5628_power_mode(struct ad5628_dev *dev, uint8_t pwr_mode, uint8_t channel)
Sets the device in a specific power mode.
Definition: ad5628.c:126
AD5628_CODE_0X0000
#define AD5628_CODE_0X0000
Definition: ad5628.h:92
AD5628_CMD_RESET
#define AD5628_CMD_RESET
Definition: ad5628.h:65
ad5628_power_mode
void ad5628_power_mode(struct ad5628_dev *dev, uint8_t pwr_mode, uint8_t channel)
Sets the device in a specific power mode.
Definition: ad5628.c:126
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112