1 /* 2 * Copyright 2012-2020 NXP 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef PHUWBTYPES_H 18 #define PHUWBTYPES_H 19 20 #include <stdint.h> 21 #include <string.h> 22 #include <stdio.h> 23 #include <stdlib.h> 24 #include <unistd.h> 25 #include <stdbool.h> 26 27 #include <memory> 28 29 #include <phMessageQueue.h> 30 31 #ifndef true 32 #define true (0x01) /* Logical True Value */ 33 #endif 34 #ifndef TRUE 35 #define TRUE (0x01) /* Logical True Value */ 36 #endif 37 #ifndef false 38 #define false (0x00) /* Logical False Value */ 39 #endif 40 #ifndef FALSE 41 #define FALSE (0x00) /* Logical False Value */ 42 #endif 43 typedef uint8_t utf8_t; /* UTF8 Character String */ 44 typedef uint8_t bool_t; /* boolean data type */ 45 typedef uint16_t tHAL_UWB_STATUS; /* Return values */ 46 47 #define STATIC static 48 49 #define PHUWB_MAX_UID_LENGTH 0x0AU /* Maximum UID length expected */ 50 /* Maximum ATR_RES (General Bytes) length expected */ 51 #define PHUWB_MAX_ATR_LENGTH 0x30U 52 #define PHUWB_UWBID_LENGTH 0x0AU /* Maximum length of UWBID 1.3*/ 53 #define PHUWB_ATQA_LENGTH 0x02U /* ATQA length */ 54 55 /* 56 * UWB Data structure 57 */ 58 typedef struct phUwb_sData { 59 uint8_t* buffer; /* Buffer to store data */ 60 uint32_t length; /* Buffer length */ 61 } phUwb_sData_t; 62 63 #define UNUSED(X) (void)(X); 64 /* 65 * Possible Hardware Configuration exposed to upper layer. 66 * Typically this should be port name (Ex:"COM1","COM2") to which SR100 is 67 * connected. 68 */ 69 typedef enum { 70 ENUM_LINK_TYPE_COM1, 71 ENUM_LINK_TYPE_COM2, 72 ENUM_LINK_TYPE_COM3, 73 ENUM_LINK_TYPE_COM4, 74 ENUM_LINK_TYPE_COM5, 75 ENUM_LINK_TYPE_COM6, 76 ENUM_LINK_TYPE_COM7, 77 ENUM_LINK_TYPE_COM8, 78 ENUM_LINK_TYPE_I2C, 79 ENUM_LINK_TYPE_SPI, 80 ENUM_LINK_TYPE_USB, 81 ENUM_LINK_TYPE_TCP, 82 ENUM_LINK_TYPE_NB 83 } phLibUwb_eConfigLinkType; 84 85 /* 86 * Deferred message. This message type will be posted to the client application 87 * thread 88 * to notify that a deferred call must be invoked. 89 */ 90 #define PH_LIBUWB_DEFERREDCALL_MSG (0x311) 91 92 /* 93 * Deferred call declaration. 94 * This type of API is called from ClientApplication ( main thread) to notify 95 * specific callback. 96 */ 97 typedef void (*pphLibUwb_DeferredCallback_t)(void*); 98 99 /* 100 * UWB Message structure contains message specific details like 101 * message type, message specific data block details, etc. 102 */ 103 struct phLibUwb_Message { 104 uint32_t eMsgType; /* Type of the message to be posted*/ 105 void* pMsgData; /* Pointer to message specific data block in case any*/ phLibUwb_MessagephLibUwb_Message106 phLibUwb_Message(uint32_t type) : eMsgType(type), pMsgData(NULL) {} phLibUwb_MessagephLibUwb_Message107 phLibUwb_Message(uint32_t type, void *data) : eMsgType(type), pMsgData(data) {} 108 }; 109 110 /* 111 * Possible Hardware Configuration exposed to upper layer. 112 * Typically this should be at least the communication link (Ex:"COM1","COM2") 113 * the controller is connected to. 114 */ 115 typedef struct phLibUwb_sConfig { 116 uint8_t* pLogFile; /* Log File Name*/ 117 /* Hardware communication link to the controller */ 118 phLibUwb_eConfigLinkType nLinkType; 119 /* message queue on the client thread */ 120 std::shared_ptr<MessageQueue<phLibUwb_Message>> pClientMq; 121 } phLibUwb_sConfig_t, *pphLibUwb_sConfig_t; 122 123 /* 124 * Deferred message specific info declaration. 125 * This type of information is packed as message data when 126 * PH_LIBUWB_DEFERREDCALL_MSG 127 * type message is posted to message handler thread. 128 */ 129 typedef struct phLibUwb_DeferredCall { 130 pphLibUwb_DeferredCallback_t pCallback; /* pointer to Deferred callback */ 131 void *pParameter; /* pointer to Deferred parameter */ 132 } phLibUwb_DeferredCall_t; 133 134 /* 135 * Definitions for supported protocol 136 */ 137 138 #endif /* PHUWBTYPES_H */ 139