i2c_export.h 3.0 KB

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