--[[
  Copyright (c) 2026 by Plexim GmbH
  All rights reserved.

  A free license is granted to anyone to use this software for any legal
  non safety-critical purpose, including commercial applications, provided
  that:
  1) IT IS NOT USED TO DIRECTLY OR INDIRECTLY COMPETE WITH PLEXIM, and
  2) THIS COPYRIGHT NOTICE IS PRESERVED in its entirety.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
--]]

U = require('common.utils')

local GPIO = {}
local pinTypeOptions = {'STD', 'PULLUP', 'OD', 'INVERT'}
GPIO.cbx_PIN_TYPE_STD = U.newComboBox('STD', pinTypeOptions)
GPIO.cbx_PIN_TYPE_PULLUP = U.newComboBox('PULLUP', pinTypeOptions)
GPIO.cbx_PIN_TYPE_OD = U.newComboBox('OD', pinTypeOptions)
GPIO.cbx_PIN_TYPE_INVERT = U.newComboBox('INVERT', pinTypeOptions)



function GPIO.isPad(data)
  return U.isTable(data) and U.checkParamContract(data, {
    pin = U.isNonNegativeIntScalar,
    opt_link = U.isString,
    opt_blockPath = U.isString,
    opt_altFunction = U.isString, -- GPIO_setPinConfig
    opt_cbx_pinType = U.isComboBox, -- For padConfig
    opt_cbx_direction = U.isComboBox, -- GPIO_setDirectionMode
    opt_cbx_analogMode = U.isComboBox, -- GPIO_setAnalogMode: Only for some targets
    opt_secondaryCPUCode = U.isString, -- GPIO_setXCore()
    opt_specialCode = U.isString, -- catchall? SysCtl_selectCPUForPeripheralInstance
    opt_qualificationMode = U.isComboBox, -- GPIO_setQualificationMode: Default is SYNC, ASYNC used for fast protocol that needs edge detection CAN, etc.
    opt_inputXbar = U.isInteger, -- can eliminate 'input_xbar' as a separate entry
    -- epwm_xbar ??
  })
end

-- Stub: GPIO pad functions not implemented for this target
return GPIO
