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