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.
dataStruct.cpp@16:08d5e5a3ee74, 2016-11-17 (annotated)
- Committer:
- noahzwiep
- Date:
- Thu Nov 17 04:03:25 2016 +0000
- Revision:
- 16:08d5e5a3ee74
- Child:
- 19:d58e1e1a9a24
- Made change to hardware class that provides sensing pin; - Made dataStruct class in which there is multiple threading for grabbing queue data; - Made queue in datastruct to allow storage of data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
noahzwiep | 16:08d5e5a3ee74 | 1 | #pragma once |
noahzwiep | 16:08d5e5a3ee74 | 2 | #include "dataStruct.h" |
noahzwiep | 16:08d5e5a3ee74 | 3 | #include "rtos.h" |
noahzwiep | 16:08d5e5a3ee74 | 4 | |
noahzwiep | 16:08d5e5a3ee74 | 5 | dataStruct::dataStruct(hardware* hWare): myQueue(1,N):thread(&dataStruct::threadStarter){ |
noahzwiep | 16:08d5e5a3ee74 | 6 | myHardware = hWare; |
noahzwiep | 16:08d5e5a3ee74 | 7 | thread.signal_set(START_THREAD); |
noahzwiep | 16:08d5e5a3ee74 | 8 | } |
noahzwiep | 16:08d5e5a3ee74 | 9 | |
noahzwiep | 16:08d5e5a3ee74 | 10 | dataStruct::~dataStruct(){ |
noahzwiep | 16:08d5e5a3ee74 | 11 | } |
noahzwiep | 16:08d5e5a3ee74 | 12 | |
noahzwiep | 16:08d5e5a3ee74 | 13 | void dataStruct::threadStarter(void const *p){ |
noahzwiep | 16:08d5e5a3ee74 | 14 | dataStruct *instance = (dataStruct*)p; |
noahzwiep | 16:08d5e5a3ee74 | 15 | instance->storeData(); |
noahzwiep | 16:08d5e5a3ee74 | 16 | } |
noahzwiep | 16:08d5e5a3ee74 | 17 | |
noahzwiep | 16:08d5e5a3ee74 | 18 | void dataStruct::storeData(){ |
noahzwiep | 16:08d5e5a3ee74 | 19 | thread.signal_wait(START_THREAD); |
noahzwiep | 16:08d5e5a3ee74 | 20 | while(true){ |
noahzwiep | 16:08d5e5a3ee74 | 21 | streamValue = myHardware->getSense(); |
noahzwiep | 16:08d5e5a3ee74 | 22 | if(myQueue.GetNumberOfItems() <= N){ |
noahzwiep | 16:08d5e5a3ee74 | 23 | myQueue.Put(&streamValue); |
noahzwiep | 16:08d5e5a3ee74 | 24 | } |
noahzwiep | 16:08d5e5a3ee74 | 25 | Thread::wait(4); |
noahzwiep | 16:08d5e5a3ee74 | 26 | } |
noahzwiep | 16:08d5e5a3ee74 | 27 | } |
noahzwiep | 16:08d5e5a3ee74 | 28 | |
noahzwiep | 16:08d5e5a3ee74 | 29 | queue dataStruct::getData(){ |
noahzwiep | 16:08d5e5a3ee74 | 30 | queue temp = myQueue; |
noahzwiep | 16:08d5e5a3ee74 | 31 | myQueue.Flush(); |
noahzwiep | 16:08d5e5a3ee74 | 32 | return temp; |
noahzwiep | 16:08d5e5a3ee74 | 33 | } |