fsl_codec_i2c.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2019 NXP
  3. * All rights reserved.
  4. *
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_CODEC_I2C_H_
  9. #define _FSL_CODEC_I2C_H_
  10. #include "fsl_common.h"
  11. #include "i2c.h"
  12. /*******************************************************************************
  13. * Definitions
  14. ******************************************************************************/
  15. /*! @brief CODEC device register address type. */
  16. typedef enum _codec_reg_addr
  17. {
  18. kCODEC_RegAddr8Bit = 1U, /*!< 8-bit register address. */
  19. kCODEC_RegAddr16Bit = 2U, /*!< 16-bit register address. */
  20. } codec_reg_addr_t;
  21. /*! @brief CODEC device register width. */
  22. typedef enum _codec_reg_width
  23. {
  24. kCODEC_RegWidth8Bit = 1U, /*!< 8-bit register width. */
  25. kCODEC_RegWidth16Bit = 2U, /*!< 16-bit register width. */
  26. kCODEC_RegWidth32Bit = 4U, /*!< 32-bit register width. */
  27. } codec_reg_width_t;
  28. /*! @brief CODEC I2C configurations structure */
  29. typedef struct _codec_i2c_config
  30. {
  31. uint32_t codecI2CInstance; /*!< i2c bus instance */
  32. uint32_t codecI2CSourceClock; /*!< i2c bus source clock frequency */
  33. } codec_i2c_config_t;
  34. /*******************************************************************************
  35. * API
  36. ******************************************************************************/
  37. #if defined(__cplusplus)
  38. extern "C" {
  39. #endif
  40. /*!
  41. * @brief Codec i2c bus initilization.
  42. *
  43. * @param handle i2c master handle.
  44. * @param i2CInstance instance number of the i2c bus, such as 0 is corresponding to I2C0.
  45. * @param i2cBaudrate i2c baudrate.
  46. * @param i2cSourceClockHz i2c source clock frequency.
  47. * @return kStatus_HAL_I2cSuccess is success, else initial failed.
  48. */
  49. status_t CODEC_I2C_Init(void *handle, uint32_t i2cInstance, uint32_t i2cBaudrate, uint32_t i2cSourceClockHz);
  50. /*!
  51. * @brief Codec i2c de-initilization.
  52. *
  53. * @param handle i2c master handle.
  54. * @return kStatus_HAL_I2cSuccess is success, else deinitial failed.
  55. */
  56. status_t CODEC_I2C_Deinit(void *handle);
  57. /*!
  58. * @brief codec i2c send function.
  59. *
  60. * @param handle i2c master handle.
  61. * @param deviceAddress codec device address.
  62. * @param subAddress register address.
  63. * @param subaddressSize register address width.
  64. * @param txBuff tx buffer pointer.
  65. * @param txBuffSize tx buffer size.
  66. * @return kStatus_HAL_I2cSuccess is success, else send failed.
  67. */
  68. status_t CODEC_I2C_Send(void *handle,
  69. uint8_t deviceAddress,
  70. uint32_t subAddress,
  71. uint8_t subaddressSize,
  72. uint8_t *txBuff,
  73. uint8_t txBuffSize);
  74. /*!
  75. * @brief codec i2c receive function.
  76. *
  77. * @param handle i2c master handle.
  78. * @param deviceAddress codec device address.
  79. * @param subAddress register address.
  80. * @param subaddressSize register address width.
  81. * @param rxBuff rx buffer pointer.
  82. * @param rxBuffSize rx buffer size.
  83. * @return kStatus_HAL_I2cSuccess is success, else receive failed.
  84. */
  85. status_t CODEC_I2C_Receive(void *handle,
  86. uint8_t deviceAddress,
  87. uint32_t subAddress,
  88. uint8_t subaddressSize,
  89. uint8_t *rxBuff,
  90. uint8_t rxBuffSize);
  91. #if defined(__cplusplus)
  92. }
  93. #endif
  94. #endif /* _FSL_CODEC_I2C_H_ */