Skip to content

Commit 4cfddd0

Browse files
committed
Remove commented out __get_PRIMASK().
Fixes issue 55. Functions that don't return a value have caused unpredicatable behavior on Cortex-M3 in the past. Added comment to docs on ARM showing primask register.
1 parent b738931 commit 4cfddd0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

libraries/SPI/src/SPI.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ void SPIClass::end()
128128
static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused));
129129
static inline unsigned char __interruptsStatus(void)
130130
{
131-
// // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html
132-
// return (__get_PRIMASK() ? 0 : 1);
131+
// See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/CHDBIBGJ.html - Cortex-M0
132+
// Equivalent Cortex-M3 http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/CHDBIBGJ.html
133+
return (__get_PRIMASK() ? 0 : 1);
133134
}
134135
#endif
135136

@@ -300,12 +301,15 @@ void SPIClass::_transfer(void *buf_out, void *buf_in, size_t count)
300301
}
301302

302303
uint32_t retVal32 = 0;
303-
if( iomTransfer.eDirection == AM_HAL_IOM_FULLDUPLEX ){
304+
if (iomTransfer.eDirection == AM_HAL_IOM_FULLDUPLEX)
305+
{
304306
retVal32 = am_hal_iom_spi_blocking_fullduplex(_handle, &iomTransfer);
305-
}else{
307+
}
308+
else
309+
{
306310
retVal32 = am_hal_iom_blocking_transfer(_handle, &iomTransfer);
307311
}
308-
312+
309313
// if (retVal32 != 0)
310314
// {
311315
// Serial.printf("got an error on _transfer: %d\n", retVal32);

0 commit comments

Comments
 (0)