create library

This commit is contained in:
Thomas Klaehn
2019-07-25 10:26:27 +02:00
parent 6aa21acac1
commit 86144d9e19
6 changed files with 293 additions and 117 deletions

24
inc/gpio_sys.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef __GPIO_SYS__
#define __GPIO_SYS__
enum direction {
IN = 0,
OUT
};
enum pin_state {
LOW = 0,
HIGH
};
struct gpio_sys {
int pin;
int direction;
};
int gpio_open(const struct gpio_sys *gpio);
int gpio_close(const struct gpio_sys *gpio);
int gpio_read(const struct gpio_sys *gpio);
int gpio_write(const struct gpio_sys *gpio, int value);
#endif

View File

@@ -1,19 +0,0 @@
#ifndef __I2C_BB_H__
#define __I2C_BB_H__
#include <gpio_ftdi/gpio.h>
struct i2c_bb {
struct gpio *sda;
struct gpio *scl;
};
int i2c_open(const struct i2c_bb *i2c);
int i2c_close(const struct i2c_bb *i2c);
void start_condition(const struct i2c_bb *i2c);
void stop_condition(const struct i2c_bb *i2c);
bool write_byte(const struct i2c_bb *i2c, unsigned char byte);
unsigned char read_byte(const struct i2c_bb *i2c, bool ack);
#endif