SYS/BIOS之Swi

2017-9-21 0:14
使用SYS/BIOS的Swi模块不能正常编译:undefined swi0

代码段:

void task_fun0(void)
{
    int count = 0 ;
    while(count<10)
    {
        Log_info1("Task0 is doing %d\n",count);
        Swi_dec(swi0);
        Task_yield();
        count++;
    }
    BIOS_exit(0);
}

void task_fun1(void)
{
    int count = 0 ;
    while(count<10)
    {
        Log_info1("Task1 is doing %d\n",count);
        Swi_dec(swi0);
        Task_yield();
        count++;
    }
    BIOS_exit(0);
}

问题描述:

Description Resource    Path    Location    Type
#20 identifier "swi0" is undefined  main.c  /SYS_BIOS_test003_c6748 line 47 C/C++ Problem
#20 identifier "swi0" is undefined  main.c  /SYS_BIOS_test003_c6748 line 34 C/C++ Problem

查找原因,找到 解决办法

2017-9-27 21:18
1、多次尝试发现无法用图形界面添加Swi模块
2、手动添加源码可以实现,代码如下

全局句柄:

Swi_Handle swi0;

初始化Swi参数

Swi_Params swiPamas;
Swi_Params_init(&swiPamas);
swiPamas.priority = 3;
swiPamas.trigger = 2;

创建Swi软件中断

swi0 = Swi_create(func_swi0, &swiPamas, NULL);

软件中断函数

void func_swi0(void)
{
    static Int count = 0;
    System_printf("Swi0 is doing %d\n",count);
    count++;
}

<完结>

你可能感兴趣的:(嵌入式开发)