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