@@ -40,32 +40,14 @@ typedef enum {
4040 I2C_NEVER_RESET ,
4141} i2c_status_t ;
4242
43- // Set each bit to indicate an active UART
44- // will be checked by ISR Handler for which ones to call
43+ // Set each bit to indicate an active I2c
4544static uint8_t i2c_active = 0 ;
4645static i2c_status_t i2c_status [NUM_I2C ];
4746static volatile int i2c_err ;
4847
4948// I2C struct for configuring GPIO pins
5049extern const mxc_gpio_cfg_t i2c_maps [NUM_I2C ];
5150
52- // I2C Interrupt Handler
53- void i2c_isr (void ) {
54- for (int i = 0 ; i < NUM_I2C ; i ++ ) {
55- if (i2c_active & (1 << i )) {
56- // NOTE: I2C_GET_TMR actually returns the I2C registers
57- MXC_I2C_AsyncHandler (MXC_I2C_GET_I2C (i ));
58- }
59- }
60- }
61-
62- // Callback gets called when AsyncRequest is COMPLETE
63- // (e.g. txLen == txCnt)
64- // static volatile void i2cCallback(mxc_i2c_req_t *req, int error) {
65- // i2c_status[MXC_I2C_GET_IDX(req->i2c)] = I2C_FREE;
66- // i2c_err = error;
67- // }
68-
6951// Construct I2C protocol, this function init i2c peripheral
7052void common_hal_busio_i2c_construct (busio_i2c_obj_t * self ,
7153 const mcu_pin_obj_t * scl ,
@@ -80,7 +62,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
8062 // Assign I2C ID based on pins
8163 temp = pinsToI2c (sda , scl );
8264 if (temp == -1 ) {
83- // Error will be indicated by pinsToUart(tx, rx) function
8465 return ;
8566 } else {
8667 self -> i2c_id = temp ;
@@ -124,12 +105,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
124105 self -> timeout = timeout ;
125106 }
126107
127- /* Setup I2C interrupt */
128- NVIC_ClearPendingIRQ (MXC_I2C_GET_IRQ (self -> i2c_id ));
129- NVIC_DisableIRQ (MXC_I2C_GET_IRQ (self -> i2c_id ));
130- NVIC_SetPriority (MXC_I2C_GET_IRQ (self -> i2c_id ), I2C_PRIORITY );
131- NVIC_SetVector (MXC_I2C_GET_IRQ (self -> i2c_id ), (uint32_t )i2c_isr );
132-
133108 return ;
134109}
135110
0 commit comments