gpio driver

This commit is contained in:
Thomas Klaehn
2019-07-13 23:22:43 +02:00
parent cc851fc929
commit 7aaac22e6b
7 changed files with 262 additions and 57 deletions

View File

@@ -1,6 +0,0 @@
#ifndef __INC_DEF_H__
#define __INC_DEF_H__
#define HELLO "Hello world!"
#endif // __INC_DEF_H__

15
inc/ftdi_dev.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef __FTDI_DEV_H__
#define __FTDI_DEV_H__
#include <ftdi.h>
struct ftdi_dev {
struct ftdi_context *ftdi;
bool is_open;
unsigned int vendor_id;
unsigned int product_id;
unsigned char bit_mask; /* Mask of used bits */
unsigned char status_mask; /* Mask of current status of used bits */
};
#endif

15
inc/gpio.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef __GPIO_H__
#define __GPIO_H__
struct gpio {
unsigned int pin;
struct ftdi_dev *ftdi_dev;
};
int gpio_open(const struct gpio *gpio);
int gpio_close(const struct gpio *gpio);
int gpio_read(const struct gpio *gpio, unsigned int *value);
int gpio_write(const struct gpio *gpio, unsigned int value);
int gpio_toggle(const struct gpio *gpio);
#endif