Test: switch to gpio_sys.
This commit is contained in:
parent
7f5d18d554
commit
6b0f6f3093
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@ -4,7 +4,7 @@
|
|||||||
"name": "Linux",
|
"name": "Linux",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/**",
|
||||||
"/usr/include/libgpio_ftdi"
|
"/usr/include/libgpio_sys"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"defines": [],
|
||||||
"compilerPath": "/usr/bin/clang",
|
"compilerPath": "/usr/bin/clang",
|
||||||
|
@ -23,9 +23,9 @@ int i2c_open(const struct i2c_bb *i2c)
|
|||||||
assert(NULL != i2c);
|
assert(NULL != i2c);
|
||||||
|
|
||||||
res = gpio_open(i2c->sda);
|
res = gpio_open(i2c->sda);
|
||||||
res |= gpio_direction(i2c->sda, OUT);
|
res |= gpio_direction(i2c->sda, 1);
|
||||||
res |= gpio_open(i2c->scl);
|
res |= gpio_open(i2c->scl);
|
||||||
res |= gpio_direction(i2c->scl, OUT);
|
res |= gpio_direction(i2c->scl, 1);
|
||||||
res |= gpio_write(i2c->sda, 1);
|
res |= gpio_write(i2c->sda, 1);
|
||||||
res |= gpio_write(i2c->scl, 1);
|
res |= gpio_write(i2c->scl, 1);
|
||||||
|
|
||||||
@ -170,11 +170,11 @@ static uint8_t read_bit(const struct i2c_bb *i2c)
|
|||||||
gpio_write(i2c->sda, 1);
|
gpio_write(i2c->sda, 1);
|
||||||
usleep(5);
|
usleep(5);
|
||||||
gpio_write(i2c->scl, 1);
|
gpio_write(i2c->scl, 1);
|
||||||
gpio_direction(i2c->sda, IN);
|
gpio_direction(i2c->sda, 0);
|
||||||
usleep(5);
|
usleep(5);
|
||||||
res = gpio_read(i2c->sda);
|
res = gpio_read(i2c->sda);
|
||||||
gpio_write(i2c->scl, 0);
|
gpio_write(i2c->scl, 0);
|
||||||
gpio_direction(i2c->sda, OUT);
|
gpio_direction(i2c->sda, 1);
|
||||||
|
|
||||||
if(res < 0) {
|
if(res < 0) {
|
||||||
res = 0;
|
res = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef __MOCK_FTDI_H__
|
#ifndef __MOCK_GPIO_H__
|
||||||
#define __MOCK_FTDI_H__
|
#define __MOCK_GPIO_H__
|
||||||
|
|
||||||
#include <fff.h>
|
#include <fff.h>
|
||||||
|
|
||||||
@ -7,8 +7,8 @@ DEFINE_FFF_GLOBALS;
|
|||||||
|
|
||||||
DECLARE_FAKE_VALUE_FUNC(int, gpio_open, const struct gpio_sys *);
|
DECLARE_FAKE_VALUE_FUNC(int, gpio_open, const struct gpio_sys *);
|
||||||
DECLARE_FAKE_VALUE_FUNC(int, gpio_close, const struct gpio_sys *);
|
DECLARE_FAKE_VALUE_FUNC(int, gpio_close, const struct gpio_sys *);
|
||||||
|
DECLARE_FAKE_VALUE_FUNC(int, gpio_direction, struct gpio_sys *, int);
|
||||||
DECLARE_FAKE_VALUE_FUNC(int, gpio_read, const struct gpio_sys *);
|
DECLARE_FAKE_VALUE_FUNC(int, gpio_read, const struct gpio_sys *);
|
||||||
DECLARE_FAKE_VALUE_FUNC(int, gpio_write, const struct gpio_sys *, int);
|
DECLARE_FAKE_VALUE_FUNC(int, gpio_write, const struct gpio_sys *, int);
|
||||||
DECLARE_FAKE_VALUE_FUNC(int, gpio_toggle, const struct gpio_sys *);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,7 +4,7 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
#include <utest.h>
|
#include <utest.h>
|
||||||
#include <mock_ftdi.h>
|
#include <mock_gpio.h>
|
||||||
|
|
||||||
#include <i2c_bb.h>
|
#include <i2c_bb.h>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
#include <utest.h>
|
#include <utest.h>
|
||||||
#include <mock_ftdi.h>
|
#include <mock_gpio.h>
|
||||||
|
|
||||||
#include <i2c_bb.h>
|
#include <i2c_bb.h>
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <mock_ftdi.h>
|
#include <mock_gpio.h>
|
||||||
|
|
||||||
DEFINE_FFF_GLOBALS;
|
DEFINE_FFF_GLOBALS;
|
||||||
|
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, gpio_open, const struct gpio_sys *);
|
DEFINE_FAKE_VALUE_FUNC(int, gpio_open, const struct gpio_sys *);
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, gpio_close, const struct gpio_sys *);
|
DEFINE_FAKE_VALUE_FUNC(int, gpio_close, const struct gpio_sys *);
|
||||||
|
DEFINE_FAKE_VALUE_FUNC(int, gpio_direction, struct gpio_sys *, int);
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, gpio_read, const struct gpio_sys *);
|
DEFINE_FAKE_VALUE_FUNC(int, gpio_read, const struct gpio_sys *);
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, gpio_write, const struct gpio_sys *, int);
|
DEFINE_FAKE_VALUE_FUNC(int, gpio_write, const struct gpio_sys *, int);
|
||||||
DEFINE_FAKE_VALUE_FUNC(int, gpio_toggle, const struct gpio_sys *);
|
|
Loading…
x
Reference in New Issue
Block a user