no-OS
Classes | Macros | Enumerations | Functions
ad5293.h File Reference
#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
Include dependency graph for ad5293.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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)   (uint16_t)((CMD_W_CTRL<<10)|(pm<<1)|(cali<<2))
 
#define AD5293_R_CTRL_FRAME   (uint16_t)CMD_R_CTRL<<10
 
#define AD5293_W_WIPER_FRAME(data)   (uint16_t)((CMD_W_WIPER<<10)|data)
 
#define AD5293_R_WIPER_FRAME   (uint16_t)CMD_R_WIPER<<10
 
#define SHUTDOWN_FRAME(sd)   (uint16_t)((CMD_PD<<10)|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. More...
 
int32_t ad5293_remove (struct ad5293_dev *dev)
 Free any resource used by the driver. More...
 
int32_t ad5293_hard_reset (struct ad5293_dev *dev)
 Reset ad5293 through Hardware Reset Pin. More...
 
int32_t ad5293_soft_reset (struct ad5293_dev *dev)
 Reset ad5293 through software reset command. More...
 
int32_t ad5293_sdo_setfloat (struct ad5293_dev *dev)
 Place SDO pin in high impedence mode. More...
 
int32_t ad5293_shutdown (struct ad5293_dev *dev, enum shutdown_t sd)
 Place ad5293 in shutdown mode or recovery. More...
 
int32_t ad5293_update_cali (struct ad5293_dev *dev, enum calibration_mode_t cali, uint8_t num)
 Update ad5293 chip info struct calibration information. More...
 
int32_t ad5293_update_wiper (struct ad5293_dev *dev, uint16_t val, uint8_t num)
 Update ad5293 chip info struct wiper value information. More...
 
int32_t ad5293_write_cali (struct ad5293_dev *dev)
 Write ad5293 chip info struct calibration value through SPI interface. More...
 
int32_t ad5293_write_wiper (struct ad5293_dev *dev)
 Write ad5293 chip info struct wiper value through SPI interface. More...
 
int32_t ad5293_read_reg_cali (struct ad5293_dev *dev)
 Read ad5293 device register calibration mode through SPI interface. More...
 
int32_t ad5293_read_reg_wiper (struct ad5293_dev *dev)
 Read ad5293 device register wiper value through SPI interface. More...
 
int8_t ad5293_get_cali (struct ad5293_dev *dev, uint8_t num)
 Get calibration of a certain chip. More...
 
int16_t ad5293_get_wiper (struct ad5293_dev *dev, uint8_t num)
 Get wiper of a certain chip. More...
 

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 
)    (uint16_t)((CMD_W_CTRL<<10)|(pm<<1)|(cali<<2))

◆ AD5293_W_WIPER_FRAME

#define AD5293_W_WIPER_FRAME (   data)    (uint16_t)((CMD_W_WIPER<<10)|data)

◆ CALI_MSK

#define CALI_MSK   NO_OS_BIT(2)

◆ CMD_NOP

#define CMD_NOP   0
 @file   ad5293.h
 @brief  Header file for the AD5293 Driver
 @author Ming Zeng

The MIT License (MIT)

Copyright (c) 2024 Ming Zeng

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

◆ 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)    (uint16_t)((CMD_PD<<10)|sd)

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.
Here is the caller graph for this function:

◆ 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.