MSP430™CapTIvateSoftwareLibraryAPIGuide 1_70_00_03

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
83
84 #define TL_PARAM_CMD_TRACKPADFILTEREN (0x60)
85 #define TL_PARAM_CMD_TRACKPADFILTERBETA (0x61)
86 #define TL_PARAM_CMD_BETATOPSPEED (0x63)
87 #define TL_PARAM_CMD_BETABOTTOMSPEED (0x64)
88 #define TL_PARAM_CMD_LOWERBETA (0x65)
89 #define TL_PARAM_CMD_TRACKPADFILTERTYPE (0x66)
90 #define TL_PARAM_CMD_RESOLUTION_X (0x67)
91 #define TL_PARAM_CMD_RESOLUTION_Y (0x68)
92
93 #define TL_PARAM_CMD_LOWERTRIM_X (0x69)
94 #define TL_PARAM_CMD_UPPERTRIM_X (0x6A)
95 #define TL_PARAM_CMD_LOWERTRIM_Y (0x6B)
96 #define TL_PARAM_CMD_UPPERTRIM_Y (0x6C)
97 #define TL_PARAM_CMD_CENTERTRIM_X (0x6D)
98 #define TL_PARAM_CMD_CENTERTRIM_Y (0x6E)
99 #define TL_PARAM_CMD_CIRCLERADIUS (0x6F)
100
101 //
102 // TRACKPAD GESTURE COMMANDS
103 //
104 #define TL_PARAM_CMD_TAPTIME_MIN (0x70)
105 #define TL_PARAM_CMD_TAPTIME_MAX (0x71)
106 #define TL_PARAM_CMD_SWIPETIME_MAX (0x72)
107 #define TL_PARAM_CMD_DBLTAPTIME_MAX (0x73)
108 #define TL_PARAM_CMD_TAPHOLDTIME_MIN (0x74)
109 #define TL_PARAM_CMD_SWIPEDISTANCE_MIN (0x75)
110
111 #define TL_PARAM_CMD_DBLTAPENABLE (0x76)
112 #define TL_PARAM_CMD_SWIPEENABLE (0x77)
113 #define TL_PARAM_CMD_CIRCLEENABLE (0x78)
114 #define TL_PARAM_CMD_ENDTRACKPAD (0x7F)
115
116 //
117 // TL PARAMETER GENERIC COMMANDS
118 //
119 #define TL_PARAM_CMD_CONVERSIONGAIN (0x80)
120 #define TL_PARAM_CMD_CONVERSIONCOUNT (0x81)
121 #define TL_PARAM_CMD_PROX_THRESH (0x82)
122 #define TL_PARAM_CMD_TOUCH_THRESH (0x83)
123 #define TL_PARAM_CMD_PROX_DBIN (0x84)
124 #define TL_PARAM_CMD_PROX_DBOUT (0x85)
125 #define TL_PARAM_CMD_TOUCH_DBIN (0x86)
126 #define TL_PARAM_CMD_TOUCH_DBOUT (0x87)
127 #define TL_PARAM_CMD_TIMEOUT (0x88)
128 #define TL_PARAM_CMD_COUNTFILTEN (0x89)
129 #define TL_PARAM_CMD_COUNTFILTBETA (0x8A)
130 #define TL_PARAM_CMD_LTAFILTBETA (0x8B)
131 #define TL_PARAM_CMD_LTAFILTERHALT (0x8C)
132 #define TL_PARAM_CMD_DRIFTRECALENABLE (0x8D)
133 #define TL_PARAM_CMD_FORCERECALIBRATE (0x8E)
134 #define TL_PARAM_CMD_BIAS_CURRENT (0x8F)
135 #define TL_PARAM_CMD_CS_DISCHARGE (0x95)
136 #define TL_PARAM_CMD_MODENABLE (0x96)
137 #define TL_PARAM_CMD_FREQDIV (0x97)
138 #define TL_PARAM_CMD_CPLEN (0x98)
139 #define TL_PARAM_CMD_TPLEN (0x99)
140 #define TL_PARAM_CMD_ERROR_THRESH (0x9A)
141 #define TL_PARAM_CMD_NEG_TOUCH_THRESH (0x9B)
142 #define TL_PARAM_CMD_IDLE_STATE (0x9C)
143 #define TL_PARAM_CMD_INPUT_SYNC (0x9D)
144 #define TL_PARAM_CMD_TIMER_SYNC (0x9E)
145 #define TL_PARAM_CMD_LPMCTRL (0x9F)
146 #define TL_PARAM_CMD_LTA_SENSOR_PTHALT (0xA0)
147 #define TL_PARAM_CMD_LTA_ELEMENT_PTHALT (0xA1)
148 #define TL_PARAM_CMD_COARSE_GAIN_RATIO (0xA2)
149 #define TL_PARAM_CMD_FINE_GAIN_RATIO (0xA3)
150 #define TL_PARAM_CMD_OFFSET_SUBTRACTION (0xA4) // Deprecated for 1.00.01.00
151 #define TL_PARAM_CMD_OFFSET_SCALE (0xD0) // Added for 1.00.01.00
152 #define TL_PARAM_CMD_OFFSET_LEVEL (0xD1) // Added for 1.00.01.00
153
154 //
155 // TL PARAMETER SLIDER/WHEEL COMMANDS
156 //
157 #define TL_PARAM_CMD_SLIDER_FILTEREN (0x90)
158 #define TL_PARAM_CMD_SLIDER_FILTERBETA (0x91)
159 #define TL_PARAM_CMD_SLIDER_RES (0x92)
160 #define TL_PARAM_CMD_SLIDER_LTRIM (0x93)
161 #define TL_PARAM_CMD_SLIDER_UTRIM (0x94)
162
163
164 //
165 // TL PARAMETER CONTROLLER COMMANDS
166 //
167 #define TL_PARAM_CMD_CTRL_ELEMENTTXEN (0xC0)
168 #define TL_PARAM_CMD_CTRL_SENSORTXEN (0xC1)
169 #define TL_PARAM_CMD_CTRL_REPORTRATE_ACTIVE (0xC2)
170 #define TL_PARAM_CMD_CTRL_REPORTRATE_AUTO (0xC3)
171 #define TL_PARAM_CMD_CTRL_WAKEINTERVAL_AUTO (0xC4)
172 #define TL_PARAM_CMD_CTRL_TIMEOUT_ACTIVE (0xC5)
173
174 //*****************************************************************************
175 //
177 //
180 //
182 //
185 //
188 //
191 //
193 //
196 //
198 //
201 //
204 //
206 //
207 //*****************************************************************************
208 #define TL_PCKT_SERIAL_OVRHD_LENGTH (0x03)
209 #define TL_PCKT_CHKSUM_LENGTH (0x02)
210 #define TL_CYCLE_STATE_OFFSET (0x06)
211 #define TL_CYCLE_STATE_LEN (0x03)
212 #define TL_CYCLE_LEN_PER_ELEMENT (0x04)
213 #define TL_CYCLE_OVRHD_LEN (0x06)
214 #define TL_SENSOR_PACKET_LENGTH (0x0B)
215 #define TL_PARAMETER_PACKET_LENGTH (0x0C)
216 #define TL_PARAMETER_DATA_LENGTH (0x07)
217 #define TL_GENERAL_PURPOSE_MAX_CNT (0x1D)
218 #define TL_STRING_MAX_CNT (0x3A)
219
220 //*****************************************************************************
221 //
223 //
225 //
227 //
230 //
233 //
235 //
237 //
238 //*****************************************************************************
239 #define TL_PCKT_CMD_FIELD (0x03)
240 #define TL_SENSOR_PCKT_ID_FIELD (0x04)
241 #define TL_CYCLE_PCKT_ID_FIELD (0x04)
242 #define TL_CYCLE_PCKT_CYCLE_FIELD (0x05)
243 #define TL_PARAM_PCKT_RW_FIELD (0x04)
244 #define TL_PARAM_PCKT_ID_FIELD (0x05)
245
246 //*****************************************************************************
247 //
249 //
251 //
266 //
272 //
273 //*****************************************************************************
274 /*
275 * TRACKPAD PACKET BASE LENGTH
276 */
277
278 #define TL_TRACKPAD_PACKET_BASE_LENGTH (0x09)
279
280
281 //*****************************************************************************
282 //
286 //
287 //*****************************************************************************
288 typedef struct
289 {
290 int8_t i8currPacketIndex;
291 bool bStuffedByteDetected;
292 } tTLProtocolProcessingVariables;
293
294 //*****************************************************************************
295 //
300 //
301 //*****************************************************************************
302 enum
303 {
304 eInvalidSensor = 0x00,
305 eInvalidCmd = 0x01,
306 eValidCmd = 0x02,
307 eValidCmdWithReCalibrate = 0x03
308 };
309 typedef uint8_t tTLParameterAccessResult;
310
311
312 //*****************************************************************************
313 //
318 //
319 //*****************************************************************************
320 typedef union
321 {
322 struct
323 {
324 uint8_t ui8Sync;
325 uint8_t ui8Blank;
326 uint8_t ui8Length;
327 uint8_t ui8Command;
328 uint8_t ui8Write;
329 uint8_t ui8SensorID;
330 uint8_t ui8Param0;
331 uint8_t ui8Param1;
332 uint8_t ui8Param2;
333 uint8_t ui8Param3;
334 uint16_t ui16Checksum;
335 };
336 uint8_t ui8Packet[TL_PARAMETER_PACKET_LENGTH];
337 } tParameterPacket;
338 extern tTLParameterAccessResult CAPT_accessTrackPadSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket);
339 //
340 // TL Protocol API Prototypes
341 //
342
343 //*****************************************************************************
344 //
348 //
353 //
357 //
358 //*****************************************************************************
359 extern uint16_t CAPT_getCyclePacket(tSensor **sensorArray,
360 uint8_t ui8SensorID, uint8_t ui8Cycle, uint8_t *pBuffer);
361
362 //*****************************************************************************
363 //
367 //
371 //
375 //
376 //*****************************************************************************
377 extern uint16_t CAPT_getSensorPacket(tSensor **sensorArray,
378 uint8_t ui8SensorID, uint8_t *pBuffer);
379
380 //*****************************************************************************
381 //
384 //
388 //
392 //
393 //*****************************************************************************
394 extern uint16_t CAPT_getGeneralPurposePacket(uint16_t *pData,
395 uint8_t ui8Cnt, uint8_t *pBuffer);
396
397 //*****************************************************************************
398 //
402 //
405 //
409 //
410 //*****************************************************************************
411 extern uint16_t CAPT_getStringPacket(const char *pSrcString, uint8_t *pBuffer);
412
413
414 //*****************************************************************************
415 //
419 //
423 //
427 //
428 extern uint16_t CAPT_getTrackPadPacket(tSensor* pSensor, uint8_t ui8SensorID, uint8_t *pBuffer);
429
430
431 //*****************************************************************************
432 //
436 //
440 //
444 extern uint16_t CAPT_getTrackPadSensorStatusPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer);
445
446
447 //*****************************************************************************
448 //
450 //
453 //
456 //
457 //*****************************************************************************
458 extern uint16_t CAPT_getChecksum(const uint8_t *pBuffer,
459 const uint16_t ui16Length);
460
461 //*****************************************************************************
462 //
464 //
468 //
471 //
472 //*****************************************************************************
473 extern bool CAPT_verifyChecksum(const uint8_t *pBuffer, const uint16_t ui16Length,
474 const uint16_t ui16Checksum);
475
476 //*****************************************************************************
477 //
480 //
483 //
486 //
487 //*****************************************************************************
488 extern uint16_t CAPT_stuffSyncBytes(uint8_t *pBuffer,
489 uint16_t ui16Length);
490
491 //*****************************************************************************
492 //
495 //
499 //
502 //
503 //*****************************************************************************
504 extern bool CAPT_processReceivedData(tByteQueue *pReceiveQueue,
505 tParameterPacket *pPacket, tTLProtocolProcessingVariables *pVariables);
506
507 //*****************************************************************************
508 //
511 //
515 //
520 //
521 //*****************************************************************************
522 extern tTLParameterAccessResult CAPT_accessSensorParameter(
523 tSensor **sensorArray, tParameterPacket *pPacket);
524
525 //*****************************************************************************
526 //
529 //
533 //
538 //
539 //*****************************************************************************
540 extern tTLParameterAccessResult CAPT_accessSpecialSensorParameter(
541 tSensor **sensorArray, tParameterPacket *pPacket);
542
543
544 //
546 //
550 //
555 //
556 extern tTLParameterAccessResult CAPT_accessTrackPadSensorParameter(
557 tSensor **sensorArray, tParameterPacket *pPacket);
558
559 #endif /* CAPT_PROTOCOL_H_ */
560 //*****************************************************************************
563 //*****************************************************************************
CAPT_stuffSyncBytes
uint16_t CAPT_stuffSyncBytes(uint8_t *pBuffer, uint16_t ui16Length)
tParameterPacket::ui8Param2
uint8_t ui8Param2
Definition: CAPT_Protocol.h:332
tTLProtocolProcessingVariables::i8currPacketIndex
int8_t i8currPacketIndex
Definition: CAPT_Protocol.h:290
tTLProtocolProcessingVariables
Definition: CAPT_Protocol.h:288
eInvalidSensor
Definition: CAPT_Protocol.h:304
CAPT_accessSensorParameter
tTLParameterAccessResult CAPT_accessSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
CAPT_getStringPacket
uint16_t CAPT_getStringPacket(const char *pSrcString, uint8_t *pBuffer)
TL_PARAMETER_PACKET_LENGTH
#define TL_PARAMETER_PACKET_LENGTH
Definition: CAPT_Protocol.h:215
CAPT_getCyclePacket
uint16_t CAPT_getCyclePacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t ui8Cycle, uint8_t *pBuffer)
tParameterPacket::ui8Sync
uint8_t ui8Sync
Definition: CAPT_Protocol.h:324
tParameterPacket::ui8Param3
uint8_t ui8Param3
Definition: CAPT_Protocol.h:333
tSensor
Definition: CAPT_Type.h:654
CAPT_getChecksum
uint16_t CAPT_getChecksum(const uint8_t *pBuffer, const uint16_t ui16Length)
This API calculate the checksum of a byte buffer of given length.
tParameterPacket::ui8SensorID
uint8_t ui8SensorID
Definition: CAPT_Protocol.h:329
eValidCmd
Definition: CAPT_Protocol.h:306
tTLParameterAccessResult
uint8_t tTLParameterAccessResult
Definition: CAPT_Protocol.h:309
tParameterPacket::ui8Command
uint8_t ui8Command
Definition: CAPT_Protocol.h:327
tParameterPacket::ui8Param0
uint8_t ui8Param0
Definition: CAPT_Protocol.h:330
tParameterPacket::ui8Blank
uint8_t ui8Blank
Definition: CAPT_Protocol.h:325
tByteQueue
typedef tByteQueue
Definition: CAPT_ByteQueue.h:35
CAPT_accessSpecialSensorParameter
tTLParameterAccessResult CAPT_accessSpecialSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
eInvalidCmd
Definition: CAPT_Protocol.h:305
eValidCmdWithReCalibrate
Definition: CAPT_Protocol.h:307
CAPT_getTrackPadSensorStatusPacket
uint16_t CAPT_getTrackPadSensorStatusPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer)
CAPT_getGeneralPurposePacket
uint16_t CAPT_getGeneralPurposePacket(uint16_t *pData, uint8_t ui8Cnt, uint8_t *pBuffer)
CAPT_getSensorPacket
uint16_t CAPT_getSensorPacket(tSensor **sensorArray, uint8_t ui8SensorID, uint8_t *pBuffer)
tParameterPacket
Definition: CAPT_Protocol.h:320
tParameterPacket::ui16Checksum
uint16_t ui16Checksum
Definition: CAPT_Protocol.h:334
CAPT_processReceivedData
bool CAPT_processReceivedData(tByteQueue *pReceiveQueue, tParameterPacket *pPacket, tTLProtocolProcessingVariables *pVariables)
CAPT_ByteQueue.h
CAPT_getTrackPadPacket
uint16_t CAPT_getTrackPadPacket(tSensor *pSensor, uint8_t ui8SensorID, uint8_t *pBuffer)
tTLProtocolProcessingVariables::bStuffedByteDetected
bool bStuffedByteDetected
Definition: CAPT_Protocol.h:291
tParameterPacket::ui8Write
uint8_t ui8Write
Definition: CAPT_Protocol.h:328
tParameterPacket::ui8Param1
uint8_t ui8Param1
Definition: CAPT_Protocol.h:331
CAPT_Type.h
tParameterPacket::ui8Length
uint8_t ui8Length
Definition: CAPT_Protocol.h:326
CAPT_accessTrackPadSensorParameter
tTLParameterAccessResult CAPT_accessTrackPadSensorParameter(tSensor **sensorArray, tParameterPacket *pPacket)
Access a special CapTIvate™ TL structure variable for a TrackPad sensor.
CAPT_verifyChecksum
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-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale