Skip to content

Commit e852ae7

Browse files
authored
Merge pull request #507 from daltonate/patch-1
Properly use critical section
2 parents 66729c4 + 77c5150 commit e852ae7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/mac/LoRaMac.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,13 +1360,15 @@ static void ProcessRadioRxTimeout( void )
13601360

13611361
static void LoRaMacHandleIrqEvents( void )
13621362
{
1363-
LoRaMacRadioEvents_t events = LoRaMacRadioEvents;
1363+
LoRaMacRadioEvents_t events;
1364+
1365+
CRITICAL_SECTION_BEGIN( );
1366+
events = LoRaMacRadioEvents;
1367+
LoRaMacRadioEvents.Value = 0;
1368+
CRITICAL_SECTION_END( );
1369+
13641370
if( events.Value != 0 )
13651371
{
1366-
CRITICAL_SECTION_BEGIN( );
1367-
LoRaMacRadioEvents.Value = 0;
1368-
CRITICAL_SECTION_END( );
1369-
13701372
if( events.Events.TxDone == 1 )
13711373
{
13721374
ProcessRadioTxDone( );

src/mac/LoRaMacClassB.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,13 +1666,15 @@ void LoRaMacClassBSetMulticastPeriodicity( MulticastCtx_t* multicastChannel )
16661666
void LoRaMacClassBProcess( void )
16671667
{
16681668
#ifdef LORAMAC_CLASSB_ENABLED
1669-
LoRaMacClassBEvents_t events = LoRaMacClassBEvents;
1669+
LoRaMacClassBEvents_t events;
1670+
1671+
CRITICAL_SECTION_BEGIN( );
1672+
events = LoRaMacClassBEvents;
1673+
LoRaMacClassBEvents.Value = 0;
1674+
CRITICAL_SECTION_END( );
1675+
16701676
if( events.Value != 0 )
16711677
{
1672-
CRITICAL_SECTION_BEGIN( );
1673-
LoRaMacClassBEvents.Value = 0;
1674-
CRITICAL_SECTION_END( );
1675-
16761678
if( events.Events.Beacon == 1 )
16771679
{
16781680
LoRaMacClassBProcessBeacon( );

0 commit comments

Comments
 (0)