fi2c_sinit.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: fi2c_sinit.c
  15. * Date: 2022-02-10 14:53:42
  16. * LastEditTime: 2022-02-18 08:36:52
  17. * Description:  This files is for
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. */
  23. /* - This file contains the implementation of driver's static initialization functionality.
  24. - 驱动静态初始化 */
  25. /***************************** Include Files *********************************/
  26. #include "ftypes.h"
  27. #include "fparameters.h"
  28. #include "fi2c.h"
  29. #include "sdkconfig.h"
  30. /************************** Constant Definitions *****************************/
  31. /**************************** Type Definitions *******************************/
  32. /***************** Macros (Inline Functions) Definitions *********************/
  33. /************************** Variable Definitions *****************************/
  34. extern const FI2cConfig FI2C_CONFIG_TBL[I2C_INSTANCE_NUM];
  35. /************************** Function Prototypes ******************************/
  36. /**
  37. * @name: FI2cLookupConfig
  38. * @msg: 获取I2C驱动的默认配置参数
  39. * @return {const FI2cConfig*} 驱动默认参数
  40. * @param {u32} instance_id, 当前控制的I2C控制器实例号
  41. */
  42. const FI2cConfig *FI2cLookupConfig(u32 instance_id)
  43. {
  44. const FI2cConfig *ptr = NULL;
  45. u32 index;
  46. for (index = 0; index < (u32)I2C_INSTANCE_NUM; index++)
  47. {
  48. if (FI2C_CONFIG_TBL[index].instance_id == instance_id)
  49. {
  50. ptr = &FI2C_CONFIG_TBL[index];
  51. break;
  52. }
  53. }
  54. return (const FI2cConfig *)ptr;
  55. }