コード例 #1
0
ファイル: SerialMgr.c プロジェクト: christation/STM32491_CPLR
/*${AOs::SerialMgr::SM::Active::Busy} ......................................*/
static QState SerialMgr_Busy(SerialMgr * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::SerialMgr::SM::Active::Busy} */
        case Q_ENTRY_SIG: {
            /* Post a timer on entry */
            QTimeEvt_rearm(
                &me->serialTimerEvt,
                SEC_TO_TICKS( LL_MAX_TIMEOUT_SERIAL_DMA_BUSY_SEC )
            );

            /* Start the DMA transfer over serial */
            Serial_DMAStartXfer( SERIAL_UART1 );
            status_ = Q_HANDLED();
            break;
        }
        /* ${AOs::SerialMgr::SM::Active::Busy} */
        case Q_EXIT_SIG: {
            QTimeEvt_disarm( &me->serialTimerEvt ); /* Disarm timer on exit */
            status_ = Q_HANDLED();
            break;
        }
        /* ${AOs::SerialMgr::SM::Active::Busy::UART_DMA_DONE} */
        case UART_DMA_DONE_SIG: {
            status_ = Q_TRAN(&SerialMgr_Idle);
            break;
        }
        /* ${AOs::SerialMgr::SM::Active::Busy::UART_DMA_TIMEOUT} */
        case UART_DMA_TIMEOUT_SIG: {
            err_slow_printf("UART DMA timeout occurred\n");
            status_ = Q_TRAN(&SerialMgr_Idle);
            break;
        }
        /* ${AOs::SerialMgr::SM::Active::Busy::UART_DMA_START, ~} */
        case UART_DMA_START_SIG: /* intentionally fall through */
        case DBG_LOG_SIG: /* intentionally fall through */
        case DBG_MENU_SIG: /* intentionally fall through */
        case CLI_SEND_DATA_SIG: {
            if (QEQueue_getNFree(&me->deferredEvtQueue) > 0) {
               /* defer the request - this event will be handled
                * when the state machine goes back to Idle state */
               QActive_defer((QActive *)me, &me->deferredEvtQueue, e);
            } else {
               /* notify the request sender that the request was ignored.. */
               err_slow_printf("Unable to defer UART_DMA_START request\n");
            }
            status_ = Q_HANDLED();
            break;
        }
        default: {
            status_ = Q_SUPER(&SerialMgr_Active);
            break;
        }
    }
    return status_;
}
コード例 #2
0
ファイル: qgprs.c プロジェクト: chalot/BWRecorder
/* @(/1/8/23/1) ............................................................*/
static QState QGprs_serving(QGprs * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* @(/1/8/23/1/0) */
        case Q_INIT_SIG: {
            status_ = Q_TRAN(&QGprs_startup);
            break;
        }
        /* @(/1/8/23/1/1) */
        case ACC_ON_SIG: {
            me->m_ACCState = POWERON;
            status_ = Q_HANDLED();
            break;
        }
        /* @(/1/8/23/1/2) */
        case ACC_OFF_SIG: {
            me->m_ACCState = POWEROFF;
            status_ = Q_HANDLED();
            break;
        }
        /* @(/1/8/23/1/3) */
        case NEW_TASKSENDREQ_SIG: {
            if (QEQueue_getNFree(&me->m_requestQueue) > 0) {
                /* defer the request */
                QActive_defer((QActive *)me, &me->m_requestQueue, e);
                TRACE_(GPRS_STAT, &me->super, "Request cmd: %x deferred;\n",
                       (int)((TaskEvt const *)e)->cmd);
            }
            else {
                TRACE_(GPRS_STAT, &me->super, "Request #%d IGNORED;\n", (int)((TaskEvt const *)e)->cmd);
            }
            status_ = Q_HANDLED();
            break;
        }
        /* @(/1/8/23/1/4) */
        case SIMCARD_ONCHANGE_SIG: {
            #if 0
            //SIM卡检测
            if(0 == GPIO_ReadInputDataBit(GPIOC,GPIOC_SIM_DET_))
            {
                ClearErrType(NET_CLASS, NET_FAULT_SIMCARD);    //SIM卡插入
            }
            else
            {
                SetErrType(NET_CLASS, NET_FAULT_SIMCARD);    //SIM卡拔出
            }
            #endif
            status_ = Q_HANDLED();
            break;
        }
        /* @(/1/8/23/1/5) */
        case SLEEP_REQ_SIG: {
            TRACE_(QS_USER, NULL, "[GPRS] ----- PowerMgr: SLEEP, but defered. -----");
            me->m_bSleepReq = 1;
            status_ = Q_HANDLED();
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}