移植华为LiteOS

1. 安装STM32CubeMX

构建裸机工程,生成MDK-ARM V5 的工程

2.拷贝 LiteOS 内核源码及测试相关代码

拷贝arch, demos, kernel目录拷贝到middlewares/liteos中
在Keil工程中添加.c 源文件,以及设置头文件路径
移植华为LiteOS_第1张图片

移植华为LiteOS_第2张图片

3.拷贝OS_CONFIG 目录

添加头文件路径。

4. PendSV_Handler 和 SysTick_Handler 这两个函数

屏蔽
如果#define LOSCFG_PLATFORM_HWI YES
则不用屏蔽SysTick_Handler

5.使用los_startup_keil.s代替startup_stm32l476xx.s

修改sct文件配置内存

6.测试中断

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(GPIO_Pin);
	dprintf("\r\n User IRQ test!!!\r\n");
  /* NOTE: This function Should not be modified, when the callback is needed,
           the HAL_GPIO_EXTI_Callback could be implemented in the user file
   */
}
static VOID User_IRQHandler(VOID)
{

//    LOS_InspectStatusSetByID(LOS_INSPECT_INTERRUPT,LOS_INSPECT_STU_SUCCESS);
 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
    return;
}

UINT32 Example_Interrupt(VOID)
{
	dprintf("\r\n Example_Interrupt\r\n");
    UINTPTR uvIntSave;
    uvIntSave = LOS_IntLock();

    Example_Exti0_Init();

    LOS_HwiCreate(40, 0, 0, User_IRQHandler, 0);//create interrupt

    LOS_IntRestore(uvIntSave);

    return LOS_OK;
}

7.其他例子

Los Inspect start.
LOS_TaskLock() Success!
Example_TaskHi create Success!
Example_TaskLo create Success!
Enter TaskHi Handler.
Enter TaskLo Handler.
TaskHi LOS_TaskDelay Done.
TaskHi LOS_TaskSuspend Success.
TaskHi LOS_TaskResume Success.
Inspect TASK success

Example_Event wait event 0x1 . 
Example_TaskEntry_Event write event .
Example_Event,read event :0x1 . 
EventMask:1 
EventMask:0 
Inspect EVENT success

create the queue success! 
recv message:test is message 0 
recv message:test is message 1 
recv message:test is message 2 
recv message:test is message 3 
recv message:test is message 4 
recv message failure,error:200061d 
delete the queue success! 
Inspect MSG success

Example_SemTask2 try get sem g_usSemID wait forever.
Example_SemTask1 try get sem g_usSemID ,timeout 10 ticks.
Example_SemTask2 get sem g_usSemID and then delay 20ticks .
Example_SemTask1 timeout and try get sem g_usSemID wait forever.
Example_SemTask2 post sem g_usSemID .
Example_SemTask1 wait_forever and got sem g_usSemID success.
Inspect SEM success

task2 try to get mutex, wait forever. 
task2 get mutex g_Testmux01 and suspend 100 Tick. 
task1 try to get mutex, wait 10 Tick. 
task1 timeout and try to get  mutex, wait forever. 
task2 resumed and post the g_Testmux01 
task1 wait forever,got mutex g_Testmux01 success. 
Inspect MUTEX success

LOS_CyclePerTickGet = 80000 .
LOS_TickCountGet = 1108 .
LOS_TickCountGet after delay = 1311 .
Inspect SYSTIC success

create Timer1 success .
create Timer2 success .
start Timer1 sucess .
stop Timer1 sucess .
g_timercount1=1 .
tick_last1=2623 .
delete Timer1 failed .
start Timer2 success .
g_timercount2=1 .
tick_last2=2728 .
g_timercount2=2 .
tick_last2=2828 .
g_timercount2=3 .
tick_last2=2928 .
g_timercount2=4 .
tick_last2=3028 .
g_timercount2=5 .
tick_last2=3128 .
g_timercount2=6 .
tick_last2=3228 .
g_timercount2=7 .
tick_last2=3328 .
g_timercount2=8 .
tick_last2=3428 .
g_timercount2=9 .
tick_last2=3528 .
g_timercount2=10 .
tick_last2=3628 .
Inspect TIMER success

initial...... 
node add and tail add......
add node success 
add tail success 
delete node......
delete node success
Inspect LIST success

Mem box init ok! .
Mem box alloc ok .
*p_num = 828 .
clear data ok 
 *p_num = 0 .
Mem box free ok! .
Inspect S_MEM success

mempool init ok! 
mem alloc ok 
*p_num = 828 
mem free ok!
Inspect D_MEM success

你可能感兴趣的:(IOT)