drv_hard_i2c.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-06-18 thread-liu the first version
  9. */
  10. #ifndef __DRV_HARD_I2C_H__
  11. #define __DRV_HARD_I2C_H__
  12. /* Includes ------------------------------------------------------------------*/
  13. #include "stm32mp1xx_hal.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #define STPMU1_I2C_ADDRESS ((0x33 & 0x7F) << 1)
  18. #ifndef I2C_SPEED
  19. #define I2C_SPEED ((uint32_t)100000)
  20. #endif /* I2C_SPEED */
  21. #ifndef I2C4_TIMING
  22. #define I2C4_TIMING ((uint32_t)0x10805E89)
  23. #endif
  24. static int32_t I2C4_WriteReg(uint16_t DevAddr, uint16_t MemAddSize, uint16_t Reg, uint8_t *pData, uint16_t Length);
  25. static int32_t I2C4_ReadReg(uint16_t DevAddr, uint16_t MemAddSize, uint16_t Reg, uint8_t *pData, uint16_t Length);
  26. int32_t BSP_I2C4_Init(void);
  27. int32_t BSP_I2C4_DeInit(void);
  28. int32_t BSP_I2C4_WriteReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
  29. int32_t BSP_I2C4_ReadReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
  30. int32_t BSP_I2C4_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
  31. int32_t BSP_I2C4_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
  32. int32_t BSP_I2C4_IsReady(uint16_t DevAddr, uint32_t Trials);
  33. HAL_StatusTypeDef MX_I2C4_Init(I2C_HandleTypeDef *hI2c);
  34. #ifdef __cplusplus
  35. }
  36. #endif
  37. #endif