@@ -177,28 +177,7 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
177177 Sleep ( portTICK_PERIOD_MS );
178178 }
179179
180- if ( xPortRunning == pdTRUE )
181- {
182- configASSERT ( xPortRunning );
183-
184- /* Can't proceed if in a critical section as pvInterruptEventMutex won't
185- * be available. */
186- WaitForSingleObject ( pvInterruptEventMutex , INFINITE );
187-
188- /* The timer has expired, generate the simulated tick event. */
189- ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK );
190-
191- /* The interrupt is now pending - notify the simulated interrupt
192- * handler thread. Must be outside of a critical section to get here so
193- * the handler thread can execute immediately pvInterruptEventMutex is
194- * released. */
195- configASSERT ( ulCriticalNesting == 0UL );
196- SetEvent ( pvInterruptEvent );
197-
198- /* Give back the mutex so the simulated interrupt handler unblocks
199- * and can access the interrupt handler variables. */
200- ReleaseMutex ( pvInterruptEventMutex );
201- }
180+ vPortGenerateSimulatedInterruptFromWindowsThread ( portINTERRUPT_TICK );
202181 }
203182
204183 return 0 ;
@@ -636,6 +615,32 @@ void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber )
636615}
637616/*-----------------------------------------------------------*/
638617
618+ void vPortGenerateSimulatedInterruptFromWindowsThread ( uint32_t ulInterruptNumber )
619+ {
620+ if ( xPortRunning == pdTRUE )
621+ {
622+ /* Can't proceed if in a critical section as pvInterruptEventMutex won't
623+ * be available. */
624+ WaitForSingleObject ( pvInterruptEventMutex , INFINITE );
625+
626+ /* Pending a user defined interrupt to be handled in simulated interrupt
627+ * handler thread. */
628+ ulPendingInterrupts |= ( 1 << ulInterruptNumber );
629+
630+ /* The interrupt is now pending - notify the simulated interrupt
631+ * handler thread. Must be outside of a critical section to get here so
632+ * the handler thread can execute immediately pvInterruptEventMutex is
633+ * released. */
634+ configASSERT ( ulCriticalNesting == 0UL );
635+ SetEvent ( pvInterruptEvent );
636+
637+ /* Give back the mutex so the simulated interrupt handler unblocks
638+ * and can access the interrupt handler variables. */
639+ ReleaseMutex ( pvInterruptEventMutex );
640+ }
641+ }
642+ /*-----------------------------------------------------------*/
643+
639644void vPortSetInterruptHandler ( uint32_t ulInterruptNumber ,
640645 uint32_t ( * pvHandler )( void ) )
641646{
0 commit comments