Repo. for the ELEC351 Coursework - Oliver Thompson
Dependencies: BMP280 ELEC350-Practicals-FZ429- TextLCD watchdog_RTOS BME280 ntp-client
main.cpp
- Committer:
- O_Thom
- Date:
- 2018-12-06
- Revision:
- 14:dbb0741ce576
- Parent:
- 13:37a7c57f4641
- Child:
- 18:a036c2e5ff89
File content as of revision 14:dbb0741ce576:
#include "mbed.h" #include "sample_hardware.hpp" #include "Sampler.hpp" //#include <watchdog_RTOS.h> #define WatchDogTimeout 2000 #define SerialRxFlag 1 void LCD_Thread(void); void SAMP_Thread(void); void SERIAL_Thread(void); void SERIAL_IRQ(void); Thread tLCD, tSAMP, tSERIAL, tSD; //Watchdog Initialisation - Implement Custom to only reset the thread which is faulty. Include a top level Watchdog to reset everything in Main //Watchdog_RTOS SerialWatch; //Watchdog_RTOS SampleWatch; //Watchdog_RTOS LCDWatch; //Watchdog_RTOS SDWatch; //Watchdog_RTOS NetWatch; // Define member object Sampler m_oSample; // LCD Defined in Cpp due to use in Sampler.hpp int main() { tLCD.start(LCD_Thread); tSAMP.start(SAMP_Thread); tSERIAL.start(SERIAL_Thread); //tSD.start(SD_Thread); Thread::wait(osWaitForever); } void LCD_Thread() { vector<int> ErrorCodes; // LCDWatch.kick(WatchDogTimeout); while(1) { // m_oDisplay.LCD_Queue.call_every(1500, LCDWatch.kick); m_oDisplay.LCD_Queue.call_every(1000, &m_oDisplay, &LCD_Data::display_LCD); //Displays the current sensor information onto the LCD screen every x miliseconds m_oDisplay.LCD_Queue.dispatch(); // Enters WAITING state when blocking ErrorCodes.push_back(ERROR_LCD_EXIT); // Update Error Vector m_oSerial.SERIAL_Queue.call(&m_oSerial, &Serialcomms::updateErrors, ErrorCodes); // Pass error vector to the serial thread } } void SAMP_Thread() { vector<int> ErrorCodes; // SamplerWatch.kick(WatchDogTimeout); while(1) { // m_oSample.SAMP_Queue.call_every(1500, SamplerWatch.kick); m_oSample.SAMP_Queue.call_every(500, &m_oSample, &Sampler::publishSample); // Publish sample m_oSample.SAMP_Queue.dispatch(); // Enters WAITING state when blocking ErrorCodes.push_back(ERROR_SAMPLER_EXIT); // Update Error Vector m_oSerial.SERIAL_Queue.call(&m_oSerial, &Serialcomms::updateErrors, ErrorCodes); // Pass error vector to the serial thread } } void SERIAL_Thread() { vector<int> ErrorCodes; // SerialWatch.kick(WatchDogTimeout); while(1) { //m_oSerial.SERIAL_Queue.call_every(1500, SerialWatch.kick); //m_oSerial.SERIAL_Queue.call_every(1000, &m_oSerial, &Serialcomms::updateTerminal); // Publish sample m_oSerial.SERIAL_Queue.dispatch(); // Enters WAITING state when blocking ErrorCodes.push_back(ERROR_SERIAL_EXIT); // Update Error Vector } }