Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
1:a5258871b33d
Method ramp scrolling improved, and more bitmaps moved to QSPI memory

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 1:a5258871b33d 1 #ifndef ETHERNETHANDLER_H
jmitc91516 1:a5258871b33d 2 #define ETHERNETHANDLER_H
jmitc91516 1:a5258871b33d 3
jmitc91516 1:a5258871b33d 4 #include "mbed.h"
jmitc91516 1:a5258871b33d 5 #include "DMBoard.h"
jmitc91516 1:a5258871b33d 6 #include "EthernetInterface.h"
jmitc91516 1:a5258871b33d 7
jmitc91516 1:a5258871b33d 8 #include "ThreadSignalEnums.h"
jmitc91516 1:a5258871b33d 9
jmitc91516 1:a5258871b33d 10 #include "USBHostGC.h"
jmitc91516 1:a5258871b33d 11
jmitc91516 1:a5258871b33d 12 /*
jmitc91516 1:a5258871b33d 13 This class handles Ethernet traffic between the LPC4088 and the PC.
jmitc91516 1:a5258871b33d 14
jmitc91516 1:a5258871b33d 15 The idea is that it 'listens' for an Ethernet command on its own thread, then either:
jmitc91516 1:a5258871b33d 16
jmitc91516 1:a5258871b33d 17 1 - signals the main thread "I have a command ready for you to send to the GC" (because we do not want to have two threads
jmitc91516 1:a5258871b33d 18 sending commands to the GC over the USB link at the same time), then waits for the main thread to signal
jmitc91516 1:a5258871b33d 19 "I have the response ready for you to send back", then sends the response back over the Ethernet link.
jmitc91516 1:a5258871b33d 20
jmitc91516 1:a5258871b33d 21 or:
jmitc91516 1:a5258871b33d 22
jmitc91516 1:a5258871b33d 23 2 - does its own comms to the GC, using the same USBHostGC instance as the main thread uses, so that
jmitc91516 1:a5258871b33d 24 we do not send a command to the GC at the same time as the main (or any other) thread is doing the same.
jmitc91516 1:a5258871b33d 25
jmitc91516 1:a5258871b33d 26 #define the symbol 'DO_USB_IN_THIS_THREAD' in the cpp file to select option 2 - comment it out to select option 1.
jmitc91516 1:a5258871b33d 27
jmitc91516 1:a5258871b33d 28 This way, the UI, handled by the main thread, should not lock up while we deal with Ethernet transactions
jmitc91516 1:a5258871b33d 29 (this is the idea, anyway).
jmitc91516 1:a5258871b33d 30
jmitc91516 1:a5258871b33d 31 Requires the ID of the main thread.
jmitc91516 1:a5258871b33d 32
jmitc91516 1:a5258871b33d 33 If it is to do its own USB comms to the GC, requires the appropriate USBHostGC pointers.
jmitc91516 1:a5258871b33d 34
jmitc91516 1:a5258871b33d 35 Note also that all this class' members are static.
jmitc91516 1:a5258871b33d 36 */
jmitc91516 1:a5258871b33d 37
jmitc91516 1:a5258871b33d 38 class EthernetHandler {
jmitc91516 1:a5258871b33d 39 public:
jmitc91516 1:a5258871b33d 40 static void HandlerFunction(void const *argument);
jmitc91516 1:a5258871b33d 41
jmitc91516 1:a5258871b33d 42 static void SetMainThreadId(osThreadId threadId);
jmitc91516 1:a5258871b33d 43
jmitc91516 1:a5258871b33d 44 static void SetEthernetServer(TCPSocketServer* server);
jmitc91516 1:a5258871b33d 45
jmitc91516 1:a5258871b33d 46 static void SetUsbGC(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC);
jmitc91516 1:a5258871b33d 47
jmitc91516 1:a5258871b33d 48 static bool GCCommandReceived(void);
jmitc91516 1:a5258871b33d 49
jmitc91516 1:a5258871b33d 50 static void GetGCCommand(char *commandBuffer, int* responseThreadSignalCode);
jmitc91516 1:a5258871b33d 51
jmitc91516 1:a5258871b33d 52 static void SetGCResponse(char *response);
jmitc91516 1:a5258871b33d 53
jmitc91516 1:a5258871b33d 54 private:
jmitc91516 1:a5258871b33d 55 static osThreadId mainThreadId;
jmitc91516 1:a5258871b33d 56 static bool mainThreadIdSet;
jmitc91516 1:a5258871b33d 57
jmitc91516 1:a5258871b33d 58 static TCPSocketServer* ethernetServer;
jmitc91516 1:a5258871b33d 59
jmitc91516 1:a5258871b33d 60 static USBDeviceConnected* usbDevice;
jmitc91516 1:a5258871b33d 61 static USBHostGC* usbHostGC;
jmitc91516 1:a5258871b33d 62
jmitc91516 1:a5258871b33d 63 static bool receivedGCCommand;
jmitc91516 1:a5258871b33d 64
jmitc91516 1:a5258871b33d 65 static int responseReadyThreadSignalCode;
jmitc91516 1:a5258871b33d 66 static const int maxResponseReadyThreadSignalCode;
jmitc91516 1:a5258871b33d 67
jmitc91516 1:a5258871b33d 68 static void SetupNextResponseReadyThreadSignalCode(void);
jmitc91516 1:a5258871b33d 69
jmitc91516 1:a5258871b33d 70 static bool HandleEthernetMessage(TCPSocketConnection* client);
jmitc91516 1:a5258871b33d 71
jmitc91516 1:a5258871b33d 72 static void SetGCDeviceReport(char *cmd, char *response);
jmitc91516 1:a5258871b33d 73
jmitc91516 1:a5258871b33d 74 static char gcCommand[20];
jmitc91516 1:a5258871b33d 75 static char gcResponse[20];
jmitc91516 1:a5258871b33d 76
jmitc91516 1:a5258871b33d 77 static Timer timer;
jmitc91516 1:a5258871b33d 78 };
jmitc91516 1:a5258871b33d 79
jmitc91516 1:a5258871b33d 80 #endif // ETHERNETHANDLER_H