Skip to content

Commit 12b3b45

Browse files
committed
blah blah pru
1 parent 6bd9972 commit 12b3b45

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

lib/pbio/drv/i2c/i2c_ev3.c

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "../drv/gpio/gpio_ev3.h"
2020

21+
#include <pbdrv/compiler.h>
2122
#include <pbdrv/gpio.h>
2223
#include <pbio/error.h>
2324
#include <pbio/os.h>
@@ -76,8 +77,14 @@ static inline void delaydelay() {
7677
for (int i = 0; i < 100; i++) __asm__ volatile("");
7778
}
7879

80+
extern void panic_puts(const char *c);
81+
extern void panic_putu8(uint8_t x);
82+
83+
uint8_t i2c_wip_buf[16];
84+
7985
pbio_error_t ev3_i2c_wip_process_thread(pbio_os_state_t *state, void *context) {
8086
static pbio_os_timer_t timer;
87+
static int i;
8188
// static int bit;
8289
// static uint8_t byte;
8390

@@ -88,33 +95,52 @@ pbio_error_t ev3_i2c_wip_process_thread(pbio_os_state_t *state, void *context) {
8895
pbdrv_gpio_out_low(&test_sda);
8996
pbdrv_gpio_input(&test_sda);
9097

91-
PBIO_OS_AWAIT_MS(state, &timer, 1000);
92-
*(volatile uint8_t *)(0x80010004) = 0xaa;
98+
PBIO_OS_AWAIT_MS(state, &timer, 100);
99+
i2c_wip_buf[0] = 0x10;
100+
pbdrv_compiler_memory_barrier();
101+
*(volatile uint32_t *)(0x80010008) = (uint32_t)i2c_wip_buf;
102+
*(volatile uint32_t *)(0x80010004) = 0x010601aa;
93103

94-
PBIO_OS_AWAIT_UNTIL(state, *(volatile uint8_t *)(0x80010004) == 0x55);
104+
pbio_os_timer_set(&timer, 1000);
105+
PBIO_OS_AWAIT_UNTIL(state, *(volatile uint8_t *)(0x80010004) == 0x55 || pbio_os_timer_is_expired(&timer));
95106
debug_pr("i2c test done\r\n");
96-
debug_pr("i2c ack 0: %d\r\n", *(volatile uint8_t *)(0x80010004 + 1));
97-
debug_pr("i2c ack 1: %d\r\n", *(volatile uint8_t *)(0x80010004 + 2));
107+
debug_pr("i2c flags %08x\r\n", *(volatile uint32_t *)(0x80010004));
108+
debug_pr("i2c delays %d\r\n", *(volatile uint32_t *)(0x8001000c));
98109

99-
uint32_t x;
100-
x = *(volatile uint32_t *)(0x80010014 + 0);
101-
debug_pr("i2c debug time %d\r\n", x);
102-
x = *(volatile uint32_t *)(0x80010014 + 4);
103-
debug_pr("i2c debug 0 clk%d dat%d\r\n", !!(x & (1 << 12)), !!(x & (1 << (14 + 16))));
104-
x = *(volatile uint32_t *)(0x80010014 + 8);
105-
debug_pr("i2c debug 1 clk%d dat%d\r\n", !!(x & (1 << 12)), !!(x & (1 << (14 + 16))));
110+
PBIO_OS_AWAIT_MS(state, &timer, 100);
106111

107-
debug_pr("i2c ack 2: %d\r\n", *(volatile uint8_t *)(0x80010004 + 3));
112+
for (i = 0; i < 512; i++) {
113+
panic_putu8(*(volatile uint8_t *)(0x01C32000 + i));
114+
if (i % 16 == 15) {
115+
panic_puts("\r\n");
116+
}
117+
}
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));
108120

109-
debug_pr("i2c get 0: %02x\r\n", *(volatile uint8_t *)(0x80010004 + 4));
110-
debug_pr("i2c get 1: %02x\r\n", *(volatile uint8_t *)(0x80010004 + 5));
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));
111133

112134
debug_pr("i2c test end C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
113135

114136
PBIO_OS_AWAIT_MS(state, &timer, 100);
115137

116138
debug_pr("i2c test end 2 C%d D%d\r\n", pbdrv_gpio_input(&test_scl), pbdrv_gpio_input(&test_sda));
117139

140+
for (i = 0; i < 6; i++) {
141+
debug_pr("i2c get %02x\r\n", i2c_wip_buf[1 + i]);
142+
}
143+
118144
PBIO_OS_ASYNC_END(PBIO_SUCCESS);
119145
}
120146

lib/pbio/drv/pwm/pwm_ev3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
// This needs to match the interface expected by the PRU firmware
2828
typedef struct shared_ram {
2929
uint8_t pwms[PBDRV_PWM_EV3_NUM_CHANNELS];
30+
uint32_t dummy0;
31+
uint32_t dummy1;
32+
uint32_t dummy2;
3033
} shared_ram;
3134
static volatile shared_ram pru1_shared_ram __attribute__((section(".shared1")));
3235

lib/pbio/platform/ev3/platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,12 @@ unsigned int EDMAVersionGet(void) {
398398
return 1;
399399
}
400400

401-
static void panic_puts(const char *c) {
401+
void panic_puts(const char *c) {
402402
while (*c) {
403403
UARTCharPut(SOC_UART_1_REGS, *(c++));
404404
}
405405
}
406-
static void panic_putu8(uint8_t x) {
406+
void panic_putu8(uint8_t x) {
407407
const char *hex = "0123456789ABCDEF";
408408
UARTCharPut(SOC_UART_1_REGS, hex[x >> 4]);
409409
UARTCharPut(SOC_UART_1_REGS, hex[x & 0xf]);

0 commit comments

Comments
 (0)