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

Header file for ADGS6414D Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
Include dependency graph for adgs6414d.h:

Classes

struct  adgs6414d_dev
 ADGS6414D Device Descriptor. More...
 
struct  adgs6414d_init_param
 ADGS6414D Initialization Parameters structure. More...
 

Macros

#define ADGS6414D_NUM_SWITCHES   8
 
#define ADGS6414D_REG_SW_DATA   0x01
 
#define ADGS6414D_REG_ERR_CONFIG   0x02
 
#define ADGS6414D_REG_ERR_FLAGS   0x03
 
#define ADGS6414D_REG_BURST_EN   0x05
 
#define ADGS6414D_REG_SOFT_RESETB   0x0B
 
#define ADGS6414D_CMD_WRITE   0x00
 
#define ADGS6414D_CMD_READ   0x80
 
#define ADGS6414D_SOFT_RESET_VAL1   0xA3
 
#define ADGS6414D_SOFT_RESET_VAL2   0x05
 
#define ADGS6414D_ERR_CLR_CMD_MSB   0x6C
 
#define ADGS6414D_ERR_CLR_CMD_LSB   0xA9
 
#define ADGS6414D_ERR_CFG_CRC_EN   0x01
 
#define ADGS6414D_ERR_CFG_SCLK_EN   0x02
 
#define ADGS6414D_ERR_CFG_RW_EN   0x04
 
#define ADGS6414D_ERR_CFG_DEFAULT   0x06
 
#define ADGS6414D_CRC8_POLYNOMIAL   0x07
 
#define ADGS6414D_SW1   0
 
#define ADGS6414D_SW2   1
 
#define ADGS6414D_SW3   2
 
#define ADGS6414D_SW4   3
 
#define ADGS6414D_SW5   4
 
#define ADGS6414D_SW6   5
 
#define ADGS6414D_SW7   6
 
#define ADGS6414D_SW8   7
 

Functions

int adgs6414d_spi_write (struct adgs6414d_dev *dev, uint8_t reg_addr, uint8_t data)
 
int adgs6414d_spi_read (struct adgs6414d_dev *dev, uint8_t reg_addr, uint8_t *data)
 
int adgs6414d_get_err_flags (struct adgs6414d_dev *dev, uint8_t *flags)
 
int adgs6414d_clear_err_flags (struct adgs6414d_dev *dev)
 
int adgs6414d_crc_enable (struct adgs6414d_dev *dev, bool enable)
 
int adgs6414d_soft_reset (struct adgs6414d_dev *dev)
 
int adgs6414d_set_switch (struct adgs6414d_dev *dev, uint8_t channel, bool state)
 
int adgs6414d_get_switch (struct adgs6414d_dev *dev, uint8_t channel, bool *state)
 
int adgs6414d_set_switches (struct adgs6414d_dev *dev, uint8_t mask)
 
int adgs6414d_get_switches (struct adgs6414d_dev *dev, uint8_t *mask)
 
int adgs6414d_init (struct adgs6414d_dev **device, struct adgs6414d_init_param *init_param)
 
int adgs6414d_remove (struct adgs6414d_dev *dev)
 

Detailed Description

Header file for ADGS6414D Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2025(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ ADGS6414D_CMD_READ

#define ADGS6414D_CMD_READ   0x80

◆ ADGS6414D_CMD_WRITE

#define ADGS6414D_CMD_WRITE   0x00

◆ ADGS6414D_CRC8_POLYNOMIAL

#define ADGS6414D_CRC8_POLYNOMIAL   0x07

◆ ADGS6414D_ERR_CFG_CRC_EN

#define ADGS6414D_ERR_CFG_CRC_EN   0x01

◆ ADGS6414D_ERR_CFG_DEFAULT

#define ADGS6414D_ERR_CFG_DEFAULT   0x06

◆ ADGS6414D_ERR_CFG_RW_EN

#define ADGS6414D_ERR_CFG_RW_EN   0x04

◆ ADGS6414D_ERR_CFG_SCLK_EN

#define ADGS6414D_ERR_CFG_SCLK_EN   0x02

◆ ADGS6414D_ERR_CLR_CMD_LSB

#define ADGS6414D_ERR_CLR_CMD_LSB   0xA9

◆ ADGS6414D_ERR_CLR_CMD_MSB

#define ADGS6414D_ERR_CLR_CMD_MSB   0x6C

◆ ADGS6414D_NUM_SWITCHES

#define ADGS6414D_NUM_SWITCHES   8

◆ ADGS6414D_REG_BURST_EN

#define ADGS6414D_REG_BURST_EN   0x05

◆ ADGS6414D_REG_ERR_CONFIG

#define ADGS6414D_REG_ERR_CONFIG   0x02

◆ ADGS6414D_REG_ERR_FLAGS

#define ADGS6414D_REG_ERR_FLAGS   0x03

◆ ADGS6414D_REG_SOFT_RESETB

#define ADGS6414D_REG_SOFT_RESETB   0x0B

◆ ADGS6414D_REG_SW_DATA

#define ADGS6414D_REG_SW_DATA   0x01

◆ ADGS6414D_SOFT_RESET_VAL1

#define ADGS6414D_SOFT_RESET_VAL1   0xA3

◆ ADGS6414D_SOFT_RESET_VAL2

#define ADGS6414D_SOFT_RESET_VAL2   0x05

◆ ADGS6414D_SW1

#define ADGS6414D_SW1   0

◆ ADGS6414D_SW2

#define ADGS6414D_SW2   1

◆ ADGS6414D_SW3

#define ADGS6414D_SW3   2

◆ ADGS6414D_SW4

#define ADGS6414D_SW4   3

◆ ADGS6414D_SW5

#define ADGS6414D_SW5   4

◆ ADGS6414D_SW6

#define ADGS6414D_SW6   5

◆ ADGS6414D_SW7

#define ADGS6414D_SW7   6

◆ ADGS6414D_SW8

#define ADGS6414D_SW8   7

Function Documentation

◆ adgs6414d_clear_err_flags()

int adgs6414d_clear_err_flags ( struct adgs6414d_dev * dev)

Clear the error flags register. Sends special command 0x6CA9 to clear all error flags.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_crc_enable()

int adgs6414d_crc_enable ( struct adgs6414d_dev * dev,
bool enable )

Enable or disable CRC error detection.

Parameters
dev- The device structure.
enable- true to enable, false to disable.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_get_err_flags()

int adgs6414d_get_err_flags ( struct adgs6414d_dev * dev,
uint8_t * flags )

Read the error flags register.

Parameters
dev- The device structure.
flags- Pointer to store error flags.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_get_switch()

int adgs6414d_get_switch ( struct adgs6414d_dev * dev,
uint8_t channel,
bool * state )

Get switch state for a specific channel.

Parameters
dev- The device structure.
channel- Switch channel (0-7).
state- Pointer to store the switch state.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_get_switches()

int adgs6414d_get_switches ( struct adgs6414d_dev * dev,
uint8_t * mask )

Get all switch states as bitmask.

Parameters
dev- The device structure.
mask- Pointer to store the switch states bitmask.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_init()

int adgs6414d_init ( struct adgs6414d_dev ** device,
struct adgs6414d_init_param * init_param )

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_remove()

int adgs6414d_remove ( struct adgs6414d_dev * dev)

Free the resources allocated by adgs6414d_init().

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_set_switch()

int adgs6414d_set_switch ( struct adgs6414d_dev * dev,
uint8_t channel,
bool state )

Set switch state for a specific channel.

Parameters
dev- The device structure.
channel- Switch channel (0-7).
state- Switch state (true = closed, false = open).
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_set_switches()

int adgs6414d_set_switches ( struct adgs6414d_dev * dev,
uint8_t mask )

Set multiple switches at once using bitmask.

Parameters
dev- The device structure.
mask- Bitmask for switch states (bit 0 = SW1, bit 7 = SW8).
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_soft_reset()

int adgs6414d_soft_reset ( struct adgs6414d_dev * dev)

Perform software reset.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_spi_read()

int adgs6414d_spi_read ( struct adgs6414d_dev * dev,
uint8_t reg_addr,
uint8_t * data )

SPI read operation.

Parameters
dev- The device structure.
reg_addr- Register address.
data- Pointer to store read data.
Returns
0 in case of success, negative error code otherwise.

◆ adgs6414d_spi_write()

int adgs6414d_spi_write ( struct adgs6414d_dev * dev,
uint8_t reg_addr,
uint8_t data )

SPI write operation.

Parameters
dev- The device structure.
reg_addr- Register address.
data- Data to write.
Returns
0 in case of success, negative error code otherwise.