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.
36 lines
952 B
36 lines
952 B
#pragma once
|
|
#include "pin.h"
|
|
#include "xs_basic.h"
|
|
#include "xs_log.h"
|
|
|
|
typedef enum {
|
|
kxs_gpio_nopull, //
|
|
kxs_gpio_pullup, //
|
|
kxs_gpio_pulldown, //
|
|
kxs_gpio_od, //
|
|
} xs_gpio_mode_t;
|
|
|
|
typedef enum { kxs_gpio_ain, kxs_gpio_input, kxs_gpio_output } xs_gpio_type_t;
|
|
|
|
typedef enum {
|
|
kxs_gpio_no_irq,
|
|
kxs_gpio_rising_irq,
|
|
kxs_gpio_falling_irq,
|
|
kxs_gpio_rising_and_falling_irq,
|
|
} xs_gpio_irq_t;
|
|
|
|
typedef struct {
|
|
Pin_t pin;
|
|
GPIO_TypeDef *gpio;
|
|
uint16_t pinoff;
|
|
xs_gpio_mode_t mode;
|
|
xs_gpio_type_t gpiotype;
|
|
xs_gpio_irq_t irqtype;
|
|
bool mirror;
|
|
bool inited;
|
|
} xs_gpio_t;
|
|
|
|
void xs_gpio_init_as_input(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, xs_gpio_irq_t irqtype, bool mirror);
|
|
void xs_gpio_init_as_output(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, bool mirror, bool initLevel);
|
|
bool xs_gpio_read(xs_gpio_t *gpio);
|
|
void xs_gpio_write(xs_gpio_t *gpio, bool level);
|