add tos_slist.h, rename tos.h to tos_k.h

This commit is contained in:
daishengdong
2020-01-03 17:25:38 +08:00
parent af07f199d9
commit c9556307df
268 changed files with 900 additions and 742 deletions

View File

@@ -1,13 +1,13 @@
#include "stdio.h"
#include "NuMicro.h"
#include "tos.h"
#include "tos_k.h"
#define task1_size 240 // size of task1 stack
#define task2_size 240
#define task2_size 240
k_task_t task1; //structure of task1
k_task_t task2;
k_task_t task2;
k_stack_t task1_stack[task1_size]; //stack of task1
k_stack_t task2_stack[task2_size];
k_stack_t task2_stack[task2_size];
void SYS_Init(void)
{
@@ -16,28 +16,28 @@ void SYS_Init(void)
/*---------------------------------------------------------------------------------------------------------*/
/* Unlock protected registers */
SYS_UnlockReg();
/* 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<6C><65> HXT clock */
CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
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
/* Enable UART module clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select UART module clock source as HIRC and UART module clock divider as 1 */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART0SEL_HIRC, CLK_CLKDIV0_UART0(1));
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
@@ -62,9 +62,9 @@ void task1_fun(void *Parameter)
while(1)
{
printf("Task1 <20><>Thansplant CORTEX-M23 Succeed\r\n");
PB14 =~ PB14;
tos_task_delay(1000);
printf("Task1 <20><>Thansplant CORTEX-M23 Succeed\r\n");
PB14 =~ PB14;
tos_task_delay(1000);
}
}
@@ -74,9 +74,9 @@ void task2_task(void *Parameter)
k_err_t err;
while(1)
{
printf("Task2: hello world, hello Nuvoton \r\n");
tos_task_delay(100);
{
printf("Task2: hello world, hello Nuvoton \r\n");
tos_task_delay(100);
}
}
@@ -88,17 +88,17 @@ int main()
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
tos_knl_init(); //tos init ,include SystickInit,should init after protected registers unlock
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 for printf */
UART0_Init();
printf("system clock to %d Hz, PLL clock to %d Hz...................... ", SystemCoreClock, CLK_SetCoreClock(FREQ_32MHZ));
GPIO_SetMode(PB, BIT14, GPIO_MODE_OUTPUT);
err = tos_task_create(
@@ -111,21 +111,21 @@ int main()
task1_size,
100
);
err = tos_task_create(
&task2,
"display",
task2_task,
NULL,
2,
task2_stack,
task2_size,
100);
&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
}

View File

@@ -10,7 +10,7 @@
#include <stdio.h>
#include <stdint.h>
#include "M251.h"
#include "tos.h" //include tos.h
#include "tos_k.h"
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#include "partition_M251.h"
#endif