versadac  1
versadac - Scalable Recorder Firmware
do_s_ssm.h
1 /*******************************************************************************
2 FILE : do_s_ssm.h
3 VERSION : $Id: do_s_ssm.h 32392 2010-07-07 14:45:44Z richardhi $
4 AUTHOR : David Cozens
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : Scheduled message class for driving any of the 2500 slow digital
7  output modules. DO4 and RELAY 4
8 *******************************************************************************/
9 #ifndef __DO_S_SSM_H
10 #define __DO_S_SSM_H
11 #include "spismsg.h"
12 
13 /*
14  When defined DO_CORRUPT enables corruption of messages to the modules of specific types / timing
15  The define must also be set in the do_s_ssm.h file
16 
17 The debug is triggered by setting g_corrupt in the Tornado shell to the following values -
18 1 Inverts the inverted data bits in the next fast update message.
19 2 Inverts the non-inverted data bits in the next fast update message.
20 3+10c Inverts all the data bits of channel c but not the message type bits and truncates message after that channels data for the next message only.
21 4+10c As above but inverts / truncates the next TPO min on time or set fast mode message only.
22 5+10c As above but forces a watchdog after truncation.
23 6+10c Inverts all the data bits of channel c for one message cycle. Checksum is not corrected to match.
24 7+10c As above but inverts the next TPO min on time or set fast mode message only.
25 8+10c As 3+10c but forces a watchdog after truncation.
26 */
27 //#define DO_CORRUPT
28 
29 #define EIO_DO_SLOW_MODULE_STATUS_MASK 0xF0
30 #define EIO_DO_SLOW_MODULE_STATUS_GOOD 0x70
31 
32 #define EIO_DO_SLOW_MODULE_CHECKSUM_SEED 0x55
33 
34 #define EIO_DO_SLOW_MODULE_NUMBER_OF_CHANNELS 4
35 
36 class DigitalOutputSlowSpiScheduledMessage:public SpiScheduledMessage
37 {
38  public:
39  DigitalOutputSlowSpiScheduledMessage(unsigned char device);
41 
42  void commandSetupComplete();
43  void setChannelSafe(int z_channel);
44  void setTPOPercentOutput(int z_channel, float z_demand);
45  void setTPOMinimumOnTime(int z_channel, unsigned long z_minimumOnTimeuS);
46  void setOnOffState(int z_channel, bool on);
47  void setVPOutput(int z_channel, bool onFirst55mS, bool onSecond55mS);
48  void setFastMode();
49 
50  bool wasCommandOk(){return ( ((*getRxPtr()&EIO_DO_SLOW_MODULE_STATUS_MASK) == EIO_DO_SLOW_MODULE_STATUS_GOOD) &&
51  (*(getRxPtr()+2) == 0) &&
52  (*(getRxPtr()+4) == 0) &&
53  (*(getRxPtr()+6) == 0) &&
54  (*(getRxPtr()+8) == 0) );};
55 
56  private:
57  static unsigned char checksum(unsigned char *p){return p[0]^p[1]^p[2]^p[3]^p[4]^p[5]^p[6]^p[7]^EIO_DO_SLOW_MODULE_CHECKSUM_SEED;};
58  static unsigned short moduleToDevice(unsigned char module);
59 
60  unsigned short m_channelCommand[EIO_DO_SLOW_MODULE_NUMBER_OF_CHANNELS];
61 };
62 #endif /*__DO_S_SSM_H */
63 
Definition: do_s_ssm.h:36