1 |
4 |
DFC |
/******************************************************************************
|
2 |
|
|
**
|
3 |
|
|
** (C) Copyright 2013 DFC Design, s.r.o., Brno, Czech Republic
|
4 |
|
|
** Author: Marek Kvas (m.kvas@dspfpga.com)
|
5 |
|
|
**
|
6 |
|
|
****************************************************************************
|
7 |
|
|
**
|
8 |
|
|
** This file is part of Xenia Ethernet Example project.
|
9 |
|
|
**
|
10 |
|
|
** Xenia Ethernet Example project is free software: you can
|
11 |
|
|
** redistribute it and/or modify it under the terms of
|
12 |
|
|
** the GNU Lesser General Public License as published by the Free
|
13 |
|
|
** Software Foundation, either version 3 of the License, or
|
14 |
|
|
** (at your option) any later version.
|
15 |
|
|
**
|
16 |
|
|
** Xenia Ethernet Example project is distributed in the hope that
|
17 |
|
|
** it will be useful, but WITHOUT ANY WARRANTY; without even
|
18 |
|
|
** the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
19 |
|
|
** PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
20 |
|
|
** for more details.
|
21 |
|
|
**
|
22 |
|
|
** You should have received a copy of the GNU Lesser General Public
|
23 |
|
|
** License along with Xenia Ethernet Example project. If not,
|
24 |
|
|
** see <http://www.gnu.org/licenses/>.
|
25 |
|
|
*******************************************************************************
|
26 |
|
|
**
|
27 |
|
|
** This is a wrapper for Xilinx IIC driver in interrupt mode.
|
28 |
|
|
**
|
29 |
|
|
*******************************************************************************
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
#ifndef __IIC_WRAP_H__
|
33 |
|
|
#define __IIC_WRAP_H__
|
34 |
|
|
#include "xiic.h"
|
35 |
|
|
|
36 |
|
|
struct handler_info {
|
37 |
|
|
int unprocessed_bytes;
|
38 |
|
|
int error; /* set by interrupt in case of error */
|
39 |
|
|
int finished; /* marks end of operation - set by interrupt */
|
40 |
|
|
int op_started; /* marks operation started */
|
41 |
|
|
u32 end_tstmp; /* time when timeout should occur */
|
42 |
|
|
|
43 |
|
|
int snd_star;
|
44 |
|
|
int rcv_stat;
|
45 |
|
|
int stat_stat;
|
46 |
|
|
};
|
47 |
|
|
|
48 |
|
|
struct iic_wrap_dev {
|
49 |
|
|
XIic iic;
|
50 |
|
|
int started; /* Xiic_start has been called already and no stop has beeen called */
|
51 |
|
|
volatile struct handler_info hi;
|
52 |
|
|
};
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
int iic_wrap_init(struct iic_wrap_dev *dev, u16 IicDeviceId);
|
56 |
|
|
int iic_wrap_send_timeout(struct iic_wrap_dev *dev, u8 addr, u8 *tx_msg, int length, int timeout_ms);
|
57 |
|
|
int iic_wrap_recv_timeout(struct iic_wrap_dev *dev, u8 addr, u8 *rx_msg, int length, int timeout_ms);
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
#endif /* __IIC_WRAP_H__ */
|