osKernelStart() How to proceed by dissecting the code

Viewed 24
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MPU Configuration--------------------------------------------------------*/
  MPU_Config();

  /* Enable I-Cache---------------------------------------------------------*/
  SCB_EnableICache();

  /* Enable D-Cache---------------------------------------------------------*/
  SCB_EnableDCache();

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

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

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

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

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_TIM6_Init();
  MX_UART7_Init();
  MX_USART3_UART_Init();
  MX_UART5_Init();
  MX_USART1_UART_Init();
  MX_USART6_UART_Init();
  MX_UART8_Init();
  MX_SPI2_Init();
  MX_SPI3_Init();
  MX_SPI5_Init();
  MX_I2C1_Init();
  MX_RNG_Init();
  MX_TIM3_Init();
  MX_USB_OTG_FS_PCD_Init();
  MX_RTC_Init();
  MX_FMC_Init();
  MX_TIM7_Init();
  /* USER CODE BEGIN 2 */
  HAL_UART_Receive_DMA(&huart3,(uint8_t*)RX_BUFFER3,RX_BUFFER3_SIZE);
  HAL_UART_Receive_DMA(&huart7,(uint8_t*)RX_BUFFER7,RX_BUFFER7_SIZE);
  
  
  HAL_UART_Receive_DMA(&huart5,(uint8_t*)BW_BUFFER5, BW_BUFFER5_SIZE);
  
#if BW16_ENABLE
  // BW16 RESET
   bw16_Reset();
  
  // BW16 Init
  bw16_init(&huart5);
  
  // BW16 Rx Buffer 더미 데이터가 있다면 제거하고 DMA 초기화 
    RxCntUart5 = __HAL_DMA_GET_COUNTER(huart5.hdmarx);  
    if(BW_BUFFER5_SIZE != RxCntUart5)
    {
      __HAL_DMA_DISABLE(huart5.hdmarx); 
      __HAL_DMA_SET_COUNTER(huart5.hdmarx, BW_BUFFER5_SIZE);
      __HAL_DMA_ENABLE(huart5.hdmarx);       
       
      
      // memset하고 나서 데이터가 12개밖에 안 받아짐 근데 안하면 에러
      // 20200907
      //memset(RX_BUFFER5,0x00,sizeof(RX_BUFFER5)); 
    }
    
#endif
   
  /* 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 */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  HAL_TIM_Base_Start_IT(&htim6);
  HAL_TIM_Base_Start_IT(&htim7);
  /* USER CODE END RTOS_QUEUES */

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

  /* definition and creation of TcpTask */
  osThreadDef(TcpTask, Tcp_Task, osPriorityIdle, 0, 256);
  TcpTaskHandle = osThreadCreate(osThread(TcpTask), NULL);

  /* definition and creation of Usart3Task */
  osThreadDef(Usart3Task, Usart3_Task, osPriorityIdle, 0, 256);
  Usart3TaskHandle = osThreadCreate(osThread(Usart3Task), NULL);

  /* definition and creation of Uart7Task */
  osThreadDef(Uart7Task, Uart7_Task, osPriorityIdle, 0, 256);
  Uart7TaskHandle = osThreadCreate(osThread(Uart7Task), NULL);

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

  HAL_UART_Transmit(&huart3,"START! READY!\r\n",13,0xFFFFFFFF);
  /* USER CODE END RTOS_THREADS */

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

I use stm32 If osKernelStart(); is executed in the above code, the repeat statement cannot be executed, so how can I get to the repeat statement?

This is the code to transfer the sensor value through Bluetooth communication, but I have to use another code in the while statement

As the osKernelStart() code is executed, the while statement must also be executed

Please tell me how to do it

0 Answers
Related