Skip to content

Commit 238e9b8

Browse files
committed
repeated start test
1 parent 12b3b45 commit 238e9b8

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

lib/pbio/drv/i2c/i2c_ev3.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,40 @@ pbio_error_t ev3_i2c_wip_process_thread(pbio_os_state_t *state, void *context) {
9696
pbdrv_gpio_input(&test_sda);
9797

9898
PBIO_OS_AWAIT_MS(state, &timer, 100);
99+
debug_pr("i2c test start C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
100+
99101
i2c_wip_buf[0] = 0x10;
102+
i2c_wip_buf[1] = 0xaa;
103+
i2c_wip_buf[2] = 0x55;
104+
i2c_wip_buf[3] = 0x12;
105+
i2c_wip_buf[4] = 0x34;
100106
pbdrv_compiler_memory_barrier();
101107
*(volatile uint32_t *)(0x80010008) = (uint32_t)i2c_wip_buf;
102-
*(volatile uint32_t *)(0x80010004) = 0x010601aa;
108+
*(volatile uint32_t *)(0x80010004) = 0x17000501;
109+
// *(volatile uint32_t *)(0x80010004) = 0x01060103;
103110

104111
pbio_os_timer_set(&timer, 1000);
105-
PBIO_OS_AWAIT_UNTIL(state, *(volatile uint8_t *)(0x80010004) == 0x55 || pbio_os_timer_is_expired(&timer));
112+
PBIO_OS_AWAIT_UNTIL(state, *(volatile uint8_t *)(0x80010004) & 0x80 || pbio_os_timer_is_expired(&timer));
106113
debug_pr("i2c test done\r\n");
107114
debug_pr("i2c flags %08x\r\n", *(volatile uint32_t *)(0x80010004));
108-
debug_pr("i2c delays %d\r\n", *(volatile uint32_t *)(0x8001000c));
115+
debug_pr("i2c max time %d\r\n", *(volatile uint32_t *)(0x8001000c));
116+
117+
debug_pr("i2c test end C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
118+
119+
PBIO_OS_AWAIT_MS(state, &timer, 100);
120+
121+
debug_pr("i2c test end 2 C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
122+
123+
// NEW
124+
i2c_wip_buf[0] = 0x0e;
125+
pbdrv_compiler_memory_barrier();
126+
*(volatile uint32_t *)(0x80010004) = 0x17060101;
127+
128+
pbio_os_timer_set(&timer, 1000);
129+
PBIO_OS_AWAIT_UNTIL(state, *(volatile uint8_t *)(0x80010004) & 0x80 || pbio_os_timer_is_expired(&timer));
130+
debug_pr("i2c #2 test done\r\n");
131+
debug_pr("i2c #2 flags %08x\r\n", *(volatile uint32_t *)(0x80010004));
132+
debug_pr("i2c #2 max time %d\r\n", *(volatile uint32_t *)(0x8001000c));
109133

110134
PBIO_OS_AWAIT_MS(state, &timer, 100);
111135

@@ -115,27 +139,6 @@ pbio_error_t ev3_i2c_wip_process_thread(pbio_os_state_t *state, void *context) {
115139
panic_puts("\r\n");
116140
}
117141
}
118-
// debug_pr("i2c ack 0: %d\r\n", *(volatile uint8_t *)(0x80010004 + 1));
119-
// debug_pr("i2c ack 1: %d\r\n", *(volatile uint8_t *)(0x80010004 + 2));
120-
121-
// uint32_t x;
122-
// x = *(volatile uint32_t *)(0x80010014 + 0);
123-
// debug_pr("i2c debug time %d\r\n", x);
124-
// x = *(volatile uint32_t *)(0x80010014 + 4);
125-
// debug_pr("i2c debug 0 clk%d dat%d\r\n", !!(x & (1 << 12)), !!(x & (1 << (14 + 16))));
126-
// x = *(volatile uint32_t *)(0x80010014 + 8);
127-
// debug_pr("i2c debug 1 clk%d dat%d\r\n", !!(x & (1 << 12)), !!(x & (1 << (14 + 16))));
128-
129-
// debug_pr("i2c ack 2: %d\r\n", *(volatile uint8_t *)(0x80010004 + 3));
130-
131-
// debug_pr("i2c get 0: %02x\r\n", *(volatile uint8_t *)(0x80010004 + 4));
132-
// debug_pr("i2c get 1: %02x\r\n", *(volatile uint8_t *)(0x80010004 + 5));
133-
134-
debug_pr("i2c test end C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
135-
136-
PBIO_OS_AWAIT_MS(state, &timer, 100);
137-
138-
debug_pr("i2c test end 2 C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
139142

140143
for (i = 0; i < 6; i++) {
141144
debug_pr("i2c get %02x\r\n", i2c_wip_buf[1 + i]);

lib/pbio/drv/pwm/pwm_ev3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct shared_ram {
3030
uint32_t dummy0;
3131
uint32_t dummy1;
3232
uint32_t dummy2;
33+
uint32_t dummy3;
3334
} shared_ram;
3435
static volatile shared_ram pru1_shared_ram __attribute__((section(".shared1")));
3536

0 commit comments

Comments
 (0)