• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 
16 #ifndef HISIGNALLING_H
17 #define HISIGNALLING_H
18 
19 #define HISIGNALLING_MSG_HEADER_LEN         (1)
20 #define HISGNALLING_MSG_FRAME_HEADER_LEN    (2)
21 #define HISIGNALLING_MSG_HEADER_TAIL_LEN    (3)
22 #define HISGNALLING_FREE_TASK_TIME          (10)
23 #define HISIGNALLING_MSG_MOTOR_ENGINE_LEN   (11)
24 #define HISIGNALLING_MSG_ONE_FRAME_LEN      (16)
25 #define HISIGNALLING_MSG_BUFF_LEN           (512)
26 
27 /*
28  * @brief 外设扩展板和Robot板的选择
29  * 使用时选择打开宏,使用外设扩展板打开#define BOARD_SELECT_IS_EXPANSION_BOARD这个宏
30  * 使用Robot板打开#define BOARD_SELECT_IS_ROBOT_BOARD这个宏
31  *
32  * @brief Selection of peripheral expansion board and Robot board
33  * Select to open the macro when using it,
34  * and use the peripheral expansion board to open the #define BOARD_SELECT_IS_EXPANSION_BOARD macro
35  * Use the Robot board to open the #define BOARD_SELECT_IS_ROBOT_BOARD macro
36  */
37 #define BOARD_SELECT_IS_EXPANSION_BOARD
38 #ifdef BOARD_SELECT_IS_EXPANSION_BOARD
39 #define EXPANSION_BOARD
40 #else
41 #define ROBOT_BOARD
42 #endif
43 
44 typedef enum {
45     EAGE_0 = 0,
46     EAGE_1,
47     EAGE_2,
48     EAGE_3
49 } GPioEage;
50 
51 typedef enum {
52     FistGesture = 0x1,
53     ForefingerGesture,
54     OkGesture,
55     PalmGesture,
56     YesGesture,
57     ForefingerAndThumbGesture,
58     LittleFingerAndThumbGesture,
59     InvalidGesture
60 } refuseClassification;
61 
62 typedef struct {
63     unsigned char frameHeader[HISGNALLING_MSG_FRAME_HEADER_LEN];
64     unsigned char hisignallingMsgBuf[HISIGNALLING_MSG_BUFF_LEN];
65     unsigned int hisigallingMsgLen;
66     unsigned char endOfFrame;
67     unsigned int hisignallingCrc32Check;
68 } HisignallingProtocalType;
69 
70 typedef enum {
71     HISIGNALLING_RET_VAL_CORRECT = 0,
72     HISIGNALLING_RET_VAL_ERROR,
73     HISGNALLING_RET_VAL_MAX
74 } HisignallingErrorType;
75 
76 /*
77  * hisignalling协议函数声明
78  * hisignalling protocal Function declaration
79  */
80 unsigned int UartOpenInit(void);
81 void UartSendRead(int fd, refuseClassification refuseType);
82 static HisignallingErrorType HisignallingMsgReceive(int fd, unsigned char *buf, unsigned int len);
83 static unsigned int HisignallingMsgSend(int fd, char *buf, unsigned int dataLen);
84 unsigned int HisignallingMsgTask(void);
85 
86 #endif