
trabalho
Dependencies: X_NUCLEO_IKS01A1 mbed-rtos mbed
Fork of HelloWorld_IKS01A1 by
Revision 12:7ef8061de189, committed 2016-05-04
- Comitter:
- nlsantos
- Date:
- Wed May 04 19:31:08 2016 +0000
- Parent:
- 11:cea55a4c778c
- Child:
- 13:569b49092661
- Commit message:
- comitteed;
Changed in this revision
mailBox.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mailBox.cpp Wed May 04 19:31:08 2016 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "rtos.h" +#include <logData.cpp> + +/* Mail +typedef struct { + float voltage; + float current; + uint32_t counter; +} mail_t; + +*/ + +//LogData mail_t + +Mail<LogData, 16> mail_box; + +void send_thread (void const *args) { + while (true) { + LogData *log = mail_box.alloc(); + log->id = ; + log->tempCelcius; + log->tempFarenheit; + log->humidity; + log->pressure; + log->accelerometer; + log->gyroscope; + log->magnetometer; + log->dd; + log->mm; + log->yyyy; + log->hh; + log->min; + log->ss; + + mail_box.put(log); + Thread::wait(1000); + } +} + +int main (void) { + Thread thread(send_thread); + + while (true) { + osEvent evt = mail_box.get(); + if (evt.status == osEventMail) { + mail_t *mail = (mail_t*)evt.value.p; + printf("\nVoltage: %.2f V\n\r" , mail->voltage); + printf("Current: %.2f A\n\r" , mail->current); + printf("Number of cycles: %u\n\r", mail->counter); + + mail_box.free(mail); + } + } +} \ No newline at end of file