4 /****************************************************
6 * Copyright Motrola 1999
8 ****************************************************/
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.
14 typedef enum _i2c_status
20 /* These are the defined tasks for I2C_do_transaction.
21 * Modes for SLAVE_RCV and SLAVE_XMIT will be added.
23 typedef enum _i2c_transaction_mode
27 } I2C_TRANSACTION_MODE
;
29 typedef enum _i2c_interrupt_mode
35 typedef enum _i2c_stop
41 typedef enum _i2c_restart
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.
54 * Note: Its App.s responsibility to swap the data
55 * byte. In our API, we just transfer whatever
57 **************************************************/
60 /* Initialize I2C unit with the following:
61 * driver's slave address
63 * optional pointer to application layer print function
65 * These parameters may be added:
67 * digital filter frequency sampling rate
69 * This function must be called before I2C unit can be used.
71 extern I2C_Status
I2C_Initialize(
72 unsigned char addr
, /* driver's I2C slave address */
73 I2C_INTERRUPT_MODE en_int
, /* 1 - enable I2C interrupt
74 * 0 - disable I2C interrupt
76 int (*app_print_function
)(char *,...)); /* pointer to optional "printf"
77 * provided by application
80 /* Perform the given I2C transaction, only MASTER_XMIT and MASTER_RCV
81 * are implemented. Both are only in polling mode.
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
94 extern I2C_Status
I2C_do_transaction( I2C_INTERRUPT_MODE en_int
,
95 I2C_TRANSACTION_MODE act
,
96 unsigned char i2c_addr
,
97 unsigned char data_addr
,
102 I2C_RESTART_MODE rsta
);