summaryrefslogtreecommitdiff
path: root/fw/fe310/test
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-12-01 01:20:10 +0100
committerUros Majstorovic <majstor@majstor.org>2021-12-01 01:20:10 +0100
commit7ded8116d90081851e0ddb1b4bdd77b645f6535c (patch)
treedc89dbc4269fc0d2e3ac0e43ca8a533371d21531 /fw/fe310/test
parent5506d89d97db87f78ab2ba4715c4248a3d49f98f (diff)
i2c added 16 bit register read/write
Diffstat (limited to 'fw/fe310/test')
-rw-r--r--fw/fe310/test/cam.c4
-rw-r--r--fw/fe310/test/test.c12
2 files changed, 13 insertions, 3 deletions
diff --git a/fw/fe310/test/cam.c b/fw/fe310/test/cam.c
index 3162b40..2cef686 100644
--- a/fw/fe310/test/cam.c
+++ b/fw/fe310/test/cam.c
@@ -140,11 +140,13 @@ void app_cam(EVEWindow *window, EVEViewStack *stack) {
eve_gpio_set(EVE_GPIO_CAM, 1);
eos_time_sleep(100);
- rv = eos_i2c_start(100000);
+ eos_i2c_speed(100000);
+ rv = eos_i2c_start();
if (!rv) rv = eos_ov2640_init();
if (!rv) rv = eos_ov2640_set_pixfmt(PIXFORMAT_JPEG);
if (!rv) rv = eos_ov2640_set_framesize(FRAMESIZE_VGA);
eos_i2c_stop();
+ eos_i2c_speed(EOS_I2C_SPEED);
if (!rv) {
printf("CAM INIT\n");
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();