Skip to content

Commit 30a4399

Browse files
committed
Move redundant IOM setup to begin function.
1 parent 4bd5ed8 commit 30a4399

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ void TwoWire::begin(void)
9292
_config.eInterfaceMode = AM_HAL_IOM_I2C_MODE;
9393
_config.ui32ClockFreq = _clockSpeed;
9494

95+
//Setup defaults that do not change
96+
iomTransfer.ui32InstrLen = 0; // Use only data phase
97+
iomTransfer.ui32Instr = 0; //
98+
// iomTransfer.ui32NumBytes = ; //
99+
iomTransfer.eDirection = AM_HAL_IOM_TX;
100+
iomTransfer.pui32TxBuffer = (uint32_t *)_linearBugger;
101+
iomTransfer.pui32RxBuffer = NULL;
102+
iomTransfer.ui8RepeatCount = 0; // ?
103+
iomTransfer.ui8Priority = 1; // ?
104+
iomTransfer.ui32PauseCondition = 0; // ?
105+
iomTransfer.ui32StatusSetClr = 0; // ?
106+
95107
initialize(); // Initialize the IOM
96108
}
97109

@@ -190,19 +202,8 @@ uint8_t TwoWire::endTransmission(bool stopBit)
190202
{
191203
_transmissionBegun = false;
192204

193-
am_hal_iom_transfer_t iomTransfer = {0};
194205
iomTransfer.uPeerInfo.ui32I2CDevAddr = _transmissionAddress;
195-
iomTransfer.ui32InstrLen = 0; // Use only data phase
196-
iomTransfer.ui32Instr = 0; //
197-
// iomTransfer.ui32NumBytes = ; //
198-
iomTransfer.eDirection = AM_HAL_IOM_TX;
199-
iomTransfer.pui32TxBuffer = (uint32_t *)_linearBugger;
200-
iomTransfer.pui32RxBuffer = NULL;
201206
iomTransfer.bContinue = (stopBit ? false : true); // whether or not to hold onto the bus after this transfer
202-
iomTransfer.ui8RepeatCount = 0; // ?
203-
iomTransfer.ui8Priority = 1; // ?
204-
iomTransfer.ui32PauseCondition = 0; // ?
205-
iomTransfer.ui32StatusSetClr = 0; // ?
206207

207208
// Copy the bytes from the TX Buffer into the linear buffer
208209
size_t count = 0;

libraries/Wire/src/Wire.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class TwoWire : public Stream, public IOMaster
6969
void onService(void);
7070

7171
private:
72+
am_hal_iom_transfer_t iomTransfer = {0};
7273
ap3_gpio_pin_t _padSDA;
7374
ap3_gpio_pin_t _padSCL;
7475

0 commit comments

Comments
 (0)