no-OS
admv8818.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef ADMV8818_H_
35 #define ADMV8818_H_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 /******************************************************************************/
41 #include <stdint.h>
42 #include "no_os_spi.h"
43 #include "no_os_util.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 /* ADMV8818 Register Map */
49 #define ADMV8818_REG_SPI_CONFIG_A 0x0
50 #define ADMV8818_REG_SPI_CONFIG_B 0x1
51 #define ADMV8818_REG_CHIPTYPE 0x3
52 #define ADMV8818_REG_PRODUCT_ID_L 0x4
53 #define ADMV8818_REG_PRODUCT_ID_H 0x5
54 #define ADMV8818_REG_FAST_LATCH_POINTER 0x10
55 #define ADMV8818_REG_FAST_LATCH_STOP 0x11
56 #define ADMV8818_REG_FAST_LATCH_START 0x12
57 #define ADMV8818_REG_FAST_LATCH_DIRECTION 0x13
58 #define ADMV8818_REG_FAST_LATCH_STATE 0x14
59 #define ADMV8818_REG_WR0_SW 0x20
60 #define ADMV8818_REG_WR0_FILTER 0x21
61 #define ADMV8818_REG_WR1_SW 0x22
62 #define ADMV8818_REG_WR1_FILTER 0x23
63 #define ADMV8818_REG_WR2_SW 0x24
64 #define ADMV8818_REG_WR2_FILTER 0x25
65 #define ADMV8818_REG_WR3_SW 0x26
66 #define ADMV8818_REG_WR3_FILTER 0x27
67 #define ADMV8818_REG_WR4_SW 0x28
68 #define ADMV8818_REG_WR4_FILTER 0x29
69 #define ADMV8818_REG_LUT0_SW 0x100
70 #define ADMV8818_REG_LUT0_FILTER 0x101
71 #define ADMV8818_REG_LUT127_SW 0x1FE
72 #define ADMV8818_REG_LUT127_FILTER 0x1FF
73 
74 /* ADMV8818_REG_SPI_CONFIG_A Map */
75 #define ADMV8818_SOFTRESET_N_MSK NO_OS_BIT(7)
76 #define ADMV8818_LSB_FIRST_N_MSK NO_OS_BIT(6)
77 #define ADMV8818_ENDIAN_N_MSK NO_OS_BIT(5)
78 #define ADMV8818_SDOACTIVE_N_MSK NO_OS_BIT(4)
79 #define ADMV8818_SDOACTIVE_MSK NO_OS_BIT(3)
80 #define ADMV8818_ENDIAN_MSK NO_OS_BIT(2)
81 #define ADMV8818_LSBFIRST_MSK NO_OS_BIT(1)
82 #define ADMV8818_SOFTRESET_MSK NO_OS_BIT(0)
83 
84 /* ADMV8818_REG_SPI_CONFIG_B Map */
85 #define ADMV8818_SINGLE_INSTRUCTION_MSK NO_OS_BIT(7)
86 #define ADMV8818_CSB_STALL_MSK NO_OS_BIT(6)
87 #define ADMV8818_MASTER_SLAVE_RB_MSK NO_OS_BIT(5)
88 #define ADMV8818_MASTER_SLAVE_TRANSFER_MSK NO_OS_BIT(0)
89 
90 /* ADMV8818_REG_WR0_SW Map */
91 #define ADMV8818_SW_IN_SET_WR0_MSK NO_OS_BIT(7)
92 #define ADMV8818_SW_OUT_SET_WR0_MSK NO_OS_BIT(6)
93 #define ADMV8818_SW_IN_WR0_MSK NO_OS_GENMASK(5, 3)
94 #define ADMV8818_SW_OUT_WR0_MSK NO_OS_GENMASK(2, 0)
95 
96 /* ADMV8818_REG_WR0_FILTER Map */
97 #define ADMV8818_HPF_WR0_MSK NO_OS_GENMASK(7, 4)
98 #define ADMV8818_LPF_WR0_MSK NO_OS_GENMASK(3, 0)
99 
100 /* Specifications */
101 #define ADMV8818_BUFF_SIZE_BYTES 3
102 #define ADMV8818_CHIP_ID NO_OS_BIT(0)
103 #define ADMV8818_SPI_READ_CMD NO_OS_BIT(7)
104 
105 /******************************************************************************/
106 /*************************** Types Declarations *******************************/
107 /******************************************************************************/
108 
116 };
117 
126  unsigned long long rf_in;
127  /* Filter Mode */
129 };
130 
135 struct admv8818_dev {
139  unsigned long long rf_in;
140  /* Filter Mode */
142 };
143 
145 int admv8818_spi_write(struct admv8818_dev *dev, uint16_t reg_addr,
146  uint8_t data);
147 
148 /* ADMV8818 Register Update */
149 int admv8818_spi_update_bits(struct admv8818_dev *dev, uint16_t reg_addr,
150  uint8_t mask, uint8_t data);
151 
153 int admv8818_spi_read(struct admv8818_dev *dev, uint16_t reg_addr,
154  uint8_t *data);
155 
157 int admv8818_hpf_select(struct admv8818_dev *dev, unsigned long long freq);
158 
160 int admv8818_read_hpf_freq(struct admv8818_dev *dev, unsigned long long *freq);
161 
163 int admv8818_lpf_select(struct admv8818_dev *dev, unsigned long long freq);
164 
166 int admv8818_read_lpf_freq(struct admv8818_dev *dev, unsigned long long *freq);
167 
169 int admv8818_rfin_select(struct admv8818_dev *dev);
170 
172 int admv8818_init(struct admv8818_dev **device,
174 
176 int admv8818_remove(struct admv8818_dev *dev);
177 
178 #endif /* ADMV8818_H_ */
admv8818_init_param::rf_in
unsigned long long rf_in
Definition: admv8818.h:126
admv8818_spi_write
int admv8818_spi_write(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t data)
Writes data to ADMV8818 over SPI.
Definition: admv8818.c:72
admv8818_spi_read
int admv8818_spi_read(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t *data)
Reads data from ADMV8818 over SPI.
Definition: admv8818.c:92
admv8818_init
int admv8818_init(struct admv8818_dev **device, struct admv8818_init_param *init_param)
Initializes the admv8818.
Definition: admv8818.c:341
no_os_alloc.h
ADMV8818_BUFF_SIZE_BYTES
#define ADMV8818_BUFF_SIZE_BYTES
Definition: admv8818.h:101
admv8818_lpf_select
int admv8818_lpf_select(struct admv8818_dev *dev, unsigned long long freq)
Set the LPF Frequency.
Definition: admv8818.c:238
admv8818_rfin_select
int admv8818_rfin_select(struct admv8818_dev *dev)
Set the RF Input Band Select.
Definition: admv8818.c:324
NO_OS_GENMASK
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:82
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
ADMV8818_REG_WR0_FILTER
#define ADMV8818_REG_WR0_FILTER
Definition: admv8818.h:60
admv8818_spi_update_bits
int admv8818_spi_update_bits(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
Update ADMV8818 register.
Definition: admv8818.c:120
no_os_spi.h
Header file of SPI Interface.
admv8818_read_lpf_freq
int admv8818_read_lpf_freq(struct admv8818_dev *dev, unsigned long long *freq)
Get the HPF Frequency.
Definition: admv8818.c:289
no_os_units.h
Header file of Units.
admv8818_init
int admv8818_init(struct admv8818_dev **device, struct admv8818_init_param *init_param)
Initializes the admv8818.
Definition: admv8818.c:341
admv8818_init_param
ADMV8818 Initialization Parameters structure.
Definition: admv8818.h:122
admv8818_init_param::mode
enum admv8818_filter_mode mode
Definition: admv8818.h:128
device
Definition: ad9361_util.h:69
ADMV8818_SOFTRESET_N_MSK
#define ADMV8818_SOFTRESET_N_MSK
Definition: admv8818.h:75
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
ad7616_init_param::mode
enum ad7616_mode mode
Definition: ad7616.h:226
ADMV8818_LPF_WR0_MSK
#define ADMV8818_LPF_WR0_MSK
Definition: admv8818.h:98
ADMV8818_REG_SPI_CONFIG_B
#define ADMV8818_REG_SPI_CONFIG_B
Definition: admv8818.h:50
ADMV8818_SW_IN_WR0_MSK
#define ADMV8818_SW_IN_WR0_MSK
Definition: admv8818.h:93
admv8818_dev::mode
enum admv8818_filter_mode mode
Definition: admv8818.h:141
admv8818_remove
int admv8818_remove(struct admv8818_dev *dev)
ADMV8818 Resources Deallocation.
Definition: admv8818.c:415
ADMV8818_SDOACTIVE_N_MSK
#define ADMV8818_SDOACTIVE_N_MSK
Definition: admv8818.h:78
admv8818_read_lpf_freq
int admv8818_read_lpf_freq(struct admv8818_dev *dev, unsigned long long *freq)
Get the HPF Frequency.
Definition: admv8818.c:289
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
admv8818_dev::rf_in
unsigned long long rf_in
Definition: admv8818.h:139
ADMV8818_HPF_WR0_MSK
#define ADMV8818_HPF_WR0_MSK
Definition: admv8818.h:97
no_os_error.h
Error codes definition.
admv8818_hpf_select
int admv8818_hpf_select(struct admv8818_dev *dev, unsigned long long freq)
Set the HPF Frequency.
Definition: admv8818.c:142
admv8818_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: admv8818.h:137
HZ_PER_MHZ
#define HZ_PER_MHZ
Definition: no_os_units.h:56
ADMV8818_MANUAL
@ ADMV8818_MANUAL
Definition: admv8818.h:115
admv8818_hpf_select
int admv8818_hpf_select(struct admv8818_dev *dev, unsigned long long freq)
Set the HPF Frequency.
Definition: admv8818.c:142
admv8818_dev
ADMV8818 Device Descriptor.
Definition: admv8818.h:135
admv8818_filter_mode
admv8818_filter_mode
Filter Modes of the ADMV8818.
Definition: admv8818.h:113
admv8818_read_hpf_freq
int admv8818_read_hpf_freq(struct admv8818_dev *dev, unsigned long long *freq)
Get the HPF Frequency.
Definition: admv8818.c:202
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
ADMV8818_SPI_READ_CMD
#define ADMV8818_SPI_READ_CMD
Definition: admv8818.h:103
admv8818_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: admv8818.h:124
ADMV8818_CHIP_ID
#define ADMV8818_CHIP_ID
Definition: admv8818.h:102
ADMV8818_SINGLE_INSTRUCTION_MSK
#define ADMV8818_SINGLE_INSTRUCTION_MSK
Definition: admv8818.h:85
admv8818_read_hpf_freq
int admv8818_read_hpf_freq(struct admv8818_dev *dev, unsigned long long *freq)
Get the HPF Frequency.
Definition: admv8818.c:202
admv8818_rfin_select
int admv8818_rfin_select(struct admv8818_dev *dev)
Set the RF Input Band Select.
Definition: admv8818.c:324
ADMV8818_REG_WR0_SW
#define ADMV8818_REG_WR0_SW
Definition: admv8818.h:59
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ADMV8818_SDOACTIVE_MSK
#define ADMV8818_SDOACTIVE_MSK
Definition: admv8818.h:79
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
admv8818_spi_update_bits
int admv8818_spi_update_bits(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
Update ADMV8818 register.
Definition: admv8818.c:120
ADMV8818_SW_OUT_WR0_MSK
#define ADMV8818_SW_OUT_WR0_MSK
Definition: admv8818.h:94
ADMV8818_REG_CHIPTYPE
#define ADMV8818_REG_CHIPTYPE
Definition: admv8818.h:51
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ADMV8818_SW_OUT_SET_WR0_MSK
#define ADMV8818_SW_OUT_SET_WR0_MSK
Definition: admv8818.h:92
ADMV8818_AUTO
@ ADMV8818_AUTO
Definition: admv8818.h:114
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
admv8818.h
Header file for admv8818 Driver.
ADMV8818_SW_IN_SET_WR0_MSK
#define ADMV8818_SW_IN_SET_WR0_MSK
Definition: admv8818.h:91
ADMV8818_REG_SPI_CONFIG_A
#define ADMV8818_REG_SPI_CONFIG_A
Definition: admv8818.h:49
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
no_os_util.h
Header file of utility functions.
admv8818_remove
int admv8818_remove(struct admv8818_dev *dev)
ADMV8818 Resources Deallocation.
Definition: admv8818.c:415
admv8818_lpf_select
int admv8818_lpf_select(struct admv8818_dev *dev, unsigned long long freq)
Set the LPF Frequency.
Definition: admv8818.c:238
admv8818_spi_write
int admv8818_spi_write(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t data)
Writes data to ADMV8818 over SPI.
Definition: admv8818.c:72
admv8818_spi_read
int admv8818_spi_read(struct admv8818_dev *dev, uint16_t reg_addr, uint8_t *data)
Reads data from ADMV8818 over SPI.
Definition: admv8818.c:92
ADMV8818_SOFTRESET_MSK
#define ADMV8818_SOFTRESET_MSK
Definition: admv8818.h:82
chip_id
chip_id
Definition: ad9172.h:51
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140