58 lines
1.8 KiB
C
58 lines
1.8 KiB
C
#ifndef __BSP_GPIO_H_
|
|
#define __BSP_GPIO_H_
|
|
|
|
#include "xinc_m0.h"
|
|
|
|
#define DETECT_INTER_NUM(num,val) ((num>=32)?((val[1]>>(num&0x1F))&0x01):((val[0]>>num)&0x01))
|
|
|
|
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{
|
|
NOT_INT=0,
|
|
NA1_INT,
|
|
NA2_INT,
|
|
NA3_INT,
|
|
NA4_INT,
|
|
RIS_EDGE_INT,//上升沿中断
|
|
NA6_INT,
|
|
FAIL_EDGE_INT,//下降沿中断
|
|
|
|
}GPIO_INT_TypeDef;
|
|
|
|
typedef enum{
|
|
GPIO_PIN_0=0,GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3,GPIO_PIN_4, GPIO_PIN_5, GPIO_PIN_6, GPIO_PIN_7,
|
|
GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10,GPIO_PIN_11,GPIO_PIN_12,GPIO_PIN_13,GPIO_PIN_14,GPIO_PIN_15,
|
|
GPIO_PIN_16,GPIO_PIN_17,GPIO_PIN_18,GPIO_PIN_19,GPIO_PIN_20,GPIO_PIN_21,GPIO_PIN_22,GPIO_PIN_23,
|
|
GPIO_PIN_24,GPIO_PIN_25,GPIO_PIN_26,GPIO_PIN_27,GPIO_PIN_28,GPIO_PIN_29,GPIO_PIN_30,GPIO_PIN_31,
|
|
}GPIO_Pin_TypeDef;
|
|
|
|
typedef enum{
|
|
GPIO_Mode_Input_Up=0, /*上拉输入*/
|
|
GPIO_Mode_Input_Down, /*下拉输入*/
|
|
GPIO_Mode_Input_Float,/*浮空输入*/
|
|
}GPIO_InputMode_TypeDef;
|
|
|
|
|
|
|
|
typedef void (*IoHandler_callback)(uint32_t val);
|
|
extern void Init_gpio(void);
|
|
extern void gpio_Register_Callback(IoHandler_callback callback);
|
|
extern void gpio_direction_input(uint8_t num, uint8_t pull_up_type);
|
|
extern uint8_t gpio_input_val(uint8_t num);
|
|
extern void gpio_output_low(uint8_t num);
|
|
extern void gpio_output_high(uint8_t num);
|
|
extern void gpio_mux_ctl(uint8_t num,uint8_t mux);
|
|
extern void gpio_mux_ctl_u(uint8_t num,uint8_t mux); //(num:32-34)
|
|
|
|
extern void gpio_fun_inter(uint8_t num,uint8_t inter);
|
|
extern void gpio_fun_sel(uint8_t num,uint8_t sel);
|
|
extern void gpio_direction_output(uint8_t num);
|
|
|
|
#endif
|
|
|