Radio Structures in OOP

Dependencies:   mbed mbed-rtos

Committer:
jjones646
Date:
Sun Dec 28 06:05:17 2014 +0000
Revision:
2:7d523bdd2f50
Child:
3:dc7e9c6bc26c
outlining communication implementations

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jjones646 2:7d523bdd2f50 1 #ifndef COMMUNICATION_MODULE_H
jjones646 2:7d523bdd2f50 2 #define COMMUNICATION_MODULE_H
jjones646 2:7d523bdd2f50 3
jjones646 2:7d523bdd2f50 4 #include "mbed.h"
jjones646 2:7d523bdd2f50 5 #include "cmsis_os.h"
jjones646 2:7d523bdd2f50 6 #include "RTP.h"
jjones646 2:7d523bdd2f50 7 #include "CommLink.h"
jjones646 2:7d523bdd2f50 8 #include "ThreadHelper.h"
jjones646 2:7d523bdd2f50 9
jjones646 2:7d523bdd2f50 10 #define COMM_MODULE_TX_QUEUE_SIZE 20
jjones646 2:7d523bdd2f50 11 #define COMM_MODULE_RX_QUEUE_SIZE 4
jjones646 2:7d523bdd2f50 12 #define COMM_MODULE_NBR_PORTS 15
jjones646 2:7d523bdd2f50 13
jjones646 2:7d523bdd2f50 14 // Base class for a communication module
jjones646 2:7d523bdd2f50 15 class CommModule
jjones646 2:7d523bdd2f50 16 {
jjones646 2:7d523bdd2f50 17 public:
jjones646 2:7d523bdd2f50 18 // Default Constructor
jjones646 2:7d523bdd2f50 19 CommModule();
jjones646 2:7d523bdd2f50 20
jjones646 2:7d523bdd2f50 21 // Deconstructor
jjones646 2:7d523bdd2f50 22 virtual ~CommModule() {};
jjones646 2:7d523bdd2f50 23
jjones646 2:7d523bdd2f50 24 // Class constants - set in CommModule.cpp
jjones646 2:7d523bdd2f50 25 static const int NBR_PORTS;
jjones646 2:7d523bdd2f50 26 static const int TX_QUEUE_SIZE;
jjones646 2:7d523bdd2f50 27 static const int RX_QUEUE_SIZE;
jjones646 2:7d523bdd2f50 28
jjones646 2:7d523bdd2f50 29 // Let the CommModule class know of a hardware link that is can use for implementing communication
jjones646 2:7d523bdd2f50 30 void setLink(CommLink*);
jjones646 2:7d523bdd2f50 31
jjones646 2:7d523bdd2f50 32 // Open a socket connection for communicating.
jjones646 2:7d523bdd2f50 33 void openSocket(uint8_t, void(*task)(void const *arg));
jjones646 2:7d523bdd2f50 34
jjones646 2:7d523bdd2f50 35 // Send a RTP packet. The details of exactly how the packet will be sent are determined from the RTP packet's port and subclass values
jjones646 2:7d523bdd2f50 36 void send(RTP_t&);
jjones646 2:7d523bdd2f50 37
jjones646 2:7d523bdd2f50 38 protected:
jjones646 2:7d523bdd2f50 39 // Memory management using memory structures from the CMSIS-RTOS API
jjones646 2:7d523bdd2f50 40 osMailQId _txQueue;
jjones646 2:7d523bdd2f50 41 osMailQId _rxQueue;
jjones646 2:7d523bdd2f50 42
jjones646 2:7d523bdd2f50 43 // Used for storing the open socket's callback functions
jjones646 2:7d523bdd2f50 44 // volatile CUSTOM callbacks[NBR_PORTS];
jjones646 2:7d523bdd2f50 45
jjones646 2:7d523bdd2f50 46 private:
jjones646 2:7d523bdd2f50 47 // Used to help define the class's threads in the constructor
jjones646 2:7d523bdd2f50 48 friend void define_thread(osThreadDef_t&, void(*task)(void const *arg), osPriority, uint32_t, unsigned char*);
jjones646 2:7d523bdd2f50 49
jjones646 2:7d523bdd2f50 50 // The working threads for handeling rx and tx data queues
jjones646 2:7d523bdd2f50 51 static void txThread(void const*);
jjones646 2:7d523bdd2f50 52 static void rxThread(void const*);
jjones646 2:7d523bdd2f50 53
jjones646 2:7d523bdd2f50 54 // NOP function for keeping a oommunication link active
jjones646 2:7d523bdd2f50 55 void nopFunc(void);
jjones646 2:7d523bdd2f50 56
jjones646 2:7d523bdd2f50 57 // Pointer for maintaining the active communication link
jjones646 2:7d523bdd2f50 58 CommLink* _link;
jjones646 2:7d523bdd2f50 59
jjones646 2:7d523bdd2f50 60 // Thread definitions and IDs
jjones646 2:7d523bdd2f50 61 osThreadDef_t _txDef;
jjones646 2:7d523bdd2f50 62 osThreadDef_t _rxDef;
jjones646 2:7d523bdd2f50 63 osThreadId _txID;
jjones646 2:7d523bdd2f50 64 osThreadId _rxID;
jjones646 2:7d523bdd2f50 65
jjones646 2:7d523bdd2f50 66 // Ignore for now
jjones646 2:7d523bdd2f50 67 // bool _dynamic_stack;
jjones646 2:7d523bdd2f50 68
jjones646 2:7d523bdd2f50 69 };
jjones646 2:7d523bdd2f50 70
jjones646 2:7d523bdd2f50 71 #endif // COMMUNICATION_MODULE_H