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.
Dependencies: mbed-rtos mbed CRC16
Fork of S5info_APP2 by
Revision 0:c637467eeb8f, committed 2017-01-30
- Comitter:
- ericbisson
- Date:
- Mon Jan 30 18:52:54 2017 +0000
- Child:
- 1:b3ae0d9f02ad
- Commit message:
- app2
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jan 30 18:52:54 2017 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+#include "rtos.h"
+
+Ticker tick;
+Thread* t1;
+Thread* t2;
+Thread* t3;
+
+DigitalIn en_1(p15);
+DigitalIn en_2(p16);
+AnalogIn ea_1(p19);
+AnalogIn ea_2(p20);
+Serial pc(USBTX, USBRX);
+
+void signal_analog()
+{
+ t1->signal_set(1);
+}
+
+void signal_digital()
+{
+ t2->signal_set(2);
+}
+
+void lecture_analog(void/* const *args*/) {
+ while (true) {
+ t1->signal_wait(1);
+// synchronisation sur la période d'échantillonnage
+// lecture de l'étampe temporelle
+// lecture des échantillons analogiques
+// calcul de la nouvelle moyenne courante
+// génération éventuelle d'un événement
+
+ t1->signal_clr(1);
+ t1->yield();
+ }
+}
+void lecture_num(void/* const *args*/) {
+ while (true) {
+ t2->signal_wait(2);
+// synchronisation sur la période d'échantillonnage
+// lecture de l'étampe temporelle
+// lecture des échantillons numériques
+// prise en charge du phénomène de rebond
+// génération éventuelle d'un événement
+
+ t2->signal_clr(2);
+ t2->yield();
+ }
+}
+void collection(void/* const *args*/) {
+ while (true) {
+// attente et lecture d'un événement
+// écriture de l'événement en sortie (port série)
+ }
+}
+int main() {
+ // initialisation du RTC
+
+ // get the current time from the terminal
+ struct tm t;
+ pc.printf("Enter current date and time:\n");
+ pc.printf("YYYY MM DD HH MM SS[enter]\n");
+ pc.scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday
+ , &t.tm_hour, &t.tm_min, &t.tm_sec);
+
+ // adjust for tm structure required values
+ t.tm_year = t.tm_year - 1900;
+ t.tm_mon = t.tm_mon - 1;
+
+ // set the time
+ set_time(mktime(&t));
+
+ // démarrage des tâches
+ t1 = new Thread();
+ t2 = new Thread();
+ t3 = new Thread();
+
+ t1->start(lecture_analog);
+ t2->start(lecture_num);
+ t3->start(collection);
+
+ tick.attach(&signal_analog, 0.25); // fréquence de 250ms
+ tick.attach(&signal_digital, 0.1); // fréquence de 100ms
+
+ while(1) {
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Jan 30 18:52:54 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 30 18:52:54 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5 \ No newline at end of file
