projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for more i2c devices.
[bertos.git]
/
bertos
/
drv
/
i2c.h
diff --git
a/bertos/drv/i2c.h
b/bertos/drv/i2c.h
index eea0073a1dd016859485fbbea077a4c0f6eb710c..75fb54a51ed1b2e7e1cec744c3afdc10cb9b8dbe 100644
(file)
--- a/
bertos/drv/i2c.h
+++ b/
bertos/drv/i2c.h
@@
-45,6
+45,11
@@
#include "cfg/cfg_i2c.h"
#include "cfg/cfg_i2c.h"
+#define LOG_LEVEL I2C_LOG_LEVEL
+#define LOG_FORMAT I2C_LOG_FORMAT
+
+#include <cfg/log.h>
+
#include <cfg/compiler.h>
#include <cfg/macros.h>
#include <cfg/debug.h>
#include <cfg/compiler.h>
#include <cfg/macros.h>
#include <cfg/debug.h>
@@
-180,6
+185,9
@@
typedef struct I2c
#include CPU_HEADER(i2c)
#include CPU_HEADER(i2c)
+void i2c_swSend(struct I2c *i2c, const void *_buf, size_t count);
+void i2c_swRecv(struct I2c *i2c, void *_buf, size_t count);
+
INLINE void i2c_start(I2c *i2c, uint16_t slave_addr, size_t size)
{
ASSERT(i2c->vt);
INLINE void i2c_start(I2c *i2c, uint16_t slave_addr, size_t size)
{
ASSERT(i2c->vt);
@@
-214,12
+222,16
@@
INLINE uint8_t i2c_get(I2c *i2c)
ASSERT(i2c->vt);
ASSERT(i2c->vt->get);
ASSERT(i2c->vt);
ASSERT(i2c->vt->get);
- ASSERT(i2c->xfer_size
>= 1
);
+ ASSERT(i2c->xfer_size);
ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_R);
if (!i2c->errors)
ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_R);
if (!i2c->errors)
- return i2c->vt->get(i2c);
+ {
+ uint8_t data = i2c->vt->get(i2c);
+ i2c->xfer_size--;
+ return data;
+ }
else
return 0xFF;
}
else
return 0xFF;
}
@@
-230,12
+242,15
@@
INLINE void i2c_put(I2c *i2c, uint8_t data)
ASSERT(i2c->vt);
ASSERT(i2c->vt->put);
ASSERT(i2c->vt);
ASSERT(i2c->vt->put);
- ASSERT(i2c->xfer_size
>= 1
);
+ ASSERT(i2c->xfer_size);
ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_W);
if (!i2c->errors)
ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_W);
if (!i2c->errors)
+ {
i2c->vt->put(i2c, data);
i2c->vt->put(i2c, data);
+ i2c->xfer_size--;
+ }
}
INLINE void i2c_send(I2c *i2c, const void *_buf, size_t count)
}
INLINE void i2c_send(I2c *i2c, const void *_buf, size_t count)
@@
-276,6
+291,12
@@
INLINE int i2c_error(I2c *i2c)
ASSERT(i2c);
int err = i2c->errors;
i2c->errors = 0;
ASSERT(i2c);
int err = i2c->errors;
i2c->errors = 0;
+
+ LOG_ERRB(
+ if (err)
+ LOG_ERR("err[%02x]\n", err);
+ );
+
return err;
}
return err;
}