no-OS
adgs5412.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef ADGS5412_H_
40 #define ADGS5412_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_spi.h"
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 #define ADGS5412_REG_SW_DATA 0x01
52 #define ADGS5412_REG_ERR_CONFIG 0x02
53 #define ADGS5412_REG_ERR_FLAGS 0x03
54 #define ADGS5412_REG_BURST_EN 0x05
55 #define ADGS5412_REG_SOFT_RESETB 0x0B
56 
57 /* ADGS5412_REG_SW_DATA for ADGS5412 */
58 #define ADGS5412_SW4_EN (1 << 3)
59 #define ADGS5412_SW3_EN (1 << 2)
60 #define ADGS5412_SW2_EN (1 << 1)
61 #define ADGS5412_SW1_EN (1 << 0)
62 
63 /* ADGS5412_REG_SW_DATA for ADGS5414 */
64 #define ADGS5414_SW7_EN (1 << 7)
65 #define ADGS5414_SW6_EN (1 << 6)
66 #define ADGS5414_SW5_EN (1 << 5)
67 #define ADGS5414_SW4_EN (1 << 4)
68 #define ADGS5414_SW3_EN (1 << 3)
69 #define ADGS5414_SW2_EN (1 << 2)
70 #define ADGS5414_SW1_EN (1 << 1)
71 #define ADGS5414_SW0_EN (1 << 0)
72 
73 /* ADGS5412_REG_ERR_CONFIG */
74 #define ADGS5412_RW_ERR_EN (1 << 2)
75 #define ADGS5412_SCLK_ERR_EN (1 << 1)
76 #define ADGS5412_CRC_ERR_EN (1 << 0)
77 
78 /* ADGS5412_REG_ERR_FLAGS */
79 #define ADGS5412_RW_ERR_FLAG (1 << 2)
80 #define ADGS5412_SCLK_ERR_FLAG (1 << 1)
81 #define ADGS5412_CRC_ERR_FLAG (1 << 0)
82 #define ADGS5412_CLR_1 0x6C
83 #define ADGS5412_CLR_2 0xA9
84 
85 /* ADGS5412_REG_BURST_EN */
86 #define ADGS5412_BURST_MODE_EN (1 << 0)
87 
88 /* ADGS5412_REG_SOFT_RESETB */
89 #define ADGS5412_SOFT_RESETB(x) (((x) & 0xFF) << 0)
90 #define ADGS5412_RESET_1 0xA3
91 #define ADGS5412_RESET_2 0x05
92 
93 #define ADGS5412_DAISY_CHAIN_1 0x25
94 #define ADGS5412_DAISY_CHAIN_2 0x00
95 
96 #define ADGS5412_ALIGNMENT 0x25
97 
98 #define ADGS5412_CRC8_POLY 0x07
99 
100 /******************************************************************************/
101 /*************************** Types Declarations *******************************/
102 /******************************************************************************/
103 typedef enum {
107 
108 typedef struct {
109  /* SPI */
111  /* Device Settings */
115 } adgs5412_dev;
116 
117 typedef struct {
118  /* SPI */
120  /* Device Settings */
125 
126 /******************************************************************************/
127 /************************ Functions Declarations ******************************/
128 /******************************************************************************/
129 /* Compute CRC8 checksum. */
130 uint8_t adgs5412_compute_crc8(uint8_t *data,
131  uint8_t data_size);
132 /* SPI register read from device. */
134  uint8_t reg_addr,
135  uint8_t *reg_data);
136 /* SPI register write to device. */
138  uint8_t reg_addr,
139  uint8_t reg_data);
140 /* SPI register read from device using a mask. */
142  uint8_t reg_addr,
143  uint8_t mask,
144  uint8_t *data);
145 /* SPI internal register write to device using a mask. */
147  uint8_t reg_addr,
148  uint8_t mask,
149  uint8_t data);
150 /* Do a software reset. */
152 /* Clear the Error Flags Register. */
154 /* Enter Daisy-Chain Mode. */
156 /* Send Daisy-Chain commands. */
158  uint8_t *cmds,
159  uint8_t cmds_size);
160 /* Initialize the device. */
163 /* Free the resources allocated by adgs5412_init(). */
164 int32_t adgs5412_remove(adgs5412_dev *dev);
165 #endif // ADGS5412_H_
ADGS5412_CRC_ERR_EN
#define ADGS5412_CRC_ERR_EN
Definition: adgs5412.h:76
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:82
adgs5412_compute_crc8
uint8_t adgs5412_compute_crc8(uint8_t *data, uint8_t data_size)
Definition: adgs5412.c:57
adgs5412_send_daisy_chain_cmds
int32_t adgs5412_send_daisy_chain_cmds(adgs5412_dev *dev, uint8_t *cmds, uint8_t cmds_size)
Definition: adgs5412.c:300
ADGS5412_CLR_1
#define ADGS5412_CLR_1
Definition: adgs5412.h:82
no_os_spi.h
Header file of SPI Interface.
ADGS5412_CLR_2
#define ADGS5412_CLR_2
Definition: adgs5412.h:83
adgs5412_init_param::spi_init
no_os_spi_init_param spi_init
Definition: adgs5412.h:119
adgs5412_dev::daisy_chain_en
adgs5412_state daisy_chain_en
Definition: adgs5412.h:114
ADGS5412_DISABLE
@ ADGS5412_DISABLE
Definition: adgs5412.h:105
adgs5412_init_param
Definition: adgs5412.h:117
ADGS5412_RESET_1
#define ADGS5412_RESET_1
Definition: adgs5412.h:90
adgs5412_remove
int32_t adgs5412_remove(adgs5412_dev *dev)
Free the resources allocated by adgs5412_init().
Definition: adgs5412.c:377
adgs5412_dev::spi_desc
no_os_spi_desc * spi_desc
Definition: adgs5412.h:110
ADGS5412_ENABLE
@ ADGS5412_ENABLE
Definition: adgs5412.h:104
adgs5412_spi_reg_read
int32_t adgs5412_spi_reg_read(adgs5412_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adgs5412.c:85
device
Definition: ad9361_util.h:75
ADGS5412_ALIGNMENT
#define ADGS5412_ALIGNMENT
Definition: adgs5412.h:96
adgs5412_spi_reg_read_mask
int32_t adgs5412_spi_reg_read_mask(adgs5412_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
Definition: adgs5412.c:167
adgs5412_dev::crc_en
adgs5412_state crc_en
Definition: adgs5412.h:112
adgs5412.h
Header file of ADGS5412 Driver.
adgs5412_enter_daisy_chain
int32_t adgs5412_enter_daisy_chain(adgs5412_dev *dev)
Definition: adgs5412.c:275
adgs5412_spi_reg_write_mask
int32_t adgs5412_spi_reg_write_mask(adgs5412_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: adgs5412.c:195
no_os_error.h
Error codes definition.
ADGS5412_REG_SOFT_RESETB
#define ADGS5412_REG_SOFT_RESETB
Definition: adgs5412.h:55
ADGS5412_REG_ERR_CONFIG
#define ADGS5412_REG_ERR_CONFIG
Definition: adgs5412.h:52
adgs5412_clear_err_flags
int32_t adgs5412_clear_err_flags(adgs5412_dev *dev)
Definition: adgs5412.c:247
ADGS5412_RESET_2
#define ADGS5412_RESET_2
Definition: adgs5412.h:91
ADGS5412_CRC8_POLY
#define ADGS5412_CRC8_POLY
Definition: adgs5412.h:98
adgs5412_spi_reg_write
int32_t adgs5412_spi_reg_write(adgs5412_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adgs5412.c:130
adgs5412_do_soft_reset
int32_t adgs5412_do_soft_reset(adgs5412_dev *dev)
Definition: adgs5412.c:222
adgs5412_init
int32_t adgs5412_init(adgs5412_dev **device, adgs5412_init_param init_param)
Definition: adgs5412.c:324
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
adgs5412_init_param::crc_en
adgs5412_state crc_en
Definition: adgs5412.h:121
adgs5412_spi_reg_read
int32_t adgs5412_spi_reg_read(adgs5412_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adgs5412.c:85
adgs5412_clear_err_flags
int32_t adgs5412_clear_err_flags(adgs5412_dev *dev)
Definition: adgs5412.c:247
adgs5412_compute_crc8
uint8_t adgs5412_compute_crc8(uint8_t *data, uint8_t data_size)
Definition: adgs5412.c:57
ADGS5412_DAISY_CHAIN_1
#define ADGS5412_DAISY_CHAIN_1
Definition: adgs5412.h:93
adgs5412_spi_reg_read_mask
int32_t adgs5412_spi_reg_read_mask(adgs5412_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
Definition: adgs5412.c:167
adgs5412_init_param::burst_mode_en
adgs5412_state burst_mode_en
Definition: adgs5412.h:122
adgs5412_init_param::daisy_chain_en
adgs5412_state daisy_chain_en
Definition: adgs5412.h:123
adgs5412_spi_reg_write
int32_t adgs5412_spi_reg_write(adgs5412_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adgs5412.c:130
adgs5412_do_soft_reset
int32_t adgs5412_do_soft_reset(adgs5412_dev *dev)
Definition: adgs5412.c:222
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
adgs5412_enter_daisy_chain
int32_t adgs5412_enter_daisy_chain(adgs5412_dev *dev)
Definition: adgs5412.c:275
adgs5412_spi_reg_write_mask
int32_t adgs5412_spi_reg_write_mask(adgs5412_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: adgs5412.c:195
adgs5412_init
int32_t adgs5412_init(adgs5412_dev **device, adgs5412_init_param init_param)
Definition: adgs5412.c:324
adgs5412_remove
int32_t adgs5412_remove(adgs5412_dev *dev)
Free the resources allocated by adgs5412_init().
Definition: adgs5412.c:377
adgs5412_state
adgs5412_state
Definition: adgs5412.h:103
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:70
ADGS5412_DAISY_CHAIN_2
#define ADGS5412_DAISY_CHAIN_2
Definition: adgs5412.h:94
ADGS5412_REG_BURST_EN
#define ADGS5412_REG_BURST_EN
Definition: adgs5412.h:54
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:51
adgs5412_send_daisy_chain_cmds
int32_t adgs5412_send_daisy_chain_cmds(adgs5412_dev *dev, uint8_t *cmds, uint8_t cmds_size)
Definition: adgs5412.c:300
ADGS5412_BURST_MODE_EN
#define ADGS5412_BURST_MODE_EN
Definition: adgs5412.h:86
adgs5412_dev::burst_mode_en
adgs5412_state burst_mode_en
Definition: adgs5412.h:113
adgs5412_dev
Definition: adgs5412.h:108
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112