commit 6b9aea2c765d1938f6b5f04bf809b11bc1e3056a Author: cfif Date: Mon Sep 29 11:21:51 2025 +0300 Добавлены интерфейсы и драйверы diff --git a/Inc/GpioPin.h b/Inc/GpioPin.h new file mode 100644 index 0000000..bbd2e1f --- /dev/null +++ b/Inc/GpioPin.h @@ -0,0 +1,31 @@ +// +// Created by cfif on 16.09.22. +// + +#ifndef HVAC_M7_GPIOPIN_H +#define HVAC_M7_GPIOPIN_H + +#include "GpioPinInterface.h" +#include CMSIS_device_header +#include "fc7xxx_driver_pcc.h" +#include "fc7xxx_driver_port.h" +#include "fc7xxx_driver_gpio.h" +#include "fc7xxx_driver_scg.h" + +#define GPIO_PIN_NOREVERSE false +#define GPIO_PIN_REVERSE true + +tGpioPin vInitGpioPinPull( + GPIO_InstanceType port, + uint32_t pinMask, + GPIO_PinDirectionType direction, + bool reverse, + GPIO_PinLevelType gpio_pull +); + + +void GpioPinSet(tGpioPin *pin, bool value); + +bool GpioPinGet(tGpioPin *pin); + +#endif //HVAC_M7_GPIOPIN_H diff --git a/Src/GpioPin.c b/Src/GpioPin.c new file mode 100644 index 0000000..a071c62 --- /dev/null +++ b/Src/GpioPin.c @@ -0,0 +1,54 @@ +// +// Created by cfif on 16.09.22. +// +#include "GpioPin.h" + +tGpioPin vInitGpioPinPull( + GPIO_InstanceType port, + uint32_t pinMask, + GPIO_PinDirectionType direction, + bool reverse, + GPIO_PinLevelType gpio_pull +) { + GPIO_InitType tGpioInitStruct; + + tGpioInitStruct.u32GpioPins = pinMask; + tGpioInitStruct.ePinDirection = direction; + tGpioInitStruct.ePinLevel = gpio_pull; + + GPIO_InitPins(port, &tGpioInitStruct); + + tGpioPin pin = { + .port = port, + .pin = pinMask, + .reverse = reverse + }; + + return pin; +} + +void GpioPinSet(tGpioPin *pin, bool value) { + if (pin->reverse) { + value = !value; + } + + if (value) { + GPIO_WritePins(pin->port, pin->pin, GPIO_HIGH); + } else { + GPIO_WritePins(pin->port, pin->pin, GPIO_LOW); + } +} + +bool GpioPinGet(tGpioPin *pin) { + bool value; + if (GPIO_ReadPins(pin->port, pin->pin)) { + value = true; + } else { //if value == RESET; + value = false; + } + if (pin->reverse) { + value = !value; + } + return value; +} + diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..f910f3c --- /dev/null +++ b/modular.json @@ -0,0 +1,17 @@ +{ + "dep": [ + { + "type": "git", + "provider": "HVAC_M7", + "repo": "GpioPinInterface" + } + ], + "cmake": { + "inc_dirs": [ + "Inc" + ], + "srcs": [ + "Src/**.c" + ] + } +} \ No newline at end of file