Skip to content

Commit 274b15c

Browse files
committed
alif/machine_i2c_target: Update bindings.
Signed-off-by: Damien George <[email protected]>
1 parent 46236eb commit 274b15c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ports/alif/machine_i2c_target.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ typedef struct _machine_i2c_target_obj_t {
4141
uint8_t state;
4242
} machine_i2c_target_obj_t;
4343

44-
static machine_i2c_target_data_t i2c_target_data[4];
45-
4644
static machine_i2c_target_obj_t machine_i2c_target_obj[] = {
4745
#if defined(MICROPY_HW_I2C0_SCL)
4846
[0] = {{&machine_i2c_target_type}, (I2C_Type *)I2C0_BASE, I2C0_IRQ_IRQn, MICROPY_HW_I2C0_SCL, MICROPY_HW_I2C0_SDA},
@@ -69,7 +67,7 @@ static machine_i2c_target_obj_t machine_i2c_target_obj[] = {
6967

7068
static void i2c_target_irq_handler(machine_i2c_target_obj_t *self) {
7169
unsigned int i2c_id = self - &machine_i2c_target_obj[0];
72-
machine_i2c_target_data_t *data = &i2c_target_data[i2c_id];
70+
machine_i2c_target_data_t *data = &machine_i2c_target_data[i2c_id];
7371
I2C_Type *i2c = self->i2c;
7472

7573
// Get the interrupt status.
@@ -137,6 +135,10 @@ void I2C3_IRQHandler(void) {
137135
/******************************************************************************/
138136
// I2CTarget port implementation
139137

138+
static inline size_t mp_machine_i2c_target_get_index(machine_i2c_target_obj_t *self) {
139+
return self - &machine_i2c_target_obj[0];
140+
}
141+
140142
static void mp_machine_i2c_target_deinit_all_port(void) {
141143
}
142144

@@ -204,8 +206,8 @@ static mp_obj_t mp_machine_i2c_target_make_new(const mp_obj_type_t *type, size_t
204206
self->state = STATE_IDLE;
205207

206208
// Initialise data.
207-
MP_STATE_PORT(i2c_target_mem_obj)[i2c_id] = args[ARG_mem].u_obj;
208-
machine_i2c_target_data_t *data = &i2c_target_data[i2c_id];
209+
MP_STATE_PORT(machine_i2c_target_mem_obj)[i2c_id] = args[ARG_mem].u_obj;
210+
machine_i2c_target_data_t *data = &machine_i2c_target_data[i2c_id];
209211
machine_i2c_target_data_init(data, args[ARG_mem].u_obj, args[ARG_mem_addrsize].u_int);
210212

211213
// Set SCL/SDA pins if given.

ports/alif/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (1)
135135
#define MICROPY_PY_MACHINE_I2C_TARGET (MICROPY_HW_ENABLE_HW_I2C)
136136
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/alif/machine_i2c_target.c"
137+
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (4)
138+
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
137139
#define MICROPY_PY_MACHINE_SOFTI2C (1)
138140
#define MICROPY_PY_MACHINE_SPI (1)
139141
#define MICROPY_PY_MACHINE_SOFTSPI (1)

0 commit comments

Comments
 (0)