欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1338|回復: 0
打印 上一主題 下一主題
收起左側

TencentOS移植到CH32V307

[復制鏈接]
跳轉到指定樓層
樓主
TencentOS是騰訊公司開發的一款應用于嵌入式平臺的物聯網操作系統,提供了物聯網相關的組件;本項目把TencentOS系統移植到CH32V307單片機上面,本例程下載之后可以直接應用,無須考濾復雜的移植過程,快速進入操作系統應用。
整個系統工程目錄如圖所示:


對于操作系統相關的源碼,單獨建立了一個文件夾,


下面是main.c文件中的代碼:
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name          : main.c
  3. * Author             : WCH
  4. * Version            : V1.0.0
  5. * Date               : 2021/06/06
  6. * Description        : Main program body.
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/

  12. /*
  13. *@Note
  14. GPIO routine:
  15. PA0push-pull output.

  16. */

  17. #include "debug.h"
  18. #include "tos_k.h"


  19. /* Global define */


  20. /* Global Variable */


  21. /*********************************************************************
  22. * @fn      GPIO_Toggle_INIT
  23. *
  24. * @brief   Initializes GPIOA.0
  25. *
  26. * @return  none
  27. */
  28. void GPIO_Toggle_INIT(void)
  29. {
  30.   GPIO_InitTypeDef  GPIO_InitStructure;

  31.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
  32.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  33.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  34.   GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  35.   GPIO_Init(GPIOA, &GPIO_InitStructure);
  36. }


  37. #define TASK1_STK_SIZE       1024
  38. k_task_t task1;
  39. __aligned(4) uint8_t task1_stk[TASK1_STK_SIZE];


  40. #define TASK2_STK_SIZE       1024
  41. k_task_t task2;
  42. __aligned(4) uint8_t task2_stk[TASK2_STK_SIZE];

  43. void task1_entry(void *arg)
  44. {
  45.     while (1)
  46.     {
  47.         printf("###I am task1\r\n");
  48.         tos_task_delay(2000);
  49.     }
  50. }

  51. void task2_entry(void *arg)
  52. {
  53.     while (1)
  54.     {
  55.         printf("***I am task2\r\n");
  56.         tos_task_delay(1000);
  57.     }
  58. }


  59. /*********************************************************************
  60. * @fn      main
  61. *
  62. * @brief   Main program.
  63. *
  64. * @return  none
  65. */
  66. int main(void)
  67. {
  68.         USART_Printf_Init(115200);
  69.         SystemCoreClockUpdate();        
  70.         printf("SystemClk:%d\r\n",SystemCoreClock);
  71.         printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
  72.         printf("Welcome to TencentOS tiny(%s)\r\n", TOS_VERSION);
  73.     tos_knl_init();
  74.     tos_task_create(&task1, "task1", task1_entry, NULL, 3, task1_stk, TASK1_STK_SIZE, 0); // Create task1
  75.     tos_task_create(&task2, "task2", task2_entry, NULL, 3, task2_stk, TASK2_STK_SIZE, 0);// Create task2
  76.     tos_knl_start();

  77.     printf("should not run at here!\r\n");

  78.     while(1)
  79.         {
  80.             asm("nop");
  81.         }
  82. }
復制代碼
原理圖: 無
仿真: 無
代碼: TencentOS.rar (133.29 KB, 下載次數: 4)
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表