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 Adapter plate selection 29 使用时选择打开宏,使用外设扩展板打开#define BOARD_SELECT_IS_EXPANSION_BOARD这个宏 30 使用Robot板打开#define BOARD_SELECT_IS_ROBOT_BOARD这个宏 31 */ 32 #define BOARD_SELECT_IS_EXPANSION_BOARD 33 #ifdef BOARD_SELECT_IS_EXPANSION_BOARD 34 #define EXPANSION_BOARD 35 #else 36 #define ROBOT_BOARD 37 #endif 38 39 typedef enum { 40 EAGE_0 = 0, 41 EAGE_1, 42 EAGE_2, 43 EAGE_3 44 } GPioEage; 45 46 typedef enum { 47 FistGesture = 0x1, 48 ForefingerGesture, 49 OkGesture, 50 PalmGesture, 51 YesGesture, 52 ForefingerAndThumbGesture, 53 LittleFingerAndThumbGesture, 54 InvalidGesture 55 }refuseClassification; 56 57 typedef struct { 58 unsigned char frameHeader[HISGNALLING_MSG_FRAME_HEADER_LEN]; 59 unsigned char hisignallingMsgBuf[HISIGNALLING_MSG_BUFF_LEN]; 60 unsigned int hisigallingMsgLen; 61 unsigned char endOfFrame; 62 unsigned int hisignallingCrc32Check; 63 }HisignallingProtocalType; 64 65 typedef enum { 66 HISIGNALLING_RET_VAL_CORRECT = 0, 67 HISIGNALLING_RET_VAL_ERROR, 68 HISGNALLING_RET_VAL_MAX 69 }HisignallingErrorType; 70 /* 71 * hisignalling protocal Function declaration 72 */ 73 unsigned int UartOpenInit(void); 74 void UartSendRead(int fd, refuseClassification refuseType); 75 static HisignallingErrorType HisignallingMsgReceive(int fd, unsigned char *buf, unsigned int len); 76 static unsigned int HisignallingMsgSend(int fd, char *buf, unsigned int dataLen); 77 unsigned int HisignallingMsgTask(void); 78 79 #endif