Skip to content

Commit 6e663e9

Browse files
committed
teensy40: add I2C support
1 parent 83b9be2 commit 6e663e9

File tree

4 files changed

+768
-5
lines changed

4 files changed

+768
-5
lines changed

src/machine/board_teensy40.go

+38
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,41 @@ const (
260260
I2C3_SDA_PIN = D25
261261
I2C3_SCL_PIN = D24
262262
)
263+
264+
var (
265+
I2C1 = I2C{
266+
Bus: nxp.LPI2C1,
267+
muxSDA: muxSelect{ // D18 (PA17 [AD_B1_01])
268+
mux: nxp.IOMUXC_LPI2C1_SDA_SELECT_INPUT_DAISY_GPIO_AD_B1_01_ALT3,
269+
sel: &nxp.IOMUXC.LPI2C1_SDA_SELECT_INPUT,
270+
},
271+
muxSCL: muxSelect{ // D19 (PA16 [AD_B1_00])
272+
mux: nxp.IOMUXC_LPI2C1_SCL_SELECT_INPUT_DAISY_GPIO_AD_B1_00_ALT3,
273+
sel: &nxp.IOMUXC.LPI2C1_SCL_SELECT_INPUT,
274+
},
275+
}
276+
277+
I2C2 = I2C{
278+
Bus: nxp.LPI2C3,
279+
muxSDA: muxSelect{ // D17 (PA22 [AD_B1_06])
280+
mux: nxp.IOMUXC_LPI2C3_SDA_SELECT_INPUT_DAISY_GPIO_AD_B1_06_ALT1,
281+
sel: &nxp.IOMUXC.LPI2C3_SDA_SELECT_INPUT,
282+
},
283+
muxSCL: muxSelect{ // D16 (PA23 [AD_B1_07])
284+
mux: nxp.IOMUXC_LPI2C3_SCL_SELECT_INPUT_DAISY_GPIO_AD_B1_07_ALT1,
285+
sel: &nxp.IOMUXC.LPI2C3_SCL_SELECT_INPUT,
286+
},
287+
}
288+
289+
I2C3 = I2C{
290+
Bus: nxp.LPI2C4,
291+
muxSDA: muxSelect{ // D25 (PA13 [AD_B0_13])
292+
mux: nxp.IOMUXC_LPI2C4_SDA_SELECT_INPUT_DAISY_GPIO_AD_B0_13_ALT0,
293+
sel: &nxp.IOMUXC.LPI2C4_SDA_SELECT_INPUT,
294+
},
295+
muxSCL: muxSelect{ // D24 (PA12 [AD_B0_12])
296+
mux: nxp.IOMUXC_LPI2C4_SCL_SELECT_INPUT_DAISY_GPIO_AD_B0_12_ALT0,
297+
sel: &nxp.IOMUXC.LPI2C4_SCL_SELECT_INPUT,
298+
},
299+
}
300+
)

src/machine/machine_mimxrt1062.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ func (jt *pinJumpTable) dispatchInterrupt(interrupt.Interrupt) {
341341
if status := gpio.ISR.Get() & gpio.IMR.Get(); status != 0 {
342342
gpio.ISR.Set(status) // clear interrupt
343343
for status != 0 {
344-
p := Pin(bits.TrailingZeros32(status))
345-
i := Pin(port + p)
346-
jt.lut[i](i)
347-
status &^= 1 << p
344+
off := Pin(bits.TrailingZeros32(status)) // ctz
345+
pin := Pin(port + off)
346+
jt.lut[pin](pin)
347+
status &^= 1 << off
348348
}
349349
}
350350
}

0 commit comments

Comments
 (0)