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.
Diff: main.cpp
- Revision:
- 1:96a4c2a39981
- Parent:
- 0:f7d5819b29d5
- Child:
- 2:6009cb96f273
--- a/main.cpp Mon Jan 27 14:22:28 2014 +0000
+++ b/main.cpp Mon Jan 27 16:50:48 2014 +0000
@@ -1,11 +1,22 @@
#include "mbed.h"
#include "rtos.h"
+#include <ctime>
DigitalIn en_1(p15);
DigitalIn en_2(p16);
+
AnalogIn ea_1(p19);
AnalogIn ea_2(p20);
+Serial pc(USBTX, USBRX);
+
+void showTime(char *buffer)
+{
+ std::time_t time = std::time(0);
+
+ strftime(buffer, 32, "%Y-%m-%d %H:%M:%S\n\r", localtime(&time));
+}
+
void lecture_analog(void const *args)
{
while (true)
@@ -18,10 +29,17 @@
}
}
+void lecture_digital1(void const *thread)
+{
+ (Thread)
+}
+
void lecture_num(void const *args)
{
while (true)
{
+ Thread::signal_wait(0x1);
+ pc.prinft("HAHAHAHAHAHAHA");
// synchronisation sur la période d'échantillonnage
// lecture de l'étampe temporelle
// lecture des échantillons numériques
@@ -32,8 +50,13 @@
void collection(void const *args)
{
+ char *time = new char;
+
while (true)
{
+ showTime(time);
+ pc.printf("time: %s", time);
+ wait(2);
// attente et lecture d'un événement
// écriture de l'événement en sortie (port série)
}
@@ -41,8 +64,15 @@
int main()
{
- set_time(time(NULL));
// initialisation du RTC
+ set_time(1390820561); //2014-01-27 11:02:41
+
// démarrage des tâches
- while(1) {}
+ Thread thread1(lecture_num);
+ RtosTimer lect_num(lecture_digital1, osTimerPeriodic, (void*)thread1);
+ lect_num.start(100);
+ //Thread thread2(lecture_analog);
+ //Thread thread3(collection);
+
+ while(true) {}
}
\ No newline at end of file