EV-Embedded-Control-System/project/inc/wk_gpio.h

104 lines
2.7 KiB
C

#ifndef __WK_GPIO_H
#define __WK_GPIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* includes -----------------------------------------------------------------------*/
#include "at32f403a_407_wk_config.h"
typedef enum
{
LED_RUN = 0,
RS485_DE1 = 1,
RS485_DE2 = 2,
} wk_gpio_type;
typedef enum
{
In1 = 0,
In2 = 1,
In3 = 2,
In4 = 3,
In5 = 4,
In6 = 5,
In7 = 6,
In8 = 7,
} wk_gpio_input_type;
#define WK_GPIO_NUM 3
#define WK_GPIO_INPUT_NUM 8
//LED
#define LED_RUN_PIN GPIO_PINS_6
#define LED_RUN_GPIO GPIOA
#define LED_RUN_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
//RS485
#define RS485_DE1_PIN GPIO_PINS_3
#define RS485_DE1_GPIO GPIOC
#define RS485_DE1_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
#define RS485_DE2_PIN GPIO_PINS_2
#define RS485_DE2_GPIO GPIOC
#define RS485_DE2_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
typedef struct
{
// uint8_t sig_num;
gpio_type *port;
uint32_t pins;
}ftu_io_t;
#define IN1_PIN GPIO_PINS_8
#define IN1_GPIO GPIOC
#define IN1_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
#define IN2_PIN GPIO_PINS_9
#define IN2_GPIO GPIOC
#define IN2_GPIO_CRM_CLK CRM_GPIOC_PERIPH_CLOCK
#define IN3_PIN GPIO_PINS_8
#define IN3_GPIO GPIOA
#define IN3_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
#define IN4_PIN GPIO_PINS_9
#define IN4_GPIO GPIOA
#define IN4_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
#define IN5_PIN GPIO_PINS_10
#define IN5_GPIO GPIOA
#define IN5_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
#define IN6_PIN GPIO_PINS_11
#define IN6_GPIO GPIOA
#define IN6_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
#define IN7_PIN GPIO_PINS_0
#define IN7_GPIO GPIOA
#define IN7_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
#define IN8_PIN GPIO_PINS_12
#define IN8_GPIO GPIOA
#define IN8_GPIO_CRM_CLK CRM_GPIOA_PERIPH_CLOCK
void at32_gpio_init(wk_gpio_type led);
void at32_led_toggle(wk_gpio_type led);
void at32_gpio_low(wk_gpio_type wk_gpio);
void at32_gpio_high(wk_gpio_type wk_gpio);
uint32_t ftu_input_check(void);
#ifdef __cplusplus
}
#endif
#endif