1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef AVCTP_ST_H 16 #define AVCTP_ST_H 17 18 #include <stdint.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /***************************************************************************** 25 * Macro Define 26 ****************************************************************************/ 27 /* state table events */ 28 typedef enum { 29 AVCT_BIND_EVT, 30 AVCT_UNBIND_EVT, 31 AVCT_SED_MSG_EVT, 32 AVCT_DISCONN_EVT, 33 AVCT_REV_CONN_EVT, 34 AVCT_REV_DISCONN_EVT, 35 AVCT_REV_MSG_EVT, 36 AVCT_REV_BUSY_EVT, 37 AVCT_MAX_EVT, 38 } AvctEvt; 39 40 /* state table states */ 41 typedef enum { 42 AVCT_IDLE_ST, 43 AVCT_OPENING_ST, 44 AVCT_OPENED_ST, 45 AVCT_CLOSING_ST, 46 AVCT_BUSY_ST, 47 AVCT_MAX_ST, 48 } AvctSt; 49 50 /* state table action enumeration list */ 51 typedef enum { 52 AVCT_CHANNEL_CONN, 53 AVCT_CHANNEL_BIND, 54 AVCT_CHANNEL_BIND_FAIL, 55 AVCT_CHANNEL_DISCONNECT, 56 AVCT_CHANNEL_UNBIND, 57 AVCT_CHANNEL_CHECK_DISCONNECT, 58 AVCT_SEND_MSG, 59 AVCT_DISCARD_MSG, 60 AVCT_CONN_IND, 61 AVCT_CONN_FAIL, 62 AVCT_DISCONN_IND, 63 AVCT_DISCONN_CFM, 64 AVCT_REV_MSG, 65 AVCT_DISCARD_REV_MSG, 66 AVCT_BUSY_IND, 67 AVCT_UNBUSY_IND, 68 AVCT_IGNORE, 69 AVCT_ACTION_MAX, 70 } AvctAct; 71 72 /* state table information */ 73 #define AVCT_ACTION 0 /* position of action */ 74 #define AVCT_NEXT_STATE 1 /* position of next state */ 75 #define AVCT_NUM_COLUMNS 2 /* number of columns in state tables */ 76 77 /***************************************************************************** 78 * Data Define 79 ****************************************************************************/ 80 /* type for state table */ 81 typedef const uint8_t (*AvctStateTable)[AVCT_NUM_COLUMNS]; 82 /***************************************************************************** 83 * Globle Variable 84 ****************************************************************************/ 85 extern const uint8_t C_AVCT_ST_IDLE[AVCT_MAX_EVT][AVCT_NUM_COLUMNS]; 86 extern const uint8_t C_AVCT_ST_OPENING[AVCT_MAX_EVT][AVCT_NUM_COLUMNS]; 87 extern const uint8_t C_AVCT_ST_OPENED[AVCT_MAX_EVT][AVCT_NUM_COLUMNS]; 88 extern const uint8_t C_AVCT_ST_CLOSING[AVCT_MAX_EVT][AVCT_NUM_COLUMNS]; 89 extern const uint8_t C_AVCT_ST_BUSY[AVCT_MAX_EVT][AVCT_NUM_COLUMNS]; 90 extern const AvctStateTable C_AVCT_ST_TBL[AVCT_MAX_ST]; 91 /***************************************************************************** 92 * Extern Function Declare 93 ****************************************************************************/ 94 extern uint8_t AvctGetNextStation(uint8_t curState, uint8_t event); 95 extern uint8_t AvctGetEvtAction(uint8_t curState, uint8_t event); 96 97 #ifdef __cplusplus 98 } 99 #endif 100 #endif /* AVCTP_ST_H */