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
src/main.cpp@48:1c7861d80d16, 2016-09-13 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Sep 13 16:00:45 2016 +0000
- Revision:
- 48:1c7861d80d16
- Parent:
- 45:3b9e1923cb15
- Child:
- 50:6924b1a2c769
- Child:
- 51:66b820f203a5
skeleton output task created;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:65cfa4873284 | 1 | /****************************************************************************** |
jmarkel44 | 3:8ea4db957749 | 2 | * |
jmarkel44 | 0:65cfa4873284 | 3 | * File: main.cpp |
jmarkel44 | 0:65cfa4873284 | 4 | * Desciption: main ICE driver routine |
jmarkel44 | 0:65cfa4873284 | 5 | * |
jmarkel44 | 0:65cfa4873284 | 6 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 7 | #include "mbed.h" |
jmarkel44 | 0:65cfa4873284 | 8 | #include "rtos.h" |
jmarkel44 | 0:65cfa4873284 | 9 | #include <stdio.h> |
jmarkel44 | 0:65cfa4873284 | 10 | #include "mDot.h" |
jmarkel44 | 0:65cfa4873284 | 11 | #include "global.h" |
jmarkel44 | 0:65cfa4873284 | 12 | #include "ConfigurationHandler.h" |
jmarkel44 | 0:65cfa4873284 | 13 | #include "AnalyticsLogger.h" |
jmarkel44 | 0:65cfa4873284 | 14 | #include "ModbusMaster.h" |
jmarkel44 | 0:65cfa4873284 | 15 | #include "BLEDataHandler.h" |
davidjhoward | 16:7f6599312962 | 16 | #include "LoRaInit.h" |
jmarkel44 | 20:653923c2f37a | 17 | #include "ControlTask.h" |
jmarkel44 | 48:1c7861d80d16 | 18 | #include "OutputTask.h" |
jmarkel44 | 20:653923c2f37a | 19 | #include "CloudDataHandler.h" |
jmarkel44 | 0:65cfa4873284 | 20 | |
jmarkel44 | 0:65cfa4873284 | 21 | // main thread identifier (for signaling) |
jmarkel44 | 0:65cfa4873284 | 22 | osThreadId mainThreadId = NULL; |
jmarkel44 | 0:65cfa4873284 | 23 | int sig_continue = 0x1; |
jmarkel44 | 0:65cfa4873284 | 24 | |
jmarkel44 | 0:65cfa4873284 | 25 | // data handler to configuration hanlder mailbox |
jmarkel44 | 0:65cfa4873284 | 26 | Mail<Message_t, 16> MailBox; |
davidjhoward | 31:4b1587034318 | 27 | Mail<Message_t, 16> ModbusMasterMailBox; |
jmarkel44 | 0:65cfa4873284 | 28 | |
jmarkel44 | 0:65cfa4873284 | 29 | // local function prototypes |
jmarkel44 | 0:65cfa4873284 | 30 | static void banner(void); |
jmarkel44 | 0:65cfa4873284 | 31 | |
davidjhoward | 7:c0c03193612d | 32 | // for file system access outside of main() |
jmarkel44 | 13:c80c283f9db2 | 33 | mDot *GLOBAL_mdot; |
jmarkel44 | 13:c80c283f9db2 | 34 | |
jmarkel44 | 34:f345fdec711d | 35 | Thread *GLOBAL_analyticsLogger_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 36 | Thread *GLOBAL_modbusMaster_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 37 | Thread *GLOBAL_BLE_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 38 | Thread *GLOBAL_CDH_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 39 | Thread *GLOBAL_configHandler_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 40 | Thread *GLOBAL_controlTask_thread = NULL; |
jmarkel44 | 48:1c7861d80d16 | 41 | Thread *GLOBAL_outputTask_thread = NULL; |
jmarkel44 | 34:f345fdec711d | 42 | |
jmarkel44 | 13:c80c283f9db2 | 43 | // store modbus register information |
jmarkel44 | 13:c80c283f9db2 | 44 | std::map<std::string,ModbusRegister> ModbusRegisterMap; |
davidjhoward | 7:c0c03193612d | 45 | |
jmarkel44 | 0:65cfa4873284 | 46 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 47 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 48 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 49 | * |
jmarkel44 | 0:65cfa4873284 | 50 | * @param none |
jmarkel44 | 0:65cfa4873284 | 51 | * @return none |
jmarkel44 | 0:65cfa4873284 | 52 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 53 | static void banner( void ) |
jmarkel44 | 0:65cfa4873284 | 54 | { |
jmarkel44 | 35:6235ef67faa1 | 55 | printf("\n\n\r\nWelcome to Project: ICE v0.0.35\n"); |
jmarkel44 | 0:65cfa4873284 | 56 | printf("\rThe Intelligent Connected Experience\n"); |
jmarkel44 | 0:65cfa4873284 | 57 | printf("\rCopyright 2016 Nalco Water, an Ecolab Company\n"); |
jmarkel44 | 0:65cfa4873284 | 58 | |
jmarkel44 | 0:65cfa4873284 | 59 | printf("\r\t _____ _____ ______ \n"); |
jmarkel44 | 0:65cfa4873284 | 60 | printf("\r\t |_ _| / ____| | ____|\n"); |
jmarkel44 | 0:65cfa4873284 | 61 | printf("\r\t | | | | | |__ \n"); |
jmarkel44 | 0:65cfa4873284 | 62 | printf("\r\t | | | | | __| \n"); |
jmarkel44 | 0:65cfa4873284 | 63 | printf("\r\t _| |_ | |____ | |____ \n"); |
jmarkel44 | 0:65cfa4873284 | 64 | printf("\r\t |_____| \\_____| |______|\n"); |
jmarkel44 | 0:65cfa4873284 | 65 | |
jmarkel44 | 0:65cfa4873284 | 66 | printf("\r\n\r\n\r\r\n"); |
jmarkel44 | 0:65cfa4873284 | 67 | } |
jmarkel44 | 0:65cfa4873284 | 68 | |
jmarkel44 | 0:65cfa4873284 | 69 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 70 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 71 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 72 | * |
jmarkel44 | 0:65cfa4873284 | 73 | * @param none |
jmarkel44 | 0:65cfa4873284 | 74 | * @return none |
jmarkel44 | 0:65cfa4873284 | 75 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 76 | int main( void ) |
jmarkel44 | 0:65cfa4873284 | 77 | { |
jmarkel44 | 0:65cfa4873284 | 78 | mDot *dot; |
davidjhoward | 16:7f6599312962 | 79 | |
jmarkel44 | 48:1c7861d80d16 | 80 | // singleton object instatiation |
davidjhoward | 21:85c69494c0ff | 81 | GLOBAL_mdot = dot = mDot::getInstance(); |
davidjhoward | 21:85c69494c0ff | 82 | mDotRadioInit( dot ); |
davidjhoward | 21:85c69494c0ff | 83 | |
jmarkel44 | 13:c80c283f9db2 | 84 | // for signaling from the configuration handler |
jmarkel44 | 0:65cfa4873284 | 85 | mainThreadId = osThreadGetId(); |
jmarkel44 | 3:8ea4db957749 | 86 | |
jmarkel44 | 0:65cfa4873284 | 87 | banner(); |
jmarkel44 | 0:65cfa4873284 | 88 | printf("\rMultiTech mDot library version: %s\n", dot->getId().c_str()); |
jmarkel44 | 3:8ea4db957749 | 89 | |
jmarkel44 | 3:8ea4db957749 | 90 | // start the configuration handler |
jmarkel44 | 35:6235ef67faa1 | 91 | Thread configHandler_thread(ConfigurationHandler, NULL, osPriorityNormal, 3072, NULL); |
jmarkel44 | 48:1c7861d80d16 | 92 | Thread outputTask_thread(OutputTask, NULL, osPriorityNormal, 3072, NULL); |
jmarkel44 | 20:653923c2f37a | 93 | Thread controlTask_thread(ControlTask); |
jmarkel44 | 3:8ea4db957749 | 94 | |
jmarkel44 | 0:65cfa4873284 | 95 | // wait for the configuration handler to signal us |
jmarkel44 | 0:65cfa4873284 | 96 | osSignalWait(sig_continue, osWaitForever); |
jmarkel44 | 3:8ea4db957749 | 97 | |
jmarkel44 | 0:65cfa4873284 | 98 | printf("\r%s: continuing to initialize...\n", __func__); |
jmarkel44 | 3:8ea4db957749 | 99 | |
jmarkel44 | 34:f345fdec711d | 100 | Thread analyticsLoggerThread(AnalyticsLogger); |
jmarkel44 | 3:8ea4db957749 | 101 | Thread modbusMaster_thread(ModbusMaster); |
jmarkel44 | 3:8ea4db957749 | 102 | Thread BLE_thread(BLEDataHandler); |
davidjhoward | 45:3b9e1923cb15 | 103 | Thread CDH_thread(CloudDataHandler, NULL, osPriorityNormal, 6000, NULL); |
jmarkel44 | 34:f345fdec711d | 104 | |
jmarkel44 | 35:6235ef67faa1 | 105 | // assign globals |
jmarkel44 | 34:f345fdec711d | 106 | GLOBAL_analyticsLogger_thread = &analyticsLoggerThread; |
jmarkel44 | 34:f345fdec711d | 107 | GLOBAL_modbusMaster_thread = &modbusMaster_thread; |
jmarkel44 | 34:f345fdec711d | 108 | GLOBAL_BLE_thread = & BLE_thread; |
jmarkel44 | 34:f345fdec711d | 109 | GLOBAL_CDH_thread = & CDH_thread; |
jmarkel44 | 34:f345fdec711d | 110 | GLOBAL_configHandler_thread = &configHandler_thread; |
jmarkel44 | 34:f345fdec711d | 111 | GLOBAL_controlTask_thread = &controlTask_thread; |
jmarkel44 | 48:1c7861d80d16 | 112 | GLOBAL_outputTask_thread = &outputTask_thread; |
jmarkel44 | 3:8ea4db957749 | 113 | |
jmarkel44 | 1:057d8fc6cb2f | 114 | Thread::wait(1000); |
jmarkel44 | 3:8ea4db957749 | 115 | |
jmarkel44 | 3:8ea4db957749 | 116 | // display free memory on the heap |
jmarkel44 | 18:9cf694a764c0 | 117 | printf("\r\n"); |
jmarkel44 | 3:8ea4db957749 | 118 | __heapstats((__heapprt)fprintf,stdout); |
jmarkel44 | 3:8ea4db957749 | 119 | |
jmarkel44 | 3:8ea4db957749 | 120 | printf("\r\n"); |
jmarkel44 | 13:c80c283f9db2 | 121 | Thread::wait(1000); |
jmarkel44 | 0:65cfa4873284 | 122 | printf("\r\n"); |
jmarkel44 | 20:653923c2f37a | 123 | |
jmarkel44 | 3:8ea4db957749 | 124 | // start the command shell |
jmarkel44 | 0:65cfa4873284 | 125 | ntshell_execute(&ntshell, func_read, func_write, func_cb_ntshell); |
jmarkel44 | 3:8ea4db957749 | 126 | } |