From b21840094e320f824c451dbcd54f5e63efaa13a1 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Wed, 18 Sep 2024 12:28:59 +1000 Subject: [PATCH] AP_Scripting: add bindings get/set full mode for GPIO allows setting alternate pin modes pin drive strengths etc. --- libraries/AP_Scripting/docs/docs.lua | 20 +++++++++++++++++++ .../generator/description/bindings.desc | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/libraries/AP_Scripting/docs/docs.lua b/libraries/AP_Scripting/docs/docs.lua index 889ffa089dca4c..73281b83399f9d 100644 --- a/libraries/AP_Scripting/docs/docs.lua +++ b/libraries/AP_Scripting/docs/docs.lua @@ -1711,6 +1711,26 @@ function gpio:write(pin_number, value) end ---@return boolean -- pin state function gpio:read(pin_number) end +-- desc +---@param pin_number integer +---@param mode uint32_t_ud|integer|number +function gpio:set_mode(param1, param2) end + +-- desc +---@param pin_number integer +---@return uint32_t_ud|nil -- full pin mode ioline_t in chibios +function gpio:get_mode(param1) end + +-- desc +---@param pin_number integer +---@param mode uint32_t_ud|integer|number +function gpio:setPinFullMode(pin_number, mode) end + +-- desc +---@param pin_number integer +---@return uint32_t_ud|nil -- full pin mode ioline_t in chibios +function gpio:getPinFullMode(pin_number) end + -- desc Motors_6DoF = {} diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index 30b5be0c766ef4..f623bead2e50d2 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/libraries/AP_Scripting/generator/description/bindings.desc @@ -631,6 +631,10 @@ singleton hal.gpio method read boolean uint8_t'skip_check singleton hal.gpio method write void uint8_t'skip_check uint8_t 0 1 singleton hal.gpio method toggle void uint8_t'skip_check singleton hal.gpio method pinMode void uint8_t'skip_check uint8_t 0 1 +singleton hal.gpio method get_mode boolean uint8_t'skip_check uint32_t'Null +singleton hal.gpio method get_mode alias getPinFullMode +singleton hal.gpio method set_mode void uint8_t'skip_check uint32_t'skip_check +singleton hal.gpio method set_mode alias setPinFullMode singleton hal.analogin depends !defined(HAL_DISABLE_ADC_DRIVER) singleton hal.analogin rename analog