1 /* 2 * ========================================================== 3 * 4 * Copyright (C) 2020 QuickLogic Corporation 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * File : eoss3_hal_pad_config.h 16 * Purpose : This file contains macros, structures and APIs to 17 * configure pads 18 * 19 * 20 * =========================================================== 21 * 22 */ 23 24 #ifndef __EOSS3_HAL_PAD_AF_H 25 #define __EOSS3_HAL_PAD_AF_H 26 27 #include "eoss3_hal_pads.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /*PAD configuration Register bits*/ 34 35 /*! \def PAD_CTRL_SRC_A0 36 \brief Control block that controls pad, It's M4 or other controller where 37 connected device does not interfear. 38 */ 39 #define PAD_CTRL_SRC_A0 ((uint8_t)0x00) /* Source is Firmware for GPIO */ 40 41 /*! \def PAD_CTRL_SRC_OTHER 42 \brief Control block that controls pad eg I2C controller, FFE0. 43 */ 44 #define PAD_CTRL_SRC_OTHER ((uint8_t)0x01) /* Source is HW controller */ 45 46 /*! \def PAD_CTRL_SRC_FPGA 47 \brief FPGA block controls pad. 48 */ 49 #define PAD_CTRL_SRC_FPGA ((uint8_t)0x02) /* Source is FPGA */ 50 51 /*! \def PAD_MODE_OUTPUT_EN 52 \brief Pad mode set as an output. 53 */ 54 #define PAD_MODE_OUTPUT_EN ((uint8_t)0x02) 55 56 /*! \def PAD_MODE_INPUT_EN 57 \brief Pad mode set as an input. 58 */ 59 #define PAD_MODE_INPUT_EN ((uint8_t)0x01) 60 61 /*! \def PAD_NOPULL 62 \brief Pad no pull. 63 */ 64 #define PAD_NOPULL ((uint8_t)0x00) 65 66 /*! \def PAD_PULLUP 67 \brief Pad pull up. 68 */ 69 #define PAD_PULLUP ((uint8_t)0x01) 70 71 /*! \def PAD_PULLDOWN 72 \brief Pad pull down. 73 */ 74 #define PAD_PULLDOWN ((uint8_t)0x02) 75 76 /*! \def PAD_KEEPER 77 \brief Pad keeper. 78 */ 79 #define PAD_KEEPER ((uint8_t)0x03) 80 81 /*! \def PAD_DRV_STRENGHT_2MA 82 \brief Pad driving current 2mA. 83 */ 84 #define PAD_DRV_STRENGHT_2MA ((uint8_t)0x00) 85 86 /*! \def PAD_DRV_STRENGHT_4MA 87 \brief Pad driving current 4mA. 88 */ 89 #define PAD_DRV_STRENGHT_4MA ((uint8_t)0x01) 90 91 /*! \def PAD_DRV_STRENGHT_8MA 92 \brief Pad driving current 8mA.. 93 */ 94 #define PAD_DRV_STRENGHT_8MA ((uint8_t)0x02) 95 96 /*! \def PAD_DRV_STRENGHT_12MA 97 \brief Pad driving current 12mA.. 98 */ 99 #define PAD_DRV_STRENGHT_12MA ((uint8_t)0x03) 100 101 /*! \def PAD_SLEW_RATE_SLOW 102 \brief Pad slew rate slow half of actual frequency. 103 */ 104 #define PAD_SLEW_RATE_SLOW ((uint8_t)0x00) /* Slow (half frequency) */ 105 106 /*! \def PAD_SLEW_RATE_FAST 107 \brief Pad slew rate fast. 108 */ 109 #define PAD_SLEW_RATE_FAST ((uint8_t)0x01) 110 111 /*! \def PAD_SMT_TRIG_EN 112 \brief Schmitt trigger enable for given pad. 113 */ 114 #define PAD_SMT_TRIG_EN ((uint8_t)0x01) 115 116 /*! \def PAD_SMT_TRIG_DIS 117 \brief Schmitt trigger disable for given pad. 118 */ 119 #define PAD_SMT_TRIG_DIS ((uint8_t)0x00) 120 121 122 /*! \struct PadConfig 123 * \brief Pad Configuration structure that is filled up by programmer to select 124 pad function. 125 */ 126 typedef struct 127 { 128 uint8_t ucPin; /*!< Pad or Pin number starts from 0, Refer file eoss3_hal_pads.h macros PAD_0 to PAD_45*/ 129 130 uint32_t ucFunc; /*!< Pad function selection listed in eoss3_hal_pad.h for each pad, each pad function listed with PAD0_FUNC_XXX to PAD45_FUNC_XXX*/ 131 132 uint8_t ucCtrl; /*!< Pad controller A0 = Firmware; Other=M4 HW(Debugger, I2C) or FFE, FPGA */ 133 134 uint8_t ucMode; /*!< Pad Output or Input function, OEN or REN*/ 135 136 uint8_t ucPull; /*!< Pad Pull up config Z/up/down/keeper*/ 137 138 uint8_t ucDrv; /*!< Pad Current driving strenght*/ 139 140 uint8_t ucSpeed; /*!< Pad operating speed slow or fast*/ 141 142 uint8_t ucSmtTrg; /*!< Pad configure for Schmitt trigger*/ 143 144 }PadConfig; 145 146 /// @cond INTERNAL_STRUCT 147 /*! \struct PadConfigReg 148 * \brief Pad Configuration register bit field to write directly in Pad config 149 register. This is for internal use, Programmer may not need to use it. 150 */ 151 typedef struct 152 { 153 uint32_t bFunc:3; 154 155 uint32_t bCtrl:2; 156 157 uint32_t bOEn:1; 158 159 uint32_t bOPull:2; 160 161 uint32_t bODrv:2; 162 163 uint32_t bSpeed:1; 164 165 uint32_t bIEn:1; 166 167 uint32_t bSmtTrg:1; 168 }PadConfigReg; 169 /// @endcond 170 171 /*! \fn HAL_PAD_Config(PadConfig *pxPadInit) 172 \brief Pad config function to configure pad functionality. This function 173 need to be called with appropriate configuration before using it. 174 175 \param *pxPadInit - Pad config structure data filled for given pad. 176 */ 177 void HAL_PAD_Config(PadConfig *pxPadInit); 178 179 /*! \fn HAL_PAD_DeConfig(PadConfig *pxPadInit) 180 \brief Pad config function to deconfigure of pad functionality and put that 181 pad in the default state. 182 183 \param *pxPadInit - Pad config structure data filled for given pad. 184 */ 185 void HAL_PAD_DeConfig(PadConfig *pxPadInit); 186 187 #ifdef __cplusplus 188 } 189 #endif 190 191 #endif /* __EOSS3_HAL_PAD_AF_H */ 192