Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
Diff: core/uip/NyLPC_cUipService.c
- Revision:
- 48:00d211aac2ec
- Parent:
- 37:fc4b4fd6a649
- Child:
- 50:35e765380772
diff -r d27b9b2dcac6 -r 00d211aac2ec core/uip/NyLPC_cUipService.c
--- a/core/uip/NyLPC_cUipService.c Sun Jul 28 01:07:37 2013 +0000
+++ b/core/uip/NyLPC_cUipService.c Wed Aug 07 13:53:02 2013 +0000
@@ -65,14 +65,14 @@
/****************************************************
* UipServiceに関する宣言:タスクメッセージ
***************************************************/
-
+/*
#define TTaskMsg_NOP 0
#define TTaskMsg_START 1
#define TTaskMsg_STOP 2
-
+*/
/**
* サービスの起動メッセージです。
- */
+ *//*
struct TTaskMsg{
NyLPC_TUInt16 msg;
union{
@@ -80,7 +80,7 @@
const NyLPC_TcIPv4Config_t* ref_config;
}start;
};
-};
+};*/
/****************************************************
* UipServiceに関する宣言:その他
@@ -148,8 +148,7 @@
//EMAC割込セマフォ
NyLPC_cSemaphore_initialize(&inst->_emac_semapho);
- inst->_task_cmd=NULL;
- inst->_status=NyLPC_TcUipService_STATUS_STOP;
+ inst->_status=0x00;
NyLPC_cStopwatch_initialize(&(inst->_arp_sw));
NyLPC_cStopwatch_initialize(&(inst->_periodic_sw));
NyLPC_cIPv4_initialize(&(inst->_tcpv4));
@@ -177,7 +176,6 @@
void NyLPC_cUipService_start(const NyLPC_TcIPv4Config_t* i_ref_config)
{
NyLPC_TcUipService_t* inst=&_service_instance;
- struct TTaskMsg msg;
NyLPC_Assert(NyLPC_TcUipService_isInitService());
if(!NyLPC_cUipService_isRun())
{
@@ -185,17 +183,15 @@
if(inst->_ethif==NULL){
inst->_ethif=getEthernetDevicePnP();
}
- //コマンドセット
- msg.msg=TTaskMsg_START;
- msg.start.ref_config=i_ref_config;
- _NyLPC_TcUipService_inst->_task_cmd=&msg;
- //状態が変わるまでループ
- while(!NyLPC_cUipService_isRun()){
+ //コンフィグレーションセット
+ inst->_ref_config=i_ref_config;
+ //開始要求セット
+ NyLPC_TUInt16_setBit(inst->_status,NyLPC_TcUipService_ORDER_START);
+ //Order実行待ち
+ while(NyLPC_TUInt16_isBitOn(inst->_status,NyLPC_TcUipService_ORDER_START)){
NyLPC_cThread_sleep(10);
}
}
- //コマンドクリア
- _NyLPC_TcUipService_inst->_task_cmd=NULL;
return;
}
/**
@@ -206,23 +202,16 @@
*/
void NyLPC_cUipService_stop(void)
{
- struct TTaskMsg msg;
NyLPC_TcUipService_t* inst=&_service_instance;
NyLPC_Assert(NyLPC_TcUipService_isInitService());
if(NyLPC_cUipService_isRun())
{
- //コマンドセット
- msg.msg=TTaskMsg_STOP;
- _NyLPC_TcUipService_inst->_task_cmd=&msg;
- //状態が変わるまでループ
- while(NyLPC_cUipService_isRun()){
+ NyLPC_TUInt16_setBit(inst->_status,NyLPC_TcUipService_ORDER_STOP);
+ //Order実行待ち
+ while(NyLPC_TUInt16_isBitOn(inst->_status,NyLPC_TcUipService_ORDER_STOP)){
NyLPC_cThread_sleep(10);
}
- NyLPC_cIPv4_stop(&(inst->_tcpv4));
-
}
- //コマンドクリア
- _NyLPC_TcUipService_inst->_task_cmd=NULL;
return;
}
@@ -270,63 +259,49 @@
/**
* 操作キューを確認して、タスクのステータスをアップデートします。
* 高速化のため、Proc-Callerを使用していません。複雑なタスク操作をするときには、書き換えてください。
+ * @return
+ * UIPタスクの実行状態
*/
-static void updateTaskStatus()
+static NyLPC_TBool updateTaskStatus()
{
NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
-
- struct TTaskMsg* msg=(struct TTaskMsg*)(inst->_task_cmd);
-
- //コマンドが設定されていない時は、何もしない。
- if(msg==NULL){
- return;
- }
- switch(msg->msg)
- {
- //何もしない。
- case TTaskMsg_NOP:
- break;
- //開始操作
- case TTaskMsg_START:
- //状態チェック
- if(NyLPC_cUipService_isRun()){
- break;
+ if(NyLPC_cUipService_isRun()){
+ //開始状態
+ if(NyLPC_TUInt16_isBitOn(inst->_status,NyLPC_TcUipService_ORDER_STOP))
+ {
+ //停止操作
+ inst->_ethif->stop();
+ NyLPC_cIPv4_stop(&(inst->_tcpv4));
+ NyLPC_cIPv4IComp_finalize(&(inst->_icomp));
+ NyLPC_cIPv4Arp_finalize(&(inst->_arp));
+ inst->_ref_config=NULL;
+ NyLPC_TUInt16_unsetBit(inst->_status,NyLPC_TcUipService_STATUSBIT_IS_RUNNING);
+ NyLPC_TUInt16_unsetBit(inst->_status,NyLPC_TcUipService_ORDER_STOP);
+ return NyLPC_TBool_FALSE;
}
- inst->_ref_config=msg->start.ref_config;
- //TCP,ICOMPの初期化
- NyLPC_cIPv4_start(&(inst->_tcpv4),inst->_ref_config);
- NyLPC_cIPv4IComp_initialize(&(inst->_icomp),inst->_ref_config);
- //uip_arp_init(msg->start.ref_config);
- NyLPC_cIPv4Arp_initialize(&(inst->_arp),inst->_ref_config);
- NyLPC_cStopwatch_startExpire(&(inst->_arp_sw),1);//1度ARPを起動するため。
- NyLPC_cStopwatch_startExpire(&(inst->_periodic_sw),PERIODIC_TIMER);
- //InBuffer初期化
- inst->stx.h.is_lock=NyLPC_TUInt8_FALSE;
- inst->stx.h.ref=0;
- //EtherNETデバイス初期化
- while(!inst->_ethif->start(&(inst->_ref_config->eth_mac)));
- inst->_status=NyLPC_TcUipService_STATUS_RUN;
- break;
- //終了操作
- case TTaskMsg_STOP:
- //状態チェック
- if(!NyLPC_cUipService_isRun()){
- break;
+ return NyLPC_TBool_TRUE;
+ }else{
+ //停止状態
+ if(NyLPC_TUInt16_isBitOn(inst->_status,NyLPC_TcUipService_ORDER_START))
+ {
+ //TCP,ICOMPの初期化
+ NyLPC_cIPv4_start(&(inst->_tcpv4),inst->_ref_config);
+ NyLPC_cIPv4IComp_initialize(&(inst->_icomp),inst->_ref_config);
+ //uip_arp_init(msg->start.ref_config);
+ NyLPC_cIPv4Arp_initialize(&(inst->_arp),inst->_ref_config);
+ NyLPC_cStopwatch_startExpire(&(inst->_arp_sw),1);//1度ARPを起動するため。
+ NyLPC_cStopwatch_startExpire(&(inst->_periodic_sw),PERIODIC_TIMER);
+ //InBuffer初期化
+ inst->stx.h.is_lock=NyLPC_TUInt8_FALSE;
+ inst->stx.h.ref=0;
+ //EtherNETデバイス初期化
+ while(!inst->_ethif->start(&(inst->_ref_config->eth_mac)));
+ NyLPC_TUInt16_setBit(inst->_status,NyLPC_TcUipService_STATUSBIT_IS_RUNNING);
+ NyLPC_TUInt16_unsetBit(inst->_status,NyLPC_TcUipService_ORDER_START);
+ return NyLPC_TBool_TRUE;
}
- //停止操作
- inst->_ethif->stop();
- NyLPC_cIPv4_stop(&(inst->_tcpv4));
- NyLPC_cIPv4IComp_finalize(&(inst->_icomp));
- NyLPC_cIPv4Arp_finalize(&(inst->_arp));
- inst->_status=NyLPC_TcUipService_STATUS_STOP;
- break;
- default:
- //実行してはいけない。
- NyLPC_Abort();
+ return NyLPC_TBool_FALSE;
}
- //コマンドを無効化
- inst->_task_cmd=TTaskMsg_NOP;
- return;
}
/**
@@ -342,8 +317,7 @@
for( ;; )
{
//タスク状態の更新
- updateTaskStatus();
- if(inst->_status!=NyLPC_TcUipService_STATUS_RUN)
+ if(!updateTaskStatus())
{
//RUNステータス以外の時は、ここで終了する。
NyLPC_cThread_sleep(50);
MiMic Webservice library