CMake构建CH58x项目,脱离eclipse使用Clion或者Vscode编写代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

89 lines
2.3 KiB

#ifndef API_GPIO_H
#define API_GPIO_H
#include "CH58x_common.h"
#define GPIOX (0xF0000000)
#define GPIOPIN (0x0FFFFFFF)
#define GPIOA (1<< 28)
#define GPIOB (2<< 28)
typedef enum {
// 自定义GPIO
PA_0 = 0x00000001 | GPIOA,
PA_1 = 0x00000002 | GPIOA,
PA_2 = 0x00000004 | GPIOA,
PA_3 = 0x00000008 | GPIOA,
PA_4 = 0x00000010 | GPIOA,
PA_5 = 0x00000020 | GPIOA,
PA_6 = 0x00000040 | GPIOA,
PA_7 = 0x00000080 | GPIOA,
PA_8 = 0x00000100 | GPIOA,
PA_9 = 0x00000200 | GPIOA,
PA_10 = 0x00000400 | GPIOA,
PA_11 = 0x00000800 | GPIOA,
PA_12 = 0x00001000 | GPIOA,
PA_13 = 0x00002000 | GPIOA,
PA_14 = 0x00004000 | GPIOA,
PA_15 = 0x00008000 | GPIOA,
PA_16 = 0x00010000 | GPIOA,
PA_17 = 0x00020000 | GPIOA,
PA_18 = 0x00040000 | GPIOA,
PA_19 = 0x00080000 | GPIOA,
PA_20 = 0x00100000 | GPIOA,
PA_21 = 0x00200000 | GPIOA,
PA_22 = 0x00400000 | GPIOA,
PA_23 = 0x00800000 | GPIOA,
PA_ALL = 0x0FFFFFFF | GPIOA,
PB_0 = 0x00000001 | GPIOB,
PB_1 = 0x00000002 | GPIOB,
PB_2 = 0x00000004 | GPIOB,
PB_3 = 0x00000008 | GPIOB,
PB_4 = 0x00000010 | GPIOB,
PB_5 = 0x00000020 | GPIOB,
PB_6 = 0x00000040 | GPIOB,
PB_7 = 0x00000080 | GPIOB,
PB_8 = 0x00000100 | GPIOB,
PB_9 = 0x00000200 | GPIOB,
PB_10 = 0x00000400 | GPIOB,
PB_11 = 0x00000800 | GPIOB,
PB_12 = 0x00001000 | GPIOB,
PB_13 = 0x00002000 | GPIOB,
PB_14 = 0x00004000 | GPIOB,
PB_15 = 0x00008000 | GPIOB,
PB_16 = 0x00010000 | GPIOB,
PB_17 = 0x00020000 | GPIOB,
PB_18 = 0x00040000 | GPIOB,
PB_19 = 0x00080000 | GPIOB,
PB_20 = 0x00100000 | GPIOB,
PB_21 = 0x00200000 | GPIOB,
PB_22 = 0x00400000 | GPIOB,
PB_23 = 0x00800000 | GPIOB,
PB_ALL = 0x0FFFFFFF | GPIOB,
} GpioPin_t;
typedef struct {
void *context;
void (*Callback)(void *context);
} GPIOITCB_Typedef;
#define GPIOAITSIZE (16)
#define GPIOBITSIZE (16)
typedef struct {
GPIOITCB_Typedef GPIOA_Callback[GPIOAITSIZE];
GPIOITCB_Typedef GPIOB_Callback[GPIOBITSIZE];
} GpioItCallback_t;
void Gpio_Init(GpioPin_t gpio, GPIOModeTypeDef mode);
void Gpio_Set(GpioPin_t gpio);
void Gpio_Reset(GpioPin_t gpio);
bool Gpio_Read(GpioPin_t gpio);
void Gpio_Inverse(GpioPin_t gpio);
void Gpio_IT_Init(GpioPin_t gpio, GPIOModeTypeDef mode, GPIOITModeTpDef modeIt, void(Callback)(void *), void *context);
#endif