Skip to content

Commit e6ba3f5

Browse files
committed
pbio/drv/i2c/i2c_ev3.c: Actually initialize I2C
This calls the I2C init function from core.c and removes the platform data which is unneeded with how we're using the PRU.
1 parent a04fac9 commit e6ba3f5

File tree

3 files changed

+7
-36
lines changed

3 files changed

+7
-36
lines changed

lib/pbio/drv/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clock/clock.h"
1919
#include "counter/counter.h"
2020
#include "display/display.h"
21+
#include "i2c/i2c.h"
2122
#include "imu/imu.h"
2223
#include "led/led_array.h"
2324
#include "led/led.h"
@@ -49,6 +50,7 @@ void pbdrv_init(void) {
4950
pbdrv_charger_init();
5051
pbdrv_counter_init();
5152
pbdrv_display_init();
53+
pbdrv_i2c_init();
5254
pbdrv_imu_init();
5355
pbdrv_led_array_init();
5456
pbdrv_led_init();

lib/pbio/drv/i2c/i2c_ev3.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <pbio/util.h>
1717

1818
#include <pbdrv/i2c.h>
19-
#include "i2c_ev3.h"
2019

2120
#include "../rproc/rproc_ev3.h"
2221

@@ -33,11 +32,8 @@
3332
#endif
3433

3534
struct _pbdrv_i2c_dev_t {
36-
/** Platform-specific data */
37-
const pbdrv_i2c_ev3_platform_data_t *pdata;
38-
//
39-
// TODO: i2c state goes here.
40-
//
35+
bool is_initialized;
36+
uint8_t pru_i2c_idx;
4137
};
4238

4339
static pbdrv_i2c_dev_t i2c_devs[PBDRV_RPROC_EV3_PRU1_NUM_I2C_BUSES];
@@ -47,7 +43,7 @@ pbio_error_t pbdrv_i2c_get_instance(uint8_t id, pbdrv_i2c_dev_t **i2c_dev) {
4743
return PBIO_ERROR_INVALID_ARG;
4844
}
4945
pbdrv_i2c_dev_t *dev = &i2c_devs[id];
50-
if (!dev->pdata) {
46+
if (!dev->is_initialized) {
5147
// has not been initialized yet
5248
return PBIO_ERROR_AGAIN;
5349
}
@@ -62,9 +58,9 @@ pbio_error_t pbdrv_i2c_placeholder_operation(pbdrv_i2c_dev_t *i2c_dev, const cha
6258

6359
void pbdrv_i2c_init(void) {
6460
for (int i = 0; i < PBDRV_RPROC_EV3_PRU1_NUM_I2C_BUSES; i++) {
65-
const pbdrv_i2c_ev3_platform_data_t *pdata = &pbdrv_i2c_ev3_platform_data[i];
6661
pbdrv_i2c_dev_t *i2c = &i2c_devs[i];
67-
i2c->pdata = pdata;
62+
i2c->pru_i2c_idx = i;
63+
i2c->is_initialized = true;
6864
}
6965
}
7066

lib/pbio/drv/i2c/i2c_ev3.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)