no-OS
Loading...
Searching...
No Matches
ad5293.h File Reference

Header file for the AD5293 Driver. More...

#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
Include dependency graph for ad5293.h:

Classes

struct  ad5293_chip_info
 
struct  ad5293_dev
 
struct  ad5293_init_param
 

Macros

#define CMD_NOP   0
 
#define CMD_W_WIPER   1
 
#define CMD_R_WIPER   2
 
#define CMD_RESET   4
 
#define CMD_W_CTRL   6
 
#define CMD_R_CTRL   7
 
#define CMD_PD   8
 
#define CMD_SDO_Z   0x8001
 
#define CALI_MSK   NO_OS_BIT(2)
 
#define PROTECT_MSK   NO_OS_BIT(1)
 
#define AD5293_W_CTRL_FRAME(pm, cali)
 
#define AD5293_R_CTRL_FRAME   (uint16_t)CMD_R_CTRL<<10
 
#define AD5293_W_WIPER_FRAME(data)
 
#define AD5293_R_WIPER_FRAME   (uint16_t)CMD_R_WIPER<<10
 
#define SHUTDOWN_FRAME(sd)
 
#define RESET_FRAME   (uint16_t)CMD_RESET<<10
 

Enumerations

enum  calibration_mode_t {
  CALI_PERFORMANCE ,
  CALI_NORMAL
}
 
enum  protect_mode_t {
  PROTECT_LOCK ,
  PROTECT_UNLOCK
}
 
enum  shutdown_t {
  NORMAL ,
  SHUTDOWN
}
 
enum  operation_mode_t {
  BUS ,
  DAISY_CHAIN
}
 
enum  sdo_mode_t {
  SDO_DISENABLE ,
  SDO_ENABLE
}
 

Functions

int32_t ad5293_init (struct ad5293_dev **device, struct ad5293_init_param *init_param)
 Initialize the ad5293 device structure.
 
int32_t ad5293_remove (struct ad5293_dev *dev)
 Free any resource used by the driver.
 
int32_t ad5293_hard_reset (struct ad5293_dev *dev)
 Reset ad5293 through Hardware Reset Pin.
 
int32_t ad5293_soft_reset (struct ad5293_dev *dev)
 Reset ad5293 through software reset command.
 
int32_t ad5293_sdo_setfloat (struct ad5293_dev *dev)
 Place SDO pin in high impedence mode.
 
int32_t ad5293_shutdown (struct ad5293_dev *dev, enum shutdown_t sd)
 Place ad5293 in shutdown mode or recovery.
 
int32_t ad5293_update_cali (struct ad5293_dev *dev, enum calibration_mode_t cali, uint8_t num)
 Update ad5293 chip info struct calibration information.
 
int32_t ad5293_update_wiper (struct ad5293_dev *dev, uint16_t val, uint8_t num)
 Update ad5293 chip info struct wiper value information.
 
int32_t ad5293_write_cali (struct ad5293_dev *dev)
 Write ad5293 chip info struct calibration value through SPI interface.
 
int32_t ad5293_write_wiper (struct ad5293_dev *dev)
 Write ad5293 chip info struct wiper value through SPI interface.
 
int32_t ad5293_read_reg_cali (struct ad5293_dev *dev)
 Read ad5293 device register calibration mode through SPI interface.
 
int32_t ad5293_read_reg_wiper (struct ad5293_dev *dev)
 Read ad5293 device register wiper value through SPI interface.
 
int8_t ad5293_get_cali (struct ad5293_dev *dev, uint8_t num)
 Get calibration of a certain chip.
 
int16_t ad5293_get_wiper (struct ad5293_dev *dev, uint8_t num)
 Get wiper of a certain chip.
 

Detailed Description

Header file for the AD5293 Driver.

Author
Ming Zeng

Copyright (c) 2024 Ming Zeng

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ AD5293_R_CTRL_FRAME

#define AD5293_R_CTRL_FRAME   (uint16_t)CMD_R_CTRL<<10

◆ AD5293_R_WIPER_FRAME

#define AD5293_R_WIPER_FRAME   (uint16_t)CMD_R_WIPER<<10

◆ AD5293_W_CTRL_FRAME

#define AD5293_W_CTRL_FRAME ( pm,
cali )
Value:
(uint16_t)((CMD_W_CTRL<<10)|(pm<<1)|(cali<<2))
#define CMD_W_CTRL
Definition ad5293.h:25

◆ AD5293_W_WIPER_FRAME

#define AD5293_W_WIPER_FRAME ( data)
Value:
(uint16_t)((CMD_W_WIPER<<10)|data)
#define CMD_W_WIPER
Definition ad5293.h:22

◆ CALI_MSK

#define CALI_MSK   NO_OS_BIT(2)

◆ CMD_NOP

#define CMD_NOP   0

◆ CMD_PD

#define CMD_PD   8

◆ CMD_R_CTRL

#define CMD_R_CTRL   7

◆ CMD_R_WIPER

#define CMD_R_WIPER   2

◆ CMD_RESET

#define CMD_RESET   4

◆ CMD_SDO_Z

#define CMD_SDO_Z   0x8001

◆ CMD_W_CTRL

#define CMD_W_CTRL   6

◆ CMD_W_WIPER

#define CMD_W_WIPER   1

◆ PROTECT_MSK

#define PROTECT_MSK   NO_OS_BIT(1)

◆ RESET_FRAME

#define RESET_FRAME   (uint16_t)CMD_RESET<<10

◆ SHUTDOWN_FRAME

#define SHUTDOWN_FRAME ( sd)
Value:
(uint16_t)((CMD_PD<<10)|sd)
#define CMD_PD
Definition ad5293.h:27

Enumeration Type Documentation

◆ calibration_mode_t

Enumerator
CALI_PERFORMANCE 
CALI_NORMAL 

◆ operation_mode_t

Enumerator
BUS 
DAISY_CHAIN 

◆ protect_mode_t

Enumerator
PROTECT_LOCK 
PROTECT_UNLOCK 

◆ sdo_mode_t

enum sdo_mode_t
Enumerator
SDO_DISENABLE 
SDO_ENABLE 

◆ shutdown_t

enum shutdown_t
Enumerator
NORMAL 
SHUTDOWN 

Function Documentation

◆ ad5293_get_cali()

int8_t ad5293_get_cali ( struct ad5293_dev * dev,
uint8_t num )

Get calibration of a certain chip.

return chip info struct calibration value to caller.

Parameters
dev- The device structure.
num- The device number.( 0 to chip_num-1)
Returns
ret - return code. Example: -EINVAL - No valid chip selected. 0 - No errors encountered.

◆ ad5293_get_wiper()

int16_t ad5293_get_wiper ( struct ad5293_dev * dev,
uint8_t num )

Get wiper of a certain chip.

return chip info struct wiper value to caller.

Parameters
dev- The device structure.
num- The device number.( 0 to chip_num-1)
Returns
ret - return code. Example: -EINVAL - No valid chip selected. 0 - No errors encountered.

◆ ad5293_hard_reset()

int32_t ad5293_hard_reset ( struct ad5293_dev * dev)

Reset ad5293 through Hardware Reset Pin.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_init()

int32_t ad5293_init ( struct ad5293_dev ** device,
struct ad5293_init_param * init_param )

Initialize the ad5293 device structure.

Performs memory allocation of the device structure.

Parameters
device- Pointer to location of device structure to write.
init_param- Pointer to configuration of the driver.
Returns
ret - return code. Example: -ENOMEM - Memory allocation error. -EINVAL - No GPIO instance. -EINVAL - No valid chip number. -EIO - SPI communication error. -EIO - GPIO initialization error. 0 - No errors encountered.

◆ ad5293_read_reg_cali()

int32_t ad5293_read_reg_cali ( struct ad5293_dev * dev)

Read ad5293 device register calibration mode through SPI interface.

read ad5293 calibration value and update it to chip info struct. Note: multiple chips operation should in daisy-chain mode.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_read_reg_wiper()

int32_t ad5293_read_reg_wiper ( struct ad5293_dev * dev)

Read ad5293 device register wiper value through SPI interface.

read ad5293 wiper value and update it to chip info struct. Note: multiple chips operation should in daisy-chain mode.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_remove()

int32_t ad5293_remove ( struct ad5293_dev * dev)

Free any resource used by the driver.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_sdo_setfloat()

int32_t ad5293_sdo_setfloat ( struct ad5293_dev * dev)

Place SDO pin in high impedence mode.

Minimize power dissipation when pin is used.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_shutdown()

int32_t ad5293_shutdown ( struct ad5293_dev * dev,
enum shutdown_t sd )

Place ad5293 in shutdown mode or recovery.

In shut down mode, terminal A open, Wiper and terminal B connected.

Parameters
dev- The device structure.
sd- shutdown mode selection.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_soft_reset()

int32_t ad5293_soft_reset ( struct ad5293_dev * dev)

Reset ad5293 through software reset command.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_update_cali()

int32_t ad5293_update_cali ( struct ad5293_dev * dev,
enum calibration_mode_t cali,
uint8_t num )

Update ad5293 chip info struct calibration information.

For calibration register write operation.

Parameters
dev- The device structure.
cali- calibration mode selection.
num- chip indication.
Returns
ret - return code. Example: -EINVAL - No valid num input. 0 - No errors encountered.

◆ ad5293_update_wiper()

int32_t ad5293_update_wiper ( struct ad5293_dev * dev,
uint16_t val,
uint8_t num )

Update ad5293 chip info struct wiper value information.

For wiper register write operation.

Parameters
dev- The device structure.
val- wiper value.
num- chip indication.
Returns
ret - return code. Example: -EINVAL - No valid num input. 0 - No errors encountered.

◆ ad5293_write_cali()

int32_t ad5293_write_cali ( struct ad5293_dev * dev)

Write ad5293 chip info struct calibration value through SPI interface.

Note: multiple chips operation should in daisy-chain mode.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.

◆ ad5293_write_wiper()

int32_t ad5293_write_wiper ( struct ad5293_dev * dev)

Write ad5293 chip info struct wiper value through SPI interface.

Note: multiple chips operation should in daisy-chain mode.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EINVAL - No valid pointer input. -ENOSYS - No valid operation. 0 - No errors encountered.