コード例 #1
0
ファイル: menu.c プロジェクト: nguyenvuhung/STM32Cube_FW_F4
/**
  * @brief  Demo state machine.
  * @param  None
  * @retval None
  */
void HID_MenuInit(void)
{
  /* Create Menu Semaphore */
  osSemaphoreDef(osSem);

  MenuEvent = osSemaphoreCreate(osSemaphore(osSem), 1); 
  
  /* Force menu to show Item 0 by default */
  osSemaphoreRelease(MenuEvent);
  
  /* Menu task */
  osThreadDef(Menu_Thread, HID_MenuThread, osPriorityHigh, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(Menu_Thread), NULL);
  
  BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
  BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [Joystick Left/Right] to scroll up/down");
  BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down] to scroll HID menu");
}
コード例 #2
0
/**
  * @brief  Initializes audio
  * @param  None.
  * @retval Audio state.
  */
AUDIOPLAYER_ErrorTypdef  AUDIOPLAYER_Init(void)
{
  /* Initialize internal audio structure */
  haudio.state  = AUDIOPLAYER_STOP;
  haudio.mute   = MUTE_OFF;
  haudio.volume = AUDIO_DEFAULT_VOLUME;  

  /* Create Audio Queue */
  osMessageQDef(AUDIO_Queue, 1, uint16_t);
  AudioEvent = osMessageCreate (osMessageQ(AUDIO_Queue), NULL); 
  
  /* Create Audio task */
  osThreadDef(osAudio_Thread, Audio_Thread, osPriorityHigh, 0, 4 * configMINIMAL_STACK_SIZE);
  AudioThreadId = osThreadCreate (osThread(osAudio_Thread), NULL);  

  BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
  return AUDIOPLAYER_ERROR_NONE;
}
コード例 #3
0
/**  
  * @brief  Function that initializes the transmitter.
  * @param  *transmitter: Pointer to a Transmitter structure.
	* @param  *tid_thread_transmitter: Pointer to the pushbutton thread control block.
  * @retval None  
  */
void init_transmitter(struct Transmitter *transmitter, osThreadId **tid_thread_transmitter) {
	transmitter->state = 0;
	transmitter->buffer_space = 0;
	
	uint32_t i;
	for (i=0; i<sizeof(transmitter->data)/sizeof(transmitter->data[0]); i++) {
		transmitter->data[i] = 0;
	}
	
	CC2500_Init();
	CC2500_config_transmitter();
	goToTX(&(transmitter->state), &(transmitter->buffer_space));
	
	osThreadDef(transmitterThread, osPriorityNormal, 1, 0);
	transmitter->threadID = osThreadCreate(osThread(transmitterThread), transmitter);
	
	osMutexDef(transmitterMutex);
	transmitter->mutexID=osMutexCreate(osMutex(transmitterMutex));
	
	*tid_thread_transmitter = &(transmitter->threadID);
}
コード例 #4
0
ファイル: usbh_core.c プロジェクト: 19emtuck/micropython
/**
  * @brief  HCD_Init 
  *         Initialize the HOST Core.
  * @param  phost: Host Handle
  * @param  pUsrFunc: User Callback
  * @retval USBH Status
  */
USBH_StatusTypeDef  USBH_Init(USBH_HandleTypeDef *phost, void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t ), uint8_t id)
{
  /* Check whether the USB Host handle is valid */
  if(phost == NULL)
  {
    USBH_ErrLog("Invalid Host handle");
    return USBH_FAIL; 
  }
  
  /* Set DRiver ID */
  phost->id = id;
  
  /* Unlink class*/
  phost->pActiveClass = NULL;
  phost->ClassNumber = 0;
  
  /* Restore default states and prepare EP0 */ 
  DeInitStateMachine(phost);
  
  /* Assign User process */
  if(pUsrFunc != NULL)
  {
    phost->pUser = pUsrFunc;
  }
  
#if (USBH_USE_OS == 1) 
  
  /* Create USB Host Queue */
  osMessageQDef(USBH_Queue, 10, uint16_t);
  phost->os_event = osMessageCreate (osMessageQ(USBH_Queue), NULL); 
  
  /*Create USB Host Task */
  osThreadDef(USBH_Thread, USBH_Process_OS, USBH_PROCESS_PRIO, 0, 8 * configMINIMAL_STACK_SIZE);
  phost->thread = osThreadCreate (osThread(USBH_Thread), phost);
#endif  
  
  /* Initialize low level driver */
  USBH_LL_Init(phost);
  return USBH_OK;
}
コード例 #5
0
ファイル: main.c プロジェクト: eleciawhite/STM32Cube
/**
  * @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(LED3);

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

    /* Initialize buttons */
    BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);

    /* Define used semaphore */
    osSemaphoreDef(SEM);

    /* Create the semaphore used by the two threads */
    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(NULL, NULL);

    /* We should never get here as control is now taken by the scheduler */
    for (;;);
}
コード例 #6
0
/**
  * @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);
  
  /* Init Host Library */
  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
    /* Create USB background task */
  osThreadDef(STORAGE_Thread, StorageThread, osPriorityLow, 0, 64);
  osThreadCreate (osThread(STORAGE_Thread), NULL);
  
  /* Create Storage Message Queue */
  osMessageQDef(osqueue, 10, uint16_t);
  StorageEvent = osMessageCreate (osMessageQ(osqueue), NULL);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSB_Host);
}
コード例 #7
0
/**
  * @brief  starts VNC server thread  
  * @param  LayerIndex: LCD layer index
  * @param  ServerIndex: Server index
  * @retval server started or not
  */
int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) {

  /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */
  GUI_VNC_AttachToLayer(&_Context, LayerIndex);
  _Context.ServerIndex = ServerIndex;
  _Context.LayerIndex = LayerIndex;
  
  /* Create task for VNC Server */
  osThreadDef(VNC_Server, _ServerThread, _VNCServer_PRIO, 0, _VNCServer_Stack);
  _VNCServer_TCB = osThreadCreate (osThread(VNC_Server), NULL);
 
  if (_VNCServer_TCB == 0)
  {
    /* K.O., server initialization failed */
    return 0;
  }
  else
  {
    /* O.k., server has been started */ 
    return 1;
  }
}
コード例 #8
0
ファイル: main.c プロジェクト: pierreroth64/STM32Cube_FW_F4
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F469xx HAL library initialization  */
  HAL_Init();
  
  /* Configure the System clock to have a frequency of 180 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( ;; ); 
}
コード例 #9
0
ファイル: comm.c プロジェクト: tusimbe/battery
void CommInit(void)
{
    huart2.Instance = USART2;
    huart2.Init.BaudRate = 57600;
    huart2.Init.WordLength = UART_WORDLENGTH_8B;
    huart2.Init.StopBits = UART_STOPBITS_1;
    huart2.Init.Parity = UART_PARITY_NONE;
    huart2.Init.Mode = UART_MODE_TX_RX;
    huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart2.Init.OverSampling = UART_OVERSAMPLING_16;
    HAL_UART_Init(&huart2);

    hcrc.Instance = CRC;
    HAL_CRC_Init(&hcrc);

    chIQInit(&g_iqp, g_comm_iqp_buf, COMM_IQP_BUF_SIZE, NULL);

    osSemaphoreDef(COMM_SEMA);
    commSema = osSemaphoreEmptyCreate(osSemaphore(COMM_SEMA));
    if (NULL == commSema)
    {
        printf("[%s, L%d] create semaphore failed!\r\n", __FILE__, __LINE__);
        return;
    }

    osThreadDef(CommTask, CommStartTask, osPriorityNormal, 0, 1024);
    CommTaskHandle = osThreadCreate(osThread(CommTask), NULL);
    if (NULL == CommTaskHandle)
    {
        printf("[%s, L%d] create thread failed!\r\n", __FILE__, __LINE__);
        return;
    }

    HAL_NVIC_SetPriority(USART2_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY, 0);
    HAL_NVIC_EnableIRQ(USART2_IRQn);

    __HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE);
    return;
}
コード例 #10
0
/**
  * @brief  Initializes audio
  * @param  None.
  * @retval Audio state.
  */
AUDIO_RECORDER_ErrorTypdef  AUDIO_RECORDER_Init(uint8_t volume)
{
  /* Initialize internal audio structure */

  haudio.in.volume = DEFAULT_REC_AUDIO_VOLUME;  
   
 
  /* Register audio BSP drivers callbacks */
  AUDIO_IF_RegisterCallbacks(AUDIO_TransferComplete_CallBack, 
                             AUDIO_HalfTransfer_CallBack, 
                             AUDIO_Error_CallBack);
  
  /* Create Audio Queue */
  osMessageQDef(AUDIO_Queue, 1, uint16_t);
  AudioEvent = osMessageCreate (osMessageQ(AUDIO_Queue), NULL); 
  
  /* Create Audio task */
  osThreadDef(osAudio_Thread, Audio_Thread, osPriorityNormal, 0, 1024);
  AudioThreadId = osThreadCreate (osThread(osAudio_Thread), NULL);  
  haudio.in.state  = AUDIO_RECORDER_IDLE;
  return AUDIO_RECORDER_ERROR_NONE;
}
コード例 #11
0
ファイル: main.c プロジェクト: Lembed/STM32CubeF1-mirrors
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
  
  /* Configure the system clock to 72 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( ;; );
}
コード例 #12
0
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
	/* init code for FATFS */
//	MX_FATFS_Init();

	/* init code for USB_HOST */
//	MX_USB_HOST_Init();
	
	/* USER CODE BEGIN StartDefaultTask */
    osThreadDef(ledTask, StartLedTask, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
    ledGreenTaskHandle = osThreadCreate(osThread(ledTask), NULL);
    
//    osThreadDef(lcdDisplayTask, StartLcdDisplayTask, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
//    lcdDisplayTaskHandle = osThreadCreate(osThread(lcdDisplayTask), NULL);
	/* Infinite loop */
    
    osThreadTerminate(defaultTaskHandle);
	for(;;){
	  osDelay(1);
	}
	/* USER CODE END StartDefaultTask */
}
コード例 #13
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 */
}
コード例 #14
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 (;;);

}
コード例 #15
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
       - Low Level Initialization
     */
  HAL_Init();  
  
  /* Configure the system clock to 216 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 used by the two threads. */
  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(;;);
}
コード例 #16
0
ファイル: main.c プロジェクト: ClintHaerinck/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();
  
  /* Init task */
  osThreadDef(Start, StartThread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE *2);
  osThreadCreate (osThread(Start), NULL);
  
  /* Start the scheduler */
  osKernelStart(NULL, NULL);
  
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #17
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();
  
  /* Initialize IO expander */
  BSP_IO_Init();

  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);  

  /* ###########################################################################
   When the uSD Card is used; the Camera module must be unplugged, this is due
   to the shared pins between the two devices. 
  
   Otherwise, you have to set camera sensor in Power Down mode, by calling the
   BSP_CAMERA_PwrDown() available under stm32469i_eval_camera.c BSP driver */
  
  /*##-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( ;; );
}
コード例 #18
0
ファイル: menu.c プロジェクト: z80/stm32f429
/**
  * @brief  Demo state machine.
  * @param  None
  * @retval None
  */
void Menu_Init(void)
{
  /* Create Menu Semaphore */
  osSemaphoreDef(osSem);

  MenuEvent = osSemaphoreCreate(osSemaphore(osSem), 1); 
  
  /* Force menu to show Item 0 by default */
  osSemaphoreRelease(MenuEvent);

  /* Menu task */
  osThreadDef(Menu_Thread, MSC_MenuThread, osPriorityHigh, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(Menu_Thread), NULL);
  
  /* Define used semaphore fot Joystick*/
  osSemaphoreDef(JOY_SEM);
  
  /* Create the semaphore used by the two threads. */
  osJoySemaphore = osSemaphoreCreate(osSemaphore(JOY_SEM) , 1);
  
  BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
  BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [Joystick Left/Right] to scroll up/down");
  BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down] to scroll MSC menu");  
}
コード例 #19
0
ファイル: freertos.c プロジェクト: MrH2S/coin_sort_mach_l0
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, ... */
	osThreadDef(thread_push,thread_push_entry,osPriorityRealtime,1,128);
	thread_push_id    = osThreadCreate(osThread(thread_push),NULL);
  /* USER CODE END RTOS_THREADS */
	
  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
	osMessageQDef(mesq,MesQ_Size,uint32_t);
	mesq_id           = osMessageCreate(osMessageQ(mesq),thread_push_id); 
  /* USER CODE END RTOS_QUEUES */
}
コード例 #20
0
ファイル: freertos.c プロジェクト: Oxbern/CCube_Firmware
void StartInitTask(void const * argument)
{
	console_init();

	osThreadDef(touchTask, StartTouchTask, osPriorityHigh, 0, 8192);
	touchTaskHandle = osThreadCreate(osThread(touchTask), NULL);

	osThreadDef(pwmTask, StartPwmTask, osPriorityNormal, 0, 8192);
	pwmTaskHandle = osThreadCreate(osThread(pwmTask), NULL);

	osThreadDef(ledTask, StartLedTask, osPriorityNormal, 0, 8192);
	ledTaskHandle = osThreadCreate(osThread(ledTask), NULL);

	osThreadDef(fsTask, StartFsTask, osPriorityNormal, 0, 32768);
	fsTaskHandle = osThreadCreate(osThread(fsTask), NULL);

	osThreadDef(guiTask, StartGuiTask, osPriorityNormal, 0, 8192);
	guiTaskHandle = osThreadCreate(osThread(guiTask), NULL);

	osThreadDef(blinkTask, StartBlinkTask, osPriorityNormal, 0, 8192);
	blinkTaskHandle = osThreadCreate(osThread(blinkTask), NULL);

	vTaskDelete(initTaskHandle);
}
コード例 #21
0
ファイル: main.c プロジェクト: uavosky/STM32Cube
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_CAN_Init();
  MX_IWDG_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* 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 */
 

  /* 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 */

}
コード例 #22
0
static void low_level_init(struct netif *netif)
{
  uint8_t macaddress[6];
  uint32_t regvalue = 0;

  // Get Ethernet MAC address
  stm32f_set_mac_addr((uint8_t*) macaddress);

  EthHandle.Instance = ETH;
  EthHandle.Init.MACAddr = macaddress;
  EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
  EthHandle.Init.Speed = ETH_SPEED_100M;
  EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
  EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII;
  EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE;
  EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
  EthHandle.Init.PhyAddress = DP83848_PHY_ADDRESS;

  /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
  if (HAL_ETH_Init(&EthHandle) == HAL_OK)
  {
    /* Set netif link flag */
    netif->flags |= NETIF_FLAG_LINK_UP;
  }

  /* Initialize Tx Descriptors list: Chain Mode */
  HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);

  /* Initialize Rx Descriptors list: Chain Mode  */
  HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);

  /* set MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set netif MAC hardware address */
  stm32f_set_mac_addr((uint8_t*) netif->hwaddr);

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

  /* device capabilities */
  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
  netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;

  /* Enable MAC and DMA transmission and reception */
  HAL_ETH_Start(&EthHandle);

  /**** Configure PHY to generate an interrupt when Eth Link state changes ****/
  /* Read Register Configuration */
  HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MICR, &regvalue);

  regvalue |= (PHY_MICR_INT_EN | PHY_MICR_INT_OE);

  /* Enable Interrupts */
  HAL_ETH_WritePHYRegister(&EthHandle, PHY_MICR, regvalue );

  /* Read Register Configuration */
  HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MISR, &regvalue);

  regvalue |= PHY_MISR_LINK_INT_EN;

  /* create a binary semaphore used for informing ethernetif of frame reception */
  osSemaphoreDef( SEM , rtems_build_name( 'E', 'T', 'H', 'I' ));
  s_xSemaphore = osSemaphoreCreate( osSemaphore( SEM ), 0 );

  /* create the task that handles the ETH_MAC */
  osThreadDef( EthIf,
    ethernetif_input,
    osPriorityRealtime,
    1,
    INTERFACE_THREAD_STACK_SIZE,
    rtems_build_name( 'E', 'T', 'H', 'I' ));

  osThreadCreate( osThread( EthIf ), netif );

  /* Enable Interrupt on change of link status */
  HAL_ETH_WritePHYRegister(&EthHandle, PHY_MISR, regvalue);
}
コード例 #23
0
static void low_level_init( struct netif *netif )
{
  uint8_t macaddress[ 6 ];

  // Get Ethernet MAC address
  stm32f_set_mac_addr((uint8_t*) macaddress);

  EthHandle.Instance = ETH;
  EthHandle.Init.MACAddr = macaddress;
  EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
  EthHandle.Init.Speed = ETH_SPEED_100M;
  EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
  EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;
  EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE;
  EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
  EthHandle.Init.PhyAddress = LAN8742A_PHY_ADDRESS;

  /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
  if ( HAL_ETH_Init( &EthHandle ) == HAL_OK ) {
    /* Set netif link flag */
    netif->flags |= NETIF_FLAG_LINK_UP;
  }

  /* Initialize Tx Descriptors list: Chain Mode */
  HAL_ETH_DMATxDescListInit( &EthHandle,
    DMATxDscrTab,
    &Tx_Buff[ 0 ][ 0 ],
    ETH_TXBUFNB );

  /* Initialize Rx Descriptors list: Chain Mode  */
  HAL_ETH_DMARxDescListInit( &EthHandle,
    DMARxDscrTab,
    &Rx_Buff[ 0 ][ 0 ],
    ETH_RXBUFNB );

  /* set netif MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set netif MAC hardware address */
  stm32f_set_mac_addr((uint8_t*) netif->hwaddr);

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

  /* Accept broadcast address and ARP traffic */
  netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;

  /* create a binary semaphore used for informing ethernetif of frame reception */
  osSemaphoreDef( SEM , rtems_build_name( 'E', 'T', 'H', 'I' ));
  s_xSemaphore = osSemaphoreCreate( osSemaphore( SEM ), 0 );

  /* create the task that handles the ETH_MAC */
  osThreadDef( EthIf,
    ethernetif_input,
    osPriorityRealtime,
    1,
    INTERFACE_THREAD_STACK_SIZE,
    rtems_build_name( 'E', 'T', 'H', 'I' ));
  osThreadCreate( osThread( EthIf ), netif );

  /* Enable MAC and DMA transmission and reception */
  HAL_ETH_Start( &EthHandle );
}
コード例 #24
0
ファイル: main.c プロジェクト: z80/stm32f429
/**
* @brief  Main program
* @param  None
* @retval int
*/
int main(void)
{     
  /* STM32F4xx 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
  */
#ifdef INCLUDE_THIRD_PARTY_MODULE 
   /* Code Need to handle third party module */  
  __HAL_RCC_RTC_ENABLE();
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_RCC_BKPSRAM_CLK_ENABLE(); 
  
  HAL_PWR_EnableBkUpAccess();

  if(*(__IO uint32_t *)(0x40024000) == GFX_DEMO_SIGNATURE_A)
  {
    *(__IO uint32_t *)(0x40024000) = 0;
    
    /* Reinitialize the Stack pointer*/
    __set_MSP(*(__IO uint32_t*) GFX_DEMO_ADDRESS);
    /* jump to application address */  
    ((pFunc) (*(__IO uint32_t*) (GFX_DEMO_ADDRESS + 4)))();
  }
#endif  
  HAL_Init();
  
  /* Configure the system clock @ 180 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);  
#ifdef INCLUDE_THIRD_PARTY_MODULE
  k_ModuleAdd(&third_party_board);
#else
  k_ModuleAdd(&gardening_control_board);   
#endif     
  k_ModuleAdd(&home_alarm_board); 
  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();  
 
  /* Start scheduler */
  osKernelStart ();

  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
コード例 #25
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( ;; );
}
コード例 #26
0
ファイル: task_led.c プロジェクト: mupimenov/plane
void task_led_init(void)
{
	osThreadDef(led_task, _led, osPriorityAboveNormal, 0, 256);
	task_led = osThreadCreate(osThread(led_task), NULL);
}
コード例 #27
0
ファイル: main.c プロジェクト: antgrem/proga
int main(void)
{
    GPIO_InitTypeDef GPIO_InitStruct;
    uint32_t treg;
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

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

    DBGMCU->CR = 0xFFFFFFFF;

    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    ADC_Init_my();
    I2C1_Init_my();
    RTC_my_Init();
    MX_SPI1_Init();
    MX_TIM1_Init();



    NVIC_EnableIRQ (EXTI0_IRQn);
//
//	HAL_PWR_EnterSLEEPMode(treg, PWR_SLEEPENTRY_WFE);



//  /* USER CODE BEGIN 2 */
//	if(TM_STMPE811_Init() == TM_STMPE811_State_Ok)
//		{
//			if (TM_I2C_Read(STMPE811_I2C, LM75_ADDRESS, 0x00) == 0)
//			{
//				TM_ILI9341_Puts(60, 40, "Error init LM75", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED);
//			}
//
//			TM_I2C_Write(STMPE811_I2C, STMPE811_ADDRESS, STMPE811_INT_CTRL, 0x03);
//			TM_I2C_Write(STMPE811_I2C, STMPE811_ADDRESS, STMPE811_INT_STA, 0x01);
//			TM_I2C_Write(STMPE811_I2C, STMPE811_ADDRESS, STMPE811_INT_EN, 0x01);
//
//		};

//
//			if (f_mount(&FatFs, "0:", 1) == FR_OK)
//				{
//							//Get time
//						TM_RTC_GetDateTime(&datatime, TM_RTC_Format_BIN);
//				//	sprintf(buffer, "0:F%02d_%02d_%04d.txt", datatime.date, datatime.month, datatime.year);
//						sprintf(file_name_data, "0:%04d_%02d_%02d_Watt.txt", datatime.year+2000, datatime.month, datatime.date);
//					temp_sd_res = f_open(&fil, (TCHAR*) file_name_data, FA_OPEN_EXISTING | FA_READ | FA_WRITE);
//							if (temp_sd_res != FR_OK)
//								{
//									if (f_open(&fil, file_name_data, FA_CREATE_NEW | FA_READ | FA_WRITE) == FR_OK)
//										{//write redline
//											sprintf(buffer, "Data\t\tTime\t\tVoltage\tCurrent\tWatt\n");
//											if(f_lseek(&fil, f_size(&fil)) == FR_OK){};
//
//												/* If we put more than 0 characters (everything OK) */
//												if (f_puts(buffer, &fil) > 0) {
//													if (TM_FATFS_DriveSize(&total, &free_fat) == FR_OK) {
//														/* Data for drive size are valid */
//														/* Close file, don't forget this! */
//														f_close(&fil);
//													}
//											}
//										}
//									}
//								else f_close(&fil);//file exists, was openned and must be closed
//
//							sprintf(file_name_tempr, "0:%04d_%02d_%02d_Tempr_Pr.txt", datatime.year+2000, datatime.month, datatime.date);
//							temp_sd_res = f_open(&fil, (TCHAR*) file_name_tempr, FA_OPEN_EXISTING | FA_READ | FA_WRITE);
//							if (temp_sd_res != FR_OK)
//								{
//									if (f_open(&fil, file_name_tempr, FA_CREATE_NEW | FA_READ | FA_WRITE) == FR_OK)
//										{//write redline
//											sprintf(buffer, "Data\t\tTime\t\tTempr\tPresure\n");
//											if(f_lseek(&fil, f_size(&fil)) == FR_OK){};
//
//												/* If we put more than 0 characters (everything OK) */
//												if (f_puts(buffer, &fil) > 0) {
//													if (TM_FATFS_DriveSize(&total, &free_fat) == FR_OK) {
//														/* Data for drive size are valid */
//														/* Close file, don't forget this! */
//														f_close(&fil);
//													}
//											}
//										}
//									}
//								else f_close(&fil);//file exists, was openned and must be closed


//					temp_sd_res = f_open(&fil, "0:Tempr.txt", FA_OPEN_EXISTING | FA_READ | FA_WRITE);
//					if (temp_sd_res != FR_OK)
//						{
//							if (f_open(&fil, "0:Tempr.txt", FA_CREATE_NEW | FA_READ | FA_WRITE) == FR_OK)
//								{//write redline
//									sprintf(buffer, "Data\t\tTime\t\tVoltage\tTempr\tPresure\n");
//									if(f_lseek(&fil, f_size(&fil)) == FR_OK){};
//
//										/* If we put more than 0 characters (everything OK) */
//										if (f_puts(buffer, &fil) > 0) {
//											if (TM_FATFS_DriveSize(&total, &free_fat) == FR_OK) {
//												/* Data for drive size are valid */
//												/* Close file, don't forget this! */
//												f_close(&fil);
//											}
//									}
//								}
//							}
//						else f_close(&fil);//file exists, was openned and must be closed
//
//							/* Unmount drive, don't forget this! */
//							f_mount(0, "0:", 1);
//
//				}//end mount SD


    /* USER CODE END 2 */

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

    /* USER CODE BEGIN RTOS_THREADS */
    osThreadDef(UserTask, UserDefaultTask, osPriorityNormal, 0, 256);
    UserTaskHandle = osThreadCreate(osThread(UserTask), NULL);
    /* USER CODE END RTOS_THREADS */

    /* USER CODE BEGIN RTOS_QUEUES */
    /* add queues, ... */
    /* 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 */

}
コード例 #28
0
/**
  * @brief  Network configuration 
  * @param  use_dhcp: indicates if DHCP client is activated or not
  * @retval None
  */
void NetworkInit(uint8_t use_dhcp)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;
  
  /* Create tcp_ip stack thread */
  tcpip_init( NULL, NULL );
  
  /* IP address setting */
  if (use_dhcp)
  {
    ipaddr.addr = 0;
    netmask.addr = 0;
    gw.addr = 0;
  } 
  else
  {
    IP4_ADDR(&ipaddr, ip_address[3], ip_address[2], ip_address[1], ip_address[0]);
    IP4_ADDR(&netmask, sn_mask[3], sn_mask[2] , sn_mask[1], sn_mask[0]);
    IP4_ADDR(&gw, gw_address[3], gw_address[2], gw_address[1], gw_address[0]); 
  }
  
  /* Add the network interface */
  netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
  
  /*  Registers the default network interface. */
  netif_set_default(&gnetif);
  
  if (netif_is_link_up(&gnetif))
  {
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(&gnetif);
    
    _VNCServer_Notify(NOTIFY_SERVER_NETIF_UP);
    
    if (use_dhcp) 
    {
      DHCP_state = DHCP_START;
    }
  }
  else
  {
    /* When the netif link is down this function must be called */
    netif_set_down(&gnetif);

    _VNCServer_Notify(NOTIFY_SERVER_NETIF_DOWN);
  }
  
  if (use_dhcp) 
  {
    /* Start DHCPClient */
    osThreadDef(DHCP, DHCP_thread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE);
    _DHCPClinet_TCB = osThreadCreate (osThread(DHCP), &gnetif);
  }
  
  /* Cable management BSP Configuration ***************************************/
  /* Init IO Expander */
  BSP_IO_Init();
  /* Enable IO Expander interrupt for ETH MII pin */
  BSP_IO_ConfigPin(MII_INT_PIN, IO_MODE_IT_FALLING_EDGE);
}
コード例 #29
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( ;; );
}
コード例 #30
0
ファイル: freertos.c プロジェクト: Oxbern/CCube_Firmware
/**
 * FreeRTOS Initialisation function
 */
void FREERTOS_Init(void)
{
	osThreadDef(initTask, StartInitTask, osPriorityHigh, 0, 8192);
	initTaskHandle = osThreadCreate(osThread(initTask), NULL);

}