MSP430™CapTIvateSoftwareLibraryAPIGuide  1_83_00_05
CAPT_Protocol.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // CAPT_Protocol.h
3 //
5 //
8 //
9 //*****************************************************************************
10 //*****************************************************************************
13 //*****************************************************************************
14 
15 #ifndef CAPT_PROTOCOL_H_
16 #define CAPT_PROTOCOL_H_
17 
18 #ifndef S_SPLINT_S
19 #include <stdio.h>
20 #include <stdbool.h>
21 #endif
22 
23 //
24 // Include ByteQueue for queue APIs
25 //
26 #include "CAPT_ByteQueue.h"
27 
28 //
29 // Include CAPT_TL_Type for CapTIvate&tm; types
30 //
31 #include "CAPT_Type.h"
32 
33 
34 //*****************************************************************************
35 //
37 //
39 //
42 //
44 //
46 //
47 //*****************************************************************************
48 #define TL_PROTOCOL_SYNC (0x55)
49 #define TL_PROTOCOL_BLANK (0xAA)
50 #define TL_PROTOCOL_READ (0x00)
51 #define TL_PROTOCOL_WRITE (0x01)
52 
53 //*****************************************************************************
54 //
56 //
63 //
64 //*****************************************************************************
65 #define TL_SENSOR_PACKET_CMD (0x00)
66 #define TL_CYCLE_PACKET_CMD (0x01)
67 #define TL_TRACKPAD_PACKET_CMD (0x02)
68 #define TL_GENERAL_PURPOSE_PACKET_CMD (0x10)
69 #define TL_STRING_PACKET_CMD (0x3E)
70 
71 #define TL_PARAM_CMD_GENERIC_MASK (0x80)
72 #define TL_PARAM_CMD_SLIDER_WHEEL_MASK (0x90)
73 #define TL_PARAM_CMD_TP_MASK (0xA0)
74 #define TL_PARAM_CMD_DYCAL_MASK (0xB0)
75 #define TL_PARAM_CMD_CTRL_MASK (0xC0)
76 #define TL_PARAM_CMD_SPECIAL_MASK (0xD0)
77 #define TL_PARAM_CMD_INVALID_MASK (0xF0)
78 
79 //
80 // TRACKPAD PARAMETER COMMANDS
81 //
82 #define TL_PARAM_CMD_FILTER_ENABLE (0x60)
83 #define TL_PARAM_CMD_STATIC_FILTER_BETA (0x61)
84 #define TL_PARAM_CMD_HIGH_SPEED_THRESHOLD (0x63)
85 #define TL_PARAM_CMD_LOW_SPEED_THRESHOLD (0x64)
86 #define TL_PARAM_CMD_LOW_SPEED_BETA (0x65)
87 #define TL_PARAM_CMD_FILTER_TYPE (0x66)
88 #define TL_PARAM_CMD_RESOLUTION_X (0x67)
89 #define TL_PARAM_CMD_RESOLUTION_Y (0x68)
90 #define TL_PARAM_CMD_LOWER_TRIM_X (0x69)
91 #define TL_PARAM_CMD_UPPER_TRIM_X (0x6A)
92 #define TL_PARAM_CMD_LOWER_TRIM_Y (0x6B)
93 #define TL_PARAM_CMD_UPPER_TRIM_Y (0x6C)
94 #define TL_PARAM_CMD_REJECTION_THRESHOLD (0x6D)
95 
96 //
97 // TRACKPAD GESTURE COMMANDS
98 //
99 #define TL_PARAM_CMD_TAP_TIME_MIN (0x70)
100 #define TL_PARAM_CMD_TAP_TIME_MAX (0x71)
101 #define TL_PARAM_CMD_SWIPE_TIME_MAX (0x72)
102 #define TL_PARAM_CMD_DBLTAP_TIME_MAX (0x73)
103 #define TL_PARAM_CMD_TAPHOLD_TIME_MIN (0x74)
104 #define TL_PARAM_CMD_SWIPE_DISTANCE_MIN (0x75)
105 #define TL_PARAM_CMD_END_TRACKPAD (0x7F)
106 
107 //
108 // TL PARAMETER GENERIC COMMANDS
109 //
110 #define TL_PARAM_CMD_CONVERSIONGAIN (0x80)
111 #define TL_PARAM_CMD_CONVERSIONCOUNT (0x81)
112 #define TL_PARAM_CMD_PROX_THRESH (0x82)
113 #define TL_PARAM_CMD_TOUCH_THRESH (0x83)
114 #define TL_PARAM_CMD_PROX_DBIN (0x84)
115 #define TL_PARAM_CMD_PROX_DBOUT (0x85)
116 #define TL_PARAM_CMD_TOUCH_DBIN (0x86)
117 #define TL_PARAM_CMD_TOUCH_DBOUT (0x87)
118 #define TL_PARAM_CMD_TIMEOUT (0x88)
119 #define TL_PARAM_CMD_COUNTFILTEN (0x89)
120 #define TL_PARAM_CMD_COUNTFILTBETA (0x8A)
121 #define TL_PARAM_CMD_LTAFILTBETA (0x8B)
122 #define TL_PARAM_CMD_LTAFILTERHALT (0x8C)
123 #define TL_PARAM_CMD_DRIFTRECALENABLE (0x8D)
124 #define TL_PARAM_CMD_FORCERECALIBRATE (0x8E)
125 #define TL_PARAM_CMD_BIAS_CURRENT (0x8F)
126 #define TL_PARAM_CMD_CS_DISCHARGE (0x95)
127 #define TL_PARAM_CMD_MODENABLE (0x96)
128 #define TL_PARAM_CMD_FREQDIV (0x97)
129 #define TL_PARAM_CMD_CPLEN (0x98)
130 #define TL_PARAM_CMD_TPLEN (0x99)
131 #define TL_PARAM_CMD_ERROR_THRESH (0x9A)
132 #define TL_PARAM_CMD_NEG_TOUCH_THRESH (0x9B)
133 #define TL_PARAM_CMD_IDLE_STATE (0x9C)
134 #define TL_PARAM_CMD_INPUT_SYNC (0x9D)
135 #define TL_PARAM_CMD_TIMER_SYNC (0x9E)
136 #define TL_PARAM_CMD_LPMCTRL (0x9F)
137 #define TL_PARAM_CMD_LTA_SENSOR_PTHALT (0xA0)
138 #define TL_PARAM_CMD_LTA_ELEMENT_PTHALT (0xA1)
139 #define TL_PARAM_CMD_COARSE_GAIN_RATIO (0xA2)
140 #define TL_PARAM_CMD_FINE_GAIN_RATIO (0xA3)
141 #define TL_PARAM_CMD_OFFSET_SUBTRACTION (0xA4) // Deprecated for 1.00.01.00
142 #define TL_PARAM_CMD_OFFSET_SCALE (0xD0) // Added for 1.00.01.00
143 #define TL_PARAM_CMD_OFFSET_LEVEL (0xD1) // Added for 1.00.01.00
144 
145 //
146 // TL PARAMETER SLIDER/WHEEL COMMANDS
147 //
148 #define TL_PARAM_CMD_SLIDER_FILTEREN (0x90)
149 #define TL_PARAM_CMD_SLIDER_FILTERBETA (0x91)
150 #define TL_PARAM_CMD_SLIDER_RES (0x92)
151 #define TL_PARAM_CMD_SLIDER_LTRIM (0x93)
152 #define TL_PARAM_CMD_SLIDER_UTRIM (0x94)
153 
154 
155 //
156 // TL PARAMETER CONTROLLER COMMANDS
157 //
158 #define TL_PARAM_CMD_CTRL_ELEMENTTXEN (0xC0)
159 #define TL_PARAM_CMD_CTRL_SENSORTXEN (0xC1)
160 #define TL_PARAM_CMD_CTRL_REPORTRATE_ACTIVE (0xC2)
161 #define TL_PARAM_CMD_CTRL_REPORTRATE_AUTO (0xC3)
162 #define TL_PARAM_CMD_CTRL_WAKEINTERVAL_AUTO (0xC4)
163 #define TL_PARAM_CMD_CTRL_TIMEOUT_ACTIVE (0xC5)
164 
165 //*****************************************************************************
166 //
168 //
171 //
173 //
176 //
179 //
182 //
184 //
187 //
189 //
192 //
195 //
197 //
198 //*****************************************************************************
199 #define TL_PCKT_SERIAL_OVRHD_LENGTH (0x03)
200 #define TL_PCKT_CHKSUM_LENGTH (0x02)
201 #define TL_CYCLE_STATE_OFFSET (0x06)
202 #define TL_CYCLE_STATE_LEN (0x03)
203 #define TL_CYCLE_LEN_PER_ELEMENT (0x04)
204 #define TL_CYCLE_OVRHD_LEN (0x06)
205 #define TL_SENSOR_PACKET_LENGTH (0x0B)
206 #define TL_PARAMETER_PACKET_LENGTH (0x0C)
207 #define TL_PARAMETER_DATA_LENGTH (0x07)
208 #define TL_GENERAL_PURPOSE_MAX_CNT (0x1D)
209 #define TL_STRING_MAX_CNT (0x3A)
210 
211 //*****************************************************************************
212 //
214 //
216 //
218 //
221 //
224 //
226 //
228 //
229 //*****************************************************************************
230 #define TL_PCKT_CMD_FIELD (0x03)
231 #define TL_SENSOR_PCKT_ID_FIELD (0x04)
232 #define TL_CYCLE_PCKT_ID_FIELD (0x04)
233 #define TL_CYCLE_PCKT_CYCLE_FIELD (0x05)
234 #define TL_PARAM_PCKT_RW_FIELD (0x04)
235 #define TL_PARAM_PCKT_ID_FIELD (0x05)
236 
237  //*****************************************************************************
238 //
240 //
242 //
257 //
263 //
264 //*****************************************************************************
265 /*
266  * TRACKPAD PACKET BASE LENGTH
267  */
268 
269 #define TL_TRACKPAD_PACKET_BASE_LENGTH (0x09)
270 
271 
272 //*****************************************************************************
273 //
277 //
278 //*****************************************************************************
279 typedef struct
280 {
284 
285 //*****************************************************************************
286 //
291 //
292 //*****************************************************************************
293 enum
294 {
296  eInvalidCmd = 0x01,
297  eValidCmd = 0x02,
299 };
300 typedef uint8_t tTLParameterAccessResult;
301 
302 
303 //*****************************************************************************
304 //
309 //
310 //*****************************************************************************
311 typedef union
312 {
313  struct
314  {
315  uint8_t ui8Sync;
316  uint8_t ui8Blank;
317  uint8_t ui8Length;
318  uint8_t ui8Command;
319  uint8_t ui8Write;
320  uint8_t ui8SensorID;
321  uint8_t ui8Param0;
322  uint8_t ui8Param1;
323  uint8_t ui8Param2;
324  uint8_t ui8Param3;
325  uint16_t ui16Checksum;
326  };
327  uint8_t ui8Packet[TL_PARAMETER_PACKET_LENGTH];
330 //
331 // TL Protocol API Prototypes
332 //
333 
334 //*****************************************************************************
335 //
339 //
344 //
348 //
349 //*****************************************************************************
350 extern uint16_t CAPT_getCyclePacket(tSensor **sensorArray,
351  uint8_t ui8SensorID, uint8_t ui8Cycle, uint8_t *pBuffer);
352 
353 //*****************************************************************************
354 //
358 //
362 //
366 //
367 //*****************************************************************************
368 extern uint16_t CAPT_getSensorPacket(tSensor **sensorArray,
369  uint8_t ui8SensorID, uint8_t *pBuffer);
370 
371 //*****************************************************************************
372 //
375 //
379 //
383 //
384 //*****************************************************************************
385 extern uint16_t CAPT_getGeneralPurposePacket(uint16_t *pData,
386  uint8_t ui8Cnt, uint8_t *pBuffer);
387 
388 //*****************************************************************************
389 //
393 //
396 //
400 //
401 //*****************************************************************************
402 extern uint16_t CAPT_getStringPacket(const char *pSrcString, uint8_t *pBuffer);
403 
404 
405 //*****************************************************************************
406 //
410 //
414 //
418 //
419 extern uint16_t CAPT_getTrackPadPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer);
420 
421 
422 
423 //*****************************************************************************
424 //
428 //
432 //
436 extern uint16_t CAPT_getTrackPadSensorStatusPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer);
437 
438 
439 //*****************************************************************************
440 //
442 //
445 //
448 //
449 //*****************************************************************************
450 extern uint16_t CAPT_getChecksum(const uint8_t *pBuffer,
451  const uint16_t ui16Length);
452 
453 //*****************************************************************************
454 //
456 //
460 //
463 //
464 //*****************************************************************************
465 extern bool CAPT_verifyChecksum(const uint8_t *pBuffer, const uint16_t ui16Length,
466  const uint16_t ui16Checksum);
467 
468 //*****************************************************************************
469 //
472 //
475 //
478 //
479 //*****************************************************************************
480 extern uint16_t CAPT_stuffSyncBytes(uint8_t *pBuffer,
481  uint16_t ui16Length);
482 
483 //*****************************************************************************
484 //
487 //
491 //
494 //
495 //*****************************************************************************
496 extern bool CAPT_processReceivedData(tByteQueue *pReceiveQueue,
497  tParameterPacket *pPacket, tTLProtocolProcessingVariables *pVariables);
498 
499 //*****************************************************************************
500 //
503 //
507 //
512 //
513 //*****************************************************************************
515  tSensor **sensorArray, tParameterPacket *pPacket);
516 
517 //*****************************************************************************
518 //
521 //
525 //
530 //
531 //*****************************************************************************
533  tSensor **sensorArray, tParameterPacket *pPacket);
534 
535 
536 //
538 //
542 //
547 //
549  tSensor **sensorArray, tParameterPacket *pPacket);
550 
551 #endif /* CAPT_PROTOCOL_H_ */
552 //*****************************************************************************
555 //*****************************************************************************
uint16_t CAPT_stuffSyncBytes(uint8_t *pBuffer, uint16_t ui16Length)
Definition: CAPT_Protocol.h:298
uint8_t ui8Param2
Definition: CAPT_Protocol.h:323
int8_t i8currPacketIndex
Definition: CAPT_Protocol.h:281
Definition: CAPT_Protocol.h:279
Definition: CAPT_Protocol.h:296
tTLParameterAccessResult CAPT_accessSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
uint16_t CAPT_getStringPacket(const char *pSrcString, uint8_t *pBuffer)
#define TL_PARAMETER_PACKET_LENGTH
Definition: CAPT_Protocol.h:206
Definition: CAPT_Protocol.h:295
uint16_t CAPT_getCyclePacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t ui8Cycle, uint8_t *pBuffer)
uint8_t ui8Sync
Definition: CAPT_Protocol.h:315
uint8_t ui8Param3
Definition: CAPT_Protocol.h:324
For large code model devices, a function pointer should be 32-bits.
Definition: CAPT_Type.h:748
uint16_t CAPT_getChecksum(const uint8_t *pBuffer, const uint16_t ui16Length)
This API calculate the checksum of a byte buffer of given length.
uint8_t ui8SensorID
Definition: CAPT_Protocol.h:320
uint16_t CAPT_getTrackPadPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer)
uint8_t tTLParameterAccessResult
Definition: CAPT_Protocol.h:300
uint8_t ui8Command
Definition: CAPT_Protocol.h:318
uint8_t ui8Param0
Definition: CAPT_Protocol.h:321
uint8_t ui8Blank
Definition: CAPT_Protocol.h:316
typedef tByteQueue
Definition: CAPT_ByteQueue.h:35
tTLParameterAccessResult CAPT_accessSpecialSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
Definition: CAPT_Protocol.h:297
uint16_t CAPT_getTrackPadSensorStatusPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer)
uint16_t CAPT_getGeneralPurposePacket(uint16_t *pData, uint8_t ui8Cnt, uint8_t *pBuffer)
uint16_t CAPT_getSensorPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer)
Definition: CAPT_Protocol.h:311
uint16_t ui16Checksum
Definition: CAPT_Protocol.h:325
bool CAPT_processReceivedData(tByteQueue *pReceiveQueue, tParameterPacket *pPacket, tTLProtocolProcessingVariables *pVariables)
bool bStuffedByteDetected
Definition: CAPT_Protocol.h:282
uint8_t ui8Write
Definition: CAPT_Protocol.h:319
uint8_t ui8Param1
Definition: CAPT_Protocol.h:322
uint8_t ui8Length
Definition: CAPT_Protocol.h:317
tTLParameterAccessResult CAPT_accessTrackPadSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
Access a special CapTIvateā„¢ TL structure variable for a TrackPad sensor.
bool CAPT_verifyChecksum(const uint8_t *pBuffer, const uint16_t ui16Length, const uint16_t ui16Checksum)
This API verifies the checksum of a byte buffer of given length.
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale