Exemple #1
0
/*! 
    \brief Invokes the scheduler

     Increment systick counter, invoke scheduler and flag any context switching needed for PendSV to take care of.
*/
void SysTick_Handler(void) // 1KHz
{
	os_KernelEnterCriticalSection();
	// Increment systick counter 
  systick_count++;
	// Run scheduler to determine if a context switch is needed
  scheduler();
  if (curr_task != next_task)
	{ 
		// Context switching needed
    ScheduleContextSwitch();
  }
	os_KernelExitCriticalSection();
  return;	
}
void SysTick_Handler(void) // 1KHz
{
	os_KernelEnterCriticalSection();  // TWP ... why???
	// Increment systick counter 
  systick_count++;
	
	//TWPV6: SysTick heartbeat on BLUE LED
	switch (++ticker ) {
		case( 1850 ):
			unprotected_LED_blink( LED2 );
		  break;
		case( 2000 ) :
			ticker = 0;
			unprotected_LED_blink( LED2 );
		  break;
	}  // end switch
	
	// nothing more to do (yet) ... timed waiting and sleeping is not supported in this version
	
	os_KernelExitCriticalSection();
  return;	
}
/// \brief Initialize the RTOS Kernel for creating objects.
/// \details Enable double-word stack alignment and initialize the Idle thread.
/// \return Status code that indicates the execution status of the function.
/// \note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS.
osStatus osKernelInitialize (void)
{
	os_KernelEnterCriticalSection();
	
	// Enable double-word stack alignment
	SCB->CCR |= SCB_CCR_STKALIGN_Msk; // Set STKALIGN bit (bit 9) of CCR
	
	// Enable lazy stacking for interrupt handlers.  This allows floating-point
	// instructions to be used within interrupt handlers, but at the expense of
	// extra stack usage.
	//
	ROM_FPULazyStackingEnable();	
	
	os_KernelExitCriticalSection();	
	
	// Initialize the Idle thread
	// Needs SVC exceptions not masked
	if (Init_threadIdle() != 0)
	{
		stop_cpu;
	}
	
	return osOK;
}