mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
machine: make I2C usable in the simulator
This fixes/improves a few issues with I2C support:
* Validate I2C pins, so only pins that are supported by the hardware
can be used (similar to how it's done with PWM).
* Add address to Tx API (without it, the simulator can't really
simulate I2C).
* Add frequency when configuring. Not currently used, but might be
useful in the future and adding it now avoids possibly breaking
changes.
This is a breaking change, but since the simulator doesn't support I2C
yet that seems fine to me. (It does in my local changes, but those need
to be cleaned up before I can push them).
This commit is contained in:
committed by
Ron Evans
parent
35adbffa54
commit
f845b469b1
@@ -94,3 +94,15 @@ var PWM7 = &timerType{
|
||||
{GPIO15}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var I2C0 = &I2C{
|
||||
Bus: 0,
|
||||
PinsSCL: []Pin{GPIO1, GPIO5, GPIO9, GPIO13, GPIO17, GPIO21},
|
||||
PinsSDA: []Pin{GPIO0, GPIO4, GPIO8, GPIO12, GPIO16, GPIO20},
|
||||
}
|
||||
|
||||
var I2C1 = &I2C{
|
||||
Bus: 0,
|
||||
PinsSCL: []Pin{GPIO3, GPIO7, GPIO11, GPIO15, GPIO19, GPIO27},
|
||||
PinsSDA: []Pin{GPIO2, GPIO6, GPIO10, GPIO14, GPIO18, GPIO26},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user