no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5293.h
Go to the documentation of this file.
1/***************************************************************************/
28
29#ifndef _AD5293_H_
30#define _AD5293_H_
31
32/****************************** Include Files ********************************/
33#include <stdint.h>
34#include "no_os_gpio.h"
35#include "no_os_spi.h"
36#include "no_os_util.h"
37
38/* SPI Read/Write commands */
39#define CMD_NOP 0
40#define CMD_W_WIPER 1
41#define CMD_R_WIPER 2
42#define CMD_RESET 4
43#define CMD_W_CTRL 6
44#define CMD_R_CTRL 7
45#define CMD_PD 8
46#define CMD_SDO_Z 0x8001
47
48/* Bit mask*/
49#define CALI_MSK NO_OS_BIT(2)
50#define PROTECT_MSK NO_OS_BIT(1)
51
52/* calibration mode */
57
58/* protect mode */
61 PROTECT_UNLOCK // enable update wiper position through digital interface
62};
63
64/* shutdown mode */
69
70/* operation mode */
75
76/* SDO mode */
81
82/* SPI frame */
83#define AD5293_W_CTRL_FRAME(pm,cali) (uint16_t)((CMD_W_CTRL<<10)|(pm<<1)|(cali<<2))
84#define AD5293_R_CTRL_FRAME (uint16_t)CMD_R_CTRL<<10
85#define AD5293_W_WIPER_FRAME(data) (uint16_t)((CMD_W_WIPER<<10)|data)
86#define AD5293_R_WIPER_FRAME (uint16_t)CMD_R_WIPER<<10
87#define SHUTDOWN_FRAME(sd) (uint16_t)((CMD_PD<<10)|sd)
88#define RESET_FRAME (uint16_t)CMD_RESET<<10
89
90/**********************************struct*****************************************/
93 uint16_t Wiper_value; //10bit
94};
95
96struct ad5293_dev {
97 /* SPI */
99 /* GPIO */
101 /* number of chips */
102 uint16_t chip_num;
103 /* pointer of chip struct */
104 struct ad5293_chip_info* chip; //point to chip 0
105};
106
108 /* SPI */
110 /* GPIO */
112 /* number of chips */
113 uint16_t chip_num;
114};
115
116/*******************************functions prototype*******************************/
117/* Initialize the ad5293 device structure. */
118int32_t ad5293_init(struct ad5293_dev **device,
120/* Free any resource used by the driver. */
121int32_t ad5293_remove(struct ad5293_dev* dev);
122/* Reset ad5293 through Hardware Reset Pin. */
123int32_t ad5293_hard_reset(struct ad5293_dev* dev);
124/* Reset ad5293 through software reset command. */
125int32_t ad5293_soft_reset(struct ad5293_dev* dev);
126/* Place SDO pin in high impedence mode. */
127int32_t ad5293_sdo_setfloat(struct ad5293_dev* dev);
128/* Place ad5293 in shutdown mode or recovery. */
129int32_t ad5293_shutdown(struct ad5293_dev* dev, enum shutdown_t sd);
130/* Update ad5293 chip info struct calibration information. */
131int32_t ad5293_update_cali(struct ad5293_dev* dev, enum calibration_mode_t cali,
132 uint8_t num);
133/* Update ad5293 chip info struct wiper value information. */
134int32_t ad5293_update_wiper(struct ad5293_dev* dev, uint16_t val, uint8_t num);
135/* Write ad5293 chip info struct calibration value through SPI interface. */
136int32_t ad5293_write_cali(struct ad5293_dev* dev);
137/* Write ad5293 chip info struct wiper value through SPI interface. */
138int32_t ad5293_write_wiper(struct ad5293_dev* dev);
139/* Read ad5293 device register calibration mode through SPI interface. */
140int32_t ad5293_read_reg_cali(struct ad5293_dev* dev);
141/* Read ad5293 device register wiper value through SPI interface. */
142int32_t ad5293_read_reg_wiper(struct ad5293_dev* dev);
143/* Get calibration of a certain chip. */
144int8_t ad5293_get_cali(struct ad5293_dev* dev, uint8_t num);
145/* Get wiper of a certain chip. */
146int16_t ad5293_get_wiper(struct ad5293_dev* dev, uint8_t num);
147
148#endif // _AD5293_H_
int32_t ad5293_remove(struct ad5293_dev *dev)
Free any resource used by the driver.
Definition ad5293.c:152
int32_t ad5293_read_reg_cali(struct ad5293_dev *dev)
Read ad5293 device register calibration mode through SPI interface.
Definition ad5293.c:447
int8_t ad5293_get_cali(struct ad5293_dev *dev, uint8_t num)
Get calibration of a certain chip.
Definition ad5293.c:526
operation_mode_t
Definition ad5293.h:71
@ BUS
Definition ad5293.h:72
@ DAISY_CHAIN
Definition ad5293.h:73
int32_t ad5293_init(struct ad5293_dev **device, struct ad5293_init_param *init_param)
Initialize the ad5293 device structure.
Definition ad5293.c:71
int32_t ad5293_write_cali(struct ad5293_dev *dev)
Write ad5293 chip info struct calibration value through SPI interface.
Definition ad5293.c:379
int16_t ad5293_get_wiper(struct ad5293_dev *dev, uint8_t num)
Get wiper of a certain chip.
Definition ad5293.c:546
int32_t ad5293_update_cali(struct ad5293_dev *dev, enum calibration_mode_t cali, uint8_t num)
Update ad5293 chip info struct calibration information.
Definition ad5293.c:313
int32_t ad5293_soft_reset(struct ad5293_dev *dev)
Reset ad5293 through software reset command.
Definition ad5293.c:216
calibration_mode_t
Definition ad5293.h:53
@ CALI_PERFORMANCE
Definition ad5293.h:54
@ CALI_NORMAL
Definition ad5293.h:55
shutdown_t
Definition ad5293.h:65
@ SHUTDOWN
Definition ad5293.h:67
protect_mode_t
Definition ad5293.h:59
@ PROTECT_UNLOCK
Definition ad5293.h:61
@ PROTECT_LOCK
Definition ad5293.h:60
int32_t ad5293_sdo_setfloat(struct ad5293_dev *dev)
Place SDO pin in high impedence mode.
Definition ad5293.c:251
int32_t ad5293_write_wiper(struct ad5293_dev *dev)
Write ad5293 chip info struct wiper value through SPI interface.
Definition ad5293.c:408
int32_t ad5293_update_wiper(struct ad5293_dev *dev, uint16_t val, uint8_t num)
Update ad5293 chip info struct wiper value information.
Definition ad5293.c:338
int32_t ad5293_hard_reset(struct ad5293_dev *dev)
Reset ad5293 through Hardware Reset Pin.
Definition ad5293.c:182
int32_t ad5293_shutdown(struct ad5293_dev *dev, enum shutdown_t sd)
Place ad5293 in shutdown mode or recovery.
Definition ad5293.c:285
sdo_mode_t
Definition ad5293.h:77
@ SDO_ENABLE
Definition ad5293.h:79
@ SDO_DISENABLE
Definition ad5293.h:78
int32_t ad5293_read_reg_wiper(struct ad5293_dev *dev)
Read ad5293 device register wiper value through SPI interface.
Definition ad5293.c:487
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
@ NORMAL
Definition ade9153a.h:443
Header file of GPIO Interface.
Header file of SPI Interface.
Header file of utility functions.
Definition ad5293.h:91
enum calibration_mode_t cali
Definition ad5293.h:92
uint16_t Wiper_value
Definition ad5293.h:93
Definition ad5293.h:96
uint16_t chip_num
Definition ad5293.h:102
struct no_os_spi_desc * spi_desc
Definition ad5293.h:98
struct no_os_gpio_desc * gpio_reset
Definition ad5293.h:100
struct ad5293_chip_info * chip
Definition ad5293.h:104
Definition ad5293.h:107
struct no_os_gpio_init_param * gpio_reset
Definition ad5293.h:111
uint16_t chip_num
Definition ad5293.h:113
struct no_os_spi_init_param spi_init
Definition ad5293.h:109
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128