am_hal_i2c_bit_bang.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.9 of the AmbiqSuite Development Package.
  43. //
  44. //*****************************************************************************
  45. #ifndef AM_HAL_I2C_BIT_BANG_H
  46. #define AM_HAL_I2C_BIT_BANG_H
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // Enumerated return constants
  54. //
  55. //*****************************************************************************
  56. typedef enum
  57. {
  58. AM_HAL_I2C_BIT_BANG_SUCCESS = 0,
  59. AM_HAL_I2C_BIT_BANG_ADDRESS_NAKED,
  60. AM_HAL_I2C_BIT_BANG_DATA_NAKED,
  61. AM_HAL_I2C_BIT_BANG_CLOCK_TIMEOUT,
  62. AM_HAL_I2C_BIT_BANG_DATA_TIMEOUT,
  63. }am_hal_i2c_bit_bang_enum_t;
  64. //*****************************************************************************
  65. //
  66. // External function definitions
  67. //
  68. //*****************************************************************************
  69. extern am_hal_i2c_bit_bang_enum_t am_hal_i2c_bit_bang_init(uint32_t sck_gpio_number,
  70. uint32_t sda_gpio_number);
  71. extern am_hal_i2c_bit_bang_enum_t am_hal_i2c_bit_bang_send(uint8_t address,
  72. uint32_t number_of_bytes,
  73. uint8_t *pData,
  74. uint8_t ui8Offset,
  75. bool bUseOffset,
  76. bool bNoStop);
  77. extern am_hal_i2c_bit_bang_enum_t am_hal_i2c_bit_bang_receive(uint8_t address,
  78. uint32_t number_of_bytes,
  79. uint8_t *pData,
  80. uint8_t ui8Offset,
  81. bool bUseOffset,
  82. bool bNoStop);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif //AM_HAL_I2C_BIT_BANG_H
  87. //*****************************************************************************
  88. //
  89. // End Doxygen group.
  90. //! @}
  91. //
  92. //*****************************************************************************