Skip to content

Commit 95a9516

Browse files
authored
Add API to grab handle of platform SPI device (#3029)
***NO_CI***
1 parent 57d477b commit 95a9516

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/PAL/Include/CPU_SPI_decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,7 @@ uint32_t CPU_SPI_ChipSelectLineCount(uint32_t busIndex);
169169
HRESULT CPU_SPI_MinClockFrequency(uint32_t busIndex, int32_t *frequency);
170170
HRESULT CPU_SPI_MaxClockFrequency(uint32_t busIndex, int32_t *frequency);
171171

172+
// return the SPI hande for the SPI device (platform specific)
173+
uint32_t CPU_SPI_GetSpiHandle(uint32_t deviceHandle);
174+
172175
#endif // DRIVERS_SPI_DECL_H

src/System.Device.Spi/nanoHAL_Spi.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,19 @@ HRESULT nanoSPI_Write_Read(
481481
readPtr,
482482
readSize);
483483
}
484+
485+
//
486+
// Get the SPI handle from the device handle
487+
//
488+
uint32_t CPU_SPI_GetSpiHandle(uint32_t deviceHandle)
489+
{
490+
uint8_t spiBus;
491+
int deviceIndex;
492+
493+
if (!getDevice(deviceHandle, spiBus, deviceIndex))
494+
{
495+
return 0;
496+
}
497+
498+
return spiconfig[spiBus].deviceHandles[deviceIndex];
499+
}

0 commit comments

Comments
 (0)