am_hal_i2c_bit_bang.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //*****************************************************************************
  2. //
  3. // am_hal_i2c_bit_bang.h
  4. //! @file
  5. //!
  6. //! @brief I2C bit bang module.
  7. //!
  8. //! These functions implement the I2C bit bang utility
  9. //
  10. //*****************************************************************************
  11. //*****************************************************************************
  12. //
  13. // Copyright (c) 2017, Ambiq Micro
  14. // All rights reserved.
  15. //
  16. // Redistribution and use in source and binary forms, with or without
  17. // modification, are permitted provided that the following conditions are met:
  18. //
  19. // 1. Redistributions of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // 2. Redistributions in binary form must reproduce the above copyright
  23. // notice, this list of conditions and the following disclaimer in the
  24. // documentation and/or other materials provided with the distribution.
  25. //
  26. // 3. Neither the name of the copyright holder nor the names of its
  27. // contributors may be used to endorse or promote products derived from this
  28. // software without specific prior written permission.
  29. //
  30. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  31. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  34. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  36. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  37. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  38. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  39. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. // POSSIBILITY OF SUCH DAMAGE.
  41. //
  42. // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
  43. //
  44. //*****************************************************************************
  45. #ifndef AM_HAL_I2C_BIT_BANG_H
  46. #define AM_HAL_I2C_BIT_BANG_H
  47. //*****************************************************************************
  48. //
  49. // Enumerated return constants
  50. //
  51. //*****************************************************************************
  52. typedef enum
  53. {
  54. AM_HAL_I2C_BIT_BANG_SUCCESS = 0,
  55. AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED,
  56. AM_HAL_I2C_BIT_BANG_DATA_NAKED,
  57. AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT,
  58. AM_HAL_I2C_BIT_BANG_DATA_TIMEOUT,
  59. AM_HAL_I2C_BIT_BANG_STATUS_MAX,
  60. }am_hal_i2c_bit_bang_enum_e;
  61. #ifdef __cplusplus
  62. extern "C"
  63. {
  64. #endif
  65. //*****************************************************************************
  66. //
  67. // External function definitions
  68. //
  69. //*****************************************************************************
  70. extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_init(uint32_t sck_gpio_number,
  71. uint32_t sda_gpio_number);
  72. extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_send(uint8_t address,
  73. uint32_t number_of_bytes,
  74. uint8_t *pData,
  75. uint8_t ui8Offset,
  76. bool bUseOffset,
  77. bool bNoStop);
  78. extern am_hal_i2c_bit_bang_enum_e am_hal_i2c_bit_bang_receive(uint8_t address,
  79. uint32_t number_of_bytes,
  80. uint8_t *pData,
  81. uint8_t ui8Offset,
  82. bool bUseOffset,
  83. bool bNoStop);
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif //AM_HAL_I2C_BIT_BANG_H
  88. //*****************************************************************************
  89. //
  90. // End Doxygen group.
  91. //! @}
  92. //
  93. //*****************************************************************************