diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-12-01 01:20:10 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-12-01 01:20:10 +0100 |
commit | 7ded8116d90081851e0ddb1b4bdd77b645f6535c (patch) | |
tree | dc89dbc4269fc0d2e3ac0e43ca8a533371d21531 /fw/fe310/test/test.c | |
parent | 5506d89d97db87f78ab2ba4715c4248a3d49f98f (diff) |
i2c added 16 bit register read/write
Diffstat (limited to 'fw/fe310/test/test.c')
-rw-r--r-- | fw/fe310/test/test.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fw/fe310/test/test.c b/fw/fe310/test/test.c index cda0255..87c1e2b 100644 --- a/fw/fe310/test/test.c +++ b/fw/fe310/test/test.c @@ -24,6 +24,14 @@ #include <stdio.h> +static int reg_read(uint8_t reg, uint8_t *data) { + return eos_i2c_read8(BQ25895_ADDR, reg, data, 1); +} + +static int reg_write(uint8_t reg, uint8_t data) { + return eos_i2c_write8(BQ25895_ADDR, reg, &data, 1); +} + int app_test_uievt(EVEForm *form, uint16_t evt, void *param) { uint8_t data = 0; int rv, ret = 0, i; @@ -32,13 +40,13 @@ int app_test_uievt(EVEForm *form, uint16_t evt, void *param) { case EVE_UIEVT_PAGE_TOUCH: printf("PAGE TOUCH\n"); printf("BQ25895:\n"); - rv = eos_i2c_start(400000); + rv = eos_i2c_start(); if (rv) { printf("I2C BUSY\n"); return 0; } for (i=0; i<0x15; i++) { - rv = eos_i2c_read8(BQ25895_ADDR, i, &data); + rv = reg_read(i, &data); if (!rv) printf("REG%02x: %02x\n", i, data); } eos_i2c_stop(); |