test.c

来自「itron操作系统在日本用的很多」· C语言 代码 · 共 110 行

C
110
字号
#include "itron.h"
#include "target.h"

#define SW_ON   0
#define SW_OFF  1

typedef struct
{
    INT lednum;
    INT counter;
}T_MSG;

static INT rm_sw1chat(void);
static INT rm_sw2chat(void);

void sw1_func(void)
{
    if(rm_sw1chat() == SW_ON)
    {
        iwup_tsk((ID)1);
    }
}

void sw2_func(void)
{
    if(rm_sw2chat() == SW_ON)
    {
        isnd_msg((ID)1, (void*)0xaa);
    }
}

void task1(void)
{
    unsigned char i = 0x55;

    for(;;)
    {
        i = ~i;
        //i ++;
        //slp_tsk();
        wai_sem((ID)1);
        //p2 = 0x00;
        snd_msg((ID)1, (void*)i);
        dly_tsk((DLYTIME)1);
        sig_sem((ID)1);
    }
}

void task2(void)
{
    void *p;

    for(;;)
    {
        rcv_msg(&p, (ID)1);

        wai_sem((ID)1);
        p2 = ~((unsigned char)p);
        dly_tsk((DLYTIME)1);
        sig_sem((ID)1);
    }
}

void idle(void)
{
    for(;;);
}

void initialize(void)
{
    p2 = 0xff;
    pd2 = 0xff;

    int0ic = 0x01;
    int1ic = 0x02;
}

static INT rm_sw1chat(void)
{
    int i;
    for(i=0; i<1000; i++);

    ir_int0ic = 0;

    if(p8_2 == 0)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
static INT rm_sw2chat(void)
{
    int i;
    for(i=0; i<1000; i++);

    ir_int0ic = 0;

    if(p8_3 == 0)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?