Files
hpw421/component/xc6xx_drivers/Drivers/xc_driver/xc_drv_gpio.h
T
2026-07-03 18:08:25 +08:00

184 lines
3.9 KiB
C

/*!
* \file xc_drv_aotimer.h
*
* \brief The header of xc_drv_aotimer.c
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
#ifndef _XC_DRV_GPIO_H_
#define _XC_DRV_GPIO_H_
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdio.h>
#include "xc6xxx.h"
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
typedef enum
{
GPIO_PIN_RESET = 0u,
GPIO_PIN_SET
} GPIO_PinState;
enum
{
GPIO_0,
GPIO_1,
GPIO_2,
GPIO_3,
GPIO_4,
GPIO_5,
GPIO_6,
GPIO_7,
GPIO_8,
GPIO_9,
GPIO_10,
GPIO_11,
GPIO_12,
GPIO_13,
GPIO_14,
GPIO_15,
GPIO_16,
GPIO_17,
GPIO_18,
GPIO_19,
GPIO_20,
GPIO_21,
GPIO_22,
GPIO_23,
GPIO_24,
GPIO_25,
GPIO_26,
GPIO_27,
GPIO_28,
GPIO_29,
GPIO_30,
GPIO_31,
GPIO_32,
GPIO_33,
GPIO_34,
GPIO_35,
GPIO_36,
GPIO_37,
GPIO_38,
GPIO_39,
GPIO_MAX,
GPIO_NONE
};
typedef enum
{
GPIO_Mux0 = 0,
GPIO_Mux1,
GPIO_Mux2,
GPIO_Mux3
} GPIO_MUX_TypeDef;
typedef enum
{
GPIO_Dx = 0,
UART0_TX,
UART0_RX,
UART0_CTS,
UART0_RTS,
I2C_SCL,
I2C_SDA,
UART1_RX,
UART1_TX,
SIM_IO,
SIM_RST,
SIM_CLK_OUT,
PWM0,
PWM1,
SSI1_CLK,
SSI1_SSN,
SSI1_RX,
SSI1_TX,
PWM0_INV,
PWM1_INV,
PWM2_INV,
PWM3_INV,
} GPIO_FUN_SEL_TypeDef;
typedef enum
{
GPIO_PULLUP = 0,
GPIO_PULLDOWN = 1,
GPIO_NOPULL = 2,
} GPIO_PULL_TypeDef;
typedef enum
{
GPIO_DIR_INPUT = 0,
GPIO_DIR_OUTPUT
} GPIO_DIR_TypeDef;
typedef enum
{
NOT_INT = 0,
NA1_INT,
NA2_INT,
NA3_INT,
NA4_INT,
RIS_EDGE_INT,
NA6_INT,
FAIL_EDGE_INT,
NA8_INT,
RIS_FAIL_EDGE_INT,
} GPIO_INT_TypeDef;
typedef struct
{
uint16_t Pin;
GPIO_MUX_TypeDef Mux;
GPIO_FUN_SEL_TypeDef FunSel;
GPIO_DIR_TypeDef Dir;
GPIO_PULL_TypeDef Pull;
GPIO_INT_TypeDef Int;
} GPIO_InitCfg_t;
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void xc_gpio_init(GPIO_InitCfg_t *init_cfg);
void xc_gpio_mux_ctl(uint8_t num, GPIO_MUX_TypeDef mux);
void xc_gpio_fun_sel(uint8_t num, GPIO_FUN_SEL_TypeDef sel);
void xc_gpio_pull_config(uint8_t num, GPIO_PULL_TypeDef pull);
void xc_gpio_it_config(uint8_t num, GPIO_INT_TypeDef inter);
void xc_gpio_direction_config(uint8_t num, GPIO_DIR_TypeDef direction);
uint32_t xc_gpio_read_pin(uint8_t num);
void xc_gpio_write_pin(uint8_t num, GPIO_PinState pin_state);
void xc_gpio_toggle_pin(uint8_t num);
void gpio_intr_callback(uint64_t intr_sta);
#endif // _XC_DRV_AOTIMER_H_