//------------------------------------------------------------------------------
tOplkError processSync(void)
{
    tOplkError      ret = kErrorOk;
    UINT32          appOutVal;
    UINT8           appInVal;

    ret = oplk_exchangeProcessImageOut();
    if (ret != kErrorOk)
        return ret;

    /* read input image - digital outputs */
    appOutVal = pProcessImageOut_l->digitalOut[0] << 0  |
                pProcessImageOut_l->digitalOut[1] << 8  |
                pProcessImageOut_l->digitalOut[2] << 16 |
                pProcessImageOut_l->digitalOut[3] << 24;

    gpio_setAppOutputs(appOutVal);

    /* setup output image - digital inputs */
    appInVal = gpio_getAppInput();

    pProcessImageIn_l->digitalIn[0] = appInVal;
    pProcessImageIn_l->digitalIn[1] = appInVal;
    pProcessImageIn_l->digitalIn[2] = appInVal;
    pProcessImageIn_l->digitalIn[3] = appInVal;

    ret = oplk_exchangeProcessImageIn();

    return ret;
}
Example #2
0
//------------------------------------------------------------------------------
tOplkError processSync(void)
{
    tOplkError  ret;
    int         i;

    ret = oplk_exchangeProcessImageOut();
    if (ret != kErrorOk)
        return ret;

    cnt_l++;

    aNodeVar_l[0].input = pProcessImageOut_l->CN1_M00_DigitalInput_00h_AU8_DigitalInput;
    aNodeVar_l[1].input = pProcessImageOut_l->CN32_M00_DigitalInput_00h_AU8_DigitalInput;
    aNodeVar_l[2].input = pProcessImageOut_l->CN110_M00_DigitalInput_00h_AU8_DigitalInput;

    for (i = 0; (i < MAX_NODES) && (aUsedNodeIds_l[i] != 0); i++)
    {
        /* Running LEDs */
        /* period for LED flashing determined by inputs */
        aNodeVar_l[i].period = (aNodeVar_l[i].input == 0) ? 1 : (aNodeVar_l[i].input * 20);
        if (cnt_l % aNodeVar_l[i].period == 0)
        {
            if (aNodeVar_l[i].leds == 0x00)
            {
                aNodeVar_l[i].leds = 0x1;
                aNodeVar_l[i].toggle = 1;
            }
            else
            {
                if (aNodeVar_l[i].toggle)
                {
                    aNodeVar_l[i].leds <<= 1;
                    if (aNodeVar_l[i].leds == APP_LED_MASK_1)
                        aNodeVar_l[i].toggle = 0;
                }
                else
                {
                    aNodeVar_l[i].leds >>= 1;
                    if (aNodeVar_l[i].leds == 0x01)
                        aNodeVar_l[i].toggle = 1;
                }
            }
        }

        if (aNodeVar_l[i].input != aNodeVar_l[i].inputOld)
            aNodeVar_l[i].inputOld = aNodeVar_l[i].input;

        if (aNodeVar_l[i].leds != aNodeVar_l[i].ledsOld)
            aNodeVar_l[i].ledsOld = aNodeVar_l[i].leds;
    }

    pProcessImageIn_l->CN1_M00_DigitalOutput_00h_AU8_DigitalOutput = aNodeVar_l[0].leds;
    pProcessImageIn_l->CN32_M00_DigitalOutput_00h_AU8_DigitalOutput = aNodeVar_l[1].leds;
    pProcessImageIn_l->CN110_M00_DigitalOutput_00h_AU8_DigitalOutput = aNodeVar_l[2].leds;

    ret = oplk_exchangeProcessImageIn();

    return ret;
}