fspim_sinit.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: fspim_sinit.c
  15. * Date: 2022-02-10 14:53:42
  16. * LastEditTime: 2022-02-18 09:08:24
  17. * Description:  This files is for
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 zhugengyu 2021-12-3 init commit
  23. * 1.1 zhugengyu 2022-4-15 support test mode
  24. */
  25. /***************************** Include Files *********************************/
  26. #include "ftypes.h"
  27. #include "fparameters.h"
  28. #include "fspim.h"
  29. /************************** Constant Definitions *****************************/
  30. /**************************** Type Definitions *******************************/
  31. /***************** Macros (Inline Functions) Definitions *********************/
  32. /************************** Variable Definitions *****************************/
  33. extern const FSpimConfig FSPIM_CONFIG_TBL[FSPI_DEVICE_NUM];
  34. /************************** Function Prototypes ******************************/
  35. /**
  36. * @name: FSpimLookupConfig
  37. * @msg: 获取FSPIM实例的默认配置
  38. * @return {const FSpimConfig *} FSPIM实例的默认配置
  39. * @param {u32} instance_id, SPI控制器ID
  40. */
  41. const FSpimConfig *FSpimLookupConfig(u32 instance_id)
  42. {
  43. const FSpimConfig *ptr = NULL;
  44. u32 index;
  45. for (index = 0; index < (u32)FSPI_DEVICE_NUM; index++)
  46. {
  47. if (FSPIM_CONFIG_TBL[index].instance_id == instance_id)
  48. {
  49. ptr = &FSPIM_CONFIG_TBL[index];
  50. break;
  51. }
  52. }
  53. return (const FSpimConfig *)ptr;
  54. }