iot_i2c_ex.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2020 Huawei Device Co., Ltd.
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. /**
  16. * @addtogroup wifiiot
  17. * @{
  18. *
  19. * @brief Provides dedicated device operation interfaces on the Wi-Fi module,
  20. * including ADC, AT, flash, GPIO, I2C, I2S, partition, PWM, SDIO, UART, and watchdog.
  21. *
  22. *
  23. *
  24. * @since 1.0
  25. * @version 1.0
  26. */
  27. /**
  28. * @file wifiiot_i2c_ex.h
  29. *
  30. * @brief Declares the extended I2C interface functions.
  31. *
  32. * These functions are used for I2C baud rate setting and device exception callback. \n
  33. *
  34. * @since 1.0
  35. * @version 1.0
  36. */
  37. #ifndef IOT_I2C_EX_H
  38. #define IOT_I2C_EX_H
  39. /**
  40. * @brief Defines I2C data transmission attributes.
  41. */
  42. typedef struct {
  43. /** Pointer to the buffer storing data to send */
  44. unsigned char *sendBuf;
  45. /** Length of data to send */
  46. unsigned int sendLen;
  47. /** Pointer to the buffer for storing data to receive */
  48. unsigned char *receiveBuf;
  49. /** Length of data received */
  50. unsigned int receiveLen;
  51. } IotI2cData;
  52. /**
  53. * @brief Sends data to and receives data responses from an I2C device.
  54. *
  55. *
  56. *
  57. * @param id Indicates the I2C device ID.
  58. * @param deviceAddr Indicates the I2C device address.
  59. * @param i2cData Indicates the pointer to the device descriptor of the data to receive.
  60. * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful;
  61. * returns an error code defined in {@link wifiiot_errno.h} otherwise.
  62. * @since 1.0
  63. * @version 1.0
  64. */
  65. unsigned int IoTI2cWriteread(unsigned int id, unsigned short deviceAddr, const IotI2cData *i2cData);
  66. #endif
  67. /** @} */