OpenCores
URL https://opencores.org/ocsvn/xenie/xenie/trunk

Subversion Repositories xenie

[/] [xenie/] [trunk/] [examples/] [Eth_example/] [mb_fw/] [drivers/] [iic_v3_4/] [src/] [xiic_l.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 DFC
/******************************************************************************
2
*
3
* Copyright (C) 2002 - 2016 Xilinx, Inc.  All rights reserved.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a copy
6
* of this software and associated documentation files (the "Software"), to deal
7
* in the Software without restriction, including without limitation the rights
8
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
* copies of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
14
*
15
* Use of the Software is limited solely to applications:
16
* (a) running on a Xilinx device, or
17
* (b) that interact with a Xilinx device through a bus or interconnect.
18
*
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
* SOFTWARE.
26
*
27
* Except as contained in this notice, the name of the Xilinx shall not be used
28
* in advertising or otherwise to promote the sale, use or other dealings in
29
* this Software without prior written authorization from Xilinx.
30
*
31
******************************************************************************/
32
/****************************************************************************/
33
/**
34
*
35
* @file xiic_l.h
36
* @addtogroup iic_v3_1
37
* @{
38
*
39
* This header file contains identifiers and driver functions (or
40
* macros) that can be used to access the device in normal and dynamic
41
* controller mode.  High-level driver functions are defined in xiic.h.
42
*
43
* <pre>
44
* MODIFICATION HISTORY:
45
*
46
* Ver   Who  Date     Changes
47
* ----- ---- -------- -----------------------------------------------
48
* 1.00b jhl  05/07/02 First release
49
* 1.01c ecm  12/05/02 new rev
50
* 1.01d jhl  10/08/03 Added general purpose output feature
51
* 1.02a mta  03/09/06 Implemented Repeated Start in the Low Level Driver.
52
* 1.03a mta  04/04/06 Implemented Dynamic IIC core routines.
53
* 1.03a rpm  09/08/06 Added include of xstatus.h for completeness
54
* 1.13a wgr  03/22/07 Converted to new coding style.
55
* 1.16a ktn  07/18/09 Updated the notes in XIIC_RESET macro to clearly indicate
56
*                     that only the Interrupt Registers are reset.
57
* 1.16a ktn  10/16/09 Updated the notes in the XIIC_RESET macro to mention
58
*                     that the complete IIC core is Reset on giving a software
59
*                     reset to the IIC core. Some previous versions of the
60
*                     core only reset the Interrupt Logic/Registers, please
61
*                     refer to the HW specification for futher details.
62
* 2.00a sdm  10/22/09 Converted all register accesses to 32 bit access,
63
*                     the register offsets are defined to be on 32 bit boundry.
64
*                     Removed the macro XIIC_RESET, XIic_Reset API should be
65
*                     used in its place.
66
*                     Some of the macros have been renamed to be consistent -
67
*                     XIIC_GINTR_DISABLE is renamed as XIic_IntrGlobalDisable,
68
*                     XIIC_GINTR_ENABLE is renamed as XIic_IntrGlobalEnable,
69
*                     XIIC_IS_GINTR_ENABLED is renamed as
70
*                     XIic_IsIntrGlobalEnabled,
71
*                     XIIC_WRITE_IISR is renamed as XIic_WriteIisr,
72
*                     XIIC_READ_IISR is renamed as XIic_ReadIisr,
73
*                     XIIC_WRITE_IIER is renamed as XIic_WriteIier
74
*                     The _m prefix in the name of the macros has been removed -
75
*                     XIic_mClearIisr is now XIic_ClearIisr,
76
*                     XIic_mSend7BitAddress is now XIic_Send7BitAddress,
77
*                     XIic_mDynSend7BitAddress is now XIic_DynSend7BitAddress,
78
*                     XIic_mDynSendStartStopAddress is now
79
*                     XIic_DynSendStartStopAddress,
80
*                     XIic_mDynSendStop is now XIic_DynSendStop.
81
* 3.2   sk   11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425.
82
*                     Changed the prototypes of XIic_Recv, XIic_Send,
83
*                     XIic_DynRecv, XIic_DynSend and XIic_DynInit APIs.
84
* 3.3   als  06/27/16 Added Low-level XIic_CheckIsBusBusy API.
85
* 3.3   als  06/27/16 Added low-level XIic_WaitBusFree API.
86
* </pre>
87
*
88
*****************************************************************************/
89
#ifndef XIIC_L_H                /* prevent circular inclusions */
90
#define XIIC_L_H                /* by using protection macros */
91
 
92
#ifdef __cplusplus
93
extern "C" {
94
#endif
95
 
96
/***************************** Include Files ********************************/
97
 
98
#include "xil_types.h"
99
#include "xil_assert.h"
100
#include "xstatus.h"
101
#include "xil_io.h"
102
 
103
/************************** Constant Definitions ****************************/
104
 
105
/** @name Register Map
106
 *
107
 * Register offsets for the XIic device.
108
 * @{
109
 */
110
#define XIIC_DGIER_OFFSET       0x1C  /**< Global Interrupt Enable Register */
111
#define XIIC_IISR_OFFSET        0x20  /**< Interrupt Status Register */
112
#define XIIC_IIER_OFFSET        0x28  /**< Interrupt Enable Register */
113
#define XIIC_RESETR_OFFSET      0x40  /**< Reset Register */
114
#define XIIC_CR_REG_OFFSET      0x100 /**< Control Register */
115
#define XIIC_SR_REG_OFFSET      0x104 /**< Status Register */
116
#define XIIC_DTR_REG_OFFSET     0x108 /**< Data Tx Register */
117
#define XIIC_DRR_REG_OFFSET     0x10C /**< Data Rx Register */
118
#define XIIC_ADR_REG_OFFSET     0x110 /**< Address Register */
119
#define XIIC_TFO_REG_OFFSET     0x114 /**< Tx FIFO Occupancy */
120
#define XIIC_RFO_REG_OFFSET     0x118 /**< Rx FIFO Occupancy */
121
#define XIIC_TBA_REG_OFFSET     0x11C /**< 10 Bit Address reg */
122
#define XIIC_RFD_REG_OFFSET     0x120 /**< Rx FIFO Depth reg */
123
#define XIIC_GPO_REG_OFFSET     0x124 /**< Output Register */
124
/* @} */
125
 
126
 
127
/**
128
 * @name Device Global Interrupt Enable Register masks (CR) mask(s)
129
 * @{
130
 */
131
#define XIIC_GINTR_ENABLE_MASK  0x80000000 /**< Global Interrupt Enable Mask */
132
/* @} */
133
 
134
/** @name IIC Device Interrupt Status/Enable (INTR) Register Masks
135
 *
136
 * <b> Interrupt Status Register (IISR) </b>
137
 *
138
 * This register holds the interrupt status flags for the Spi device.
139
 *
140
 * <b> Interrupt Enable Register (IIER) </b>
141
 *
142
 * This register is used to enable interrupt sources for the IIC device.
143
 * Writing a '1' to a bit in this register enables the corresponding Interrupt.
144
 * Writing a '0' to a bit in this register disables the corresponding Interrupt.
145
 *
146
 * IISR/IIER registers have the same bit definitions and are only defined once.
147
 * @{
148
 */
149
#define XIIC_INTR_ARB_LOST_MASK 0x00000001 /**< 1 = Arbitration lost */
150
#define XIIC_INTR_TX_ERROR_MASK 0x00000002 /**< 1 = Tx error/msg complete */
151
#define XIIC_INTR_TX_EMPTY_MASK 0x00000004 /**< 1 = Tx FIFO/reg empty */
152
#define XIIC_INTR_RX_FULL_MASK  0x00000008 /**< 1 = Rx FIFO/reg=OCY level */
153
#define XIIC_INTR_BNB_MASK      0x00000010 /**< 1 = Bus not busy */
154
#define XIIC_INTR_AAS_MASK      0x00000020 /**< 1 = When addr as slave */
155
#define XIIC_INTR_NAAS_MASK     0x00000040 /**< 1 = Not addr as slave */
156
#define XIIC_INTR_TX_HALF_MASK  0x00000080 /**< 1 = Tx FIFO half empty */
157
 
158
/**
159
 * All Tx interrupts commonly used.
160
 */
161
#define XIIC_TX_INTERRUPTS      (XIIC_INTR_TX_ERROR_MASK | \
162
                                 XIIC_INTR_TX_EMPTY_MASK |  \
163
                                 XIIC_INTR_TX_HALF_MASK)
164
 
165
/**
166
 * All interrupts commonly used
167
 */
168
#define XIIC_TX_RX_INTERRUPTS   (XIIC_INTR_RX_FULL_MASK | XIIC_TX_INTERRUPTS)
169
 
170
/* @} */
171
 
172
/**
173
 * @name Reset Register mask
174
 * @{
175
 */
176
#define XIIC_RESET_MASK         0x0000000A /**< RESET Mask  */
177
/* @} */
178
 
179
 
180
/**
181
 * @name Control Register masks (CR) mask(s)
182
 * @{
183
 */
184
#define XIIC_CR_ENABLE_DEVICE_MASK      0x00000001 /**< Device enable = 1 */
185
#define XIIC_CR_TX_FIFO_RESET_MASK      0x00000002 /**< Transmit FIFO reset=1 */
186
#define XIIC_CR_MSMS_MASK               0x00000004 /**< Master starts Txing=1 */
187
#define XIIC_CR_DIR_IS_TX_MASK          0x00000008 /**< Dir of Tx. Txing=1 */
188
#define XIIC_CR_NO_ACK_MASK             0x00000010 /**< Tx Ack. NO ack = 1 */
189
#define XIIC_CR_REPEATED_START_MASK     0x00000020 /**< Repeated start = 1 */
190
#define XIIC_CR_GENERAL_CALL_MASK       0x00000040 /**< Gen Call enabled = 1 */
191
/* @} */
192
 
193
/**
194
 * @name Status Register masks (SR) mask(s)
195
 * @{
196
 */
197
#define XIIC_SR_GEN_CALL_MASK           0x00000001 /**< 1 = A Master issued
198
                                                    * a GC */
199
#define XIIC_SR_ADDR_AS_SLAVE_MASK      0x00000002 /**< 1 = When addressed as
200
                                                    * slave */
201
#define XIIC_SR_BUS_BUSY_MASK           0x00000004 /**< 1 = Bus is busy */
202
#define XIIC_SR_MSTR_RDING_SLAVE_MASK   0x00000008 /**< 1 = Dir: Master <--
203
                                                    * slave */
204
#define XIIC_SR_TX_FIFO_FULL_MASK       0x00000010 /**< 1 = Tx FIFO full */
205
#define XIIC_SR_RX_FIFO_FULL_MASK       0x00000020 /**< 1 = Rx FIFO full */
206
#define XIIC_SR_RX_FIFO_EMPTY_MASK      0x00000040 /**< 1 = Rx FIFO empty */
207
#define XIIC_SR_TX_FIFO_EMPTY_MASK      0x00000080 /**< 1 = Tx FIFO empty */
208
/* @} */
209
 
210
/**
211
 * @name Data Tx Register (DTR) mask(s)
212
 * @{
213
 */
214
#define XIIC_TX_DYN_START_MASK          0x00000100 /**< 1 = Set dynamic start */
215
#define XIIC_TX_DYN_STOP_MASK           0x00000200 /**< 1 = Set dynamic stop */
216
#define IIC_TX_FIFO_DEPTH               16     /**< Tx fifo capacity */
217
/* @} */
218
 
219
/**
220
 * @name Data Rx Register (DRR) mask(s)
221
 * @{
222
 */
223
#define IIC_RX_FIFO_DEPTH               16      /**< Rx fifo capacity */
224
/* @} */
225
 
226
 
227
#define XIIC_TX_ADDR_SENT               0x00
228
#define XIIC_TX_ADDR_MSTR_RECV_MASK     0x02
229
 
230
 
231
/**
232
 * The following constants are used to specify whether to do
233
 * Read or a Write operation on IIC bus.
234
 */
235
#define XIIC_READ_OPERATION     1 /**< Read operation on the IIC bus */
236
#define XIIC_WRITE_OPERATION    0 /**< Write operation on the IIC bus */
237
 
238
/**
239
 * The following constants are used with the transmit FIFO fill function to
240
 * specify the role which the IIC device is acting as, a master or a slave.
241
 */
242
#define XIIC_MASTER_ROLE        1 /**< Master on the IIC bus */
243
#define XIIC_SLAVE_ROLE         0 /**< Slave on the IIC bus */
244
 
245
/**
246
 * The following constants are used with Transmit Function (XIic_Send) to
247
 * specify whether to STOP after the current transfer of data or own the bus
248
 * with a Repeated start.
249
 */
250
#define XIIC_STOP               0x00 /**< Send a stop on the IIC bus after
251
                                        * the current data transfer */
252
#define XIIC_REPEATED_START     0x01 /**< Donot Send a stop on the IIC bus after
253
                                        * the current data transfer */
254
 
255
/***************** Macros (Inline Functions) Definitions *********************/
256
 
257
#define XIic_In32       Xil_In32
258
#define XIic_Out32      Xil_Out32
259
 
260
/****************************************************************************/
261
/**
262
*
263
* Read from the specified IIC device register.
264
*
265
* @param        BaseAddress is the base address of the device.
266
* @param        RegOffset is the offset from the 1st register of the device to
267
*               select the specific register.
268
*
269
* @return       The value read from the register.
270
*
271
* @note         C-Style signature:
272
*               u32 XIic_ReadReg(u32 BaseAddress, u32 RegOffset);
273
*
274
*               This macro does not do any checking to ensure that the
275
*               register exists if the register may be excluded due to
276
*               parameterization, such as the GPO Register.
277
*
278
******************************************************************************/
279
#define XIic_ReadReg(BaseAddress, RegOffset) \
280
        XIic_In32((BaseAddress) + (RegOffset))
281
 
282
/***************************************************************************/
283
/**
284
*
285
* Write to the specified IIC device register.
286
*
287
* @param        BaseAddress is the base address of the device.
288
* @param        RegOffset is the offset from the 1st register of the
289
*               device to select the specific register.
290
* @param        RegisterValue is the value to be written to the register.
291
*
292
* @return       None.
293
*
294
* @note         C-Style signature:
295
*               void XIic_WriteReg(u32 BaseAddress, u32 RegOffset,
296
*                                       u32 RegisterValue);
297
*               This macro does not do any checking to ensure that the
298
*               register exists if the register may be excluded due to
299
*               parameterization, such as the GPO Register.
300
*
301
******************************************************************************/
302
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue) \
303
        XIic_Out32((BaseAddress) + (RegOffset), (RegisterValue))
304
 
305
/******************************************************************************/
306
/**
307
*
308
* This macro disables all interrupts for the device by writing to the Global
309
* interrupt enable register.
310
*
311
* @param        BaseAddress is the base address of the IIC device.
312
*
313
* @return       None.
314
*
315
* @note         C-Style signature:
316
*               void XIic_IntrGlobalDisable(u32 BaseAddress);
317
*
318
******************************************************************************/
319
#define XIic_IntrGlobalDisable(BaseAddress)                             \
320
        XIic_WriteReg((BaseAddress), XIIC_DGIER_OFFSET, 0)
321
 
322
/******************************************************************************/
323
/**
324
*
325
* This macro writes to the global interrupt enable register to enable
326
* interrupts from the device. This function does not enable individual
327
* interrupts as the Interrupt Enable Register must be set appropriately.
328
*
329
* @param        BaseAddress is the base address of the IIC device.
330
*
331
* @return       None.
332
*
333
* @note         C-Style signature:
334
*               void XIic_IntrGlobalEnable(u32 BaseAddress);
335
*
336
******************************************************************************/
337
#define XIic_IntrGlobalEnable(BaseAddress)                              \
338
        XIic_WriteReg((BaseAddress), XIIC_DGIER_OFFSET,                 \
339
                XIIC_GINTR_ENABLE_MASK)
340
 
341
/******************************************************************************/
342
/**
343
*
344
* This function determines if interrupts are enabled at the global level by
345
* reading the global interrupt register.
346
*
347
* @param        BaseAddress is the base address of the IIC device.
348
*
349
* @return
350
*               - TRUE if the global interrupt is enabled.
351
*               - FALSE if global interrupt is disabled.
352
*
353
* @note         C-Style signature:
354
*               int XIic_IsIntrGlobalEnabled(u32 BaseAddress);
355
*
356
******************************************************************************/
357
#define XIic_IsIntrGlobalEnabled(BaseAddress)                   \
358
        (XIic_ReadReg((BaseAddress), XIIC_DGIER_OFFSET) ==              \
359
                XIIC_GINTR_ENABLE_MASK)
360
 
361
/******************************************************************************/
362
/**
363
*
364
* This function sets the Interrupt status register to the specified value.
365
*
366
* This register implements a toggle on write functionality. The interrupt is
367
* cleared by writing to this register with the bits to be cleared set to a one
368
* and all others to zero. Setting a bit which is zero within this register
369
* causes an interrupt to be generated.
370
*
371
* This function writes only the specified value to the register such that
372
* some status bits may be set and others cleared.  It is the caller's
373
* responsibility to get the value of the register prior to setting the value
374
* to prevent an destructive behavior.
375
*
376
* @param        BaseAddress is the base address of the IIC device.
377
* @param        Status is the value to be written to the Interrupt
378
*               status register.
379
*
380
* @return       None.
381
*
382
* @note         C-Style signature:
383
*               void XIic_WriteIisr(u32 BaseAddress, u32 Status);
384
*
385
******************************************************************************/
386
#define XIic_WriteIisr(BaseAddress, Status)     \
387
        XIic_WriteReg((BaseAddress), XIIC_IISR_OFFSET, (Status))
388
 
389
/******************************************************************************/
390
/**
391
*
392
* This function gets the contents of the Interrupt Status Register.
393
* This register indicates the status of interrupt sources for the device.
394
* The status is independent of whether interrupts are enabled such
395
* that the status register may also be polled when interrupts are not enabled.
396
*
397
* @param        BaseAddress is the base address of the IIC device.
398
*
399
* @return       The value read from the Interrupt Status Register.
400
*
401
* @note         C-Style signature:
402
*               u32 XIic_ReadIisr(u32 BaseAddress);
403
*
404
******************************************************************************/
405
#define XIic_ReadIisr(BaseAddress)                                      \
406
        XIic_ReadReg((BaseAddress), XIIC_IISR_OFFSET)
407
 
408
/******************************************************************************/
409
/**
410
*
411
* This function sets the contents of the Interrupt Enable Register.
412
*
413
* This function writes only the specified value to the register such that
414
* some interrupt sources may be enabled and others disabled.  It is the
415
* caller's responsibility to get the value of the interrupt enable register
416
* prior to setting the value to prevent a destructive behavior.
417
*
418
* @param        BaseAddress is the base address of the IIC device.
419
* @param        Enable is the value to be written to the Interrupt Enable
420
*               Register. Bit positions of 1 will be enabled. Bit positions of 0
421
*               will be disabled.
422
*
423
* @return       None
424
*
425
* @note         C-Style signature:
426
*               void XIic_WriteIier(u32 BaseAddress, u32 Enable);
427
*
428
******************************************************************************/
429
#define XIic_WriteIier(BaseAddress, Enable)                             \
430
        XIic_WriteReg((BaseAddress), XIIC_IIER_OFFSET, (Enable))
431
 
432
/******************************************************************************/
433
/**
434
*
435
*
436
* This function gets the Interrupt Enable Register contents.
437
*
438
* @param        BaseAddress is the base address of the IIC device.
439
*
440
* @return       The contents read from the Interrupt Enable Register.
441
*               Bit positions of 1 indicate that the corresponding interrupt
442
*               is enabled. Bit positions of 0 indicate that the corresponding
443
*               interrupt is disabled.
444
*
445
* @note         C-Style signature:
446
*               u32 XIic_ReadIier(u32 BaseAddress)
447
*
448
******************************************************************************/
449
#define XIic_ReadIier(BaseAddress)                                      \
450
        XIic_ReadReg((BaseAddress), XIIC_IIER_OFFSET)
451
 
452
/******************************************************************************/
453
/**
454
*
455
* This macro clears the specified interrupt in the Interrupt status
456
* register.  It is non-destructive in that the register is read and only the
457
* interrupt specified is cleared.  Clearing an interrupt acknowledges it.
458
*
459
* @param        BaseAddress is the base address of the IIC device.
460
* @param        InterruptMask is the bit mask of the interrupts to be cleared.
461
*
462
* @return       None.
463
*
464
* @note         C-Style signature:
465
*               void XIic_ClearIisr(u32 BaseAddress, u32 InterruptMask);
466
*
467
******************************************************************************/
468
#define XIic_ClearIisr(BaseAddress, InterruptMask)              \
469
        XIic_WriteIisr((BaseAddress),                   \
470
        XIic_ReadIisr(BaseAddress) & (InterruptMask))
471
 
472
/******************************************************************************/
473
/**
474
*
475
* This macro sends the address for a 7 bit address during both read and write
476
* operations. It takes care of the details to format the address correctly.
477
* This macro is designed to be called internally to the drivers.
478
*
479
* @param        BaseAddress is the base address of the IIC Device.
480
* @param        SlaveAddress is the address of the slave to send to.
481
* @param        Operation indicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION
482
*
483
* @return       None.
484
*
485
* @note         C-Style signature:
486
*               void XIic_Send7BitAddress(u32 BaseAddress, u8 SlaveAddress,
487
*                                               u8 Operation);
488
*
489
******************************************************************************/
490
#define XIic_Send7BitAddress(BaseAddress, SlaveAddress, Operation)      \
491
{                                                                       \
492
        u8 LocalAddr = (u8)(SlaveAddress << 1);                         \
493
        LocalAddr = (LocalAddr & 0xFE) | (Operation);                   \
494
        XIic_WriteReg(BaseAddress, XIIC_DTR_REG_OFFSET, LocalAddr);     \
495
}
496
 
497
/******************************************************************************/
498
/**
499
*
500
* This macro sends the address for a 7 bit address during both read and write
501
* operations. It takes care of the details to format the address correctly.
502
* This macro is designed to be called internally to the drivers for Dynamic
503
* controller functionality.
504
*
505
* @param        BaseAddress is the base address of the IIC Device.
506
* @param        SlaveAddress is the address of the slave to send to.
507
* @param        Operation indicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION.
508
*
509
* @return       None.
510
*
511
* @note         C-Style signature:
512
*               void XIic_DynSend7BitAddress(u32 BaseAddress,
513
*                               u8 SlaveAddress, u8 Operation);
514
*
515
******************************************************************************/
516
#define XIic_DynSend7BitAddress(BaseAddress, SlaveAddress, Operation)   \
517
{                                                                       \
518
        u8 LocalAddr = (u8)(SlaveAddress << 1);                         \
519
        LocalAddr = (LocalAddr & 0xFE) | (Operation);                   \
520
        XIic_WriteReg(BaseAddress, XIIC_DTR_REG_OFFSET,         \
521
                        XIIC_TX_DYN_START_MASK | LocalAddr);            \
522
}
523
 
524
/******************************************************************************/
525
/**
526
*
527
* This macro sends the address, start and stop for a 7 bit address during both
528
* write operations. It takes care of the details to format the address
529
* correctly. This macro is designed to be called internally to the drivers.
530
*
531
* @param        BaseAddress is the base address of the IIC Device.
532
* @param        SlaveAddress is the address of the slave to send to.
533
* @param        Operation indicates XIIC_WRITE_OPERATION.
534
*
535
* @return       None.
536
*
537
* @note         C-Style signature:
538
*               void XIic_DynSendStartStopAddress(u32 BaseAddress,
539
*                                                       u8 SlaveAddress,
540
*                                                       u8 Operation);
541
*
542
******************************************************************************/
543
#define XIic_DynSendStartStopAddress(BaseAddress, SlaveAddress, Operation) \
544
{                                                                        \
545
        u8 LocalAddr = (u8)(SlaveAddress << 1);                          \
546
        LocalAddr = (LocalAddr & 0xFE) | (Operation);                    \
547
        XIic_WriteReg(BaseAddress, XIIC_DTR_REG_OFFSET,          \
548
                        XIIC_TX_DYN_START_MASK | XIIC_TX_DYN_STOP_MASK | \
549
                        LocalAddr);                                      \
550
}
551
 
552
/******************************************************************************/
553
/**
554
*
555
* This macro sends a stop condition on IIC bus for Dynamic logic.
556
*
557
* @param        BaseAddress is the base address of the IIC Device.
558
* @param        ByteCount is the number of Rx bytes received before the master.
559
*               doesn't respond with ACK.
560
*
561
* @return       None.
562
*
563
* @note         C-Style signature:
564
*               void XIic_DynSendStop(u32 BaseAddress, u32 ByteCount);
565
*
566
******************************************************************************/
567
#define XIic_DynSendStop(BaseAddress, ByteCount)                        \
568
{                                                                       \
569
        XIic_WriteReg(BaseAddress, XIIC_DTR_REG_OFFSET,         \
570
                        XIIC_TX_DYN_STOP_MASK | ByteCount);             \
571
}
572
 
573
/************************** Function Prototypes *****************************/
574
 
575
unsigned XIic_Recv(UINTPTR BaseAddress, u8 Address,
576
                   u8 *BufferPtr, unsigned ByteCount, u8 Option);
577
 
578
unsigned XIic_Send(UINTPTR BaseAddress, u8 Address,
579
                   u8 *BufferPtr, unsigned ByteCount, u8 Option);
580
 
581
unsigned XIic_DynRecv(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, u8 ByteCount);
582
 
583
unsigned XIic_DynSend(UINTPTR BaseAddress, u16 Address, u8 *BufferPtr,
584
                      u8 ByteCount, u8 Option);
585
 
586
int XIic_DynInit(UINTPTR BaseAddress);
587
 
588
u32 XIic_CheckIsBusBusy(UINTPTR BaseAddress);
589
 
590
u32 XIic_WaitBusFree(UINTPTR BaseAddress);
591
 
592
#ifdef __cplusplus
593
}
594
#endif
595
 
596
#endif /* end of protection macro */
597
/** @} */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.