Browse Source

refactoring

Fischer, Simon | Friedrich Lütze GmbH 3 years ago
parent
commit
a73683fad5
3 changed files with 25 additions and 6 deletions
  1. 1 1
      src/shellmatta_crc.c
  2. 1 1
      src/shellmatta_crc.h
  3. 23 4
      src/shellmatta_transport.h

+ 1 - 1
src/shellmatta_crc.c

@@ -131,4 +131,4 @@ uint32_t crc32Fast(char* data, uint16_t size, uint32_t* lookupTable)
 
     return ~crcTemp;
 }
-#endif
+#endif

+ 1 - 1
src/shellmatta_crc.h

@@ -19,4 +19,4 @@ uint32_t crc32Slow(char* data, uint16_t size);
 uint32_t crc32Fast(char* data, uint16_t size, uint32_t* lookupTable);
 #endif
 
-#endif /* _SHELLMATTA_CRC_H_ */
+#endif /* _SHELLMATTA_CRC_H_ */

+ 23 - 4
src/shellmatta_transport.h

@@ -47,6 +47,25 @@
 /** @brief length of headerfield: crc32 of header + payload without crc32 */
 #define SHELLMATTA_LENGTH_CRC               ((uint8_t)(4))
 
+/* positional defines */
+#define SHELLMATTA_POS_SOH                  ((uint8_t)0)
+#define SHELLMATTA_POS_PROT_VER             ((uint8_t)1)
+#define SHELLMATTA_POS_PACKET_TYPE          ((uint8_t)2)
+#define SHELLMATTA_POS_PAYLOAD_LEN          ((uint8_t)3)
+#define SHELLMATTA_POS_SRC                  ((uint8_t)4)
+#define SHELLMATTA_POS_DST                  ((uint8_t)5)
+#define SHELLMATTA_POS_CNT_H2S              ((uint8_t)6)
+#define SHELLMATTA_POS_CNT_S2H              ((uint8_t)7)
+#define SHELLMATTA_POS_PAYLOAD              ((uint8_t)8)
+
+/* utility defines */
+#define SHELLMATTA_SHIFT_BY_1               ((uint8_t)(1))
+#define SHELLMATTA_SHIFT_BY_2               ((uint8_t)(2))
+#define SHELLMATTA_SHIFT_BY_3               ((uint8_t)(3))
+#define SHELLMATTA_SHIFT_BY_8               ((uint8_t)(8))
+#define SHELLMATTA_SHIFT_BY_16              ((uint8_t)(16))
+#define SHELLMATTA_SHIFT_BY_24              ((uint8_t)(24))
+
 /**
  * @brief definition of shellmatta transport layer states
  */
@@ -103,16 +122,16 @@ extern uint8_t payloadCounter;
 extern uint8_t crcCounter;
 extern uint8_t packetSequenceCounter_h2s;
 extern uint8_t packetSequenceCounter_s2h;
-extern char payloadBuffer[SHELLMATTA_PAYLOAD_MAXLENGTH + 1];
+extern char payloadBuffer[SHELLMATTA_PAYLOAD_MAXLENGTH];
 
 extern shellmatta_transport_layer_t transportLayerInst;
 
-shellmatta_retCode_t shellmatta_reset_transport();
+shellmatta_retCode_t shellmatta_reset_transport(void);
 
-shellmatta_retCode_t shellmatta_init_transport_inst();
+shellmatta_retCode_t shellmatta_init_transport_inst(void);
 
 shellmatta_retCode_t shellmatta_handle_transport_fsm(char *data);
 
 shellmatta_retCode_t shellmatta_write_transport(const char* data, uint32_t length);
 
-#endif /* _SHELLMATTA_TRANSPORT_H_ */
+#endif /* _SHELLMATTA_TRANSPORT_H_ */