@@ -52,13 +52,10 @@ typedef struct _machine_i2c_target_obj_t {
5252
5353uint8_t machine_i2c_pin_config (mp_obj_t pin_obj , uint8_t id , uint8_t pad_nr );
5454
55- static machine_i2c_target_data_t i2c_target_data [SERCOM_INST_NUM ];
56- MP_REGISTER_ROOT_POINTER (mp_obj_t pyb_i2cslave_mem [SERCOM_INST_NUM ]);
57-
5855void common_i2c_target_irq_handler (int i2c_id ) {
5956 // Handle Sercom I2C IRQ for target memory mode.
6057 machine_i2c_target_obj_t * self = MP_STATE_PORT (sercom_table [i2c_id ]);
61- machine_i2c_target_data_t * data = & i2c_target_data [i2c_id ];
58+ machine_i2c_target_data_t * data = & machine_i2c_target_data [i2c_id ];
6259
6360 if (self != NULL ) {
6461 Sercom * i2c = self -> instance ;
@@ -95,6 +92,10 @@ void common_i2c_target_irq_handler(int i2c_id) {
9592/******************************************************************************/
9693// I2CTarget port implementation
9794
95+ static inline size_t mp_machine_i2c_target_get_index (machine_i2c_target_obj_t * self ) {
96+ return self -> id ;
97+ }
98+
9899static void mp_machine_i2c_target_deinit_all_port (void ) {
99100}
100101
@@ -161,8 +162,8 @@ mp_obj_t mp_machine_i2c_target_make_new(const mp_obj_type_t *type, size_t n_args
161162
162163 // Get the address and initialise data.
163164 self -> addr = args [ARG_addr ].u_int ;
164- MP_STATE_PORT (pyb_i2cslave_mem )[id ] = args [ARG_mem ].u_obj ;
165- machine_i2c_target_data_t * data = & i2c_target_data [id ];
165+ MP_STATE_PORT (machine_i2c_target_mem_obj )[id ] = args [ARG_mem ].u_obj ;
166+ machine_i2c_target_data_t * data = & machine_i2c_target_data [id ];
166167 machine_i2c_target_data_init (data , args [ARG_mem ].u_obj , args [ARG_mem_addrsize ].u_int );
167168
168169 // Set up the clocks
@@ -210,6 +211,6 @@ static void mp_machine_i2c_target_print(const mp_print_t *print, mp_obj_t self_i
210211static void mp_machine_i2c_target_deinit (machine_i2c_target_obj_t * self ) {
211212 // Disable I2C
212213 sercom_enable (self -> instance , 0 );
213- MP_STATE_PORT (pyb_i2cslave_mem )[self -> id ] = NULL ;
214+ MP_STATE_PORT (machine_i2c_target_mem_obj )[self -> id ] = MP_OBJ_NULL ;
214215 MP_STATE_PORT (sercom_table [self -> id ]) = NULL ;
215216}
0 commit comments