Example #1
0
/* Global system variables */
void systemStart()
{
  xSemaphoreGive(canStartMutex);
#ifndef DEBUG
  watchdogInit();
#endif
}
Example #2
0
void userInit(void)
{
    delayInit(72);
    uartxInit();
    rgbLedInit();
    ledGpioInit();
    rgbKeyGpioInit();
    motorInit();
    dht11Init();
    irInit();
    watchdogInit(2);    //5,625看门狗复位时间2s
    
    memset((uint8_t*)&reportData, 0, sizeof(gizwitsReport_t));
    reportData.devStatus.Motor_Speed = protocolExchangeBytes(Y2X(MOTOR_SPEED_RATIO,MOTOR_SPEED_ADDITION,MOTOR_SPEED_DEFAULT));
    motorStatus(MOTOR_SPEED_DEFAULT);
}
Example #3
0
int main(void)
{
    halInit();
    chSysInit();
    sdStart(&STDOUT_SD, NULL);

    watchdogInit(WATCHDOG_TIMEOUT_MS);
    const int wdid = watchdogStart();

    restoreConfig();
    magnetInit();
    consoleInit();

    int res = canasctlInit();
    if (res)
    {
        TRACE("init", "CANAS NOT INITED (%d), FIX CONFIG AND RESTART", res);
        while (1)
        {
            ledOn();
            watchdogReset(wdid);
            chThdSleepMilliseconds(100);
        }
    }

#if RELEASE
    TRACE("init", "debug port will be disabled %d sec later", DEBUG_PORT_DISABLE_DEADLINE_SEC);
#endif

    bool debug_port_disabled = false;
    while (1)
    {
        const bool
            feedback = magnetReadFeedback(),
            requested = magnetGetRequestedState();

        ledOn();

        if (feedback != requested)
        {
            chThdSleepMilliseconds(70);
            ledOff();
            chThdSleepMilliseconds(70);
        }
        else if (feedback)
        {
            chThdSleepMilliseconds(500);
            ledOff();
            chThdSleepMilliseconds(500);
        }
        else
        {
            chThdSleepMilliseconds(70);
            ledOff();
            chThdSleepMilliseconds(930);
        }

        if (!debug_port_disabled)
        {
            if (sysTimestampMicros() / 1000000 > DEBUG_PORT_DISABLE_DEADLINE_SEC)
            {
#if RELEASE
                debugPortDisable();
#endif
                debug_port_disabled = true;
            }
        }

        watchdogReset(wdid);
    }
    return 0;
}