Skip to content

Commit 60d31ee

Browse files
authored
Move ByteTime field to SPI_DEVICE_CONFIGURATION (#2406)
***NO_CI***
1 parent 8ad53cf commit 60d31ee

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/HAL/Include/nanoHAL_Spi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct nanoSPI_BusConfig
2020
int8_t devicesInUse;
2121
SPI_DEVICE_CONFIGURATION deviceConfig[MAX_SPI_DEVICES];
2222
uint32_t deviceHandles[MAX_SPI_DEVICES];
23-
float byteTime[MAX_SPI_DEVICES];
2423
SPI_OP_STATUS spiStatus;
2524
};
2625

src/PAL/Include/CPU_SPI_decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ struct SPI_DEVICE_CONFIGURATION
7777
bool MD16bits;
7878
// Data order for 16 bit operation
7979
DataBitOrder DataOrder16;
80+
// Rough estimate on the time it takes to send/receive one byte (in milliseconds)
81+
// Used to compute length of time for each IO to see if this is a long running operation
82+
float ByteTime;
8083

8184
// Master Only
8285
uint32_t Clock_RateHz; // Master - SPI bus clock frequency, in hertz (Hz).

src/System.Device.Spi/nanoHAL_Spi.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,16 @@ HRESULT nanoSPI_OpenDeviceEx(
347347
}
348348
}
349349

350+
// Compute rough estimate on the time to tx/rx a byte (in milliseconds)
351+
// Used to compute length of time for each IO to see if this is a long running operation
352+
// Store for each device as each device could use a different bit rate
353+
spiDeviceConfig.ByteTime = (1.0 / spiDeviceConfig.Clock_RateHz) * 1000.0 * 8;
354+
350355
// Add next Device - Copy device config, save handle, increment number devices on bus
351356
nanoSPI_BusConfig *pBusConfig = &spiconfig[spiDeviceConfig.Spi_Bus];
352357
pBusConfig->deviceConfig[spiDeviceConfig.Spi_Bus] = spiDeviceConfig;
353358
pBusConfig->deviceHandles[spiDeviceConfig.Spi_Bus] = deviceHandle;
354359

355-
// Compute rough estimate on the time to tx/rx a byte (in milliseconds)
356-
// Used to compute length of time for each IO to see if this is a long running operation
357-
// Store for each device as each device could use a different bit rate
358-
pBusConfig->byteTime[spiDeviceConfig.Spi_Bus] = (float)(1.0 / spiDeviceConfig.Clock_RateHz) * 1000 * 8;
359-
360360
pBusConfig->devicesInUse++;
361361

362362
// Return unique generated device handle
@@ -419,7 +419,7 @@ float nanoSPI_GetByteTime(uint32_t handle)
419419

420420
getDevice(handle, spiBus, deviceIndex);
421421

422-
return spiconfig[spiBus].byteTime[deviceIndex];
422+
return spiconfig[spiBus].deviceConfig->ByteTime;
423423
}
424424

425425
void nanoSPI_Wait_Busy(uint32_t handle)

src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool System_Device_IsLongRunningOperation(
2626
uint32_t readSize,
2727
bool fullDuplex,
2828
bool bufferIs16bits,
29-
float byteTime,
29+
int32_t byteTime,
3030
uint32_t &estimatedDurationMiliseconds)
3131
{
3232
if (bufferIs16bits)

0 commit comments

Comments
 (0)