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