]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/cclink.git/blobdiff - CCIEF-BASIC_Master/sample/src/CCIEF_BASIC_SLAVES.c
Merge pull request #2 in PROCESSOR-SDK/cclink from master-fix-for-slave-duplication...
[processor-sdk/cclink.git] / CCIEF-BASIC_Master / sample / src / CCIEF_BASIC_SLAVES.c
index a45a5953b5bb150a73960e24821f6561e0b5e070..a887bc98477f1abfd785111669a8459eaa952ffb 100644 (file)
-/*\r
- * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/\r
- * Copyright (C) 2016 CC-Link Partner Association -http://am.cc-link.org/\r
- * \r
- * \r
- *  Redistribution and use in source and binary forms, with or without \r
- *  modification, are permitted provided that the following conditions \r
- *  are met:\r
- *\r
- *    Redistributions of source code must retain the above copyright \r
- *    notice, this list of conditions and the following disclaimer.\r
- *\r
- *    Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the \r
- *    documentation and/or other materials provided with the   \r
- *    distribution.\r
- *\r
- *    Neither the name of Texas Instruments Incorporated nor the names of\r
- *    its contributors may be used to endorse or promote products derived\r
- *    from this software without specific prior written permission.\r
- *\r
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
-*/\r
-\r
-#include "CCIEF_BASIC_SLAVES.h"\r
-#include <string.h>\r
-\r
-/* Definition of function of sample program */\r
-static void ccief_basic_slaves_execute_state_disconnect( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );\r
-static void ccief_basic_slaves_execute_state_connecting( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );\r
-static void ccief_basic_slaves_execute_state_cyclic_stop( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );\r
-static void ccief_basic_slaves_execute_state_cyclic_end( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );\r
-static void ccief_basic_slaves_execute_state_cyclic( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for initialization of the slave.                           */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_initialize( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave )\r
-{\r
-       /* Set the slave state */\r
-       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for executed according to the state                                */\r
-/* of the slave.                                                                                                                                       */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Execute the state of the slave */\r
-       switch ( pSlave->iState )\r
-       {\r
-               /* Disconnection of the cyclic network. */\r
-               case CCIEF_BASIC_STATE_SLAVE_DISCONNECT:\r
-                       ccief_basic_slaves_execute_state_disconnect( pSlave, iEvent );\r
-                       break;\r
-               /* Connecting for the cyclic network. */\r
-               case CCIEF_BASIC_STATE_SLAVE_CONNECTING:\r
-                       ccief_basic_slaves_execute_state_connecting( pSlave, iEvent );\r
-                       break;\r
-               /* Stop the cyclic operation. */\r
-               case CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP:\r
-                       ccief_basic_slaves_execute_state_cyclic_stop( pSlave, iEvent );\r
-                       break;\r
-               /* End of the cyclic operation. */\r
-               case CCIEF_BASIC_STATE_SLAVE_CYCLIC_END:\r
-                       ccief_basic_slaves_execute_state_cyclic_end( pSlave, iEvent );\r
-                       break;\r
-               /* Running the cyclic operation. */\r
-               case CCIEF_BASIC_STATE_SLAVE_CYCLIC:\r
-                       ccief_basic_slaves_execute_state_cyclic( pSlave, iEvent );\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for state of disconnect of the cyclic network.     */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state_disconnect( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Check the event */\r
-       switch ( iEvent )\r
-       {\r
-               /* Changing the parameter */\r
-               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:\r
-                       /* Nothing */\r
-                       break;\r
-               /* Make the cyclic data */\r
-               case CCIEF_BASIC_EVENT_SLAVE_LINK_SCAN_START:\r
-                       /* Set the cyclic state */\r
-                       pSlave->iCyclicState = CCIEF_BASIC_CYCLIC_STATE_OFF;\r
-                       /* Check the start cyclic of user operation */\r
-                       if ( pSlave->iCyclicStart == CCIEF_BASIC_CYCLIC_START )\r
-                       {\r
-                               /* Set the cyclic state to connecting */\r
-                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CONNECTING;\r
-                               /* Initialize of the timeout count */\r
-                               pSlave->usTimeoutCount = 0;\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CONNECTING;\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Set the cyclic state to stop cyclic */\r
-                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC_STOP;\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP;\r
-                       }\r
-                       break;\r
-               /* Receiving the error of the duplication master from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:\r
-                       /* Nothing */\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for state of connecting for the cyclic network.    */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state_connecting( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Check the event */\r
-       switch ( iEvent )\r
-       {\r
-               /* Changing the parameter */\r
-               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Receiving the cyclic data from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:\r
-                       /* Check the End code of the slave */\r
-                       if ( pSlave->usEndCode == CCIEF_BASIC_END_OK )\r
-                       {\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       }\r
-                       break;\r
-               /* Timeout the response of the cyclic data */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* The end of the cyclic data of all slaves */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_END:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Receiving the error of the duplication master from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for state of stop the cyclic operation.                    */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state_cyclic_stop( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Check the event */\r
-       switch ( iEvent )\r
-       {\r
-               /* Changing the parameter */\r
-               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Timeout the response of the cyclic data */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* The end of the cyclic data of all slaves */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_END:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Receiving the error of the duplication master from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for state of end of the cyclic operation.          */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state_cyclic_end( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Check the event */\r
-       switch ( iEvent )\r
-       {\r
-               /* Changing the parameter */\r
-               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Make the cyclic data */\r
-               case CCIEF_BASIC_EVENT_SLAVE_LINK_SCAN_START:\r
-                       /* Check the start cyclic of user operation */\r
-                       if ( pSlave->iCyclicStart == CCIEF_BASIC_CYCLIC_START )\r
-                       {\r
-                               /* Set the cyclic state */\r
-                               pSlave->iCyclicState = CCIEF_BASIC_CYCLIC_STATE_ON;\r
-                               /* Set the cyclic state to cyclic */\r
-                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC;\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC;\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Set the cyclic state to stop cyclic */\r
-                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC_STOP;\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP;\r
-                       }\r
-                       break;\r
-               /* Receiving the error of the duplication master from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Receiving the cyclic data from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:\r
-                       /* Check the response received */\r
-                       if( pSlave->iReceiveComplete == CCIEF_BASIC_SLAVE_RESPONSE_RECEIVED )\r
-                       {\r
-                               /* Already receved response */\r
-                               /* Set the error code of the slave duplication */\r
-                               pSlave->iDuplicateState = CCIEF_BASIC_SLAVE_DUPLICATION_DETECT;\r
-                       }\r
-                       break;\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
-\r
-/************************************************************************************/\r
-/* This is an user defined function for state of running the cyclic operation.         */\r
-/************************************************************************************/\r
-void ccief_basic_slaves_execute_state_cyclic( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )\r
-{\r
-       /* Check the event */\r
-       switch ( iEvent )\r
-       {\r
-               /* Changing the parameter */\r
-               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-               /* Receiving the cyclic data from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:\r
-                       /* Get the current number of frame sequence */\r
-                       /* Check the end code of the slave */\r
-                       if ( pSlave->usEndCode == CCIEF_BASIC_END_OK )\r
-                       {\r
-                               /* Check the number of frame sequence */\r
-                               if ( *pSlave->pusFrameSequenceNumber == pSlave->usFrameSequenceNumber )\r
-                               {\r
-                                       /* Receive the response data from the slave */\r
-                                       /* RWr */\r
-                                       memcpy( pSlave->pusRWr, pSlave->pusSlaveRWr, pSlave->pParameter->usOccupiedStationNumber * CCIEF_BASIC_RWW_RWR_SIZE );\r
-                                       /* RX */\r
-                                       memcpy( pSlave->pusRX, pSlave->pusSlaveRX, pSlave->pParameter->usOccupiedStationNumber * CCIEF_BASIC_RX_RY_SIZE );\r
-                                       /* Initialize of the timeout count */\r
-                                       pSlave->usTimeoutCount = 0;\r
-                                       /* Set the slave state */\r
-                                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;\r
-                                       \r
-                                       /* Set the receive complete flag  */\r
-                                       pSlave->iReceiveComplete = CCIEF_BASIC_SLAVE_RESPONSE_RECEIVED;\r
-                               }\r
-                               else\r
-                               {\r
-                                       /* Nothing */\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       }\r
-                       break;\r
-               /* Timeout the response of the cyclic data */\r
-               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:\r
-                       /* Increase of the timeout count */\r
-                       pSlave->usTimeoutCount ++;\r
-                       /* Check of the timeout count */\r
-                       if ( pSlave->usTimeoutCount < pSlave->usCyclicTransmissionTimeoutCount )\r
-                       {\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Set the slave state */\r
-                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       }\r
-                       break;\r
-               /* Receiving the error of the duplication master from the slave */\r
-               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:\r
-                       /* Set the slave state */\r
-                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;\r
-                       break;\r
-\r
-               default:\r
-                       break;\r
-       }\r
-\r
-       return;\r
-}\r
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Copyright (C) 2016 CC-Link Partner Association -http://am.cc-link.org/
+ * 
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+
+#include "CCIEF_BASIC_SLAVES.h"
+#include <string.h>
+
+/* Definition of function of sample program */
+static void ccief_basic_slaves_execute_state_disconnect( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );
+static void ccief_basic_slaves_execute_state_connecting( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );
+static void ccief_basic_slaves_execute_state_cyclic_stop( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );
+static void ccief_basic_slaves_execute_state_cyclic_end( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );
+static void ccief_basic_slaves_execute_state_cyclic( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent );
+
+/************************************************************************************/
+/* This is an user defined function for initialization of the slave.                           */
+/************************************************************************************/
+void ccief_basic_slaves_initialize( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave )
+{
+       /* Set the slave state */
+       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for executed according to the state                                */
+/* of the slave.                                                                                                                                       */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Execute the state of the slave */
+       switch ( pSlave->iState )
+       {
+               /* Disconnection of the cyclic network. */
+               case CCIEF_BASIC_STATE_SLAVE_DISCONNECT:
+                       ccief_basic_slaves_execute_state_disconnect( pSlave, iEvent );
+                       break;
+               /* Connecting for the cyclic network. */
+               case CCIEF_BASIC_STATE_SLAVE_CONNECTING:
+                       ccief_basic_slaves_execute_state_connecting( pSlave, iEvent );
+                       break;
+               /* Stop the cyclic operation. */
+               case CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP:
+                       ccief_basic_slaves_execute_state_cyclic_stop( pSlave, iEvent );
+                       break;
+               /* End of the cyclic operation. */
+               case CCIEF_BASIC_STATE_SLAVE_CYCLIC_END:
+                       ccief_basic_slaves_execute_state_cyclic_end( pSlave, iEvent );
+                       break;
+               /* Running the cyclic operation. */
+               case CCIEF_BASIC_STATE_SLAVE_CYCLIC:
+                       ccief_basic_slaves_execute_state_cyclic( pSlave, iEvent );
+                       break;
+
+               default:
+                       break;
+       }
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for state of disconnect of the cyclic network.     */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state_disconnect( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Check the event */
+       switch ( iEvent )
+       {
+               /* Changing the parameter */
+               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:
+                       /* Nothing */
+                       break;
+               /* Make the cyclic data */
+               case CCIEF_BASIC_EVENT_SLAVE_LINK_SCAN_START:
+                       /* Set the cyclic state */
+                       pSlave->iCyclicState = CCIEF_BASIC_CYCLIC_STATE_OFF;
+                       /* Check the start cyclic of user operation */
+                       if ( pSlave->iCyclicStart == CCIEF_BASIC_CYCLIC_START )
+                       {
+                               /* Set the cyclic state to connecting */
+                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CONNECTING;
+                               /* Initialize of the timeout count */
+                               pSlave->usTimeoutCount = 0;
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CONNECTING;
+                       }
+                       else
+                       {
+                               /* Set the cyclic state to stop cyclic */
+                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC_STOP;
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP;
+                       }
+                       break;
+               /* Receiving the error of the duplication master from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:
+                       /* Nothing */
+                       break;
+
+               default:
+                       break;
+       }
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for state of connecting for the cyclic network.    */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state_connecting( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Check the event */
+       switch ( iEvent )
+       {
+               /* Changing the parameter */
+               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Receiving the cyclic data from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:
+                       /* Check the End code of the slave */
+                       if ( pSlave->usEndCode == CCIEF_BASIC_END_OK )
+                       {
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;
+                       }
+                       else
+                       {
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       }
+                       break;
+               /* Timeout the response of the cyclic data */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* The end of the cyclic data of all slaves */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_END:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Receiving the error of the duplication master from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+
+               default:
+                       break;
+       }
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for state of stop the cyclic operation.                    */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state_cyclic_stop( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Check the event */
+       switch ( iEvent )
+       {
+               /* Changing the parameter */
+               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Timeout the response of the cyclic data */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* The end of the cyclic data of all slaves */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_END:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Receiving the error of the duplication master from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+
+               default:
+                       break;
+       }
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for state of end of the cyclic operation.          */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state_cyclic_end( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Check the event */
+       switch ( iEvent )
+       {
+               /* Changing the parameter */
+               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Make the cyclic data */
+               case CCIEF_BASIC_EVENT_SLAVE_LINK_SCAN_START:
+                       /* Check the start cyclic of user operation */
+                       if ( pSlave->iCyclicStart == CCIEF_BASIC_CYCLIC_START )
+                       {
+                               /* Set the cyclic state */
+                               pSlave->iCyclicState = CCIEF_BASIC_CYCLIC_STATE_ON;
+                               /* Set the cyclic state to cyclic */
+                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC;
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC;
+                       }
+                       else
+                       {
+                               /* Set the cyclic state to stop cyclic */
+                               pSlave->iCyclicStateSet = CCIEF_BASIC_CYCLIC_STATE_SET_CYCLIC_STOP;
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_STOP;
+                       }
+                       break;
+               /* Receiving the error of the duplication master from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Receiving the cyclic data from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:
+                       /* Check the response received */
+                       if( pSlave->iReceiveComplete == CCIEF_BASIC_SLAVE_RESPONSE_RECEIVED )
+                       {
+                               /* Already receved response */
+                               /* Set the error code of the slave duplication */
+                               pSlave->iDuplicateState = CCIEF_BASIC_SLAVE_DUPLICATION_DETECT;
+                       }
+                       break;
+               default:
+                       break;
+       }
+
+       return;
+}
+
+/************************************************************************************/
+/* This is an user defined function for state of running the cyclic operation.         */
+/************************************************************************************/
+void ccief_basic_slaves_execute_state_cyclic( CCIEF_BASIC_SLAVES_CYCLIC_DATA_INFO *pSlave, int iEvent )
+{
+       /* Check the event */
+       switch ( iEvent )
+       {
+               /* Changing the parameter */
+               case CCIEF_BASIC_EVENT_SLAVE_PARAMETER_CHANGE:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+               /* Receiving the cyclic data from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_RECV:
+                       /* Get the current number of frame sequence */
+                       /* Check the end code of the slave */
+                       if ( pSlave->usEndCode == CCIEF_BASIC_END_OK )
+                       {
+                               /* Check the number of frame sequence */
+                               if ( *pSlave->pusFrameSequenceNumber == pSlave->usFrameSequenceNumber )
+                               {
+                                       /* Receive the response data from the slave */
+                                       /* RWr */
+                                       memcpy( pSlave->pusRWr, pSlave->pusSlaveRWr, pSlave->pParameter->usOccupiedStationNumber * CCIEF_BASIC_RWW_RWR_SIZE );
+                                       /* RX */
+                                       memcpy( pSlave->pusRX, pSlave->pusSlaveRX, pSlave->pParameter->usOccupiedStationNumber * CCIEF_BASIC_RX_RY_SIZE );
+                                       /* Initialize of the timeout count */
+                                       pSlave->usTimeoutCount = 0;
+                                       /* Set the slave state */
+                                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;
+                                       
+                                       /* Set the receive complete flag  */
+                                       pSlave->iReceiveComplete = CCIEF_BASIC_SLAVE_RESPONSE_RECEIVED;
+                               }
+                               else
+                               {
+                                       /* Nothing */
+                               }
+                       }
+                       else
+                       {
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       }
+                       break;
+               /* Timeout the response of the cyclic data */
+               case CCIEF_BASIC_EVENT_SLAVE_CYCLIC_DATA_TIMEOUT:
+                       /* Increase of the timeout count */
+                       pSlave->usTimeoutCount ++;
+                       /* Check of the timeout count */
+                       if ( pSlave->usTimeoutCount < pSlave->usCyclicTransmissionTimeoutCount )
+                       {
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_CYCLIC_END;
+                       }
+                       else
+                       {
+                               /* Set the slave state */
+                               pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       }
+                       break;
+               /* Receiving the error of the duplication master from the slave */
+               case CCIEF_BASIC_EVENT_SLAVE_DUPLICATION_MASTER_ERR:
+                       /* Set the slave state */
+                       pSlave->iState = CCIEF_BASIC_STATE_SLAVE_DISCONNECT;
+                       break;
+
+               default:
+                       break;
+       }
+
+       return;
+}