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: mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed
Fork of HTTPServerHelloWorld by
Application.cpp
00001 #include "Application.h" 00002 00003 #define WATCH_DOG_TIMER_TRIGGER_TIME 5 //seconds 00004 00005 extern "C" void mbed_reset(); 00006 00007 Application::Application() { 00008 } 00009 00010 void Application::setup() { 00011 00012 // WatchDog reset ? 00013 if (WatchDogTimer::systemResetReason() == SYSTEM_RESET_WATCH_DOG) { 00014 handleFaultyResetRecovery(); 00015 } 00016 00017 // setup ethernet 00018 00019 00020 // start spi 00021 spiHandler = new SPI(p5, p6, p7); 00022 spiHandler->frequency(100000); // 100 khz for slow periperals intialization 00023 00024 // starting the file systems 00025 localFileSystem = new LocalFileSystem("local"); 00026 sdFileSystem = new SDFileSystem(spiHandler, p8, "sd"); 00027 00028 spiHandler->frequency(16000000); // 4 Mhz spi normal operation frequency 00029 00030 // start the http api server 00031 httpServer = new HttpServer(); 00032 httpServer->start(); 00033 00034 // enable watchdog timer 00035 watchDog = new WatchDogTimer(WATCH_DOG_TIMER_TRIGGER_TIME); 00036 } 00037 00038 void Application::handleFaultyResetRecovery() { 00039 00040 } 00041 00042 void Application::loop() { 00043 00044 } 00045 00046 void Application::run() { 00047 setup(); 00048 while(1) { 00049 watchDog->feed(); 00050 if (!isSystemOnline()) { 00051 recoverSystem(); 00052 } 00053 watchDog->feed(); 00054 loop(); 00055 Thread::wait(100); 00056 } 00057 } 00058 00059 int Application::isSystemOnline() { 00060 return httpServer->isAlive(); 00061 } 00062 00063 void Application::recoverSystem() { 00064 httpServer->restart(); 00065 } 00066 00067 void Application::applicationReset() { 00068 wait(5); 00069 mbed_reset(); 00070 } 00071 00072 Application::~Application() { 00073 00074 }
Generated on Thu Jul 28 2022 23:53:25 by
1.7.2
