|
TencentOS是騰訊公司開發(fā)的一款應(yīng)用于嵌入式平臺(tái)的物聯(lián)網(wǎng)操作系統(tǒng),提供了物聯(lián)網(wǎng)相關(guān)的組件;本項(xiàng)目把TencentOS系統(tǒng)移植到CH32V307單片機(jī)上面,本例程下載之后可以直接應(yīng)用,無須考濾復(fù)雜的移植過程,快速進(jìn)入操作系統(tǒng)應(yīng)用。
整個(gè)系統(tǒng)工程目錄如圖所示:
AW.PNG (17.22 KB, 下載次數(shù): 29)
下載附件
2024-1-6 10:57 上傳
對于操作系統(tǒng)相關(guān)的源碼,單獨(dú)建立了一個(gè)文件夾,
BE.PNG (6.09 KB, 下載次數(shù): 38)
下載附件
2024-1-6 10:58 上傳
下面是main.c文件中的代碼:
- /********************************** (C) COPYRIGHT *******************************
- * File Name : main.c
- * Author : WCH
- * Version : V1.0.0
- * Date : 2021/06/06
- * Description : Main program body.
- *********************************************************************************
- * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
- * Attention: This software (modified or not) and binary are used for
- * microcontroller manufactured by Nanjing Qinheng Microelectronics.
- *******************************************************************************/
- /*
- *@Note
- GPIO routine:
- PA0push-pull output.
-
- */
- #include "debug.h"
- #include "tos_k.h"
- /* Global define */
- /* Global Variable */
- /*********************************************************************
- * @fn GPIO_Toggle_INIT
- *
- * @brief Initializes GPIOA.0
- *
- * @return none
- */
- void GPIO_Toggle_INIT(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- #define TASK1_STK_SIZE 1024
- k_task_t task1;
- __aligned(4) uint8_t task1_stk[TASK1_STK_SIZE];
- #define TASK2_STK_SIZE 1024
- k_task_t task2;
- __aligned(4) uint8_t task2_stk[TASK2_STK_SIZE];
- void task1_entry(void *arg)
- {
- while (1)
- {
- printf("###I am task1\r\n");
- tos_task_delay(2000);
- }
- }
- void task2_entry(void *arg)
- {
- while (1)
- {
- printf("***I am task2\r\n");
- tos_task_delay(1000);
- }
- }
- /*********************************************************************
- * @fn main
- *
- * @brief Main program.
- *
- * @return none
- */
- int main(void)
- {
- USART_Printf_Init(115200);
- SystemCoreClockUpdate();
- printf("SystemClk:%d\r\n",SystemCoreClock);
- printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
- printf("Welcome to TencentOS tiny(%s)\r\n", TOS_VERSION);
- tos_knl_init();
- tos_task_create(&task1, "task1", task1_entry, NULL, 3, task1_stk, TASK1_STK_SIZE, 0); // Create task1
- tos_task_create(&task2, "task2", task2_entry, NULL, 3, task2_stk, TASK2_STK_SIZE, 0);// Create task2
- tos_knl_start();
- printf("should not run at here!\r\n");
- while(1)
- {
- asm("nop");
- }
- }
復(fù)制代碼 原理圖: 無
仿真: 無
代碼:
TencentOS.rar
(133.29 KB, 下載次數(shù): 4)
2024-1-6 11:00 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|