Pacemaker code Implementation for SFWRENG 3K04
Dependencies: mbed Queue mbed-rtos FXOS8700Q
Fork of Pacemaker by
SWFRENG 3K04 Project to design, develop, and document a functional pacemaker.
The project uses the Freescale K64F Microcontroller and C++ mbed library.
Diff: dataStruct.cpp
- Revision:
- 16:08d5e5a3ee74
- Child:
- 19:d58e1e1a9a24
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dataStruct.cpp Thu Nov 17 04:03:25 2016 +0000 @@ -0,0 +1,33 @@ +#pragma once +#include "dataStruct.h" +#include "rtos.h" + +dataStruct::dataStruct(hardware* hWare): myQueue(1,N):thread(&dataStruct::threadStarter){ + myHardware = hWare; + thread.signal_set(START_THREAD); + } + +dataStruct::~dataStruct(){ + } + +void dataStruct::threadStarter(void const *p){ + dataStruct *instance = (dataStruct*)p; + instance->storeData(); + } + +void dataStruct::storeData(){ + thread.signal_wait(START_THREAD); + while(true){ + streamValue = myHardware->getSense(); + if(myQueue.GetNumberOfItems() <= N){ + myQueue.Put(&streamValue); + } + Thread::wait(4); + } +} + +queue dataStruct::getData(){ + queue temp = myQueue; + myQueue.Flush(); + return temp; +} \ No newline at end of file