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.
35 lines
729 B
35 lines
729 B
#ifndef __GPIO__H_____
|
|
#define __GPIO__H_____
|
|
|
|
#include <stdint.h>
|
|
#include "pins.h"
|
|
|
|
#define GPIO_INPUT (0)
|
|
#define GPIO_OUTPUT (1)
|
|
#define GPIO_AF (2)
|
|
#define GPIO_AN (3)
|
|
|
|
#define GPIO_FLAG_PP (0x0 << 4)
|
|
#define GPIO_FLAG_OD (0x1 << 4)
|
|
|
|
#define GPIO_FLAG_PU (0x1 << 8)
|
|
#define GPIO_FLAG_PD (0x2 << 8)
|
|
|
|
#define GPIO_SPEED_LOW (0x00 << 12)
|
|
#define GPIO_SPEED_MUEDIUM (0x01 << 12)
|
|
#define GPIO_SPEED_FAST (0x02 << 12)
|
|
#define GPIO_SPEED_HIGH (0x03 << 12)
|
|
|
|
int gpio_init(uint32_t pin, uint32_t dir);
|
|
|
|
int gpio_read(uint32_t pin);
|
|
|
|
int gpio_write(uint32_t pin, int value);
|
|
|
|
int gpio_toggle(uint32_t pin);
|
|
|
|
#define gpio_clear(pin) gpio_write((pin), 0)
|
|
#define gpio_set(pin) gpio_write((pin), 1)
|
|
|
|
#endif
|
|
|
|
|