fpinctrl.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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: fpinctrl.h
  15. * Date: 2022-03-28 14:16:09
  16. * LastEditTime: 2022-03-28 14:16:10
  17. * Description:  This file is for IO pin ctrl API definition
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 zhugengyu 2022/3/28 init commit
  23. */
  24. #ifndef FPINCTRL_H
  25. #define FPINCTRL_H
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. /***************************** Include Files *********************************/
  31. #include "ftypes.h"
  32. #include "sdkconfig.h"
  33. #if defined(CONFIG_TARGET_F2000_4) || defined(CONFIG_TARGET_D2000)
  34. #include "fioctrl.h"
  35. /**************************** Type Definitions *******************************/
  36. typedef enum
  37. {
  38. FPIN_FUNC0 = 0b000,
  39. FPIN_FUNC1,
  40. FPIN_FUNC2,
  41. FPIN_FUNC3 = 0b011,
  42. FPIN_NUM_OF_FUNC
  43. } FPinFunc; /* 引脚复用功能配置, func0为默认功能 */
  44. typedef enum
  45. {
  46. FPIN_PULL_NONE = 0b00,
  47. FPIN_PULL_DOWN = 0b01,
  48. FPIN_PULL_UP = 0b10,
  49. FPIN_NUM_OF_PULL
  50. } FPinPull; /* 引脚上下拉配置 */
  51. typedef enum
  52. {
  53. FPIN_OUTPUT_DELAY = 0, /* 延时设置方向为输出 */
  54. FPIN_INPUT_DELAY, /* 延时设置方向为输入 */
  55. FPIN_NUM_OF_DELAY_DIR
  56. } FPinDelayDir; /* 引脚延时配置方向 */
  57. typedef enum
  58. {
  59. FPIN_DELAY_COARSE_TUNING = 0, /* 延迟粗调档位 */
  60. FPIN_DELAY_FINE_TUNING, /* 延迟精调档位 */
  61. FPIN_NUM_OF_DELAY_TYPE
  62. } FPinDelayType; /* 引脚延时配置类型 */
  63. typedef enum
  64. {
  65. FPIN_DELAY_NONE = 0,
  66. FPIN_DELAY_1,
  67. FPIN_DELAY_2,
  68. FPIN_DELAY_3,
  69. FPIN_DELAY_4,
  70. FPIN_DELAY_5,
  71. FPIN_DELAY_6,
  72. FPIN_DELAY_7,
  73. FPIN_NUM_OF_DELAY
  74. } FPinDelay;
  75. typedef enum
  76. {
  77. FPIN_DELAY_IN_TYPE = 0, /* input delay */
  78. FPIN_DELAY_OUT_TYPE = 1, /* output delay */
  79. } FPinDelayIOType;
  80. typedef struct
  81. {
  82. u32 reg_off; /* 引脚配置寄存器偏移量 */
  83. u32 reg_bit; /* 引脚配置起始位 */
  84. } FPinIndex; /* 引脚索引 */
  85. /************************** Variable Definitions *****************************/
  86. /***************** Macros (Inline Functions) Definitions *********************/
  87. #define FPIN_NULL {0xffffffff, 0}
  88. /************************** Function Prototypes ******************************/
  89. /* 获取IO引脚当前的复用功能 */
  90. FPinFunc FPinGetFunc(const FPinIndex pin);
  91. /* 设置IO引脚复用功能 */
  92. void FPinSetFunc(const FPinIndex pin, FPinFunc func);
  93. /* 获取IO引脚当前的上下拉设置 */
  94. FPinPull FPinGetPull(const FPinIndex pin);
  95. /* 设置IO引脚的上下拉 */
  96. void FPinSetPull(const FPinIndex pin, FPinPull pull);
  97. /* 获取IO引脚的复用、上下拉和驱动能力设置 */
  98. void FPinGetConfig(const FPinIndex pin, FPinFunc *func, FPinPull *pull);
  99. /* 设置IO引脚的复用、上下拉和驱动能力 */
  100. void FPinSetConfig(const FPinIndex pin, FPinFunc func, FPinPull pull);
  101. /* 获取IO引脚当前的单项延时设置 */
  102. FPinDelay FPinGetDelay(const FPinIndex pin, FPinDelayDir dir, FPinDelayType type);
  103. /* 检查IO引脚延时是否使能 */
  104. boolean FPinGetDelayEn(const FPinIndex pin, FPinDelayDir dir);
  105. /* 设置IO引脚单项延时 */
  106. void FPinSetDelay(const FPinIndex pin, FPinDelayDir dir, FPinDelayType type, FPinDelay delay);
  107. /* 使能或去使能IO引脚延时 */
  108. void FPinSetDelayEn(const FPinIndex pin, FPinDelayDir dir, boolean enable);
  109. /* Update and enable common IO pin delay config */
  110. void FPinSetDelayConfig(const FPinIndex pin, FPinDelayIOType in_out_type, FPinDelay roungh_delay, FPinDelay delicate_delay, boolean enable);
  111. /* Get current common IO pin delay config */
  112. void FPinGetDelayConfig(const FPinIndex pin, FPinDelay *in_roungh_delay, FPinDelay *in_delicate_delay,
  113. FPinDelay *out_roungh_delay, FPinDelay *out_delicate_delay);
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif
  118. #endif