Jonathan Jones
/
Radios
Radio Structures in OOP
modules/CommModule/CommModule.h
- Committer:
- jjones646
- Date:
- 2014-12-28
- Revision:
- 2:7d523bdd2f50
- Child:
- 3:dc7e9c6bc26c
File content as of revision 2:7d523bdd2f50:
#ifndef COMMUNICATION_MODULE_H #define COMMUNICATION_MODULE_H #include "mbed.h" #include "cmsis_os.h" #include "RTP.h" #include "CommLink.h" #include "ThreadHelper.h" #define COMM_MODULE_TX_QUEUE_SIZE 20 #define COMM_MODULE_RX_QUEUE_SIZE 4 #define COMM_MODULE_NBR_PORTS 15 // Base class for a communication module class CommModule { public: // Default Constructor CommModule(); // Deconstructor virtual ~CommModule() {}; // Class constants - set in CommModule.cpp static const int NBR_PORTS; static const int TX_QUEUE_SIZE; static const int RX_QUEUE_SIZE; // Let the CommModule class know of a hardware link that is can use for implementing communication void setLink(CommLink*); // Open a socket connection for communicating. void openSocket(uint8_t, void(*task)(void const *arg)); // 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 void send(RTP_t&); protected: // Memory management using memory structures from the CMSIS-RTOS API osMailQId _txQueue; osMailQId _rxQueue; // Used for storing the open socket's callback functions // volatile CUSTOM callbacks[NBR_PORTS]; private: // Used to help define the class's threads in the constructor friend void define_thread(osThreadDef_t&, void(*task)(void const *arg), osPriority, uint32_t, unsigned char*); // The working threads for handeling rx and tx data queues static void txThread(void const*); static void rxThread(void const*); // NOP function for keeping a oommunication link active void nopFunc(void); // Pointer for maintaining the active communication link CommLink* _link; // Thread definitions and IDs osThreadDef_t _txDef; osThreadDef_t _rxDef; osThreadId _txID; osThreadId _rxID; // Ignore for now // bool _dynamic_stack; }; #endif // COMMUNICATION_MODULE_H