blob: 6264d189bb2a291bca6882febfbcc2e5e7a364fb [file] [log] [blame]
wdenk327f7a02001-11-28 17:49:55 +00001#ifndef I2C_EXPORT_H
2#define I2C_EXPORT_H
3
4/****************************************************
5 *
6 * Copyright Motrola 1999
7 *
8 ****************************************************/
9
10/* These are the defined return values for the I2C_do_transaction function.
11 * Any non-zero value indicates failure. Failure modes can be added for
12 * more detailed error reporting.
13 */
14typedef enum _i2c_status
15{
16 I2C_SUCCESS = 0,
17 I2C_ERROR,
18} I2C_Status;
19
20/* These are the defined tasks for I2C_do_transaction.
21 * Modes for SLAVE_RCV and SLAVE_XMIT will be added.
22 */
23typedef enum _i2c_transaction_mode
24{
25 I2C_MASTER_RCV = 0,
26 I2C_MASTER_XMIT = 1,
27} I2C_TRANSACTION_MODE;
28
29typedef enum _i2c_interrupt_mode
30{
31 I2C_INT_DISABLE = 0,
32 I2C_INT_ENABLE = 1,
33} I2C_INTERRUPT_MODE;
34
35typedef enum _i2c_stop
36{
37 I2C_NO_STOP = 0,
38 I2C_STOP = 1,
39} I2C_STOP_MODE;
40
41typedef enum _i2c_restart
42{
43 I2C_NO_RESTART = 0,
44 I2C_RESTART = 1,
45} I2C_RESTART_MODE;
46
47/******************** App. API ********************
48 * The application API is for user level application
49 * to use the functionality provided by I2C driver.
50 * This is a "generic" I2C interface, it should contain
51 * nothing specific to the Kahlua implementation.
52 * Only the generic functions are exported by the library.
53 *
54 * Note: Its App.s responsibility to swap the data
55 * byte. In our API, we just transfer whatever
56 * we are given
57 **************************************************/
58
59
60/* Initialize I2C unit with the following:
61 * driver's slave address
62 * interrupt enabled
63 * optional pointer to application layer print function
64 *
65 * These parameters may be added:
66 * desired clock rate
67 * digital filter frequency sampling rate
68 *
69 * This function must be called before I2C unit can be used.
70 */
71extern I2C_Status I2C_Initialize(
72 unsigned char addr, /* driver's I2C slave address */
73 I2C_INTERRUPT_MODE en_int, /* 1 - enable I2C interrupt
wdenk8bde7f72003-06-27 21:31:46 +000074 * 0 - disable I2C interrupt
75 */
76 int (*app_print_function)(char *,...)); /* pointer to optional "printf"
77 * provided by application
78 */
wdenk327f7a02001-11-28 17:49:55 +000079
80/* Perform the given I2C transaction, only MASTER_XMIT and MASTER_RCV
81 * are implemented. Both are only in polling mode.
82 *
83 * en_int controls interrupt/polling mode
84 * act is the type of transaction
85 * addr is the I2C address of the slave device
86 * len is the length of data to send or receive
87 * buffer is the address of the data buffer
88 * stop = I2C_NO_STOP, don't signal STOP at end of transaction
89 * I2C_STOP, signal STOP at end of transaction
90 * retry is the timeout retry value, currently ignored
91 * rsta = I2C_NO_RESTART, this is not continuation of existing transaction
92 * I2C_RESTART, this is a continuation of existing transaction
93 */
94extern I2C_Status I2C_do_transaction( I2C_INTERRUPT_MODE en_int,
wdenk8bde7f72003-06-27 21:31:46 +000095 I2C_TRANSACTION_MODE act,
96 unsigned char i2c_addr,
97 unsigned char data_addr,
98 int len,
99 char *buffer,
100 I2C_STOP_MODE stop,
101 int retry,
102 I2C_RESTART_MODE rsta);
wdenk327f7a02001-11-28 17:49:55 +0000103#endif