72 lines
1.2 KiB
C
72 lines
1.2 KiB
C
/*
|
|
* gpio.c
|
|
*
|
|
* Created on: 22-Jan-2024
|
|
* Author: saar
|
|
*/
|
|
#include <stdlib.h>
|
|
#include "../Include/gpio.h"
|
|
|
|
static uint32_t GPIOInitCounter = 0;
|
|
|
|
int8_t mcu_gpioInitAllMcal(void)
|
|
{
|
|
if (GPIOInitCounter == 0)
|
|
{
|
|
GPIOInitCounter = 1;
|
|
SYSCFG_DL_GPIO_init();
|
|
return 0;
|
|
}
|
|
else
|
|
return -1;
|
|
}
|
|
|
|
int8_t mcu_gpioDeInitMcal(GPIO_Regs *GPIOx, uint32_t GPIO_Pin)
|
|
{
|
|
if (GPIOInitCounter == 1)
|
|
{
|
|
GPIOInitCounter = 0;
|
|
(void) GPIO_Pin;
|
|
DL_GPIO_disablePower(GPIOx);
|
|
return 0;
|
|
}
|
|
else
|
|
return -1;
|
|
}
|
|
void mcu_gpioWriteMcal(void* port, uint32_t pin, uint32_t state)
|
|
{
|
|
// DL_GPIO_writePinsVal(port, pin, state);
|
|
if(state)
|
|
{
|
|
DL_GPIO_setPins(port, pin);
|
|
}
|
|
else
|
|
{
|
|
DL_GPIO_clearPins(port, pin);
|
|
}
|
|
}
|
|
|
|
uint16_t mcu_gpioReadMcal(void* port, uint32_t pin)
|
|
{
|
|
return (DL_GPIO_readPins(port, pin));
|
|
}
|
|
|
|
void mcu_gpioToggleMcal(void *port, uint32_t pin)
|
|
{
|
|
DL_GPIO_togglePins(port, pin);
|
|
}
|
|
|
|
void mcu_set_gpioDirectionMcal(uint32_t pincmIndex, bool direction)
|
|
{
|
|
|
|
if(direction)
|
|
{
|
|
DL_GPIO_initDigitalOutput(pincmIndex);
|
|
}
|
|
else
|
|
{
|
|
DL_GPIO_initDigitalInput(pincmIndex);
|
|
}
|
|
}
|
|
|