Skip to content

Commit eb2cf31

Browse files
committed
Fix code style and declaration
1 parent 147403b commit eb2cf31

File tree

1 file changed

+68
-67
lines changed

1 file changed

+68
-67
lines changed

src/System.Device.Spi/sys_dev_spi_native_System_Device_Spi_SpiDevice.cpp

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
8585
int16_t readOffset = 0;
8686
int16_t writeOffset = 0;
8787
SPI_WRITE_READ_SETTINGS rws;
88+
uint32_t deviceId;
8889

8990
bool isLongRunningOperation;
9091
uint32_t estimatedDurationMiliseconds;
@@ -98,8 +99,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
9899
FAULT_ON_NULL(pThis);
99100

100101
// get device handle saved on open
101-
uint32_t deviceId =
102-
pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___deviceId].NumericByRef().u4;
102+
deviceId = pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___deviceId].NumericByRef().u4;
103103

104104
if (stack.m_customState == 0)
105105
{
@@ -186,6 +186,7 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
186186
readSize = 0;
187187
}
188188
}
189+
189190
// Are we using SPI full-duplex for transfer ?
190191
bool fullDuplex = (bool)stack.Arg3().NumericByRef().u1;
191192

@@ -280,95 +281,95 @@ HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeTransfer(
280281

281282
// null pointers and vars
282283
pThis = NULL;
284+
}
283285

284-
NANOCLR_CLEANUP();
286+
NANOCLR_CLEANUP();
285287

286-
if (hr != CLR_E_THREAD_WAITING)
288+
if (hr != CLR_E_THREAD_WAITING)
289+
{
290+
// unpin buffers
291+
if (writeBuffer != NULL && writeBuffer->IsPinned())
287292
{
288-
// unpin buffers
289-
if (writeBuffer != NULL && writeBuffer->IsPinned())
290-
{
291-
writeBuffer->Unpin();
292-
}
293+
writeBuffer->Unpin();
294+
}
293295

294-
if (readBuffer != NULL && readBuffer->IsPinned())
295-
{
296-
readBuffer->Unpin();
297-
}
296+
if (readBuffer != NULL && readBuffer->IsPinned())
297+
{
298+
readBuffer->Unpin();
298299
}
299300
}
301+
}
300302

301-
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeOpenDevice___I4(CLR_RT_StackFrame & stack)
302-
{
303-
NANOCLR_HEADER();
303+
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeOpenDevice___I4(CLR_RT_StackFrame &stack)
304+
{
305+
NANOCLR_HEADER();
304306

305-
uint32_t handle = -1;
306-
SPI_DEVICE_CONFIGURATION spiConfig;
307-
CLR_RT_HeapBlock *config = NULL;
307+
uint32_t handle = -1;
308+
SPI_DEVICE_CONFIGURATION spiConfig;
309+
CLR_RT_HeapBlock *config = NULL;
308310

309-
// get a pointer to the managed object instance and check that it's not NULL
310-
CLR_RT_HeapBlock *pThis = stack.This();
311-
FAULT_ON_NULL(pThis);
311+
// get a pointer to the managed object instance and check that it's not NULL
312+
CLR_RT_HeapBlock *pThis = stack.This();
313+
FAULT_ON_NULL(pThis);
312314

313-
// Get reference to manage code SPI settings
314-
config =
315-
pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___connectionSettings].Dereference();
315+
// Get reference to manage code SPI settings
316+
config = pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___connectionSettings].Dereference();
316317

317-
spiConfig.BusMode = SpiBusMode_master;
318-
spiConfig.DataIs16bits = false;
318+
spiConfig.BusMode = SpiBusMode_master;
319+
spiConfig.DataIs16bits = false;
319320

320-
// internally SPI bus ID is zero based, so better take care of that here
321-
spiConfig.Spi_Bus = config[SpiConnectionSettings::FIELD___busId].NumericByRef().s4 - 1;
321+
// internally SPI bus ID is zero based, so better take care of that here
322+
spiConfig.Spi_Bus = config[SpiConnectionSettings::FIELD___busId].NumericByRef().s4 - 1;
322323

323-
spiConfig.DeviceChipSelect = config[SpiConnectionSettings::FIELD___csLine].NumericByRef().s4;
324+
spiConfig.DeviceChipSelect = config[SpiConnectionSettings::FIELD___csLine].NumericByRef().s4;
324325

325-
// sanity check chip select line
326-
if (spiConfig.DeviceChipSelect < -1)
327-
{
328-
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
329-
}
326+
// sanity check chip select line
327+
if (spiConfig.DeviceChipSelect < -1)
328+
{
329+
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
330+
}
330331

331-
// load CS active state from config (which is always PinValue.Low or PinValue.High
332-
spiConfig.ChipSelectActiveState =
333-
(bool)config[SpiConnectionSettings::FIELD___chipSelectLineActiveState].NumericByRef().s4;
332+
// load CS active state from config (which is always PinValue.Low or PinValue.High
333+
spiConfig.ChipSelectActiveState =
334+
(bool)config[SpiConnectionSettings::FIELD___chipSelectLineActiveState].NumericByRef().s4;
334335

335-
spiConfig.Spi_Mode = (SpiMode)config[SpiConnectionSettings::FIELD___spiMode].NumericByRef().s4;
336-
spiConfig.DataOrder16 = (DataBitOrder)config[SpiConnectionSettings::FIELD___dataFlow].NumericByRef().s4;
337-
spiConfig.Clock_RateHz = config[SpiConnectionSettings::FIELD___clockFrequency].NumericByRef().s4;
338-
spiConfig.BusConfiguration =
339-
(SpiBusConfiguration)config[SpiConnectionSettings::FIELD___busConfiguration].NumericByRef().s4;
336+
spiConfig.Spi_Mode = (SpiMode)config[SpiConnectionSettings::FIELD___spiMode].NumericByRef().s4;
337+
spiConfig.DataOrder16 = (DataBitOrder)config[SpiConnectionSettings::FIELD___dataFlow].NumericByRef().s4;
338+
spiConfig.Clock_RateHz = config[SpiConnectionSettings::FIELD___clockFrequency].NumericByRef().s4;
339+
spiConfig.BusConfiguration =
340+
(SpiBusConfiguration)config[SpiConnectionSettings::FIELD___busConfiguration].NumericByRef().s4;
340341

341-
// Returns handle to device
342-
hr = nanoSPI_OpenDevice(spiConfig, handle);
343-
NANOCLR_CHECK_HRESULT(hr);
342+
// Returns handle to device
343+
hr = nanoSPI_OpenDevice(spiConfig, handle);
344+
NANOCLR_CHECK_HRESULT(hr);
344345

345-
// Return device handle
346-
stack.SetResult_I4(handle);
346+
// Return device handle
347+
stack.SetResult_I4(handle);
347348

348-
NANOCLR_NOCLEANUP();
349-
}
349+
NANOCLR_NOCLEANUP();
350+
}
350351

351-
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeInit___VOID(CLR_RT_StackFrame & stack)
352+
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::NativeInit___VOID(CLR_RT_StackFrame &stack)
353+
{
354+
NANOCLR_HEADER();
352355
{
353-
NANOCLR_HEADER();
354-
{
355-
(void)stack;
356-
}
357-
NANOCLR_NOCLEANUP_NOLABEL();
356+
(void)stack;
358357
}
358+
NANOCLR_NOCLEANUP_NOLABEL();
359+
}
359360

360-
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::DisposeNative___VOID(CLR_RT_StackFrame & stack)
361+
HRESULT Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::DisposeNative___VOID(CLR_RT_StackFrame &stack)
362+
{
363+
NANOCLR_HEADER();
361364
{
362-
NANOCLR_HEADER();
363-
{
364-
// get a pointer to the managed object instance and check that it's not NULL
365-
CLR_RT_HeapBlock *pThis = stack.This();
365+
// get a pointer to the managed object instance and check that it's not NULL
366+
CLR_RT_HeapBlock *pThis = stack.This();
366367

367-
// get device handle
368-
int32_t deviceId =
369-
pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___deviceId].NumericByRef().s4;
368+
// get device handle
369+
int32_t deviceId =
370+
pThis[Library_sys_dev_spi_native_System_Device_Spi_SpiDevice::FIELD___deviceId].NumericByRef().s4;
370371

371-
nanoSPI_CloseDevice(deviceId);
372-
}
373-
NANOCLR_NOCLEANUP_NOLABEL();
372+
nanoSPI_CloseDevice(deviceId);
374373
}
374+
NANOCLR_NOCLEANUP_NOLABEL();
375+
}

0 commit comments

Comments
 (0)