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