Skip to content

Commit 9ca1814

Browse files
committed
Fix compiler errors
1 parent 17167dc commit 9ca1814

File tree

10 files changed

+16
-84
lines changed

10 files changed

+16
-84
lines changed

src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
8282
uint8_t *readData = nullptr;
8383
int16_t writeSize = 0;
8484
int16_t readSize = 0;
85-
int16_t readOffset = 0;
86-
int16_t writeOffset = 0;
8785
SPI_WRITE_READ_SETTINGS rws;
8886
uint32_t deviceId;
8987

@@ -142,13 +140,9 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
142140
writeBuffer = writeSpanByte[Span::FIELD___array].DereferenceArray();
143141
if (writeBuffer != nullptr)
144142
{
145-
// Get the write offset, only the elements defined by the span must be written, not the whole
146-
// array
147-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
148-
149143
// use the span length as write size, only the elements defined by the span must be written
150144
writeSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
151-
writeData = (unsigned char *)writeBuffer->GetElement(writeOffset);
145+
writeData = (unsigned char *)writeBuffer->GetFirstElement();
152146

153147
// pin the buffer
154148
writeBuffer->Pin();
@@ -168,12 +162,9 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
168162
readBuffer = readSpanByte[Span::FIELD___array].DereferenceArray();
169163
if (readBuffer != nullptr)
170164
{
171-
// Get the read offset, only the elements defined by the span must be read, not the whole array
172-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
173-
174-
// use the span length as read size, only the elements defined by the span must be read
165+
// use the span length as read size, only the elements defined by the span must be read
175166
readSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
176-
readData = (unsigned char *)readBuffer->GetElement(readOffset);
167+
readData = (unsigned char *)readBuffer->GetFirstElement();
177168

178169
// pin the buffer
179170
readBuffer->Pin();

targets/AzureRTOS/ST/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
406406
CLR_RT_HeapBlock *connectionSettings;
407407
CLR_RT_HeapBlock_Array *writeBuffer = nullptr;
408408
CLR_RT_HeapBlock_Array *readBuffer = nullptr;
409-
int readOffset = 0;
410-
int writeOffset = 0;
411409

412410
// get a pointer to the managed object instance and check that it's not nullptr
413411
CLR_RT_HeapBlock *pThis = stack.This();
@@ -456,9 +454,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
456454
writeBuffer = writeSpanByte[Span::FIELD___array].DereferenceArray();
457455
if (writeBuffer != nullptr)
458456
{
459-
// Get the write offset, only the elements defined by the span must be written, not the whole array
460-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
461-
462457
// use the span length as write size, only the elements defined by the span must be written
463458
palI2c->WriteSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
464459

@@ -480,9 +475,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
480475
readBuffer = readSpanByte[Span::FIELD___array].DereferenceArray();
481476
if (readBuffer != nullptr)
482477
{
483-
// Get the read offset, only the elements defined by the span must be read, not the whole array
484-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
485-
486478
// use the span length as read size, only the elements defined by the span must be read
487479
palI2c->ReadSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
488480

@@ -527,7 +519,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
527519
if (writeBuffer != nullptr)
528520
{
529521
// grab the pointer to the array by starting and the offset specified in the span
530-
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset);
522+
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetFirstElement();
531523

532524
// flush DMA buffer to ensure cache coherency
533525
// (only required for Cortex-M7)
@@ -537,7 +529,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
537529
if (readBuffer != nullptr)
538530
{
539531
// grab the pointer to the array by starting and the offset specified in the span
540-
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset);
532+
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetFirstElement();
541533
}
542534

543535
// because the bus access is shared, acquire the appropriate bus

targets/AzureRTOS/SiliconLabs/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
412412
CLR_RT_HeapBlock *connectionSettings;
413413
CLR_RT_HeapBlock_Array *writeBuffer = nullptr;
414414
CLR_RT_HeapBlock_Array *readBuffer = nullptr;
415-
int readOffset = 0;
416-
int writeOffset = 0;
417415
I2C_TransferSeq_TypeDef i2cTransfer;
418416
I2C_TransferReturn_TypeDef transactionResult = i2cTransferInProgress;
419417

@@ -468,9 +466,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
468466

469467
if (writeBuffer != nullptr)
470468
{
471-
// Get the write offset, only the elements defined by the span must be written, not the whole array
472-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
473-
474469
// use the span length as write size, only the elements defined by the span must be written
475470
palI2c->WriteSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
476471

@@ -494,9 +489,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
494489

495490
if (readBuffer != nullptr)
496491
{
497-
// Get the read offset, only the elements defined by the span must be read, not the whole array
498-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
499-
500492
// use the span length as read size, only the elements defined by the span must be read
501493
palI2c->ReadSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
502494

@@ -538,13 +530,13 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
538530
if (writeBuffer != nullptr)
539531
{
540532
// grab the pointer to the array by starting and the offset specified in the span
541-
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset);
533+
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetFirstElement();
542534
}
543535

544536
if (readBuffer != nullptr)
545537
{
546538
// grab the pointer to the array by starting and the offset specified in the span
547-
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset);
539+
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetFirstElement();
548540
}
549541
}
550542

targets/AzureRTOS/SiliconLabs/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
2121
CLR_RT_HeapBlock_Array *buffer;
2222
uint8_t *bufferData = nullptr;
2323
int16_t bufferSize = 0;
24-
int16_t bufferOffset = 0;
2524
uint32_t crc32 = 0;
2625
uint32_t hash = 0;
2726

@@ -35,12 +34,9 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
3534
// get buffer
3635
buffer = bufferSpanByte[Span::FIELD___array].DereferenceArray();
3736

38-
// Get the write offset
39-
bufferOffset = bufferSpanByte[Span::FIELD___start].NumericByRef().s4;
40-
4137
// use the span length as write size, only the elements defined by the span must be written
4238
bufferSize = bufferSpanByte[Span::FIELD___length].NumericByRef().s4;
43-
bufferData = (unsigned char *)buffer->GetElement(bufferOffset);
39+
bufferData = (unsigned char *)buffer->GetFirstElement();
4440

4541
if (bufferSize == 0)
4642
{

targets/ChibiOS/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
365365
CLR_RT_HeapBlock *connectionSettings;
366366
CLR_RT_HeapBlock_Array *writeBuffer = nullptr;
367367
CLR_RT_HeapBlock_Array *readBuffer = nullptr;
368-
int readOffset = 0;
369-
int writeOffset = 0;
370368

371369
// get a pointer to the managed object instance and check that it's not nullptr
372370
CLR_RT_HeapBlock *pThis = stack.This();
@@ -415,9 +413,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
415413
writeBuffer = writeSpanByte[Span::FIELD___array].DereferenceArray();
416414
if (writeBuffer != nullptr)
417415
{
418-
// Get the write offset, only the elements defined by the span must be written, not the whole array
419-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
420-
421416
// use the span length as write size, only the elements defined by the span must be written
422417
palI2c->WriteSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
423418

@@ -439,9 +434,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
439434
readBuffer = readSpanByte[Span::FIELD___array].DereferenceArray();
440435
if (readBuffer != nullptr)
441436
{
442-
// Get the read offset, only the elements defined by the span must be read, not the whole array
443-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
444-
445437
// use the span length as read size, only the elements defined by the span must be read
446438
palI2c->ReadSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
447439

@@ -486,7 +478,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
486478
if (writeBuffer != nullptr)
487479
{
488480
// grab the pointer to the array by starting and the offset specified in the span
489-
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetElement(writeOffset);
481+
palI2c->WriteBuffer = (uint8_t *)writeBuffer->GetFirstElement();
490482

491483
// flush DMA buffer to ensure cache coherency
492484
// (only required for Cortex-M7)
@@ -496,7 +488,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
496488
if (readBuffer != nullptr)
497489
{
498490
// grab the pointer to the array by starting and the offset specified in the span
499-
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetElement(readOffset);
491+
palI2c->ReadBuffer = (uint8_t *)readBuffer->GetFirstElement();
500492
}
501493

502494
// because the bus access is shared, acquire the appropriate bus

targets/ChibiOS/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
2727
CLR_RT_HeapBlock_Array *buffer;
2828
uint8_t *bufferData = nullptr;
2929
int16_t bufferSize = 0;
30-
int16_t bufferOffset = 0;
3130
uint32_t crc32 = 0;
3231
uint32_t hash = 0;
3332

@@ -41,12 +40,9 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
4140
// get buffer
4241
buffer = bufferSpanByte[Span::FIELD___array].DereferenceArray();
4342

44-
// Get the write offset
45-
bufferOffset = bufferSpanByte[Span::FIELD___start].NumericByRef().s4;
46-
4743
// use the span length as write size, only the elements defined by the span must be written
4844
bufferSize = bufferSpanByte[Span::FIELD___length].NumericByRef().s4;
49-
bufferData = (unsigned char *)buffer->GetElement(bufferOffset);
45+
bufferData = (unsigned char *)buffer->GetFirstElement();
5046

5147
crcAquireModule();
5248

targets/ESP32/_nanoCLR/System.Device.I2c.Slave/sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::
221221

222222
NF_PAL_I2CSLAVE *palI2c = nullptr;
223223

224-
int32_t bufferOffset = 0;
225224
int32_t requestedCount = 0;
226225
uint32_t readCount = 0;
227226
uint32_t bytesTransfered = 0;
@@ -271,9 +270,6 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::
271270
// set flag to read operation
272271
isRead = true;
273272

274-
// Get the read offset, only the elements defined by the span must be read, not the whole array
275-
bufferOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
276-
277273
// use the span length as read size, only the elements defined by the span must be read
278274
requestedCount = readSpanByte[Span::FIELD___length].NumericByRef().s4;
279275
}
@@ -284,9 +280,6 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::
284280

285281
if (writeBuffer != nullptr)
286282
{
287-
// Get the write offset, only the elements defined by the span must be written, not the whole array
288-
bufferOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
289-
290283
// use the span length as write size, only the elements defined by the span must be written
291284
requestedCount = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
292285
}
@@ -384,7 +377,7 @@ HRESULT Library_sys_dev_i2c_slave_native_System_Device_I2c_I2cSlaveDevice::
384377
// write operation
385378

386379
// copy buffer content to working buffer
387-
memcpy(palI2c->Buffer, (uint8_t *)writeBuffer->GetElement(bufferOffset), requestedCount);
380+
memcpy(palI2c->Buffer, (uint8_t *)writeBuffer->GetFirstElement(), requestedCount);
388381

389382
if (requestedCount < I2C_SLAVE_TX_BUF_LEN)
390383
{

targets/ESP32/_nanoCLR/System.Device.I2c/sys_dev_i2c_native_System_Device_I2c_I2cDevice.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
136136

137137
uint8_t *writeBuffer = nullptr;
138138
uint8_t *readBuffer = nullptr;
139-
int writeOffset = 0;
140139
int writeSize = 0;
141-
int readOffset = 0;
142140
int readSize = 0;
143141
esp_err_t opResult;
144142
uint32_t transferResult;
@@ -179,9 +177,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
179177

180178
if (writeData != nullptr)
181179
{
182-
// Get the write offset, only the elements defined by the span must be written, not the whole array
183-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
184-
185180
// use the span length as write size, only the elements defined by the span must be written
186181
writeSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
187182

@@ -196,7 +191,7 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
196191
}
197192

198193
// copy buffer content
199-
memcpy(writeBuffer, (uint8_t *)writeData->GetElement(writeOffset), writeSize);
194+
memcpy(writeBuffer, (uint8_t *)writeData->GetFirstElement(), writeSize);
200195

201196
// setup write transaction
202197
i2c_master_start(cmd);
@@ -218,9 +213,6 @@ HRESULT Library_sys_dev_i2c_native_System_Device_I2c_I2cDevice::
218213

219214
if (readData != nullptr)
220215
{
221-
// Get the read offset, only the elements defined by the span must be read, not the whole array
222-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
223-
224216
// use the span length as read size, only the elements defined by the span must be read
225217
readSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
226218

targets/ESP32/_nanoCLR/System.Device.I2s/sys_dev_i2s_native_System_Device_I2s_I2sDevice.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Read___VOID__Sys
364364
CLR_RT_HeapBlock_Array *readBuffer = nullptr;
365365
uint8_t *readData = nullptr;
366366
int readSize = 0;
367-
int readOffset = 0;
368367
uint8_t transform_buffer[SIZEOF_TRANSFORM_BUFFER_IN_BYTES];
369368
uint32_t a_index = 0;
370369

@@ -400,15 +399,12 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Read___VOID__Sys
400399

401400
if (readBuffer != nullptr)
402401
{
403-
// Get the read offset, only the elements defined by the span must be read, not the whole array
404-
readOffset = readSpanByte[Span::FIELD___start].NumericByRef().s4;
405-
406402
// use the span length as read size, only the elements defined by the span must be read
407403
readSize = readSpanByte[Span::FIELD___length].NumericByRef().s4;
408404

409405
if (readSize > 0)
410406
{
411-
readData = (uint8_t *)readBuffer->GetElement(readOffset);
407+
readData = (uint8_t *)readBuffer->GetFirstElement();
412408

413409
uint32_t num_bytes_needed_from_dma =
414410
readSize * (I2S_RX_FRAME_SIZE_IN_BYTES / appbuf_sample_size_in_bytes);
@@ -485,7 +481,6 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Write___VOID__Sy
485481
CLR_RT_HeapBlock_Array *writeBuffer = nullptr;
486482
uint8_t *writeData = nullptr;
487483
int writeSize = 0;
488-
int writeOffset = 0;
489484
size_t bytesWritten;
490485

491486
esp_err_t opResult;
@@ -516,16 +511,13 @@ HRESULT Library_sys_dev_i2s_native_System_Device_I2s_I2sDevice::Write___VOID__Sy
516511

517512
if (writeBuffer != nullptr)
518513
{
519-
// Get the write offset, only the elements defined by the span must be written, not the whole array
520-
writeOffset = writeSpanByte[Span::FIELD___start].NumericByRef().s4;
521-
522514
// use the span length as write size, only the elements defined by the span must be written
523515
writeSize = writeSpanByte[Span::FIELD___length].NumericByRef().s4;
524516

525517
if (writeSize > 0)
526518
{
527519
CLR_RT_ProtectFromGC gcWriteBuffer(*writeBuffer);
528-
writeData = (unsigned char *)writeBuffer->GetElement(writeOffset);
520+
writeData = (unsigned char *)writeBuffer->GetFirstElement();
529521

530522
if (bitsPerSample == I2S_BITS_PER_SAMPLE_32BIT)
531523
{

targets/ESP32/_nanoCLR/nanoFramework.System.IO.Hashing/nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
1717
CLR_RT_HeapBlock_Array *buffer;
1818
uint8_t *bufferData = nullptr;
1919
int16_t bufferSize = 0;
20-
int16_t bufferOffset = 0;
2120
uint32_t crc32 = 0;
2221
uint32_t hash = 0;
2322

@@ -31,12 +30,9 @@ HRESULT Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC_
3130
// get buffer
3231
buffer = bufferSpanByte[Span::FIELD___array].DereferenceArray();
3332

34-
// Get the write offset
35-
bufferOffset = bufferSpanByte[Span::FIELD___start].NumericByRef().s4;
36-
3733
// use the span length as write size, only the elements defined by the span must be written
3834
bufferSize = bufferSpanByte[Span::FIELD___length].NumericByRef().s4;
39-
bufferData = (unsigned char *)buffer->GetElement(bufferOffset);
35+
bufferData = (unsigned char *)buffer->GetFirstElement();
4036

4137
#ifdef ESP_ROM_HAS_CRC_LE
4238

0 commit comments

Comments
 (0)