1111// between the two codebases and must be kept in sync.
1212
1313#define PBDRV_RPROC_EV3_PRU1_NUM_PWM_CHANNELS 4
14+ #define PBDRV_RPROC_EV3_PRU1_NUM_I2C_CHANNELS 4
15+
16+ #define PBDRV_RPROC_EV3_PRU1_I2C_CLK_SPEED_HZ 10000
17+
18+ // I2C command bits
19+ // Start an I2C transaction
20+ #define PBDRV_RPROC_EV3_PRU1_I2C_CMD_START 0x01
21+ // Generate a stop, clock pulse, and start instead of a repeated start
22+ // Used for the NXT ultrasonic sensor.
23+ #define PBDRV_RPROC_EV3_PRU1_I2C_CMD_NXT_QUIRK 0x02
24+
25+ // I2C status bits
26+ // Indicates transaction is complete
27+ #define PBDRV_RPROC_EV3_PRU1_I2C_STAT_DONE 0x80
28+ // Mask for the status code
29+ #define PBDRV_RPROC_EV3_PRU1_I2C_STAT_MASK 0x7f
30+
31+ // I2C transaction status codes
32+ enum {
33+ PBDRV_RPROC_EV3_PRU1_I2C_STAT_OK ,
34+ PBDRV_RPROC_EV3_PRU1_I2C_STAT_TIMEOUT ,
35+ PBDRV_RPROC_EV3_PRU1_I2C_STAT_NAK ,
36+ };
37+
38+ #define PBDRV_RPROC_EV3_PRU1_I2C_PACK_FLAGS (daddr , rlen , wlen , flags ) \
39+ ((((daddr) & 0xff) << 24) | \
40+ (((rlen) & 0xff) << 16) | \
41+ (((wlen) & 0xff) << 8) | \
42+ ((flags) & 0xff))
43+
44+ typedef struct {
45+ // bit[7:0] status and flags
46+ // bit[15:8] write length
47+ // bit[23:16] read length
48+ // bit[31:24] device address (unshifted)
49+ uint32_t flags ;
50+ // Physical address of a transaction buffer
51+ uint8_t * buffer ;
52+ } pbdrv_rproc_ev3_pru1_i2c_command_t ;
1453
1554typedef struct {
1655 union {
@@ -25,6 +64,7 @@ typedef struct {
2564 // of them and route ARM accesses through the PRU.
2665 uint32_t gpio_bank_01_dir_set ;
2766 uint32_t gpio_bank_01_dir_clr ;
67+ pbdrv_rproc_ev3_pru1_i2c_command_t i2c [PBDRV_RPROC_EV3_PRU1_NUM_I2C_CHANNELS ];
2868} pbdrv_rproc_ev3_pru1_shared_ram_t ;
2969
3070#endif // _INTERNAL_PBDRV_RPROC_EV3_PRU1_H_
0 commit comments