コード例 #1
0
ファイル: Timer.c プロジェクト: scarlso/LED_controller
// 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
    }
  }
}
コード例 #2
0
/*----------------------------------------------------------------------------
 *      Thread  'Accelerometer': Reads Accelerometer
 *---------------------------------------------------------------------------*/
void Thread_ACCELEROMETER (void const *argument) 
{		
	/* These are preserved between function calls (static) */
	KalmanState kstate_pitch = {0.001, 0.0032, 0.0, 0.0, 0.0};	/* Filter parameters obtained by experiment and variance calculations */
	KalmanState kstate_roll  = {0.001, 0.0032, 0.0, 0.0, 0.0};	/* Filter parameters obtained by experiment and variance calculations */
	
	float ax, ay, az;
	float roll, pitch;

	osTimerId doubletap_timer_id, accel_dataready_timer_id;
	
	doubletap_timer_id = osTimerCreate(osTimer(doubletap_timer), osTimerOnce, NULL);
	accel_dataready_timer_id = osTimerCreate(osTimer(accel_dataready_timer), osTimerOnce, NULL);
	
	while(1)
	{
		/* Wait for accelerometer new data signal or Nucleo board SPI signal for read request.
		   No need to send data all the time. */
		osSignalWait(ACCELEROMETER_SIGNAL, osWaitForever);

		Accelerometer_ReadAccel(&ax, &ay, &az);
		Accelerometer_Calibrate(&ax, &ay, &az);
					
		Accelerometer_GetRollPitch(ax, ay, az, &pitch, &roll);		
		Kalmanfilter_asm(&pitch, &filtered_pitch, 1, &kstate_pitch);	/* filter the pitch angle */
		Kalmanfilter_asm(&roll, &filtered_roll, 1, &kstate_roll);			/* filter the roll angle 	*/
				
		if (Accelerometer_DetectDoubletap(sqrtf(ax * ax + ay * ay + az * az)))
			NucleoSPI_SetDoubletap(doubletap_timer_id, DOUBLETAP_TIMEOUT_MS);

		NucleoSPI_SetAccelDataready(accel_dataready_timer_id, ACCEL_DATAREADY_TIMEOUT_MS);
	}
}
コード例 #3
0
ファイル: main.cpp プロジェクト: 3eggert/mbed
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);
}
コード例 #4
0
ファイル: main.c プロジェクト: IOIOI/nRF51
/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module. This creates and starts application timers.
 */
static void timers_init(void)
{
    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    m_battery_timer_id = osTimerCreate(osTimer(battery_timer), osTimerPeriodic, NULL);

    m_heart_rate_timer_id = osTimerCreate(osTimer(heart_rate_timer), osTimerPeriodic, NULL);

    m_rr_interval_timer_id = osTimerCreate(osTimer(rr_interval_timer), osTimerPeriodic, NULL);

    m_sensor_contact_timer_id = osTimerCreate(osTimer(sensor_contact_timer), osTimerPeriodic, NULL);
}
コード例 #5
0
ファイル: Traffic.c プロジェクト: EnergyMicro/RTX
/*----------------------------------------------------------------------------
  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);
}
コード例 #6
0
ファイル: main.c プロジェクト: PaxInstruments/STM32CubeF3
/**
  * @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 (;;);

}
コード例 #7
0
ファイル: main.c プロジェクト: Lembed/STM32CubeF4-mirrors
/**
  * @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(;;);
}
コード例 #8
0
ファイル: timers.c プロジェクト: CBo6ogHbIu/234kjh238e7y238
bool timers_initialize(void){
	osTimerId t_id = NULL;
	//	1ms timer
	t_id = osTimerCreate(osTimer(ms_1), osTimerPeriodic, NULL);
	if(t_id != NULL)
		timers[TIMER_1MS] = t_id;
	else
		return false;
	
	t_id = NULL;
	//	1s timer
	t_id = osTimerCreate(osTimer(s_1), osTimerPeriodic, NULL);
	if(t_id != NULL)
		timers[TIMER_1S] = t_id;	
	else 
		return false;
	return is_initialized = true;
}
コード例 #9
0
ファイル: main.c プロジェクト: mpthompson/stm32_f4_firmware
// 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);
}
コード例 #10
0
ファイル: keypad.c プロジェクト: ufbycd/spectrum
/**
 * @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);
		}
	}
}
コード例 #11
0
/*!
 @brief Program entry point
 */
int main (void) {
	
  // ID for threads
  osThreadId tid_transmit;
  osThreadId tid_receive;
  osThreadId tid_accelerometer;    
  
  
  // Start wireless 
  uint8_t status;
  status = init_wireless();
  printf("CC2500 Ready (%x) \n",status);
  osDelay(1000);
  
	//Create Update Mutex
  measureUpdate = osMutexCreate(osMutex(measure_update));
  
	//Start either the Transmitter or Receiver
  if (IS_TRANSMITTER) {    
    init_accelerometer();
    transmit_locked = 0;
    enableKeyboard();
    enableKeyboardINT();
    
    //printf("Transmitter starting threads \n");
    tid_transmit = osThreadCreate(osThread(transmit_thread), NULL);
    tid_accelerometer = osThreadCreate(osThread(accelerometer_thread), NULL);
    tid_keyboard = osThreadCreate(osThread(keyboard_thread), &measurements);
  }
  
  else {
		motorEnable();
		init_accelerometer();
		enableLEDS(); 
    measurements.follow = 1; //Set Motors to follow received values
    //printf("Receiver starting threads \n");
    
    timerid_motor = osTimerCreate(osTimer(MotorTimer),osTimerPeriodic,&exec);
		tid_accelerometer = osThreadCreate(osThread(accelerometer_thread), NULL);
    tid_motor = osThreadCreate(osThread(motor_thread), &measurements);
    tid_receive = osThreadCreate(osThread(receive_thread), NULL);
  }
  
	// The main thread does nothing
	while(1){
		osDelay(osWaitForever);
	}
}
コード例 #12
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

}
コード例 #13
0
ファイル: main.c プロジェクト: afconsult-south/dragonfly-fcb
/**
  * @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 (;;);

}
コード例 #14
0
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 */
}
コード例 #15
0
ファイル: main.c プロジェクト: 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 */
  }
}
コード例 #16
0
ファイル: lpc17_emac.c プロジェクト: mgramli1/pyelixys
/**
 * 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;
}
コード例 #17
0
ファイル: main.c プロジェクト: sincoon/injex
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_SPI2_Init();
  MX_TIM1_Init();
  MX_TIM2_Init();

  /* USER CODE BEGIN 2 */
	InitMotor();
	HAL_TIM_Encoder_Start(&htim1,TIM_CHANNEL_ALL);


  /* USER CODE END 2 */

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

  /* Create the semaphores(s) */
  /* definition and creation of stopMoveByTime */
  osSemaphoreDef(stopMoveByTime);
  stopMoveByTimeHandle = osSemaphoreCreate(osSemaphore(stopMoveByTime), 1);

  /* definition and creation of suspendMoveByTime */
  osSemaphoreDef(suspendMoveByTime);
  suspendMoveByTimeHandle = osSemaphoreCreate(osSemaphore(suspendMoveByTime), 1);

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  xSemaphoreTake(stopMoveByTimeHandle, 0);
  xSemaphoreTake(suspendMoveByTimeHandle, 0);
	/* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* Create the timer(s) */
  /* definition and creation of elapsedTimer */
  osTimerDef(elapsedTimer, elapsedTimerCallback);
  elapsedTimerHandle = osTimerCreate(osTimer(elapsedTimer), osTimerPeriodic, NULL);

  /* definition and creation of moveTimer */
  osTimerDef(moveTimer, moveTimerCallback);
  moveTimerHandle = osTimerCreate(osTimer(moveTimer), osTimerPeriodic, NULL);

  /* USER CODE BEGIN RTOS_TIMERS */
	/* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 64);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

  /* definition and creation of buttonScanTask */
  osThreadDef(buttonScanTask, buttonScanFunc, osPriorityLow, 0, 128);
  buttonScanTaskHandle = osThreadCreate(osThread(buttonScanTask), NULL);

  /* definition and creation of guiTask */
  osThreadDef(guiTask, guiFunc, osPriorityNormal, 0, 128);
  guiTaskHandle = osThreadCreate(osThread(guiTask), NULL);

  /* definition and creation of motorTask */
  osThreadDef(motorTask, motorFunc, osPriorityAboveNormal, 0, 64);
  motorTaskHandle = osThreadCreate(osThread(motorTask), NULL);

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

  /* Create the queue(s) */
  /* definition and creation of buttonEvents */
  osMessageQDef(buttonEvents, 16, uint16_t);
  buttonEventsHandle = osMessageCreate(osMessageQ(buttonEvents), NULL);

  /* definition and creation of encoderEvents */
  osMessageQDef(encoderEvents, 16, uint16_t);
  encoderEventsHandle = osMessageCreate(osMessageQ(encoderEvents), NULL);

  /* USER CODE BEGIN RTOS_QUEUES */
	/* add queues, ... */
  xInputEvents = xQueueCreate( 8, sizeof( struct Event ) );
  xMotorEvents = xQueueCreate( 4, sizeof( struct MotorEvent ) );
  /* USER CODE END RTOS_QUEUES */
 

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

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	while (1)
	{
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */


	}
  /* USER CODE END 3 */

}
コード例 #18
0
ファイル: main.c プロジェクト: PaxInstruments/STM32CubeF4
/**
  * @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( ;; );
}
コード例 #19
0
ファイル: main.c プロジェクト: 451506709/automated_machine
/**
* @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( ;; );
}
コード例 #20
0
ファイル: main.c プロジェクト: 451506709/automated_machine
/**
  * @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);
  }
}
コード例 #21
0
ファイル: main.c プロジェクト: RadMie/STM32F7DiscoveryBase
/**
* @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( ;; );
}