From df17c82e522f395fc84665155775ac3bf4887255 Mon Sep 17 00:00:00 2001 From: David Lin Date: Fri, 6 Mar 2020 23:10:13 +0800 Subject: [PATCH 1/3] Fixed the wrong indentation --- board/Nuvoton_M251/BSP/Src/system_M251.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/board/Nuvoton_M251/BSP/Src/system_M251.c b/board/Nuvoton_M251/BSP/Src/system_M251.c index 86080339..8d34b202 100644 --- a/board/Nuvoton_M251/BSP/Src/system_M251.c +++ b/board/Nuvoton_M251/BSP/Src/system_M251.c @@ -140,23 +140,18 @@ void Uart0DefaultMPF(void) { /* Set GPB multi-function pins for UART0 RXD and TXD */ - SYS->GPA_MFPL = (SYS->GPA_MFPL & ~SYS_GPA_MFPL_PA0MFP_Msk) | SYS_GPA_MFPL_PA0MFP_UART0_RXD; + SYS->GPA_MFPL = (SYS->GPA_MFPL & ~SYS_GPA_MFPL_PA0MFP_Msk) | SYS_GPA_MFPL_PA0MFP_UART0_RXD; SYS->GPA_MFPL = (SYS->GPA_MFPL & ~SYS_GPA_MFPL_PA1MFP_Msk) | SYS_GPA_MFPL_PA1MFP_UART0_TXD; } - //systick interrupt Handler function void SysTick_Handler(void) { - - if (tos_knl_is_running()) - { - tos_knl_irq_enter(); - tos_tick_handler(); - tos_knl_irq_leave(); - } + if (tos_knl_is_running()) + { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } } - - - From b63867f5192939879d487ba031c78bc1dd61d07e Mon Sep 17 00:00:00 2001 From: David Lin Date: Fri, 6 Mar 2020 23:23:28 +0800 Subject: [PATCH 2/3] Fixed the wrong indentation and typos --- board/Nuvoton_M251/BSP/Src/main.c | 101 ++++++++++++++---------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/board/Nuvoton_M251/BSP/Src/main.c b/board/Nuvoton_M251/BSP/Src/main.c index 8db7e611..d3129412 100644 --- a/board/Nuvoton_M251/BSP/Src/main.c +++ b/board/Nuvoton_M251/BSP/Src/main.c @@ -1,9 +1,9 @@ #include "stdio.h" #include "NuMicro.h" #include "tos_k.h" -#define task1_size 240 // size of task1 stack -#define task2_size 240 -k_task_t task1; //structure of task1 +#define task1_size 240 // size of task1 stack +#define task2_size 240 +k_task_t task1; // structure of task1 k_task_t task2; k_stack_t task1_stack[task1_size]; //stack of task1 @@ -14,23 +14,23 @@ void SYS_Init(void) /*---------------------------------------------------------------------------------------------------------*/ /* Init System Clock */ /*---------------------------------------------------------------------------------------------------------*/ - /* Unlock protected registers */ + /* Unlock protected registers */ SYS_UnlockReg(); - /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode to prevent leakage */ + /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode to prevent leakage */ PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk); /* Disable digital input path of analog pin XT1_OUT to prevent leakage */ GPIO_DISABLE_DIGITAL_PATH(PF, BIT2 | BIT3); - /* Enable HXT clock */ + /* Enable£¬ HXT clock */ CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk); /* Switch HCLK clock source to external */ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HXT, CLK_CLKDIV0_HCLK(1)); //here switch zhe MCU clock to external - /*Set the core clock freq*/ - CLK_SetCoreClock(FREQ_32MHZ); //set the core clock freq,should not higher than your HCLK clock freq + /*Set the core clock freq*/ + CLK_SetCoreClock(FREQ_32MHZ); //set the core clock freq,should not higher than your HCLK clock freq /* Enable UART module clock */ CLK_EnableModuleClock(UART0_MODULE); @@ -59,37 +59,35 @@ void UART0_Init() //task1 function void task1_fun(void *Parameter) { - - while(1) - { - printf("Task1 Thansplant CORTEX-M23 Succeed\r\n"); - PB14 =~ PB14; - tos_task_delay(1000); - } - + while(1) + { + printf("Task1: Thansplant CORTEX-M23 Succeed\r\n"); + PB14 =~ PB14; + tos_task_delay(1000); + } } void task2_task(void *Parameter) { - - k_err_t err; - while(1) - { - printf("Task2: hello world, hello Nuvoton \r\n"); - tos_task_delay(100); - } + k_err_t err; + while(1) + { + printf("Task2: hello world, hello Nuvoton \r\n"); + tos_task_delay(100); + } } int main() { - k_err_t err; - /* Unlock protected registers */ + k_err_t err; + /* Unlock protected registers */ SYS_UnlockReg(); /* Init System, peripheral clock and multi-function I/O */ SYS_Init(); - tos_knl_init(); //tos init ,include SystickInit,should init after protected registers unlock + /* tos init ,include SystickInit,should init after protected registers unlock */ + tos_knl_init(); /* Lock protected registers */ SYS_LockReg(); @@ -97,35 +95,32 @@ int main() /* Init UART0 for printf */ UART0_Init(); - printf("system clock to %d Hz, PLL clock to %d Hz...................... ", SystemCoreClock, CLK_SetCoreClock(FREQ_32MHZ)); + printf("system clock to %d Hz, PLL clock to %d Hz...................... ", SystemCoreClock, CLK_SetCoreClock(FREQ_32MHZ)); - GPIO_SetMode(PB, BIT14, GPIO_MODE_OUTPUT); + GPIO_SetMode(PB, BIT14, GPIO_MODE_OUTPUT); - err = tos_task_create( - &task1, - "Task1", - task1_fun, - NULL, - 2, - task1_stack, - task1_size, - 100 - ); - - err = tos_task_create( - &task2, - "display", - task2_task, - NULL, - 2, - task2_stack, - task2_size, - 100); - - if(err != K_ERR_NONE) - printf("TenentOS creat task fail! code is %d\r\n",err); - - tos_knl_start(); //Start TOS TINY + err = tos_task_create( + &task1, + "Task1", + task1_fun, + NULL, + 2, + task1_stack, + task1_size, + 100); + + err = tos_task_create( + &task2, + "display", + task2_task, + NULL, + 2, + task2_stack, + task2_size, + 100); + if(err != K_ERR_NONE) + printf("TencentOS create task fail! errcode is %d\r\n",err); + tos_knl_start(); //Start TOS TINY } From 2956d75b37326aee2ba8d92d3a3d33e359010572 Mon Sep 17 00:00:00 2001 From: David Lin Date: Fri, 6 Mar 2020 23:33:41 +0800 Subject: [PATCH 3/3] Update readme.md --- board/Nuvoton_M251/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/Nuvoton_M251/readme.md b/board/Nuvoton_M251/readme.md index 43c7bd70..7880aeef 100644 --- a/board/Nuvoton_M251/readme.md +++ b/board/Nuvoton_M251/readme.md @@ -176,7 +176,7 @@ int main() oled_size, //任务堆栈大小 100); //时间片轮转机制下当前任务的时间片大小。当timeslice为0时,任务调度时间片会被设置为默认大小(TOS_CFG_CPU_TICK_PER_SECOND / 10),系统时钟滴答(systick)数 / 10。 if(err != K_ERR_NONE) - printf("TenentOS creat task fail! code is %d\r\n",err); + printf("TencentOS create task fail! code is %d\r\n",err); tos_knl_start(); //Start TOS TINY } @@ -236,4 +236,4 @@ void SysTick_Handler(void) ![打印](https://img-blog.csdnimg.cn/20191025092727795.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzMwMDc4NzUx,size_16,color_FFFFFF,t_70) -到这里,TencentOS tiny 移植新塘M251 cortex-M23内核成功! \ No newline at end of file +到这里,TencentOS tiny 移植新塘M251 cortex-M23内核成功!