コード例 #1
0
int init_myThread(void) {

  tid_myThread = osThreadCreate(osThread(myThread), NULL);
  if(!tid_myThread) return(-1);
  
  return(0);
}
コード例 #2
0
ファイル: main.c プロジェクト: PaxInstruments/STM32CubeF2
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F2xx 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 120 MHz */
  SystemClock_Config();
  
  /* Init task */
#if defined(__GNUC__)
  osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5);
#else
  osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 2);
#endif
  osThreadCreate (osThread(Start), NULL);
  
  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  for( ;; ); 
}
コード例 #3
0
ファイル: main.c プロジェクト: nguyenvuhung/STM32Cube_FW_F4
/**
  * @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(;;);
}
コード例 #4
0
ファイル: k_storage.c プロジェクト: eemei/library-stm32f4
/**
  * @brief  Storage drives initialization
  * @param  None 
  * @retval None
  */
void k_StorageInit(void)
{
  /* Link the USB Host disk I/O driver */
   FATFS_LinkDriver(&USBH_Driver, USBDISK_Drive);
  
  /* Link the micro SD disk I/O driver */
   FATFS_LinkDriver(&SD_Driver, mSDDISK_Drive);  

  /* Create USB background task */
  osThreadDef(STORAGE_Thread, StorageThread, osPriorityBelowNormal, 0, 2 * configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(STORAGE_Thread), NULL);
  
  /* Create Storage Message Queue */
  osMessageQDef(osqueue, 10, uint16_t);
  StorageEvent = osMessageCreate (osMessageQ(osqueue), NULL);
  
  /* Init Host Library */
  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSB_Host);
  
  /* Enable SD Interrupt mode */
  BSP_SD_Init();
  BSP_SD_ITConfig();
  
  if(BSP_SD_IsDetected())
  {
    osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0);
  }
}
コード例 #5
0
ファイル: main.c プロジェクト: RadMie/STM32F7DiscoveryBase
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /* 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 to 200 MHz */
    SystemClock_Config();

    /* Init task */
#if defined(__GNUC__)
    osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5);
#else
    osThreadDef(Start, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 2);
#endif

    osThreadCreate (osThread(Start), NULL);

    /* Start scheduler */
    osKernelStart();

    /* We should never get here as control is now taken by the scheduler */
    for( ;; );
}
コード例 #6
0
ファイル: freertos.c プロジェクト: issta/t-control
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 */

  /* 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, 128);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

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

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
}
コード例 #7
0
ファイル: RV_Mutex.c プロジェクト: Goodjamp/ble_app_template
/**
\brief Test case: TC_MutexTimeout
\details
- Create and initialize a mutex object
- Create a thread that acquires a mutex but never release it
- Wait for mutex release until timeout
*/
void TC_MutexTimeout (void) {
  osThreadId ctrl_id, lock_id;
  osEvent    evt;

  /* Get control thread id */
  ctrl_id = osThreadGetId ();
  ASSERT_TRUE (ctrl_id != NULL);
  
  if (ctrl_id != NULL) {
    /* - Create and initialize a mutex object */
    G_MutexId = osMutexCreate (osMutex (MutexTout));
    ASSERT_TRUE (G_MutexId != NULL);
    
    if (G_MutexId != NULL) {
      /* - Create a thread that acquires a mutex but never release it */
      lock_id = osThreadCreate (osThread (Th_MutexLock), &ctrl_id);
      ASSERT_TRUE (lock_id != NULL);
      
      if (lock_id != NULL) {
        /* - Wait for mutex release until timeout */
        ASSERT_TRUE (osMutexWait (G_MutexId, 10) == osErrorTimeoutResource);
        /* - Release a mutex */
        osSignalSet (lock_id, 0x01);
        evt = osSignalWait (0x01, 100);
        ASSERT_TRUE (evt.status == osEventSignal);
        /* - Terminate locking thread */
        ASSERT_TRUE (osThreadTerminate (lock_id)  == osOK);
      }
      /* Delete mutex object */
      ASSERT_TRUE (osMutexDelete (G_MutexId)  == osOK);
    }
  }
}
コード例 #8
0
/**
  * @brief Start temperature monitoring thread
  * @param none
  * @retval none
  */
int start_Thread_Temperature(void) {
  ADC1_Config();                              /* configure temperature ADC */

  tid_Thread_Temperature = osThreadCreate(osThread(Thread_Temperature), NULL);
  if (!tid_Thread_Temperature) return -1;
  return 0;
}
コード例 #9
0
void cpufreq_init(void)
{
    dfs_ddrc_calc();
	//dfs_to_max();
	memset(&g_cpufreq, 0x0, sizeof(T_CPUFREQ_ST));
	/* 初始化记录的上一次需要调的频率值 */
	g_cpufreq.maxprof = CPUFREQ_MAX_PROFILE;
	g_cpufreq.minprof = CPUFREQ_MIN_PROFILE;
	g_cpufreq.curprof = cpufreq_get_cur_profile();
    M3_CUR_CPUFREQ_PROFILE = g_cpufreq.curprof;
    M3_MAX_CPUFREQ_PROFILE = g_cpufreq.maxprof;
    M3_MIN_CPUFREQ_PROFILE = g_cpufreq.minprof;
    M3_CPUFREQ_DOWN_FLAG(0) = 0;
    M3_CPUFREQ_DOWN_FLAG(1) = 0;

	cpufreq_mail = osMailCreate(osMailQ(cpufreq_mail), NULL);

	thread_cpufreq_id = osThreadCreate (osThread (thread_cpufreq), NULL);
	if (thread_cpufreq_id == NULL)
	{
		M3CPUFREQ_PRINT(" thread create error\n");
	}

	/* icc channel */
	cpufreq_icc_init();

}
コード例 #10
0
ファイル: main.c プロジェクト: acrepina/STM32F7_serverWEB
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* 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
       - Low Level Initialization
     */
  HAL_Init();
  
  /* Configure the System clock to have a frequency of 200 Mhz */
  SystemClock_Config();
  
  /* Start task */
  osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(USER_Thread), NULL);
  
  /* Create Application Queue */
  osMessageQDef(osqueue, 1, uint16_t);
  AppliEvent = osMessageCreate(osMessageQ(osqueue), NULL);
  
  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #11
0
ファイル: sys_arch.c プロジェクト: brucetsao/arduino-ameba
/*---------------------------------------------------------------------------*
 * Routine:  sys_thread_new
 *---------------------------------------------------------------------------*
 * Description:
 *      Starts a new thread with priority "prio" that will begin its
 *      execution in the function "thread()". The "arg" argument will be
 *      passed as an argument to the thread() function. The id of the new
 *      thread is returned. Both the id and the priority are system
 *      dependent.
 * Inputs:
 *      char *name                -- Name of thread
 *      void (*thread)(void *arg) -- Pointer to function to run.
 *      void *arg                 -- Argument passed into function
 *      int stacksize             -- Required stack amount in bytes
 *      int priority              -- Thread priority
 * Outputs:
 *      sys_thread_t              -- Pointer to thread handle.
 *---------------------------------------------------------------------------*/
sys_thread_t sys_thread_new(const char *pcName,
                            void (*thread)(void *arg),
                            void *arg, int stacksize, int priority) {
    LWIP_DEBUGF(SYS_DEBUG, ("New Thread: %s\n", pcName));
    
    if (thread_pool_index >= SYS_THREAD_POOL_N)
        error("sys_thread_new number error\n");
    sys_thread_t t = (sys_thread_t)&thread_pool[thread_pool_index];
    thread_pool_index++;
    
#ifdef CMSIS_OS_RTX
    t->def.pthread = (os_pthread)thread;
    t->def.tpriority = (osPriority)priority;
    t->def.stacksize = stacksize;
    t->def.stack_pointer = (uint32_t*)mem_malloc(stacksize);
    if (t->def.stack_pointer == NULL) {
      error("Error allocating the stack memory");
    }
#endif
    t->id = osThreadCreate(&t->def, arg);
    if (t->id == NULL)
        error("sys_thread_new create error\n");
    
    return t;
}
コード例 #12
0
ファイル: main.c プロジェクト: acrepina/STM32F7_serverWEB
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* 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
       - Low Level Initialization
     */
  HAL_Init();  
  
  /* Configure the system clock to 216 Mhz */
  SystemClock_Config();
  
  /* Initialize LEDs */
  BSP_LED_Init(LED1);
  
  /* Thread 1 definition */
  osThreadDef(LED1, LED_Thread1, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
  
  /* Start thread 1 */
  LED1_ThreadId = osThreadCreate(osThread(LED1), NULL);
  
  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  for(;;);
}
コード例 #13
0
ファイル: main.c プロジェクト: IOIOI/nRF51
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    ble_evt_pool      = osPoolCreate(osPool(ble_evt_pool));
    ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL);

    // Start execution.
    ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL);
    UNUSED_VARIABLE(ble_stack_thread_id);
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Enter main loop.
    for (;; )
    {
        UNUSED_VARIABLE(osDelay(1000));
    }
}
コード例 #14
0
ファイル: HCBox.c プロジェクト: github188/J-KB6120E_V2x
void	HCBoxInit( void )
{
//	switch ( Configure.HeaterType )
//	{
//	default:
//	case enumHeaterNone:	MsgBox( "未安装恒温箱", vbOKOnly );	break;
//	case enumHCBoxOnly:		Configure_HCBox();	break;
//	case enumHeaterOnly:	Configure_Heater();	break;
//	case enumHCBoxHeater:	MsgBox( "硬件不能支持", vbOKOnly );	break;
//	}
// 	set_HCBoxTemp( Configure.HCBox_SetTemp * 0.1f, Configure.HCBox_SetMode );
	switch ( Configure.HeaterType )
	{
		default:
		case enumHeaterNone:
			break;	//	MsgBox( "未安装恒温箱", vbOKOnly );	break;
		case enumHCBoxOnly:
			set_HCBoxTemp( Configure.HCBox_SetTemp * 0.1f, Configure.HCBox_SetMode );
			Set_HCBox_Temp( Configure.HCBox_SetTemp * 0.1f, Configure.HCBox_SetMode );
			osThreadCreate( osThread( _task_HCBox ), NULL );
			break;
		case enumHeaterOnly:
			set_HeaterTemp( Configure.Heater_SetTemp * 0.1f);
			break;
		case enumHCBoxHeater:
			set_HCBoxTemp( Configure.HCBox_SetTemp * 0.1f, Configure.HCBox_SetMode );
			set_HeaterTemp( Configure.Heater_SetTemp*0.1f);
			break;
	}

}
コード例 #15
0
// メインスレッド
extern "C" int main(void){
	clDigitalIO<PIN_LED1> PinLED1;
	
	/* OSリソースの作成を伴うデバイスインスタンスの初期化を行う */
	
	// カメラの初期化
	Camera.Init(CAMERA_IRQ_PRIORITY);
	
	// UART0の初期化
	Uart0.Init(HOSTIF_BAUDRATE, HOSTIF_IRQ_PRIORITY);
	
	// USBの初期化
	USBSerial.Init(USB_IRQ_PRIORITY);
	
	
	
	
	
	//osThreadSetPriority(osThreadGetId(), osPriorityRealtime);
	
	
	
	
	/* スレッドを起動 */
	osThreadDef(CameraThread, osPriorityHigh, 1, 0);
	osThreadCreate(osThread(CameraThread), nullptr);
	
	//udd_enable();
	
	
	// テストメッセージ出力
	Uart0.printf("usb test\n");
	//USBSerial.printf("usb test\n");
	
	// USBを有効化
	USBSerial.Enable(true);
	
	while(true){
		USBSerial.PollVBUS(GetIn(PIN_USB_VBUS));
		
		PinLED1.SetOut(true);
		osDelay(50);
		PinLED1.SetOut(false);
		osDelay(50);
		
		/*int c;
		while((c = Uart0.getc()) != iSerial::EOF){
			Uart0.putc(c);
			USBSerial.putc(c);
		}*/
		
		/*while((c = USBSerial.getc()) != iSerial::EOF){
			Uart0.putc(c);
			USBSerial.putc(c);
		}*/
		
    }
	
	return 0;
}
コード例 #16
0
ファイル: Thread.cpp プロジェクト: SolarTeamEindhoven/mbed
osStatus Thread::start(Callback<void()> task) {
    _mutex.lock();

    if (_tid != 0) {
        _mutex.unlock();
        return osErrorParameter;
    }

#if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM)
    _thread_def.pthread = Thread::_thunk;
    if (_thread_def.stack_pointer == NULL) {
        _thread_def.stack_pointer = new uint32_t[_thread_def.stacksize/sizeof(uint32_t)];
        MBED_ASSERT(_thread_def.stack_pointer != NULL);
    }

    //Fill the stack with a magic word for maximum usage checking
    for (uint32_t i = 0; i < (_thread_def.stacksize / sizeof(uint32_t)); i++) {
        _thread_def.stack_pointer[i] = 0xE25A2EA5;
    }
#endif
    _task = task;
    _tid = osThreadCreate(&_thread_def, this);
    if (_tid == NULL) {
        if (_dynamic_stack) {
            delete[] (_thread_def.stack_pointer);
            _thread_def.stack_pointer = (uint32_t*)NULL;
        }
        _mutex.unlock();
        _join_sem.release();
        return osErrorResource;
    }

    _mutex.unlock();
    return osOK;
}
コード例 #17
0
ファイル: Thread_1.c プロジェクト: nanobrain/Kinetis_RTOS
int Init_Thread_1 (void) {

    tid_Thread_1 = osThreadCreate (osThread(Thread_1), NULL);
    if(!tid_Thread_1) return(-1);

    return(0);
}
コード例 #18
0
ファイル: ADC2_Thread.c プロジェクト: buczio/sterowanieADC
int Init_ThreadADC2 (void) {

  tid_ADC2 = osThreadCreate (osThread(Thread_ADC2), NULL);
  if (!tid_ADC2) return(-1);
  
  return(0);
}
コード例 #19
0
ファイル: main.c プロジェクト: 451506709/automated_machine
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F446xx HAL library initialization */
  HAL_Init();
  
  /* Configure the system clock to 180 Mhz */
  SystemClock_Config();
  
  /* Initialize IO expander */
  BSP_IO_Init();

  /* Start task */
  osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(USER_Thread), NULL);
  
  /* Create Application Queue */
  osMessageQDef(osqueue, 1, uint16_t);
  AppliEvent = osMessageCreate(osMessageQ(osqueue), NULL);
  
  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #20
0
/**
  * @brief Start 7-segment display thread
  * @param none
  * @retval none
  */
int start_Thread_Segment(void) {
  Display_GPIO_Config();
  display_degree(degree_on);
  tid_Thread_Segment = osThreadCreate(osThread(Thread_Segment), NULL);
  if (!tid_Thread_Segment) return -1;
  return 0;
}
コード例 #21
0
ファイル: RV_Mutex.c プロジェクト: Goodjamp/ble_app_template
/**
\brief Test case: TC_MutexNestedAcquire
\details
- Create a mutex object
- Obtain a mutex object
- Create a high priority thread that waits for the same mutex
- Recursively acquire and release a mutex object
- Release a mutex
- Verify that every subsequent call released the mutex
- Delete a mutex object
- Mutex object must be released after each acquisition
*/
void TC_MutexNestedAcquire (void) {
  osStatus stat;
  
  /* - Create a mutex object */
  G_MutexId = osMutexCreate (osMutex (Mutex_Nest));
  ASSERT_TRUE (G_MutexId != NULL);

  if (G_MutexId  != NULL) {
    /* - Obtain a mutex object */
    stat = osMutexWait (G_MutexId, 0);
    ASSERT_TRUE (stat == osOK);
    
    if (stat == osOK) {
      /* - Create a high priority thread that will wait for the same mutex */
      G_Mutex_ThreadId = osThreadCreate (osThread (Th_MutexWait), NULL);
      ASSERT_TRUE (G_Mutex_ThreadId != NULL);
    
      /* - Recursively acquire and release a mutex object */
      RecursiveMutexAcquire (5, 5);

      /* - Release a mutex */
      stat = osMutexRelease (G_MutexId);
      ASSERT_TRUE (stat == osOK);

      /* - Verify that every subsequent call released the mutex */
      ASSERT_TRUE (osMutexRelease (G_MutexId) == osErrorResource);
    }
    /* - Delete a mutex object */
    ASSERT_TRUE (osMutexDelete (G_MutexId) == osOK);
  }
}
コード例 #22
0
ファイル: EventLogger.c プロジェクト: ntonjeta/Nodo-Sensore
EventLogger_Status_TypeDef EventLogger_Init(EventLogger_Handle_TypeDef *plog, EventLogger_Interface_TypeDef *ploginterface){

	if(Attached_Once == 0){
		if(plog->LogFile == NULL) plog->LogFile = LOGFILE_DEFAULT;
		plog->Interface = ploginterface;

		plog->LogStatus = plog->Interface->Init(plog);
#if (LOG_USE_OS == 1)
		osMutexDef(Log_Mutex);
		Log_Mutex = osMutexCreate(osMutex(Log_Mutex));
#if (LOG_USE_BUFFERING == 1)
		for(int i = 0; i< LOG_MAX_BUFF; i++) LogIndex_List[i] = 0;
		osMessageQDef(Log_Queue, LOG_MAX_BUFF, uint16_t);
		plog->os_event = osMessageCreate (osMessageQ(Log_Queue), NULL);
		osThreadDef(LogCollector, LogCollector_Process_OS, osPriorityHigh, 0, (8 * configMINIMAL_STACK_SIZE));
		plog->thread = osThreadCreate (osThread(LogCollector), plog);
		plog->pLogData = 0;
#endif	//END BUFFRING
#endif	//END OS
#if (LOG_USE_BUFFERING == 0)
		plog->pLogData = &LogMsg;
#endif

		Attached_Once = 1;
	}
	else{
		plog->Interface = ploginterface;
		Attached_Once = 1;
	}
	return plog->LogStatus;
}
コード例 #23
0
ファイル: main.c プロジェクト: GreyCardinalRus/stm32-cube
/**
  * @brief  Start Thread
  * @param  argument not used
  * @retval None
  */
static void StartThread(void const * argument)
{
  /* Initialize LCD and LEDs */
  BSP_Config();
  
  /* Create tcp_ip stack thread */
  tcpip_init( NULL, NULL );
  
  /* Initilaize the LwIP stack */
  Netif_Config();
  
  /* Initialize tcp echo server */
  tcpecho_init();

  /* Initialize udp echo server */
  udpecho_init();
  
  /* Notify user about the netwoek interface config */
  User_notification(&gnetif);
  
  /* Start toogleLed4 task : Toggle LED4  every 250ms */
  osThreadDef(LED4, ToggleLed4, osPriorityLow, 0, configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(LED4), NULL);

  for( ;; )
  {
    /* Delete the Init Thread*/ 
    osThreadTerminate(NULL);
  }
}
コード例 #24
0
ファイル: main.c プロジェクト: pierreroth64/STM32Cube_FW_F4
/**
  * @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 */
  BSP_LED_Init(LED1);
  
  /* Configure TAMPER Button */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI);  
  
  /* Define used semaphore */
  osSemaphoreDef(SEM);
  
  /* Create the semaphore  */
  osSemaphore = osSemaphoreCreate(osSemaphore(SEM) , 1);
  
  /* Create the Thread that toggle LED1 */
  osThreadDef(SEM_Thread, SemaphoreTest, osPriorityNormal, 0, semtstSTACK_SIZE);
  osThreadCreate(osThread(SEM_Thread), (void *) osSemaphore);
  
  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  for(;;);
}
コード例 #25
0
ファイル: main.c プロジェクト: PaxInstruments/STM32CubeF4
/**
  * @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 168 MHz */
  SystemClock_Config();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);  
  
  /*##-1- Start task #########################################################*/
  osThreadDef(USER_Thread, StartThread, osPriorityNormal, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(USER_Thread), NULL);
  
  /*##-2- Create Application Queue ###########################################*/
  osMessageQDef(osqueue, 1, uint16_t);
  AppliEvent = osMessageCreate(osMessageQ(osqueue), NULL);
  
  /*##-3- Start scheduler ####################################################*/
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #26
0
/**************************************************************************//**
 * @brief
 *   Main function is a CMSIS RTOS thread in itself
 *
 * @note
 *   This example uses threads, memory pool and message queue to demonstrate the
 *   usage of these CMSIS RTOS features. In this simple example, the same
 *   functionality could more easily be achieved by doing everything in the main
 *   loop.
 *****************************************************************************/
int main(void)
{
  int count = 0;

  /* Chip errata */
  CHIP_Init();

  /* Initialize CMSIS RTOS structures */
  /* create memory pool */
  mpool = osPoolCreate(osPool(mpool));
  /* create msg queue */
  msgBox = osMessageCreate(osMessageQ(msgBox), NULL);
  /* create thread 1 */
  osThreadCreate(osThread(PrintLcdThread), NULL);

  /* Infinite loop */
  while (1)
  {
    count = (count + 1) & 0xF;

    /* Send message to PrintLcdThread */
    /* Allocate memory for the message */
    lcdText_t *mptr = osPoolAlloc(mpool);
    /* Set the message content */
    (*mptr)[0] = count >= 10 ? '1' : '0';
    (*mptr)[1] = count % 10 + '0';
    (*mptr)[2] = '\0';
    /* Send message */
    osMessagePut(msgBox, (uint32_t) mptr, osWaitForever);

    /* Wait now for half a second */
    osDelay(500);
  }
}
コード例 #27
0
ファイル: main.c プロジェクト: AlexShiLucky/ChibiOS
/*
 * Application entry point.
 */
int main(void) {

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* The kernel is initialized but not started yet, this means that
     main() is executing with absolute priority but interrupts are
     already enabled.*/
  osKernelInitialize();

  /* Activates the serial driver 2 using the driver default configuration.
    PA2(TX) and PA3(RX) are routed to USART2.*/
  sdStart(&SD2, NULL);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  /* Creates the example thread, it does not start immediately.*/
  osThreadCreate(osThread(Thread1), NULL);

  /* Kernel started, the main() thread has priority osPriorityNormal
     by default.*/
  osKernelStart();

  /* In the ChibiOS/RT CMSIS RTOS implementation the main() is an
     usable thread, here we just sleep in a loop printing a message.*/
  while (true) {
    sdWrite(&SD2, (uint8_t *)"Hello World!\r\n", 14);
    osDelay(500);
  }
}
コード例 #28
0
int Init_Main_Thread (void) {

  tid_MainThread = osThreadCreate (osThread(MainThread), NULL);
  if (!tid_MainThread) return(-1);
	
#ifdef USE_DGUS_DRIVER
	/*Initialize the USART driver */
  Driver_USART1.Initialize(DWIN_USART_callback);
  /*Power up the USART peripheral */
  Driver_USART1.PowerControl(ARM_POWER_FULL);
	
  /*Configure the USART to 115200 Bits/sec */
  Driver_USART1.Control(ARM_USART_MODE_ASYNCHRONOUS |
												ARM_USART_DATA_BITS_8 |
												ARM_USART_PARITY_NONE |
												ARM_USART_STOP_BITS_1 |
												ARM_USART_FLOW_CONTROL_NONE, DGUS_BAUDRATE);
	
	/* Enable Receiver and Transmitter lines */
  Driver_USART1.Control (ARM_USART_CONTROL_TX, 1);
  Driver_USART1.Control (ARM_USART_CONTROL_RX, 1);
	
	/* Set DGUS driver */
	DGUS_USART_Driver = &Driver_USART1;
#endif
	
  return(0);
}
コード例 #29
0
ファイル: main.c プロジェクト: Coderz333/cyassl
int main() 
{
    static char *argv[] = 
          {   "client",   "-h", CYASSL_CALLEE_IP, "-p", CYASSL_CALLEE_PORT, 
                                   "-v",  CYASSL_SSL_VER,  CYASSL_HTTP_GET } ;
    static   func_args args  = 
          {  7 + CYASSL_HTTP_GET_COUNT, argv } ; 
        
    init_time() ;
    init_filesystem ();
    net_initialize() ;
    osThreadCreate (osThread (tcp_poll), NULL); 
    osDelay(50000) ;  /* wait for DHCP */
    #if defined(DEBUG_CYASSL)
         printf("Turning ON Debug message\n") ;
         CyaSSL_Debugging_ON() ;
    #endif
        
    if(args.argc == 7)
        printf("Simple SSL/TLS, ") ;
    else
        printf("HTTP GET, ") ;

    printf("Callee IP: %s, Port: %s, Version:%s\n", argv[2], argv[4], argv[6]) ; 

    while(1) {
          client_test(&args) ;
          printf("Enter any key to iterate.\n") ;
          getchar() ;
    }
}
コード例 #30
0
ファイル: main.c プロジェクト: MrZANE42/verisure1512
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* 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 to 216 MHz */
  SystemClock_Config();
  
  /* Configure LED1 */
  BSP_LED_Init(LED1);
  
  /*##-1- Start task #########################################################*/
  osThreadDef(uSDThread, StartThread, osPriorityNormal, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(uSDThread), NULL);
  
  /*##-2- Start scheduler ####################################################*/
  osKernelStart();

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