This library allows to parse and work with data sent by the Paradigma pelletti oven.

Committer:
leihen
Date:
Sat Jun 22 10:59:05 2013 +0000
Revision:
0:4873b21e0bca
Child:
1:9c48326ad8c9
Fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leihen 0:4873b21e0bca 1 #ifndef __PARADIGMABASE_H__
leihen 0:4873b21e0bca 2 #define __PARADIGMABASE_H__
leihen 0:4873b21e0bca 3
leihen 0:4873b21e0bca 4
leihen 0:4873b21e0bca 5 typedef unsigned char byte;
leihen 0:4873b21e0bca 6 typedef short word;
leihen 0:4873b21e0bca 7 typedef unsigned short uword;
leihen 0:4873b21e0bca 8 typedef unsigned long ulong;
leihen 0:4873b21e0bca 9
leihen 0:4873b21e0bca 10
leihen 0:4873b21e0bca 11 __packed class ParadigmaDword
leihen 0:4873b21e0bca 12 {
leihen 0:4873b21e0bca 13 protected:
leihen 0:4873b21e0bca 14 unsigned long m_data;
leihen 0:4873b21e0bca 15
leihen 0:4873b21e0bca 16 public:
leihen 0:4873b21e0bca 17 ParadigmaDword() : m_data(0) {}
leihen 0:4873b21e0bca 18
leihen 0:4873b21e0bca 19 /** On the MBED we need to swap the high and lowbytes after reading from stream.
leihen 0:4873b21e0bca 20 * this function will be called from reading routine.
leihen 0:4873b21e0bca 21 */
leihen 0:4873b21e0bca 22 void adjustEndiness() { m_data = ((m_data>>24)&0xFF) | ((m_data>>8)&0x0000FF00) | ((m_data<<8)&0x00FF0000) | ((m_data<<24)&0xFF000000); }
leihen 0:4873b21e0bca 23
leihen 0:4873b21e0bca 24 ParadigmaDword& operator=(ulong d) { m_data = d; return *this; }
leihen 0:4873b21e0bca 25 ParadigmaDword& operator=(ParadigmaDword d) { m_data = d.m_data; return *this; }
leihen 0:4873b21e0bca 26
leihen 0:4873b21e0bca 27 operator ulong() const { return m_data; }
leihen 0:4873b21e0bca 28 };
leihen 0:4873b21e0bca 29
leihen 0:4873b21e0bca 30 __packed class ParadigmaWord
leihen 0:4873b21e0bca 31 {
leihen 0:4873b21e0bca 32 protected:
leihen 0:4873b21e0bca 33 unsigned short m_data;
leihen 0:4873b21e0bca 34
leihen 0:4873b21e0bca 35 public:
leihen 0:4873b21e0bca 36 ParadigmaWord() : m_data(0) {}
leihen 0:4873b21e0bca 37
leihen 0:4873b21e0bca 38 /** On the MBED we need to swap the high and lowbytes after reading from stream.
leihen 0:4873b21e0bca 39 * this function will be called from reading routine.
leihen 0:4873b21e0bca 40 */
leihen 0:4873b21e0bca 41 void adjustEndiness() { m_data = ((m_data&0xFF)<<8) | ((m_data>>8)&0xFF); }
leihen 0:4873b21e0bca 42
leihen 0:4873b21e0bca 43 ParadigmaWord& operator=(word d) { m_data = d; return *this; }
leihen 0:4873b21e0bca 44 ParadigmaWord& operator=(ParadigmaWord d) { m_data = d.m_data; return *this; }
leihen 0:4873b21e0bca 45
leihen 0:4873b21e0bca 46 operator word() const { return m_data; }
leihen 0:4873b21e0bca 47 };
leihen 0:4873b21e0bca 48 #endif // __PARADIGMABASE_H__