ADF7030-1 Device Drivers API Reference Manual  Alpha 0.0.1
Device Drivers for ADF7030-1 Transceiver
adf7030-1__mem.h
1 #ifndef _ADF7030_1__MEM_H_
2 #define _ADF7030_1__MEM_H_
3 
4 #include <drivers/spi/adi_spi.h>
5 #include <devices/rf/adf703x/adi_adf7030-1_reg.h>
6 
15 extern uint32_t ADF7030_1_SPI_PNTR[8];
16 
17 
18 //Forward Typedef declarartion
21 
22 typedef struct{
23  uint8_t OffsetLen;
24  uint8_t * pOffset;
26 
27 typedef struct{
28  uint16_t Size;
29  uint16_t Offset;
31 
32 typedef struct{
33  uint16_t Size;
34  const uint8_t unused;
35  const uint8_t WordXfer;
36  const uint32_t Addr;
37  const uint8_t *pData;
39 
43 typedef struct {
44  char config_name[16];
45  uint16_t build_number;
46  char family_str[4];
47  uint16_t adiid;
48  uint16_t chipid;
49  uint8_t full_layer_num;
50  uint8_t eco_num;
51  uint16_t svn_version;
52  char unused[66];
54 
59  char Name[16];
60  uint16_t Size;
61  uint8_t ByteMode;
62  uint8_t XferMode;
63  uint32_t PhyAddr;
64  void * pBuff;
65  void * pBuffRef;
69 };
70 
75  char Name[16];
76  uint16_t Size;
77  uint16_t nbBlock;
81 };
82 
83 
84 #define PHY_MEM_READ true
85 #define PHY_MEM_WRITE false
86 
87 
88 /* Write Configuration data to Radio PHY */
89 uint32_t adf7030_1__WriteConfig(
90  ADI_SPI_HANDLE hSPIDevice,
91  MEM_CFG_DESCRIPTOR_Type * pCONFIG
92 );
93 
94 /* Read Configuration data from Radio PHY */
95 uint32_t adf7030_1__ReadConfig(
96  ADI_SPI_HANDLE hSPIDevice,
97  MEM_CFG_DESCRIPTOR_Type * pCONFIG
98 );
99 
100 /* Verify Configuration integrity */
101 uint32_t adf7030_1__VerifyConfig(
102  ADI_SPI_HANDLE hSPIDevice,
103  MEM_CFG_DESCRIPTOR_Type * pCONFIG
104 );
105 
106 /* Transfers Configuration between Host and the radio PHY */
107 uint32_t adf7030_1__XferConfig(
108  ADI_SPI_HANDLE hSPIDevice,
109  MEM_CFG_DESCRIPTOR_Type * pCONFIG,
110  bool READ_nWRITE,
111  bool CHECK_ONLY
112 );
113 
114 /* Transfers generic memory blocks between Host shadow and the radio PHY */
115 uint32_t adf7030_1__SPI_Xfer_Mem(
116  ADI_SPI_HANDLE hSPIDevice,
117  MEM_DESCRIPTOR_Type * pMEM,
118  bool READ_nWRITE
119 );
120 
121 /* Read 32bits memory location via the SPI */
123  ADI_SPI_HANDLE hSPIDevice,
124  uint32_t Addr,
125  uint32_t Value
126 );
127 
128 /* Read 32bits memory location via the SPI */
129 uint32_t adf7030_1__SPI_GetMem32(
130  ADI_SPI_HANDLE hSPIDevice,
131  uint32_t Addr
132 );
133 
134 /* Read 24bits memory location via the SPI */
136  ADI_SPI_HANDLE hSPIDevice,
137  uint32_t Addr,
138  uint32_t Value
139 );
140 
141 /* Read 24bits memory location via the SPI */
142 uint32_t adf7030_1__SPI_GetMem24(
143  ADI_SPI_HANDLE hSPIDevice,
144  uint32_t Addr
145 );
146 
147 /* Read 16bits memory location via the SPI */
149  ADI_SPI_HANDLE hSPIDevice,
150  uint32_t Addr,
151  uint16_t Value
152 );
153 
154 /* Read 16bits memory location via the SPI */
155 uint16_t adf7030_1__SPI_GetMem16(
156  ADI_SPI_HANDLE hSPIDevice,
157  uint32_t Addr
158 );
159 
160 /* Read 8bits memory location via the SPI */
162  ADI_SPI_HANDLE hSPIDevice,
163  uint32_t Addr,
164  uint8_t Value
165 );
166 
167 /* Read 8bits memory location via the SPI */
168 uint8_t adf7030_1__SPI_GetMem8(
169  ADI_SPI_HANDLE hSPIDevice,
170  uint32_t Addr
171 );
172 
173 /* Generic small memory write (up to 4 bytes) via the SPI */
175  ADI_SPI_HANDLE hSPIDevice,
176  uint32_t Addr,
177  uint32_t Value,
178  uint32_t nbBytes
179 );
180 
181 /* Generic small memory read (up to 4 bytes) via the SPI */
182 uint32_t adf7030_1__SPI_GetBytes(
183  ADI_SPI_HANDLE hSPIDevice,
184  uint32_t Addr,
185  uint32_t nbBytes
186 );
187 
188 /* Generic function to Set Field value via SPI */
190  ADI_SPI_HANDLE hSPIDevice,
191  uint32_t Addr,
192  uint32_t Pos,
193  uint32_t Size,
194  uint32_t Val
195 );
196 
197 /* Generic Function to Get Field value via SPI */
198 uint32_t adf7030_1__SPI_GetField(
199  ADI_SPI_HANDLE hSPIDevice,
200  uint32_t Addr,
201  uint32_t Pos,
202  uint32_t Size
203 );
204 
205 /* Generic Macro for setting a bitfield to a value (uses adf7030_hw_macro.h & adf7030_fw_macro.h definitions) */
206 #define adf7030_1__WRITE_FIELD(fName, fValue) adf7030_1__SPI_SetField( hSPIDevice, \
207  fName##_Addr, \
208  fName##_Pos, \
209  fName##_Size, \
210  fValue )
211 
212 /* Alternative version of "adf7030_1__SET_FIELD()" macro calling directly adf7030_1__SPI_SetBytes() function */
213 #define adf7030_1__WRITE_FIELD2(fName, fValue) \
214 { \
215  /* Compute Bitfields parameters */ \
216  uint32_t fStartByte = (fName##_Pos >> 3); \
217  uint32_t fPos_fromStartByte = fName##_Pos - (fStartByte << 3); \
218  uint32_t fLenBytes = ((fName##Size - 1) >> 3) + 1; \
219  \
220  /* Read Bitfield vis SPI */ \
221  uint32_t fVal = adf7030_1__SPI_GetBytes( hSPIDevice, Addr + fStartByte, fLenBytes); \
222  \
223  /* Compute the Mask */ \
224  uint32_t fMsk = ((1 << fName##_Size) - 1) << fPos_fromStartByte; \
225  \
226  /* Bound Val to the Mask */ \
227  fValue <<= fPos_fromStartByte; \
228  fValue &= fMsk; \
229  \
230  /* And SPI returned value with inverted Mask */ \
231  fVal &= (~fMsk); \
232  \
233  /* Or SPI returned value with fValue */ \
234  fVal |= fValue; \
235  \
236  /* Write back Bitfield vis SPI */ \
237  adf7030_1__SPI_SetBytes( hSPIDevice, Addr + fStartByte, fValue, fLenBytes); \
238 };
239 
240 
241 /* Generic Macro for reading a bitfield value (uses adf7030_hw_macro.h & adf7030_fw_macro.h definitions) */
242 #define adf7030_1__READ_FIELD(fName) adf7030_1__SPI_GetField( hSPIDevice, \
243  fName##_Addr, \
244  fName##_Pos, \
245  fName##_Size )
246 
247 /* Alternative version of "adf7030_1__GET_FIELD()" macro calling directly adf7030_1__SPI_SetBytes() & adf7030_1__SPI_SetBytes() functions */
248 #define adf7030_1__READ_FIELD2(fName) \
249 ({ \
250  uint32_t fVal; \
251  \
252  /* Compute Bitfields parameters */ \
253  uint32_t fStartByte = (fName##_Pos >> 3); \
254  uint32_t fPos_fromStartByte = fName##_Pos - (fStartByte << 3); \
255  uint32_t fLenBytes = ((fName##Size - 1) >> 3) + 1; \
256  \
257  /* Read Bitfield vis SPI */ \
258  fVal = adf7030_1__SPI_GetBytes( hSPIDevice, Addr + fStartByte, fLenBytes); \
259  \
260  /* Compute the Mask */ \
261  uint32_t fMsk = ((1 << fName##_Size) - 1) << fPos_fromStartByte; \
262  \
263  /* And SPI returned value with Mask */ \
264  fVal &= fMsk; \
265  \
266  /* Shift right by fPos_fromStartByte */ \
267  fVal >>= fPos_fromStartByte; \
268  \
269  fVal; \
270 });
271 
272 
273 /* Generic Macro for setting a register address to a value (uses adf7030_hw_macro.h & adf7030_fw_macro.h definitions) */
274 #define adf7030_1__WRITE_REG(rName, rValue) adf7030_1__SPI_SetBytes( hSPIDevice, \
275  rName##_Addr, \
276  rValue, \
277  4 )
278 
279 /* Generic Macro for setting a register address to a value (uses adf7030_hw_macro.h & adf7030_fw_macro.h definitions) */
280 #define adf7030_1__READ_REG(rName) adf7030_1__SPI_GetBytes( hSPIDevice, \
281  rName##_Addr, \
282  4 )
283 
284  /* End of group adf7030-1__mem PHY Memory Interface */ /* End of group adf7030-1 adf7030-1 Driver */
287 
288 #endif /* _ADF7030_1__SPI_H_ */
void adf7030_1__SPI_SetField(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t Pos, uint32_t Size, uint32_t Val)
Generic setting of a Radio PHY bitfield to a value via the SPI.
uint16_t Size
String with name of memory bloc.
uint32_t adf7030_1__XferConfig(ADI_SPI_HANDLE hSPIDevice, MEM_CFG_DESCRIPTOR_Type *pCONFIG, bool READ_nWRITE, bool CHECK_ONLY)
Generic Configuration transfers function between Host and the Radio PHY.
void adf7030_1__SPI_SetMem8(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint8_t Value)
Write a single 8bits memory location via the SPI.
void adf7030_1__SPI_SetMem24(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t Value)
Write a single 24bits memory location via the SPI.
uint32_t adf7030_1__SPI_GetBytes(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t nbBytes)
Read "nbBytes" memory location via the SPI.
uint16_t nbBlock
Total size of the configuration.
uint32_t adf7030_1__SPI_GetField(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t Pos, uint32_t Size)
Generic readback of a bitfield value from the Radio PHY via the SPI.
uint16_t Size
String with name of configuration sequence.
uint8_t adf7030_1__SPI_GetMem8(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr)
Read a 8bits memory location via the SPI.
const uint8_t unused
Byte size of the Block to transfer.
uint8_t ByteMode
size of the memory bloc
MEM_DESCRIPTOR_Type * pNextBloc
descriptor for random access
void adf7030_1__SPI_SetBytes(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t Value, uint32_t nbBytes)
Writes "nbBytes" memory location via the SPI.
DATA_BLOCK_DESCRIPTOR_Type BLOCKS[]
Pointer to the next configuration sequence if desired, else NULL.
uint32_t adf7030_1__SPI_Xfer_Mem(ADI_SPI_HANDLE hSPIDevice, MEM_DESCRIPTOR_Type *pMEM, bool READ_nWRITE)
Generic memory transfers function between Host shadow and the Radio PHY.
void * pBuffRef
pointer to the start of the shadow memory bloc in the host memory space
uint8_t * pOffset
Size of the Offset list.
config_info_t * pInfo
Number of data blocks.
uint16_t adf7030_1__SPI_GetMem16(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr)
Read a 16bits memory location via the SPI.
void * pBuff
address of the memory bloc in the PHY memory space
uint32_t adf7030_1__SPI_GetMem32(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr)
Read a single 32bits memory location via the SPI.
uint32_t PhyAddr
0->Block, 1->Random SPI transfer mode
const uint8_t * pData
Address of the memory bloc in the PHY memory space.
const uint32_t Addr
If !NULL, force 32bits SPI transfer.
uint32_t adf7030_1__SPI_GetMem24(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr)
Read a 24bits memory location via the SPI.
uint32_t adf7030_1__ReadConfig(ADI_SPI_HANDLE hSPIDevice, MEM_CFG_DESCRIPTOR_Type *pCONFIG)
Function call to read Configuration from Radio PHY.
void adf7030_1__SPI_SetMem16(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint16_t Value)
Write a single 16bits memory location via the SPI.
uint16_t Offset
Byte size of the Block to transfer.
MEM_CFG_DESCRIPTOR_Type * pNext
Pointer to the configuration info structure in the host memory.
RANDOM_XFER_DESCRIPTOR_Type RandXfer
descriptor for block access
uint8_t XferMode
0->8bits, 1->32bits SPI transfert mode, 2->8bits Only, 3->32bits only
void adf7030_1__SPI_SetMem32(ADI_SPI_HANDLE hSPIDevice, uint32_t Addr, uint32_t Value)
Write a single 32bits memory location via the SPI.
uint32_t adf7030_1__WriteConfig(ADI_SPI_HANDLE hSPIDevice, MEM_CFG_DESCRIPTOR_Type *pCONFIG)
Function call to write Configuration to Radio PHY.
BLOCK_XFER_DESCRIPTOR_Type BlockXfer
pointer to the initial value of the shadow memory bloc in the host memory space
uint32_t adf7030_1__VerifyConfig(ADI_SPI_HANDLE hSPIDevice, MEM_CFG_DESCRIPTOR_Type *pCONFIG)
Function call to verify the integrity of the patch.