Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
inc/global.h@56:225786c56315, 2016-09-14 (annotated)
- Committer:
- jmarkel44
- Date:
- Wed Sep 14 12:56:00 2016 +0000
- Revision:
- 56:225786c56315
- Parent:
- 53:14ee82a96d93
- Child:
- 58:a4422d19b2ea
messaging between the control task and the output task;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:65cfa4873284 | 1 | /****************************************************************************** |
davidjhoward | 15:a6ee32969e8e | 2 | * |
jmarkel44 | 0:65cfa4873284 | 3 | * File: global.h |
davidjhoward | 15:a6ee32969e8e | 4 | * Desciption: global data |
jmarkel44 | 0:65cfa4873284 | 5 | * |
jmarkel44 | 0:65cfa4873284 | 6 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 7 | #ifndef GLOBAL_H |
jmarkel44 | 0:65cfa4873284 | 8 | #define GLOBAL_H |
jmarkel44 | 0:65cfa4873284 | 9 | |
jmarkel44 | 0:65cfa4873284 | 10 | #include "mbed.h" |
jmarkel44 | 0:65cfa4873284 | 11 | #include "rtos.h" |
jmarkel44 | 0:65cfa4873284 | 12 | #include "ntshell.h" |
davidjhoward | 7:c0c03193612d | 13 | #include "mDot.h" |
jmarkel44 | 0:65cfa4873284 | 14 | |
davidjhoward | 15:a6ee32969e8e | 15 | #define SUPPRESS_OUTPUT |
jmarkel44 | 2:da28f21b72a1 | 16 | |
jmarkel44 | 0:65cfa4873284 | 17 | extern int sig_continue; |
jmarkel44 | 3:8ea4db957749 | 18 | extern osThreadId mainThreadId; |
jmarkel44 | 0:65cfa4873284 | 19 | |
jmarkel44 | 0:65cfa4873284 | 20 | typedef enum action_tag { |
jmarkel44 | 0:65cfa4873284 | 21 | ACTION_CREATE, |
jmarkel44 | 0:65cfa4873284 | 22 | ACTION_MODIFY, |
davidjhoward | 31:4b1587034318 | 23 | ACTION_DESTROY, |
davidjhoward | 31:4b1587034318 | 24 | ACTION_READ_FILE, |
jmarkel44 | 0:65cfa4873284 | 25 | } Action_t; |
jmarkel44 | 0:65cfa4873284 | 26 | |
jmarkel44 | 0:65cfa4873284 | 27 | typedef enum control_tag { |
jmarkel44 | 0:65cfa4873284 | 28 | CONTROL_TIMER = 0, |
jmarkel44 | 0:65cfa4873284 | 29 | CONTROL_PID = 1, |
jmarkel44 | 0:65cfa4873284 | 30 | CONTROL_SETPOINT = 2, |
jmarkel44 | 0:65cfa4873284 | 31 | CONTROL_COMPOSITE = 3, |
jmarkel44 | 0:65cfa4873284 | 32 | CONTROL_MANUAL = 4 |
jmarkel44 | 0:65cfa4873284 | 33 | } Control_t; |
jmarkel44 | 0:65cfa4873284 | 34 | |
jmarkel44 | 0:65cfa4873284 | 35 | |
jmarkel44 | 0:65cfa4873284 | 36 | // message data type |
jmarkel44 | 0:65cfa4873284 | 37 | typedef struct message_tag { |
jmarkel44 | 0:65cfa4873284 | 38 | Action_t action; |
jmarkel44 | 0:65cfa4873284 | 39 | Control_t control; |
davidjhoward | 31:4b1587034318 | 40 | char controlFile[64]; |
jmarkel44 | 0:65cfa4873284 | 41 | } Message_t; |
jmarkel44 | 0:65cfa4873284 | 42 | |
jmarkel44 | 56:225786c56315 | 43 | typedef enum { |
jmarkel44 | 56:225786c56315 | 44 | OFF = 0, |
jmarkel44 | 56:225786c56315 | 45 | ON = 1 |
jmarkel44 | 56:225786c56315 | 46 | } State; |
jmarkel44 | 56:225786c56315 | 47 | |
jmarkel44 | 51:66b820f203a5 | 48 | // output control request message |
jmarkel44 | 51:66b820f203a5 | 49 | typedef struct output_control_req_t { |
jmarkel44 | 51:66b820f203a5 | 50 | string relay; |
jmarkel44 | 56:225786c56315 | 51 | State state; |
jmarkel44 | 51:66b820f203a5 | 52 | unsigned int priority; |
jmarkel44 | 51:66b820f203a5 | 53 | } OutputControlReq_t; |
jmarkel44 | 51:66b820f203a5 | 54 | |
jmarkel44 | 0:65cfa4873284 | 55 | extern Mail<Message_t, 16> MailBox; |
davidjhoward | 31:4b1587034318 | 56 | extern Mail<Message_t, 16> ModbusMasterMailBox; |
jmarkel44 | 51:66b820f203a5 | 57 | extern Mail<OutputControlReq_t, 16> OutputMasterMailBox; |
jmarkel44 | 0:65cfa4873284 | 58 | |
jmarkel44 | 0:65cfa4873284 | 59 | extern ntshell_t ntshell; |
jmarkel44 | 0:65cfa4873284 | 60 | |
jmarkel44 | 0:65cfa4873284 | 61 | extern int func_read(char *buf, int cnt); |
jmarkel44 | 0:65cfa4873284 | 62 | extern int func_write(const char *buf, int cnt); |
jmarkel44 | 0:65cfa4873284 | 63 | extern int func_cb_ntshell(const char *text); |
jmarkel44 | 0:65cfa4873284 | 64 | extern void func_cb_ntopt(int argc, char **argv); |
davidjhoward | 7:c0c03193612d | 65 | extern mDot *GLOBAL_mdot; |
jmarkel44 | 0:65cfa4873284 | 66 | |
davidjhoward | 9:ef0ca2f8a8a6 | 67 | struct ModbusRegister { |
davidjhoward | 9:ef0ca2f8a8a6 | 68 | std::string name; |
davidjhoward | 9:ef0ca2f8a8a6 | 69 | std::string units; |
davidjhoward | 9:ef0ca2f8a8a6 | 70 | double min; |
davidjhoward | 9:ef0ca2f8a8a6 | 71 | double max; |
davidjhoward | 9:ef0ca2f8a8a6 | 72 | int node; |
davidjhoward | 9:ef0ca2f8a8a6 | 73 | int reg; |
davidjhoward | 9:ef0ca2f8a8a6 | 74 | int rtype; |
davidjhoward | 9:ef0ca2f8a8a6 | 75 | int type; |
davidjhoward | 15:a6ee32969e8e | 76 | int size; |
davidjhoward | 15:a6ee32969e8e | 77 | int order; |
davidjhoward | 49:0456ee2271be | 78 | int rfreq; |
davidjhoward | 9:ef0ca2f8a8a6 | 79 | std::string fmt; |
davidjhoward | 15:a6ee32969e8e | 80 | float float_value; |
davidjhoward | 15:a6ee32969e8e | 81 | uint32_t uint32_value; |
davidjhoward | 15:a6ee32969e8e | 82 | uint16_t uint16_value; |
davidjhoward | 9:ef0ca2f8a8a6 | 83 | }; |
davidjhoward | 9:ef0ca2f8a8a6 | 84 | |
davidjhoward | 15:a6ee32969e8e | 85 | typedef enum byte_order { |
davidjhoward | 15:a6ee32969e8e | 86 | BigEndian = 0, |
davidjhoward | 15:a6ee32969e8e | 87 | LittleEndian = 1, |
davidjhoward | 15:a6ee32969e8e | 88 | BigEndianReverseWord = 2, |
davidjhoward | 15:a6ee32969e8e | 89 | LittleEndianReversWord = 3, |
davidjhoward | 15:a6ee32969e8e | 90 | } Byte_Order; |
davidjhoward | 9:ef0ca2f8a8a6 | 91 | |
davidjhoward | 15:a6ee32969e8e | 92 | extern std::map<std::string,ModbusRegister> ModbusRegisterMap; |
davidjhoward | 15:a6ee32969e8e | 93 | |
jmarkel44 | 34:f345fdec711d | 94 | extern Thread *GLOBAL_analyticsLogger_thread; |
jmarkel44 | 34:f345fdec711d | 95 | extern Thread *GLOBAL_modbusMaster_thread; |
jmarkel44 | 34:f345fdec711d | 96 | extern Thread *GLOBAL_BLE_thread; |
jmarkel44 | 34:f345fdec711d | 97 | extern Thread *GLOBAL_CDH_thread; |
jmarkel44 | 34:f345fdec711d | 98 | extern Thread *GLOBAL_configHandler_thread; |
jmarkel44 | 34:f345fdec711d | 99 | extern Thread *GLOBAL_controlTask_thread; |
jmarkel44 | 48:1c7861d80d16 | 100 | extern Thread *GLOBAL_outputTask_thread; |
jmarkel44 | 34:f345fdec711d | 101 | |
davidjhoward | 15:a6ee32969e8e | 102 | #endif |