Example #1
0
// Example: Create and Start timers
void Init_Timers (void) {
  osStatus  status;                                        // function return status
 
  // Create one-shoot timer
  exec1 = 1;
  id1 = osTimerCreate (osTimer(Timer1), osTimerOnce, &exec1);
  if (id1 != NULL)  {     // One-shot timer created
    // start timer with delay 100ms
		status = osTimerStart (id1, 100);            
    if (status != osOK)  {
      // Timer could not be started
    }
	}
 
  // Create periodic timer
  exec2 = 2;
  id2 = osTimerCreate (osTimer(Timer2), osTimerPeriodic, &exec2);
  if (id2 != NULL)  {     // Periodic timer created
    // start timer with periodic 1000ms interval
		status = osTimerStart (id2, 1000);            
    if (status != osOK)  {
      // Timer could not be started
    }
  }
}
Example #2
0
bool timers_start(void){
	bool result = true;	
	if(is_initialized == false)
		return false;
	result &= timers[TIMER_1MS] != NULL && osTimerStart(timers[TIMER_1MS], 1)   == osOK;
	result &= timers[TIMER_1S]  != NULL && osTimerStart(timers[TIMER_1S], 1000) == osOK;
	return result;
}
Example #3
0
File: main.c Project: IOIOI/nRF51
/**@brief Function for starting application timers.
 */
static void application_timers_start(void)
{
    // Start application timers.
    UNUSED_VARIABLE(osTimerStart(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL));

    UNUSED_VARIABLE(osTimerStart(m_heart_rate_timer_id, HEART_RATE_MEAS_INTERVAL));

    UNUSED_VARIABLE(osTimerStart(m_rr_interval_timer_id, RR_INTERVAL_INTERVAL));

    UNUSED_VARIABLE(osTimerStart(m_sensor_contact_timer_id, SENSOR_CONTACT_DETECTED_INTERVAL));
}
Example #4
0
int main(void) {
    osTimerId timer_0 = osTimerCreate(osTimer(blink_0), osTimerPeriodic, (void *)0);
    osTimerId timer_1 = osTimerCreate(osTimer(blink_1), osTimerPeriodic, (void *)1);
    osTimerId timer_2 = osTimerCreate(osTimer(blink_2), osTimerPeriodic, (void *)2);
    osTimerId timer_3 = osTimerCreate(osTimer(blink_3), osTimerPeriodic, (void *)3);
    
    osTimerStart(timer_0, 2000);
    osTimerStart(timer_1, 1000);
    osTimerStart(timer_2,  500);
    osTimerStart(timer_3,  250);
    
    osDelay(osWaitForever);
}
Example #5
0
/*----------------------------------------------------------------------------
  Main Thread 'main'
 *---------------------------------------------------------------------------*/
int main (void) {                         /* program execution starts here   */

  GLCD_Init();                            /* initialize GLCD                 */
  SER_Init ();                            /* initialize serial interface     */
  LED_Init ();                            /* initialize LEDs                 */
  KBD_Init ();                            /* initialize Push Button          */

  mut_GLCD = osMutexCreate(osMutex(mut_GLCD));
                                          /* create and start clock timer    */
  clock1s = osTimerCreate(osTimer(clock1s), osTimerPeriodic, NULL);                                          
  if (clock1s) osTimerStart(clock1s, 1000);                                          
                                          /* start thread lcd                */
  tid_lcd = osThreadCreate(osThread(lcd), NULL);

  osDelay(500);
                                          /* start command thread            */
  tid_command = osThreadCreate(osThread(command), NULL);
                                          /* start lights thread             */
  tid_lights  = osThreadCreate(osThread(lights), NULL);
                                          /* start keyread thread            */
  tid_keyread = osThreadCreate(osThread(keyread), NULL);

  osDelay(osWaitForever);
  while(1);
}
Example #6
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /* STM32F3xx HAL library initialization:
         - Configure the Flash prefetch
         - Configure the Systick to generate an interrupt each 1 msec
         - Set NVIC Group Priority to 4
         - Low Level Initialization
       */
    HAL_Init();

    /* Configure the System clock to 64 MHz */
    SystemClock_Config();

    /* Initialize LED */
    BSP_LED_Init(LED2);

    /* Create Timer */
    osTimerDef(LEDTimer, osTimerCallback);
    osTimerId osTimer = osTimerCreate(osTimer(LEDTimer), osTimerPeriodic, NULL);
    /* Start Timer */
    osTimerStart(osTimer, 200);


    /* Start scheduler */
    osKernelStart();

    /* We should never get here as control is now taken by the scheduler */
    for (;;);

}
Example #7
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();  
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /* Create Timer */
  osTimerDef(LEDTimer, osTimerCallback);
  osTimerId osTimer = osTimerCreate (osTimer(LEDTimer), osTimerPeriodic, NULL);
  
  /* Start Timer */
  osTimerStart(osTimer, 200);
 
  /* Create LED Thread */
  osThreadDef(LEDThread, ToggleLEDsThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(LEDThread), NULL);
  
  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  for(;;);
}
Example #8
0
// Initialize the blink timer.
void blink_init(void)
{
  // Initialize the blink counter.
  blink_counter = 0;

  // Create the blink timer.
  blink_timer_id = osTimerCreate(osTimer(blink_timer), osTimerPeriodic, NULL);

  // Start the blink timer running with a period of 250 ms.
  osTimerStart(blink_timer_id, 250);
}
Example #9
0
uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context)
{
    if ((timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    uint32_t timeout_ms =
        ((uint32_t)ROUNDED_DIV(timeout_ticks * 1000 * (app_timer_control.prescaler + 1),
                               (uint32_t)APP_TIMER_CLOCK_FREQ));

    app_timer_info_t * p_timer_info = (app_timer_info_t *)timer_id;
    if (rt_id2obj((void *)p_timer_info->id) == NULL)
        return NRF_ERROR_INVALID_PARAM;

    // Pass p_context to timer_timeout_handler
    ((os_timer_cb *)(p_timer_info->id))->arg = p_context;

    if (((os_timer_cb *)(p_timer_info->id))->state == osTimerRunning)
    {
        return NRF_SUCCESS;
    }
    // osTimerStart() returns osErrorISR if it is called in interrupt routine.
    switch (osTimerStart((osTimerId)p_timer_info->id, timeout_ms) )
    {
        case osOK:
            return NRF_SUCCESS;

        case osErrorISR:
            break;

        case osErrorParameter:
            return NRF_ERROR_INVALID_PARAM;

        default:
            return NRF_ERROR_INVALID_PARAM;
    }

    // Start timer without svcCall
    switch (svcTimerStart((osTimerId)p_timer_info->id, timeout_ms))
    {
        case osOK:
            return NRF_SUCCESS;

        case osErrorISR:
            return NRF_ERROR_INVALID_STATE;

        case osErrorParameter:
            return NRF_ERROR_INVALID_PARAM;

        default:
            return NRF_ERROR_INVALID_PARAM;
    }
}
Example #10
0
// Initialize touch input
void touchInit(uint32_t channelMask)
{
   int i;

   // Turn on clock gating for TSI and configure touch input
   clkEnable(CLK_TSI);

   TSI0_GENCS |= ( TSI_GENCS_ESOR_MASK    // Enable end of scan interrupt
                 | TSI_GENCS_MODE(0)      // Capacitive sensing
                 | TSI_GENCS_REFCHRG(4)   // Reference charge 4 uA
                 | TSI_GENCS_DVOLT(0)     // Voltage rails
                 | TSI_GENCS_EXTCHRG(7)   // External osc charge
                 | TSI_GENCS_PS(4)        // Pre-scalar divide by 4
                 | TSI_GENCS_NSCN(11)     // Scans per electrode
                 | TSI_GENCS_TSIIEN_MASK  // Input interrupt enable
                 | TSI_GENCS_STPE_MASK    // Enable in STOP mode
                 );

   TSI0_GENCS |= TSI_GENCS_TSIEN_MASK;

   // Read initial (baseline) values for each enabled channel
   sEnableMask = channelMask;
   for (i = (NUM_CHANNELS - 1); i >= 0; i--)
   {
      if ((1 << i) & sEnableMask)
      {
         scanStart(i);
         while (!(TSI0_GENCS & TSI_GENCS_EOSF_MASK)) // Wait until done
         ;

         sBaseCounts[i] = scanData();
      }
   }

   // Enable TSI interrupts and start the scan timer
   irqRegister(INT_TSI0, tsiIrqHandler, 0);
   irqEnable(INT_TSI0);

   {
      osTimerDef_t tDef;
      
      tDef.ptimer = startTimerCb;
      tDef.millisec = TOUCH_SCAN_TIME;
      tDef.name = "touch";

      sStartTimer = osTimerCreate(&tDef, osTimerPeriodic, 0);
      osTimerStart(sStartTimer, TOUCH_SCAN_TIME);
   }
}
Example #11
0
/**
 * @brief 按键检测Task
 * @param args
 * TODO 修改为使用定时扫描的检测方式
 */
static void _KeyDetectTask(void const *args)
{
	osEvent event;

#if ! _KEY_DETECT_METHOD_INTERRUPT
	osTimerId timid;

	_keyTrigger = 0;
	_keyContinue = 0;

	osTimerDef(keyScan, _KeyScan);
	timid = osTimerCreate(osTimer(keyScan), osTimerPeriodic, NULL);
	osTimerStart(timid, 50);
#endif

	while(1)
	{
		event = osSignalWait(_LOCAL_EVENT_KEY0 | _LOCAL_EVENT_KEY1, osWaitForever);
		if(event.status != osEventSignal)
		{
			Util_NVIC_Cmd(EXTI0_IRQn, ENABLE);
			Util_NVIC_Cmd(EXTI1_IRQn, ENABLE);
			continue;
		}

		if(event.value.signals & _LOCAL_EVENT_KEY0)
		{
			osDelay(20); // 去抖动
			if(_KEY_PRESSED(_IO_KEY0))
			{
				DEBUG_MSG("K0\n");
				Audio_SetCalibrationOn();
			}

			Util_NVIC_Cmd(EXTI0_IRQn, ENABLE);
		}

		if(event.value.signals & _LOCAL_EVENT_KEY1)
		{
			osDelay(20); // 去抖动
			if(_KEY_PRESSED(_IO_KEY1))
			{
				DEBUG_MSG("K1\n");
			}

			Util_NVIC_Cmd(EXTI1_IRQn, ENABLE);
		}
	}
}
Example #12
0
/****************************************************************************************************
 * @fn      ASFTimerStart
 *          Creates a timer with given reference and tick value assigned to the owner.
 *
 * @param   owner  Task ID of the task that will receive the expiry message
 * @param   ref  Unique reference number for the timer
 * @param   tick  Tick count in OS ticks
 * @param   pTimer  Pointer to timer type
 *
 * @return  none
 *
 * @see     ASFTimerKill()
***************************************************************************************************/
void _ASFTimerStart( TaskId owner, uint16_t ref, uint16_t tick, AsfTimer *pTimer, char *_file, int _line  )
{
    uint16_t index = AsfTimerAddTimerToList(pTimer);  // Add this timer to the managed list 

    pTimer->owner = owner;
    pTimer->ticks = tick;
    pTimer->userValue = ref;
    if(pTimer->timerId == NULL)
    {
        pTimer->timerId = osTimerCreate(C_gAsfTaskInitTable[owner].timerDef,osTimerOnce,(void *)index);
    }
    if (pTimer->timerId) 
    {
        pTimer->sysUse = TIMER_SYS_ID;
        osTimerStart(pTimer->timerId, pTimer->ticks);
    }

}
Example #13
0
void InitializeAppShooter()
{
  TimerId = osTimerCreate (osTimer(PeriodicTimer), osTimerPeriodic, NULL);
  if (TimerId) {
    osTimerStart (TimerId, 8);
  }
	
  /* Prepare display */
	GLCD_SetBackgroundColor (GLCD_COLOR_BLACK);
  GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
  GLCD_ClearScreen();
	
	// Variables initialization
	timerTick_01 = 0;										// Timer counter for Main
	timerTick_02 = 0;										// Timer counter for drawing the Objects
	plane_x = 0;												// Plane X position
	plane_y = 110;											// Plane Y position
	actualBallNumber = 0;
	newBall = false;										// Tells to the routine S_MoveBall to create a new ball
	objectNumb = 0;
	objectColor = 1;
	stopThreads = false;
	ballTimer = 0;
	stopShooter = false;
	playerScore = 0;
	machineScore = 0;
	
	S_IncPlayerScore();
	S_IncMachineScore();
	
	if(S_firstTime){
		glcd_semaph_id = osSemaphoreCreate(osSemaphore(glcd_semaph), 1); // Semaphore binaire, only one thread at the same time
		planeVar_mutex_id = osMutexCreate(osMutex(planeVar_mutex));
		objectVar_mutex_id = osMutexCreate(osMutex(objectVar_mutex));
		S_firstTime = false;
	}
	
	idThreadPlane = osThreadCreate (osThread (S_Thread_MovePlane), NULL);   // create the thread

}
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */
       
  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* Create the timer(s) */
  /* definition and creation of debugTimer */
  osTimerDef(debugTimer, debugTimerCallback);
  debugTimerHandle = osTimerCreate(osTimer(debugTimer), osTimerPeriodic, NULL);

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
	osTimerStart(debugTimerHandle, 1000);
  /* USER CODE END RTOS_TIMERS */

  /* Create the thread(s) */
  /* definition and creation of mainTask */
  osThreadDef(mainTask, StartMainTask, osPriorityNormal, 0, 128);
  mainTaskHandle = osThreadCreate(osThread(mainTask), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
	osMessageQDef(mainTaskMessageQ, 10, uint32_t);
	mainTaskMessageQId = osMessageCreate(osMessageQ(mainTaskMessageQ), NULL);
  /* USER CODE END RTOS_QUEUES */
}
Example #15
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F3xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Initialize LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);

  /* Configure the system clock to 72 MHz */
  SystemClock_Config();

  /* Create Timer */
  osTimerDef(LEDTimer, osTimerCallback);
  osTimerId osTimer = osTimerCreate(osTimer(LEDTimer), osTimerPeriodic, NULL);
  /* Start Timer */
  osTimerStart(osTimer, 200);

  /* Create LED Thread */
  osThreadDef(LEDThread, ToggleLEDsThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(LEDThread), NULL);

  /* Start scheduler */
  osKernelStart(NULL, NULL);

  /* We should never get here as control is now taken by the scheduler */
  for (;;);

}
Example #16
0
File: main.c Project: z80/stm32f429
/**
  * @brief  Start task
  * @param  argument: pointer that is passed to the thread function as start argument.
  * @retval None
  */
static void GUIThread(void const * argument)
{   
  /* Initialize Storage Units */
  k_StorageInit();
  
   /* Set General Graphical proprieties */
  k_SetGuiProfile();
#ifdef INCLUDE_THIRD_PARTY_MODULE 
  if(*(__IO uint32_t *)(0x40024000) == GFX_DEMO_SIGNATURE_B)
  {
    *(__IO uint32_t *)(0x40024000) = 0; 
  }
  else
  {
    /* Demo Startup */
    k_StartUp();
  }
#else
  k_StartUp();
#endif
  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 30);
  
  /* Show the main menu */
  k_InitMenu();
    
  /* Gui background Task */
  while(1) {
    GUI_Exec(); /* Do the background work ... Update windows etc.) */
    osDelay(10); /* Nothing left to do for the moment ... Idle processing */
  }
}
Example #17
0
/**
 * Should be called at the beginning of the program to set up the
 * network interface.
 *
 * This function should be passed as a parameter to netif_add().
 *
 * @param[in] netif the lwip network interface structure for this lpc_enetif
 * @return ERR_OK if the loopif is initialized
 *         ERR_MEM if private data couldn't be allocated
 *         any other err_t on error
 */
err_t lpc_enetif_init(struct netif *netif)
{
	err_t err;

	LWIP_ASSERT("netif != NULL", (netif != NULL));

	lpc_enetdata.netif = netif;

	/* set MAC hardware address */
	LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("hwaddress check\r\n"));
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
	netif->hwaddr[0] = MBED_MAC_ADDR_0;
	netif->hwaddr[1] = MBED_MAC_ADDR_1;
	netif->hwaddr[2] = MBED_MAC_ADDR_2;
	netif->hwaddr[3] = MBED_MAC_ADDR_3;
	netif->hwaddr[4] = MBED_MAC_ADDR_4;
	netif->hwaddr[5] = MBED_MAC_ADDR_5;
	LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("using mbed address\r\n"));
#else
	LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("using our address\r\n"));
	mbed_mac_address((char *)netif->hwaddr);
#endif
	netif->hwaddr_len = ETHARP_HWADDR_LEN;

 	/* maximum transfer unit */
	netif->mtu = 1500;

	/* device capabilities */
	netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;

	/* Initialize the hardware */
		LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("initialize the hw\r\n"));
	netif->state = &lpc_enetdata;
		LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("calling low_level_init\r\n"));	
	err = low_level_init(netif);
	if (err != ERR_OK) {
		LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("low_level_init error %d!\r\n", err));	
		return err;
	}

#if LWIP_NETIF_HOSTNAME
	/* Initialize interface hostname */
	netif->hostname = "lwiplpc";
#endif /* LWIP_NETIF_HOSTNAME */

	netif->name[0] = 'e';
	netif->name[1] = 'n';

	netif->output = lpc_etharp_output;
	netif->linkoutput = lpc_low_level_output;
	
    /* CMSIS-RTOS, start tasks */
    LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("running RTOS tasks\r\n"));
#if NO_SYS == 0
#ifdef CMSIS_OS_RTX
    memset(lpc_enetdata.xTXDCountSem.data, 0, sizeof(lpc_enetdata.xTXDCountSem.data));
    lpc_enetdata.xTXDCountSem.def.semaphore = lpc_enetdata.xTXDCountSem.data;
#endif
    lpc_enetdata.xTXDCountSem.id = osSemaphoreCreate(&lpc_enetdata.xTXDCountSem.def, LPC_NUM_BUFF_TXDESCS);
	LWIP_ASSERT("xTXDCountSem creation error", (lpc_enetdata.xTXDCountSem.id != NULL));

	err = sys_mutex_new(&lpc_enetdata.TXLockMutex);
	LWIP_ASSERT("TXLockMutex creation error", (err == ERR_OK));

	/* Packet receive task */
	lpc_enetdata.RxThread = sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
	LWIP_ASSERT("RxThread creation error", (lpc_enetdata.RxThread));

	/* Transmit cleanup task */
	err = sys_sem_new(&lpc_enetdata.TxCleanSem, 0);
	LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK));
	sys_thread_new("txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY);

	/* periodic PHY status update */
	osTimerId phy_timer = osTimerCreate(osTimer(phy_update), osTimerPeriodic, (void *)netif);
	osTimerStart(phy_timer, 250);
#endif
	LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("returning from lpc_enetif_init, %d\r\n", ERR_OK));
    return ERR_OK;
}
/*
	Main Receive Thread. It reads from the wireless  and checks the control part of the packet to determine
	what kind of data we are receiving. There are three types PACKET_CTRL1_BEGIN, PACKET_CTRL1_PR, PACKET_CTRL1_RECORD_BEGIN.
	PACKET_CTRL1_BEGIN = Receiving a desired Roll and Pitch Angle that the board should travel to over some time
	PACKET_CTRL1_PR = simply update the current pitch and roll angle for the board to follow. i.e. real time angle following
	PACKET_CTRL1_RECORD_BEGIN = indicate that we are receiving a sequence of angles that the board will follow.
	
*/
void receive_thread(void const *argument) {
  uint8_t status = CC2500_CommandProbe(CC2500_READBIT, CC2500_SRX);
  printf("Moved to RX (%x) \n",status);
  //osDelay(500);
  
  ring_buffer_t dist_filter; 
  int size = DIST_FILTER_SIZE; 
  int dist_buffer[size];
  init_buffer(&dist_filter,dist_buffer,size);  
    
  float f1, f2, value; 
  uint16_t control;
  uint8_t ctrl = 0;
  uint8_t ctrl2 = 0;
  while (1) { 
    control = receive_pitchroll(&f1, &f2, &ctrl2);
		
		//Check to see what kind of Packet we have received
    if (control == PACKET_CTRL1_BEGIN) {
      while (ctrl != PACKET_CTRL1_END) {
        receive_keypad(&ctrl, &value);
				//update our global values from the recieved data
        switch(ctrl) {
            case PACKET_CTRL1_PITCH: 
              measurements.pitchIncrement = value; 
              break;
            case PACKET_CTRL1_ROLL: 
              measurements.rollIncrement = value; 
              break;
            case PACKET_CTRL1_TIME: 
              measurements.time = value; 
              break;
        } 
      } 
      //printf("EX MOVE pitchIncrement = %f, rollIncrement = %f, time = %f \n",measurements.pitchIncrement,measurements.rollIncrement,measurements.time);
      //Turn off Motor Follow Mode
			measurements.follow = 0;
			//Start OS Timer for Motor 
      osTimerStart(timerid_motor,100);
			//Wait till follow flag has been reset
      while (!measurements.follow) {
        osDelay(500);
      }  
      ctrl = 0; // reset control
    }
		//Update Pitch and Roll angles for motor to follow
    else if (control == PACKET_CTRL1_PR) {

      measurements.pitch = f1;
      measurements.roll = f2;
      //Return the signal strength of the wireless receiver. 
      float f = filter_point(get_signal_strength(), &dist_filter);
      showSignalStrength(f); //updates the LEDs  
      //printf("READ: Pitch = %f (%f) Roll = %f (%f)  Control1 = %x  Pkt_index = %i Power = %f \n",f1,global_pitch,f2,global_roll,control,ctrl2,f);
    }
	//Begin playing Recorded Sequence	
	else if (control == PACKET_CTRL1_RECORD_BEGIN) {
	  float pitchBuffer[256];
	  float rollBuffer[256];
    float time_interval = f1;
		//start receiving the sequence and store in the buffers	
	  receive_record_sequence(pitchBuffer,rollBuffer,&time_interval);
	  //printf("RECV: Record Sequence: \n");
      int i;

      measurements.follow = 3; // Stop Motors Following
      
      //printf("Motors moving sequence, timedelay = %f \n",time_interval); 
      i = 0;
      uint8_t j;
      float f1, f2; 
      float pitchInc, rollInc; 
			//Playing back the Angle Sequence
      while (i < 256) {
        j = 0;
        pitchInc = (pitchBuffer[i+1] - pitchBuffer[i]) / 10;
        rollInc = (rollBuffer[i+1] - rollBuffer[i]) / 10;
        f1 = pitchBuffer[i];
        f2 = rollBuffer[i];
				//Linear Interpolation of the Data as we received only 1/10th the actual sequence
				//so we fill in the blanks using the average of two consequetive angles in the sequence.
        while (j < 10) {
            f1 += pitchInc; 
            f2 += rollInc;
            motorControl(f1, f2, global_pitch, global_roll);
            printf("Motors moving to angle: index = %i  Pitch = %f  Roll = %f \n",i,pitchBuffer[i],rollBuffer[i]); 
            j++;
						osDelay(10);//Delay of 100 so the Loop runs at 100Hz, the rate of which the accelerometer reads.
        }
        //osDelay((int)time_interval);
        i++;
      }
      
      osDelay(1000);
      measurements.follow = 1; // Stop following
		}	
			
  }
}
Example #19
0
void tcpTick(void)
{
   error_t error;
   uint_t i;
   uint_t n;
   uint_t u;

   //Enter critical section
   osMutexAcquire(socketMutex);

   //Loop through opened sockets
   for(i = 0; i < SOCKET_MAX_COUNT; i++)
   {
      //Shortcut to the current socket
      Socket *socket = socketTable + i;
      //Check socket type
      if(socket->type != SOCKET_TYPE_STREAM)
         continue;
      //Check the current state of the TCP state machine
      if(socket->state == TCP_STATE_CLOSED)
         continue;

      //Is there any packet in the retransmission queue?
      if(socket->retransmitQueue != NULL)
      {
         //Retransmission timeout?
         if(osTimerElapsed(&socket->retransmitTimer))
         {
            //When a TCP sender detects segment loss using the retransmission
            //timer and the given segment has not yet been resent by way of
            //the retransmission timer, the value of ssthresh must be updated
            if(!socket->retransmitCount)
            {
               //Amount of data that has been sent but not yet acknowledged
               uint_t flightSize = socket->sndNxt - socket->sndUna;
               //Adjust ssthresh value
               socket->ssthresh = max(flightSize / 2, 2 * socket->mss);
            }

            //Furthermore, upon a timeout cwnd must be set to no more than
            //the loss window, LW, which equals 1 full-sized segment
            socket->cwnd = min(TCP_LOSS_WINDOW * socket->mss, socket->txBufferSize);

            //Make sure the maximum number of retransmissions has not been reached
            if(socket->retransmitCount < TCP_MAX_RETRIES)
            {
               //Debug message
               TRACE_INFO("%s: TCP segment retransmission #%u (%u data bytes)...\r\n",
                  timeFormat(osGetTickCount()), socket->retransmitCount + 1, socket->retransmitQueue->length);

               //Retransmit the earliest segment that has not been
               //acknowledged by the TCP receiver
               tcpRetransmitSegment(socket);

               //Use exponential back-off algorithm to calculate the new RTO
               socket->rto = min(socket->rto * 2, TCP_MAX_RTO);
               //Restart retransmission timer
               osTimerStart(&socket->retransmitTimer, socket->rto);
               //Increment retransmission counter
               socket->retransmitCount++;
            }
            else
            {
               //The maximum number of retransmissions has been exceeded
               tcpChangeState(socket, TCP_STATE_CLOSED);
               //Turn off the retransmission timer
               osTimerStop(&socket->retransmitTimer);
            }

            //TCP must use Karn's algorithm for taking RTT samples. That is, RTT
            //samples must not be made using segments that were retransmitted
            socket->rttBusy = FALSE;
         }
      }

      //Check the current state of the TCP state machine
      if(socket->state == TCP_STATE_CLOSED)
         continue;

      //The persist timer is used when the remote host advertises
      //a window size of zero
      if(!socket->sndWnd && socket->wndProbeInterval)
      {
         //Time to send a new probe?
         if(osTimerElapsed(&socket->persistTimer))
         {
            //Make sure the maximum number of retransmissions has not been reached
            if(socket->wndProbeCount < TCP_MAX_RETRIES)
            {
               //Debug message
               TRACE_INFO("%s: TCP zero window probe #%u...\r\n",
                  timeFormat(osGetTickCount()), socket->wndProbeCount + 1);

               //Zero window probes usually have the sequence number one less than expected
               tcpSendSegment(socket, TCP_FLAG_ACK, socket->sndNxt - 1, socket->rcvNxt, 0, FALSE);
               //The interval between successive probes should be increased exponentially
               socket->wndProbeInterval = min(socket->wndProbeInterval * 2, TCP_MAX_PROBE_INTERVAL);
               //Restart the persist timer
               osTimerStart(&socket->persistTimer, socket->wndProbeInterval);
               //Increment window probe counter
               socket->wndProbeCount++;
            }
            else
            {
               //Enter CLOSED state
               tcpChangeState(socket, TCP_STATE_CLOSED);
            }
         }
      }

      //To avoid a deadlock, it is necessary to have a timeout to force
      //transmission of data, overriding the SWS avoidance algorithm. In
      //practice, this timeout should seldom occur (see RFC 1122 4.2.3.4)
      if(socket->state == TCP_STATE_ESTABLISHED || socket->state == TCP_STATE_CLOSE_WAIT)
      {
         //The override timeout occurred?
         if(socket->sndUser && osTimerElapsed(&socket->overrideTimer))
         {
            //The amount of data that can be sent at any given time is
            //limited by the receiver window and the congestion window
            n = min(socket->sndWnd, socket->cwnd);
            n = min(n, socket->txBufferSize);

            //Retrieve the size of the usable window
            u = n - (socket->sndNxt - socket->sndUna);

            //Send as much data as possible
            while(socket->sndUser > 0)
            {
               //The usable window size may become zero or negative,
               //preventing packet transmission
               if((int_t) u <= 0) break;

               //Calculate the number of bytes to send at a time
               n = min(u, socket->sndUser);
               n = min(n, socket->mss);

               //Send TCP segment
               error = tcpSendSegment(socket, TCP_FLAG_PSH | TCP_FLAG_ACK,
                  socket->sndNxt, socket->rcvNxt, n, TRUE);
               //Failed to send TCP segment?
               if(error) break;

               //Advance SND.NXT pointer
               socket->sndNxt += n;
               //Adjust the number of bytes buffered but not yet sent
               socket->sndUser -= n;
            }

            //Check whether the transmitter can accept more data
            tcpUpdateEvents(socket);

            //Restart override timer if necessary
            if(socket->sndUser > 0)
               osTimerStart(&socket->overrideTimer, TCP_OVERRIDE_TIMEOUT);
         }
      }

      //The FIN-WAIT-2 timer prevents the connection
      //from staying in the FIN-WAIT-2 state forever
      if(socket->state == TCP_STATE_FIN_WAIT_2)
      {
         //Maximum FIN-WAIT-2 time has elapsed?
         if(osTimerElapsed(&socket->finWait2Timer))
         {
            //Debug message
            TRACE_WARNING("TCP FIN-WAIT-2 timer elapsed...\r\n");
            //Enter CLOSED state
            tcpChangeState(socket, TCP_STATE_CLOSED);
         }
      }

      //TIME-WAIT timer
      if(socket->state == TCP_STATE_TIME_WAIT)
      {
         //2MSL time has elapsed?
         if(osTimerElapsed(&socket->timeWaitTimer))
         {
            //Debug message
            TRACE_WARNING("TCP 2MSL timer elapsed (socket %u)...\r\n", i);
            //Enter CLOSED state
            tcpChangeState(socket, TCP_STATE_CLOSED);

            //Dispose the socket if the user does not have the ownership anymore
            if(!socket->ownedFlag)
            {
               //Delete the TCB
               tcpDeleteControlBlock(socket);
               //Mark the socket as closed
               socket->type = SOCKET_TYPE_UNUSED;
            }
         }
      }
   }

   //Leave critical section
   osMutexRelease(socketMutex);
}
Example #20
0
error_t tcpSend(Socket *socket, const uint8_t *data,
   size_t length, size_t *written, uint_t flags)
{
   uint_t n;
   uint_t totalLength;
   uint_t event;

   //Check whether the socket is in the listening state
   if(socket->state == TCP_STATE_LISTEN)
      return ERROR_NOT_CONNECTED;

   //Send as much data as possible
   for(totalLength = 0; totalLength < length; )
   {
      //Wait until there is more room in the send buffer
      event = tcpWaitForEvents(socket, SOCKET_EVENT_TX_READY, socket->timeout);

      //A timeout exception occurred?
      if(event != SOCKET_EVENT_TX_READY)
         return ERROR_TIMEOUT;

      //Check current TCP state
      switch(socket->state)
      {
      //ESTABLISHED or CLOSE-WAIT state?
      case TCP_STATE_ESTABLISHED:
      case TCP_STATE_CLOSE_WAIT:
         //The send buffer is now available for writing
         break;

      //LAST-ACK, FIN-WAIT-1, FIN-WAIT-2, CLOSING or TIME-WAIT state?
      case TCP_STATE_LAST_ACK:
      case TCP_STATE_FIN_WAIT_1:
      case TCP_STATE_FIN_WAIT_2:
      case TCP_STATE_CLOSING:
      case TCP_STATE_TIME_WAIT:
         //The connection is being closed
         return ERROR_CONNECTION_CLOSING;

      //CLOSED state?
      default:
         //The connection was reset by remote side?
         return (socket->resetFlag) ? ERROR_CONNECTION_RESET : ERROR_NOT_CONNECTED;
      }

      //Determine the actual number of bytes in the send buffer
      n = socket->sndUser + socket->sndNxt - socket->sndUna;
      //Exit immediately if the transmission buffer is full (sanity check)
      if(n >= socket->txBufferSize)
         return ERROR_FAILURE;

      //Number of bytes available for writing
      n = socket->txBufferSize - n;
      //Calculate the number of bytes to copy at a time
      n = min(n, length - totalLength);

      //Copy user data to send buffer
      tcpWriteTxBuffer(socket, socket->sndNxt + socket->sndUser, data, n);

      //Update the number of data buffered but not yet sent
      socket->sndUser += n;
      //Advance data pointer
      data += n;
      //Update byte counter
      totalLength += n;
      //Total number of data that have been written
      if(written) *written = totalLength;

      //Update TX events
      tcpUpdateEvents(socket);

      //To avoid a deadlock, it is necessary to have a timeout to force
      //transmission of data, overriding the SWS avoidance algorithm. In
      //practice, this timeout should seldom occur (see RFC 1122 4.2.3.4)
      if(socket->sndUser == n)
         osTimerStart(&socket->overrideTimer, TCP_OVERRIDE_TIMEOUT);

      //The Nagle algorithm should be implemented to coalesce
      //short segments (refer to RFC 1122 4.2.3.4)
      tcpNagleAlgo(socket);
   }

   //The SOCKET_FLAG_WAIT_ACK flag causes the function to
   //wait for acknowledgement from the remote side
   if(flags & SOCKET_FLAG_WAIT_ACK)
   {
      //Wait for the data to be acknowledged
      event = tcpWaitForEvents(socket, SOCKET_EVENT_TX_COMPLETE, socket->timeout);

      //A timeout exception occurred?
      if(event != SOCKET_EVENT_TX_COMPLETE)
         return ERROR_TIMEOUT;

      //The connection was closed before an acknowledgement was received?
      if(socket->state != TCP_STATE_ESTABLISHED && socket->state != TCP_STATE_CLOSE_WAIT)
         return ERROR_NOT_CONNECTED;
   }

   //Successful write operation
   return NO_ERROR;
}
Example #21
0
/**
* @brief  Main program
* @param  None
* @retval int
*/
int main(void)
{
  osTimerId lcd_timer;
  
    /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
  */
  HAL_Init();
 
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
    
  /* Initialize Joystick, Touch screen and Leds */
  k_BspInit();
  k_LogInit();  
  
  /* Initializes backup domain */
  k_CalendarBkupInit();  
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityHigh, 0, 1024);
  osThreadCreate (osThread(GUI_Thread), NULL); 

  /*Initialize memory pools */
  k_MemInit();
  
  /* Add Modules*/
  k_ModuleInit();
  
  k_ModuleAdd(&video_player);
  k_ModuleOpenLink(&video_player, "emf");
  k_ModuleOpenLink(&video_player, "EMF");
  k_ModuleAdd(&image_browser);  
  k_ModuleOpenLink(&image_browser, "jpg"); 
  k_ModuleOpenLink(&image_browser, "JPG");
  k_ModuleOpenLink(&image_browser, "bmp"); 
  k_ModuleOpenLink(&image_browser, "BMP");
  k_ModuleAdd(&audio_player);  
  k_ModuleOpenLink(&audio_player, "wav"); 
  k_ModuleOpenLink(&audio_player, "WAV"); 
  k_ModuleAdd(&camera_capture);    
  k_ModuleAdd(&system_info);
  k_ModuleAdd(&file_browser);  
  k_ModuleAdd(&cpu_bench);  
  k_ModuleAdd(&game_board);  
  k_ModuleAdd(&usb_device);   
  
  /* Initialize GUI */
  GUI_Init();  

  /* Enable memory devices */
  WM_SetCreateFlags(WM_CF_MEMDEV);  
  
  /* Set General Graphical proprieties */
  k_SetGuiProfile();
  
  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 40);
  
  GUI_X_InitOS();
  
  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
Example #22
0
/**
  * @brief  Start task
  * @param  argument: pointer that is passed to the thread function as start argument.
  * @retval None
  */
static void StartThread(void const * argument)
{
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;
  uint32_t FLatency;
  SystemSettingsTypeDef settings;
  osTimerId lcd_timer;
       
  /* Initialize Joystick, Touch screen and LEDs */
  k_BspInit();
  k_LogInit();
  
  /* Initialize GUI */
  GUI_Init();
  WM_MULTIBUF_Enable(1);
  GUI_SelectLayer(1);
  
  /* Initialize RTC */
  k_CalendarBkupInit();
  
  /* Get General settings */
  settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
    
  if(settings.b.use_180Mhz)
  {
    HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &FLatency);
    /* Select HSE as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

    HAL_RCC_GetOscConfig(&RCC_OscInitStruct);  
    RCC_OscInitStruct.PLL.PLLM = 8;
    RCC_OscInitStruct.PLL.PLLN = 360;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLQ = 7;
    HAL_RCC_OscConfig(&RCC_OscInitStruct);
    
    HAL_PWREx_EnableOverDrive();
    
    /* Select PLL as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
  }
  
  k_StartUp();
  
  /* Initialize Storage Units */
  k_StorageInit();
  
  /*Initialize memory pools */
  k_MemInit();
  
  /* Add Modules*/
  k_ModuleInit();
  
  k_ModuleAdd(&video_player);
  k_ModuleOpenLink(&video_player, "emf");
  k_ModuleOpenLink(&video_player, "EMF");
  k_ModuleAdd(&image_browser);  
  k_ModuleOpenLink(&image_browser, "jpg"); 
  k_ModuleOpenLink(&image_browser, "JPG");
  k_ModuleOpenLink(&image_browser, "bmp"); 
  k_ModuleOpenLink(&image_browser, "BMP");
  k_ModuleAdd(&system_info);
  k_ModuleAdd(&file_browser);
  k_ModuleAdd(&cpu_bench);
  k_ModuleAdd(&game_board);
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityHigh, 0, 15 * configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(GUI_Thread), NULL); 

  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 100);
  
  for( ;; )
  {
        /* Toggle LED3 and LED4 */
        BSP_LED_Toggle(LED3);
        BSP_LED_Toggle(LED4);    
        osDelay(250);
  }
}
Example #23
0
/**
* @brief  Main program
* @param  None
* @retval int
*/
int main(void)
{   
  /* Configure the MPU attributes as Write Through */
  MPU_Config();

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();

  /* STM32F7xx HAL library initialization:
  - Configure the Flash ART accelerator on ITCM interface
  - Configure the Systick to generate an interrupt each 1 msec
  - Set NVIC Group Priority to 4
  - Global MSP (MCU Support Package) initialization
  */
  HAL_Init();
  
  /* Configure the system clock @ 200 Mhz */
  SystemClock_Config();
  
  k_BspInit(); 
  
  /* Initialize RTC */
  k_CalendarBkupInit();    
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityNormal, 0, 2048);
  osThreadCreate (osThread(GUI_Thread), NULL); 
  
  /* Add Modules*/
  k_ModuleInit();
  
  /* Link modules */ 
  k_ModuleAdd(&audio_player_board);       
  k_ModuleAdd(&video_player_board);  
  k_ModuleAdd(&games_board);
  k_ModuleAdd(&audio_recorder_board);
  k_ModuleAdd(&gardening_control_board);          
  k_ModuleAdd(&home_alarm_board); 
  k_ModuleAdd(&vnc_server);  
  k_ModuleAdd(&settings_board);  

  /* Initialize GUI */
  GUI_Init();   
  
  WM_MULTIBUF_Enable(1);
  GUI_SetLayerVisEx (1, 0);
  GUI_SelectLayer(0);
  
  GUI_SetBkColor(GUI_WHITE);
  GUI_Clear();  

   /* Set General Graphical proprieties */
  k_SetGuiProfile();
    
  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 100);

  /* Start scheduler */
  osKernelStart ();

  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
Example #24
0
/**
  * @brief  Main program
  * @param  None
  * @retval int
  */
int main(void)
{
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;
  uint32_t FLatency;
  SystemSettingsTypeDef setting;    
  osTimerId lcd_timer;  
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
  */
  HAL_Init();
 
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Initialize Joystick, Touch screen and LEDs */
  k_BspInit();
  k_LogInit(); 
  
  /* Initialize memory pools */
  k_MemInit();  
  
  /* Initialize audio Interface */
  k_BspAudioInit();  
  
  /* Initialize RTC */
  k_CalendarBkupInit();  

  /* Add Modules */
  k_ModuleInit();  
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityHigh, 0, 2048);
  osThreadCreate (osThread(GUI_Thread), NULL); 
  
  k_ModuleAdd(&video_player);
  k_ModuleOpenLink(&video_player, "emf");
  k_ModuleOpenLink(&video_player, "EMF");
  k_ModuleAdd(&image_browser);  
  k_ModuleOpenLink(&image_browser, "jpg"); 
  k_ModuleOpenLink(&image_browser, "JPG");
  k_ModuleOpenLink(&image_browser, "bmp"); 
  k_ModuleOpenLink(&image_browser, "BMP");
  k_ModuleAdd(&audio_player);  
  k_ModuleOpenLink(&audio_player, "wav"); 
  k_ModuleOpenLink(&audio_player, "WAV"); 
  k_ModuleAdd(&camera_capture);    
  k_ModuleAdd(&system_info);
  k_ModuleAdd(&file_browser);  
  k_ModuleAdd(&cpu_bench);  
  k_ModuleAdd(&game_board);  
  k_ModuleAdd(&usb_device);   
  
  /* Initialize GUI */
  GUI_Init();
  WM_MULTIBUF_Enable(1);  
  
  /* Set General Graphical proprieties */
  k_SetGuiProfile();  

  /* Get General settings */
  setting.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
    
  if(setting.b.use_180Mhz)
  {
    HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &FLatency);
    /* Select HSE as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

    HAL_RCC_GetOscConfig(&RCC_OscInitStruct);  
    RCC_OscInitStruct.PLL.PLLM = 25;
    RCC_OscInitStruct.PLL.PLLN = 360;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLQ = 7;
    HAL_RCC_OscConfig(&RCC_OscInitStruct);
    
    HAL_PWREx_EnableOverDrive();
    
    /* Select PLL as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
  }  
  
  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 55);

  GUI_X_InitOS();  
  
  /* Start scheduler */
  osKernelStart();
    
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
Example #25
0
osStatus RtosTimer::start(uint32_t millisec)
{
    return osTimerStart(_id, millisec);
}