functions for the communication between SOLID slow control modules and Cprograms

Dependents:   sscm SPItest sscm

Committer:
wbeaumont
Date:
Thu Oct 23 17:42:11 2014 +0000
Revision:
11:1fb5d6810b29
Parent:
10:0675c2e3d330
Child:
12:cf007e9619e1
only one float  data field in structure

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 0:2afae79ea9ca 1 #ifndef SSCM_COMM_H
wbeaumont 0:2afae79ea9ca 2 #define SSCM_COMM_H
wbeaumont 1:288db0531b1f 3 /*
wbeaumont 5:357fa8928d63 4 * v 1.01 inital published , tested
wbeaumont 5:357fa8928d63 5 * v 1.20 added devnr, added range checking
wbeaumont 5:357fa8928d63 6 * v 1.30 added \0 to cmd field
wbeaumont 5:357fa8928d63 7 * v 1.40 added status in cmd , added SSCM as device
wbeaumont 5:357fa8928d63 8 * v 2.00 corrected the type for data in data out
wbeaumont 6:d9a96735d0fb 9 * v 3.00 added x, y , removed ch (replaced by x
wbeaumont 7:6d3c421026df 10 * v 3.01 corrected name SSCCM to SSCM
wbeaumont 7:6d3c421026df 11 * v 3.20 added version functions
wbeaumont 7:6d3c421026df 12 * v 3.30 version functions moved to getVersion class
wbeaumont 8:ff6ba217a089 13 * v 3.40 added fdatain and fdataout for float communication
wbeaumont 11:1fb5d6810b29 14 * v 3.41 removed fdataout , renamed fdatain to fdata
wbeaumont 11:1fb5d6810b29 15
wbeaumont 1:288db0531b1f 16 */
wbeaumont 0:2afae79ea9ca 17
wbeaumont 11:1fb5d6810b29 18 #define SSCM_COMM_LIB_HDR_VERSION "3.41"
wbeaumont 7:6d3c421026df 19
wbeaumont 7:6d3c421026df 20 #include "getVersion.h"
wbeaumont 0:2afae79ea9ca 21
wbeaumont 0:2afae79ea9ca 22
wbeaumont 7:6d3c421026df 23 namespace sscm_comm {
wbeaumont 0:2afae79ea9ca 24 //public :
wbeaumont 0:2afae79ea9ca 25
wbeaumont 7:6d3c421026df 26 enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCM=4};
wbeaumont 0:2afae79ea9ca 27 typedef unsigned char u8;
wbeaumont 5:357fa8928d63 28 typedef unsigned short u16;
wbeaumont 0:2afae79ea9ca 29 typedef struct {
wbeaumont 0:2afae79ea9ca 30 u8 module; // 1 char 0 --F
wbeaumont 0:2afae79ea9ca 31 u8 con; // 1 char 0--2
wbeaumont 0:2afae79ea9ca 32 ssc_dev dev; // 2 char 01--03
wbeaumont 2:1f9887337a1b 33 u8 devnr;
wbeaumont 6:d9a96735d0fb 34 char cmd[5]; // 4 char + \0
wbeaumont 6:d9a96735d0fb 35 u8 ch; // identify the channel or register address for the firmware
wbeaumont 6:d9a96735d0fb 36 u8 x; // char 00 -- 32 x coordinate MPPC not used for the firmware ,so not coded in the string
wbeaumont 6:d9a96735d0fb 37 u8 y; // y coordinate MPPC not used for the communication to the SSCM y coordinate MPPC
wbeaumont 5:357fa8928d63 38 u16 datain; // 2 char 0000 -- FFFF
wbeaumont 5:357fa8928d63 39 u16 dataout;// 2 char 00 -- FF
wbeaumont 11:1fb5d6810b29 40 float fdata ;
wbeaumont 4:66d1a4200f67 41 u8 status;
wbeaumont 0:2afae79ea9ca 42 } ssc_cmd;
wbeaumont 0:2afae79ea9ca 43
wbeaumont 0:2afae79ea9ca 44 const char CMDSTART= '$';
wbeaumont 0:2afae79ea9ca 45 const char CMDSTOP= '#';
wbeaumont 0:2afae79ea9ca 46 const char SEP= ';';
wbeaumont 0:2afae79ea9ca 47
wbeaumont 0:2afae79ea9ca 48 // decode the string sent to the uP to the original cmd structure , for the moment the input string is cleared
wbeaumont 0:2afae79ea9ca 49 // param input : input string at least char [30]
wbeaumont 0:2afae79ea9ca 50 // param ssc_cmd the cmd structure to be filled
wbeaumont 0:2afae79ea9ca 51 int decode_cmd(char* input, ssc_cmd * sc);
wbeaumont 0:2afae79ea9ca 52
wbeaumont 0:2afae79ea9ca 53
wbeaumont 0:2afae79ea9ca 54 // param output the string to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 55 // param sc the cmd to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 56 void encode_cmd ( char *output , ssc_cmd *sc);
wbeaumont 0:2afae79ea9ca 57
wbeaumont 0:2afae79ea9ca 58 // to get info of the module nr , connector serial number for a given plane
wbeaumont 0:2afae79ea9ca 59 // param plane plane nr for which the cmd coordinates has to be known
wbeaumont 0:2afae79ea9ca 60 // param modulenr the module nr ( first nr in the cmd structure
wbeaumont 0:2afae79ea9ca 61 // param connr connector number ( 1 or 2)
wbeaumont 0:2afae79ea9ca 62 // param serailnr the serial nr of the board ( can be used for verification) .
wbeaumont 0:2afae79ea9ca 63
wbeaumont 0:2afae79ea9ca 64 void getmodulecordinate(u8 plane, u8& modulenr, u8& connr ,u8& serialnr );
wbeaumont 6:d9a96735d0fb 65 void get_mppc_dac_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr ,u8&dacch, u8& serialnr );
wbeaumont 6:d9a96735d0fb 66 void get_mppc_adc_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr , u8& adcdevnr, u8& adcchnr , u8& serialnr );
wbeaumont 2:1f9887337a1b 67 // check if ranges are correct
wbeaumont 2:1f9887337a1b 68 // v 1.20 only check ADC devnr range broadcast not supported
wbeaumont 2:1f9887337a1b 69 int check_ranges( ssc_cmd* sc );
wbeaumont 7:6d3c421026df 70
wbeaumont 7:6d3c421026df 71 // returns the version and sub version nr.
wbeaumont 7:6d3c421026df 72 // param hexversion : 16 bits MSB byt contains the version nr, LSB byte contains the subversion nr (hex)
wbeaumont 7:6d3c421026df 73 // param version : will be set to the version
wbeaumont 7:6d3c421026df 74 // param subversion : will be set to the subversion
wbeaumont 7:6d3c421026df 75 void get_dec_version( u16 hexversion , u8& version, u8& subversion);
wbeaumont 7:6d3c421026df 76
wbeaumont 7:6d3c421026df 77 // reuse vesion class
wbeaumont 2:1f9887337a1b 78
wbeaumont 7:6d3c421026df 79 class getsscmVersion:
wbeaumont 7:6d3c421026df 80 public getVersion
wbeaumont 0:2afae79ea9ca 81
wbeaumont 7:6d3c421026df 82 {
wbeaumont 7:6d3c421026df 83 public: getsscmVersion() ;
wbeaumont 7:6d3c421026df 84 };
wbeaumont 0:2afae79ea9ca 85
wbeaumont 10:0675c2e3d330 86
wbeaumont 10:0675c2e3d330 87 void float2_2u16( float in, u16& msb, u16& lsb);
wbeaumont 10:0675c2e3d330 88
wbeaumont 10:0675c2e3d330 89 float u162float( u16 msb, u16 lsb);
wbeaumont 10:0675c2e3d330 90
wbeaumont 10:0675c2e3d330 91
wbeaumont 7:6d3c421026df 92 };
wbeaumont 0:2afae79ea9ca 93 #endif