
PNI Sensor Corporation
DOC#1014688 r09.2
TCM User Manual
Page 61
7.5
Code Examples
The following example files, CommProtocol.h, CommProtocol.cp, TCM.h and TCM.cp would
be used together for proper communication with a TCM module.
Note:
The following files are not included in the sample codes and need to be created by the user:
Processes.h & TickGenerator.h. The comments in the code explain what is needed to be sent or
received from these functions
so the user can write this section for the user’s platform. For example,
with the TickGenerator.h, the user needs to write a routing that generates 10 msec ticks.
7.5.1
Header File & CRC-16 Function
// type declarations
typedef struct
{
UInt8 AcquisitionMode, FlushFilter;
Float32 AcquireDelay, SampleDelay;
} __attribute__ ((packed)) AcqParams;
typedef struct
{
Float32 MagCalScore;
Float32 reserve1;
Float32 AccelCalScore;
Float32 DistError;
Float32 TiltError;
Float32 TiltRange;
} __attribute__ ((packed)) MagCalScore;
enum
{
// Frame IDs (Commands)
kGetModInfo = 1,
// 1
kGetModInfoResp,
// 2
kSetDataComponents,
// 3
kGetData,
// 4
kGetDataResp,
// 5
kSetConfig,
// 6
kGetConfig,
// 7
kGetConfigResp,
// 8
kSave,
// 9
kStartCal,
// 10
kStopCal,
// 11
kSetFilters,
// 12
kGetFilters,
// 13
kGetFiltersResp,
// 14
kPowerDown,
// 15
kSaveDone,
// 16
kUserCalSampCount,
// 17
kCalScore,
// 18