Добавлены интерфейсы и драйверы
This commit is contained in:
commit
6b9aea2c76
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"dep": [
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "HVAC_M7",
|
||||
"repo": "GpioPinInterface"
|
||||
}
|
||||
],
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"Inc"
|
||||
],
|
||||
"srcs": [
|
||||
"Src/**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue