40 lines
987 B
C
Raw Normal View History

2025-05-21 11:31:07 +08:00
/*
* drv_gpio.c
*
* Created on: 202549
* Author: 22332
*/
#include"drv_gpio.h"
#define INPUT_NUM 7
#define OUTPUT_NUM 14
void bsp_gpio_cfg_input(void)
{
for(uint8_t i=0; i<INPUT_NUM; i++)
{
PINS_DRV_SetPinDirection(g_pArrayPortIn[i].port,g_pArrayPortIn[i].pin,0);
}
}
void bsp_gpio_cfg_output(void)
{
for(uint8_t i=0; i<OUTPUT_NUM; i++)
{
PINS_DRV_SetPinDirection(g_pArrayPortOut[i].port,g_pArrayPortOut[i].pin,1);
PINS_DRV_WritePin(g_pArrayPortOut[i].port,g_pArrayPortOut[i].pin,g_pArrayPortOut[i].def);
}
}
int bsp_gpio_pin_read(int index){
if(index >= INPUT_NUM)return -1;
pins_channel_type_t read_pins;
read_pins = PINS_DRV_ReadPins(g_pArrayPortIn[index].port);
return (read_pins>>g_pArrayPortIn[index].pin)&0x01;
}
void bsp_gpio_pin_write(int index, gpio_pin_level_t status){
if(index >= OUTPUT_NUM)return;
PINS_DRV_WritePin(g_pArrayPortOut[index].port,g_pArrayPortOut[index].pin,status);
}