Code examples, Header file & crc-16 function, 4 code examples – PNI TCM User Manual
Page 64: 1 header file & crc-16 function

PNI Sensor Corporation
DOC#1014688 r06
TCM User Manual
– July 2013
Page 59
7.4
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.4.1
Header File & CRC-16 Function
/ / t ype decl ar at i ons
t y pedef st r uct
{
UI nt 8 Ac qui s i t i onMode, Fl us hFi l t er ;
Fl oat 32 Ac qui r eDel ay , Sampl eDel ay ;
} __at t r i but e__ ( ( pac ked) ) Ac qPar ams;
t y pedef st r uct
{
Fl oat 32 MagCal Sc or e;
Fl oat 32 r eser v e1;
Fl oat 32 Ac cel Cal Sc or e;
Fl oat 32 Di st Er r or ;
Fl oat 32 Ti l t Er r or ;
Fl oat 32 Ti l t Range;
} __at t r i but e__ ( ( pac ked) ) MagCal Sc or e;
enum
{
/ / Fr ame I Ds ( Commands)
k Get ModI nf o = 1,
/ / 1
k Get ModI nf oRes p,
/ / 2
k Set Dat aComponent s ,
/ / 3
k Get Dat a,
/ / 4
k Get Dat aResp,
/ / 5
k Set Conf i g,
/ / 6
k Get Conf i g,
/ / 7
k Get Conf i gResp,
/ / 8
k Sav e,
/ / 9
k St ar t Cal ,
/ / 10
k St opCal ,
/ / 11
k Set Fi l t er s ,
/ / 12
k Get Fi l t er s ,
/ / 13
k Get Fi l t er s Res p,
/ / 14
k Power Down,
/ / 15
k Sav eDone,
/ / 16
k User Cal SampCount ,
/ / 17
k Cal Sc or e,
/ / 18
k Set Conf i gDone,
/ / 19
k Set Fi l t er s Done,
/ / 20
k St ar t Cont i nuous Mode, / / 21
k St opCont i nuous Mode,
/ / 22
k Power Up,
/ / 23