• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef true
28 #define true (0x01) /* Logical True Value */
29 #endif
30 #ifndef TRUE
31 #define TRUE (0x01) /* Logical True Value */
32 #endif
33 #ifndef false
34 #define false (0x00) /* Logical False Value */
35 #endif
36 #ifndef FALSE
37 #define FALSE (0x00) /* Logical False Value */
38 #endif
39 typedef uint8_t utf8_t;     /* UTF8 Character String */
40 typedef uint8_t bool_t;     /* boolean data type */
41 typedef uint16_t tHAL_UWB_STATUS; /* Return values */
42 
43 #define STATIC static
44 
45 #define PHUWB_MAX_UID_LENGTH 0x0AU /* Maximum UID length expected */
46 /* Maximum ATR_RES (General Bytes) length expected */
47 #define PHUWB_MAX_ATR_LENGTH 0x30U
48 #define PHUWB_UWBID_LENGTH 0x0AU /* Maximum length of UWBID 1.3*/
49 #define PHUWB_ATQA_LENGTH 0x02U  /* ATQA length */
50 
51 /*
52  * UWB Data structure
53  */
54 typedef struct phUwb_sData {
55   uint8_t* buffer; /* Buffer to store data */
56   uint32_t length; /* Buffer length */
57 } phUwb_sData_t;
58 
59 #define UNUSED(X) (void)(X);
60 /*
61  * Possible Hardware Configuration exposed to upper layer.
62  * Typically this should be port name (Ex:"COM1","COM2") to which SR100 is
63  * connected.
64  */
65 typedef enum {
66   ENUM_LINK_TYPE_COM1,
67   ENUM_LINK_TYPE_COM2,
68   ENUM_LINK_TYPE_COM3,
69   ENUM_LINK_TYPE_COM4,
70   ENUM_LINK_TYPE_COM5,
71   ENUM_LINK_TYPE_COM6,
72   ENUM_LINK_TYPE_COM7,
73   ENUM_LINK_TYPE_COM8,
74   ENUM_LINK_TYPE_I2C,
75   ENUM_LINK_TYPE_SPI,
76   ENUM_LINK_TYPE_USB,
77   ENUM_LINK_TYPE_TCP,
78   ENUM_LINK_TYPE_NB
79 } phLibUwb_eConfigLinkType;
80 
81 /*
82  * Deferred message. This message type will be posted to the client application
83  * thread
84  * to notify that a deferred call must be invoked.
85  */
86 #define PH_LIBUWB_DEFERREDCALL_MSG (0x311)
87 
88 /*
89  * Deferred call declaration.
90  * This type of API is called from ClientApplication ( main thread) to notify
91  * specific callback.
92  */
93 typedef void (*pphLibUwb_DeferredCallback_t)(void*);
94 
95 /*
96  * Deferred parameter declaration.
97  * This type of data is passed as parameter from ClientApplication (main thread)
98  * to the
99  * callback.
100  */
101 typedef void* pphLibUwb_DeferredParameter_t;
102 
103 /*
104  * Possible Hardware Configuration exposed to upper layer.
105  * Typically this should be at least the communication link (Ex:"COM1","COM2")
106  * the controller is connected to.
107  */
108 typedef struct phLibUwb_sConfig {
109   uint8_t* pLogFile; /* Log File Name*/
110   /* Hardware communication link to the controller */
111   phLibUwb_eConfigLinkType nLinkType;
112   /* The client ID (thread ID or message queue ID) */
113   uintptr_t nClientId;
114 } phLibUwb_sConfig_t, *pphLibUwb_sConfig_t;
115 
116 /*
117  * UWB Message structure contains message specific details like
118  * message type, message specific data block details, etc.
119  */
120 typedef struct phLibUwb_Message {
121   uint32_t eMsgType; /* Type of the message to be posted*/
122   void* pMsgData;    /* Pointer to message specific data block in case any*/
123   uint32_t Size;     /* Size of the datablock*/
124 } phLibUwb_Message_t, *pphLibUwb_Message_t;
125 
126 /*
127  * Deferred message specific info declaration.
128  * This type of information is packed as message data when
129  * PH_LIBUWB_DEFERREDCALL_MSG
130  * type message is posted to message handler thread.
131  */
132 typedef struct phLibUwb_DeferredCall {
133   pphLibUwb_DeferredCallback_t pCallback;   /* pointer to Deferred callback */
134   pphLibUwb_DeferredParameter_t pParameter; /* pointer to Deferred parameter */
135 } phLibUwb_DeferredCall_t;
136 
137 /*
138  * Definitions for supported protocol
139  */
140 
141 #endif /* PHUWBTYPES_H */
142