wdenk | 327f7a0 | 2001-11-28 17:49:55 +0000 | [diff] [blame] | 1 | #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 | */ |
| 14 | typedef 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 | */ |
| 23 | typedef enum _i2c_transaction_mode |
| 24 | { |
| 25 | I2C_MASTER_RCV = 0, |
| 26 | I2C_MASTER_XMIT = 1, |
| 27 | } I2C_TRANSACTION_MODE; |
| 28 | |
| 29 | typedef enum _i2c_interrupt_mode |
| 30 | { |
| 31 | I2C_INT_DISABLE = 0, |
| 32 | I2C_INT_ENABLE = 1, |
| 33 | } I2C_INTERRUPT_MODE; |
| 34 | |
| 35 | typedef enum _i2c_stop |
| 36 | { |
| 37 | I2C_NO_STOP = 0, |
| 38 | I2C_STOP = 1, |
| 39 | } I2C_STOP_MODE; |
| 40 | |
| 41 | typedef 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 | */ |
| 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 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 74 | * 0 - disable I2C interrupt |
| 75 | */ |
| 76 | int (*app_print_function)(char *,...)); /* pointer to optional "printf" |
| 77 | * provided by application |
| 78 | */ |
wdenk | 327f7a0 | 2001-11-28 17:49:55 +0000 | [diff] [blame] | 79 | |
| 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 | */ |
| 94 | extern I2C_Status I2C_do_transaction( I2C_INTERRUPT_MODE en_int, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 95 | 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); |
wdenk | 327f7a0 | 2001-11-28 17:49:55 +0000 | [diff] [blame] | 103 | #endif |