This code is to collect data from the ADCs in burst mode, decimate the data, encapsulate it in a simple UDP-like packet and then transmit it over the serial port.

Dependencies:   mbed

Revision:
0:03e8a03052c9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/comms.h	Fri Aug 27 15:20:30 2010 +0000
@@ -0,0 +1,53 @@
+/**
+    * @file comms.h
+    * Header file for comms.cpp
+    * A simplistic communication profile for streaming data sampled
+    * from sensors over UART->radio->UART->dislpay
+    *
+    * @brief Header file for comms.cpp
+    *
+    * @author James A C Patterson
+ */
+#ifndef COMMS_H
+#define COMMS_H
+
+#define MAX_PACKET_SIZE 64
+
+#define PORT_BASE (1<<13)
+#define PROTOCOL 17
+
+typedef struct header {
+    uint16_t src_port;
+    uint16_t dst_port;
+    uint16_t length;
+    uint16_t checksum;
+} header_t;
+
+
+typedef uint8_t packet_t[MAX_PACKET_SIZE];
+
+typedef struct pseudo_header {
+    uint32_t src_addr;
+    uint32_t dst_addr;
+    uint16_t protocol;
+    uint16_t length;
+    uint16_t checksum;
+} pseudo_header_t;
+
+/**
+ * A class to implement a basic transport layer that is based very
+ * loosely on UDP/UDP-lite
+ */
+class Transport {
+public:
+    Transport (uint32_t, uint32_t, uint32_t);
+    void get_packet (uint8_t**,uint16_t*);
+    void load_data (uint16_t*,uint16_t);
+    void set_dst_port (uint16_t);
+private:
+    pseudo_header_t pseudo_header_;
+    header_t header_;
+    packet_t packet_;
+};
+
+#endif
\ No newline at end of file