![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
JGtoJR
Dependencies: MODSERIAL Watchdog
PC/PC.h@0:1c1c9f47b8ad, 2017-06-15 (annotated)
- Committer:
- JavierGC
- Date:
- Thu Jun 15 12:01:36 2017 +0000
- Revision:
- 0:1c1c9f47b8ad
JG_to_JR
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JavierGC | 0:1c1c9f47b8ad | 1 | #ifndef _PC_H_ |
JavierGC | 0:1c1c9f47b8ad | 2 | #define _PC_H_ |
JavierGC | 0:1c1c9f47b8ad | 3 | |
JavierGC | 0:1c1c9f47b8ad | 4 | #include "mbed.h" |
JavierGC | 0:1c1c9f47b8ad | 5 | #include "MODSERIAL.h" |
JavierGC | 0:1c1c9f47b8ad | 6 | #include "GV.h" |
JavierGC | 0:1c1c9f47b8ad | 7 | |
JavierGC | 0:1c1c9f47b8ad | 8 | #define PCTxBufferSize 250 |
JavierGC | 0:1c1c9f47b8ad | 9 | #define PCRxBufferSize 250 |
JavierGC | 0:1c1c9f47b8ad | 10 | #define PCMaxMailElements 10 |
JavierGC | 0:1c1c9f47b8ad | 11 | #define PCBaudRateDef 115200 |
JavierGC | 0:1c1c9f47b8ad | 12 | #define PCWaitByte_us (10000000/PCBaudRateDef) |
JavierGC | 0:1c1c9f47b8ad | 13 | #define PCWaitMess_us PCWaitByte_us*10 |
JavierGC | 0:1c1c9f47b8ad | 14 | |
JavierGC | 0:1c1c9f47b8ad | 15 | #define Rate 1 |
JavierGC | 0:1c1c9f47b8ad | 16 | |
JavierGC | 0:1c1c9f47b8ad | 17 | extern "C" void mbed_reset(); |
JavierGC | 0:1c1c9f47b8ad | 18 | |
JavierGC | 0:1c1c9f47b8ad | 19 | class PC : public MODSERIAL |
JavierGC | 0:1c1c9f47b8ad | 20 | { |
JavierGC | 0:1c1c9f47b8ad | 21 | |
JavierGC | 0:1c1c9f47b8ad | 22 | public: |
JavierGC | 0:1c1c9f47b8ad | 23 | |
JavierGC | 0:1c1c9f47b8ad | 24 | |
JavierGC | 0:1c1c9f47b8ad | 25 | PC(GV * _pac, PinName _led, PinName tx, PinName rx); |
JavierGC | 0:1c1c9f47b8ad | 26 | PC(GV * _pac, PinName _led, PinName tx, PinName rx, void (*iEventHandler)(int, char *)); |
JavierGC | 0:1c1c9f47b8ad | 27 | ~PC(); |
JavierGC | 0:1c1c9f47b8ad | 28 | |
JavierGC | 0:1c1c9f47b8ad | 29 | void LoadMail(char comm, char *mess); //para cargar mensajes de trabajo al proceso paralelo ComPC_thread_proc |
JavierGC | 0:1c1c9f47b8ad | 30 | |
JavierGC | 0:1c1c9f47b8ad | 31 | void start(void); |
JavierGC | 0:1c1c9f47b8ad | 32 | |
JavierGC | 0:1c1c9f47b8ad | 33 | bool LOG; |
JavierGC | 0:1c1c9f47b8ad | 34 | bool SendStatus; |
JavierGC | 0:1c1c9f47b8ad | 35 | int mode; |
JavierGC | 0:1c1c9f47b8ad | 36 | |
JavierGC | 0:1c1c9f47b8ad | 37 | enum MyEventsLCD {eLOG}; |
JavierGC | 0:1c1c9f47b8ad | 38 | |
JavierGC | 0:1c1c9f47b8ad | 39 | private: |
JavierGC | 0:1c1c9f47b8ad | 40 | |
JavierGC | 0:1c1c9f47b8ad | 41 | GV *pgv; |
JavierGC | 0:1c1c9f47b8ad | 42 | |
JavierGC | 0:1c1c9f47b8ad | 43 | void (*iEvent)(int, char *); |
JavierGC | 0:1c1c9f47b8ad | 44 | |
JavierGC | 0:1c1c9f47b8ad | 45 | DigitalOut *led; |
JavierGC | 0:1c1c9f47b8ad | 46 | char messageBufferIncoming[PCRxBufferSize]; |
JavierGC | 0:1c1c9f47b8ad | 47 | char messageBufferOutgoing[PCTxBufferSize]; |
JavierGC | 0:1c1c9f47b8ad | 48 | |
JavierGC | 0:1c1c9f47b8ad | 49 | Thread thread; |
JavierGC | 0:1c1c9f47b8ad | 50 | |
JavierGC | 0:1c1c9f47b8ad | 51 | typedef struct { |
JavierGC | 0:1c1c9f47b8ad | 52 | char command; /* command to execute */ |
JavierGC | 0:1c1c9f47b8ad | 53 | char message[PCTxBufferSize]; /* arguments */ |
JavierGC | 0:1c1c9f47b8ad | 54 | } mail_t; |
JavierGC | 0:1c1c9f47b8ad | 55 | |
JavierGC | 0:1c1c9f47b8ad | 56 | Mail<mail_t, PCMaxMailElements> mails; |
JavierGC | 0:1c1c9f47b8ad | 57 | int MailNum; |
JavierGC | 0:1c1c9f47b8ad | 58 | |
JavierGC | 0:1c1c9f47b8ad | 59 | void TLogSTR(char *Tstr); |
JavierGC | 0:1c1c9f47b8ad | 60 | int Com_Write(char *mess); //sólo para usarse en ComPC_thread_proc |
JavierGC | 0:1c1c9f47b8ad | 61 | void messageFrom(MODSERIAL_IRQ_INFO *q); |
JavierGC | 0:1c1c9f47b8ad | 62 | void Paralell_thread(); |
JavierGC | 0:1c1c9f47b8ad | 63 | |
JavierGC | 0:1c1c9f47b8ad | 64 | Ticker TStatusToPC; |
JavierGC | 0:1c1c9f47b8ad | 65 | void StatusToPC(void); |
JavierGC | 0:1c1c9f47b8ad | 66 | }; |
JavierGC | 0:1c1c9f47b8ad | 67 | |
JavierGC | 0:1c1c9f47b8ad | 68 | #endif /* _PC_H_ */ |
JavierGC | 0:1c1c9f47b8ad | 69 | |
JavierGC | 0:1c1c9f47b8ad | 70 | |
JavierGC | 0:1c1c9f47b8ad | 71 |