|
|
|
|
|
|
|
|
port.A1 = address << 1; |
|
|
port.A1 = address << 1; |
|
|
slave_mode = 1; |
|
|
slave_mode = 1; |
|
|
port.C1 = I2C_C1_IICEN | I2C_C1_IICIE; |
|
|
port.C1 = I2C_C1_IICEN | I2C_C1_IICIE; |
|
|
NVIC_ENABLE_IRQ(IRQ_I2C0); |
|
|
|
|
|
|
|
|
NVIC_ENABLE_IRQ(hardware.irq); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void TwoWire::end() |
|
|
void TwoWire::end() |
|
|
{ |
|
|
{ |
|
|
if (!(hardware.clock_gate_register & hardware.clock_gate_mask)) return; |
|
|
if (!(hardware.clock_gate_register & hardware.clock_gate_mask)) return; |
|
|
NVIC_DISABLE_IRQ(IRQ_I2C0); |
|
|
|
|
|
|
|
|
NVIC_DISABLE_IRQ(hardware.irq); |
|
|
// TODO: should this try to create a stop condition?? |
|
|
// TODO: should this try to create a stop condition?? |
|
|
port.C1 = 0; |
|
|
port.C1 = 0; |
|
|
volatile uint32_t *reg; |
|
|
volatile uint32_t *reg; |
|
|
|
|
|
|
|
|
hardware.clock_gate_register &= ~hardware.clock_gate_mask; |
|
|
hardware.clock_gate_register &= ~hardware.clock_gate_mask; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIRE_IMPLEMENT_WIRE |
|
|
void i2c0_isr(void) |
|
|
void i2c0_isr(void) |
|
|
{ |
|
|
{ |
|
|
Wire.isr(); |
|
|
Wire.isr(); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIRE_IMPLEMENT_WIRE1 |
|
|
|
|
|
void i2c1_isr(void) |
|
|
|
|
|
{ |
|
|
|
|
|
Wire1.isr(); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIRE_IMPLEMENT_WIRE2 |
|
|
|
|
|
void i2c2_isr(void) |
|
|
|
|
|
{ |
|
|
|
|
|
Wire2.isr(); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIRE_IMPLEMENT_WIRE3 |
|
|
|
|
|
void i2c3_isr(void) |
|
|
|
|
|
{ |
|
|
|
|
|
Wire3.isr(); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TwoWire::isr(void) |
|
|
void TwoWire::isr(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
19, 16, 33, 7, 47, |
|
|
19, 16, 33, 7, 47, |
|
|
2, 2, 5, 7, 2, |
|
|
2, 2, 5, 7, 2, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
IRQ_I2C0 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
TwoWire Wire(KINETIS_I2C0, TwoWire::i2c0_hardware); |
|
|
TwoWire Wire(KINETIS_I2C0, TwoWire::i2c0_hardware); |
|
|
|
|
|
|
|
|
37, 255, 255, 255, 255, |
|
|
37, 255, 255, 255, 255, |
|
|
2, 0, 0, 0, 0, |
|
|
2, 0, 0, 0, 0, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
IRQ_I2C1 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
TwoWire Wire1(KINETIS_I2C1, TwoWire::i2c1_hardware); |
|
|
TwoWire Wire1(KINETIS_I2C1, TwoWire::i2c1_hardware); |
|
|
|
|
|
|
|
|
3, 26, 255, 255, 255, |
|
|
3, 26, 255, 255, 255, |
|
|
5, 5, 0, 0, 0, |
|
|
5, 5, 0, 0, 0, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
IRQ_I2C2 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#endif // WIRE_IMPLEMENT_WIRE2 |
|
|
#endif // WIRE_IMPLEMENT_WIRE2 |
|
|
|
|
|
|
|
|
57, 255, 255, 255, 255, |
|
|
57, 255, 255, 255, 255, |
|
|
2, 0, 0, 0, 0, |
|
|
2, 0, 0, 0, 0, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
IRQ_I2C3 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#endif // WIRE_IMPLEMENT_WIRE3 |
|
|
#endif // WIRE_IMPLEMENT_WIRE3 |