Guillaume GARBAY
/
Chenillard
Chenillard-NucléoSTM32F411RE
main.cpp@0:9696488f730a, 2015-03-10 (annotated)
- Committer:
- Guillaume31
- Date:
- Tue Mar 10 08:58:00 2015 +0000
- Revision:
- 0:9696488f730a
Chenillard-NucleoSTM32F411RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Guillaume31 | 0:9696488f730a | 1 | #include "mbed.h" |
Guillaume31 | 0:9696488f730a | 2 | |
Guillaume31 | 0:9696488f730a | 3 | Serial pc(SERIAL_TX, SERIAL_RX); // Port Serie Avec le PC |
Guillaume31 | 0:9696488f730a | 4 | |
Guillaume31 | 0:9696488f730a | 5 | // Digital I/O |
Guillaume31 | 0:9696488f730a | 6 | DigitalOut Led1(D7); // Port D7 : Sortie, nom=>Led1 |
Guillaume31 | 0:9696488f730a | 7 | DigitalOut Led2(D8); |
Guillaume31 | 0:9696488f730a | 8 | DigitalOut Led3(D2); |
Guillaume31 | 0:9696488f730a | 9 | DigitalOut Led4(D3); |
Guillaume31 | 0:9696488f730a | 10 | |
Guillaume31 | 0:9696488f730a | 11 | DigitalIn Inter(D5); // Port D5 : Entree, nom=>Inter |
Guillaume31 | 0:9696488f730a | 12 | |
Guillaume31 | 0:9696488f730a | 13 | void initialisations () { |
Guillaume31 | 0:9696488f730a | 14 | pc.printf("Initialisation\n\r"); |
Guillaume31 | 0:9696488f730a | 15 | Inter.mode(PullUp); // Bouton Poussoir Normalement Ouvert a l'etat haut |
Guillaume31 | 0:9696488f730a | 16 | |
Guillaume31 | 0:9696488f730a | 17 | |
Guillaume31 | 0:9696488f730a | 18 | pc.printf("Fin Initialisation\n\r"); |
Guillaume31 | 0:9696488f730a | 19 | } |
Guillaume31 | 0:9696488f730a | 20 | |
Guillaume31 | 0:9696488f730a | 21 | int main() { |
Guillaume31 | 0:9696488f730a | 22 | pc.printf("Lancement Programme\n\r"); |
Guillaume31 | 0:9696488f730a | 23 | initialisations (); |
Guillaume31 | 0:9696488f730a | 24 | // Declaration Variables Locales |
Guillaume31 | 0:9696488f730a | 25 | int allume = 0, i=0; |
Guillaume31 | 0:9696488f730a | 26 | float temps = 0.5; |
Guillaume31 | 0:9696488f730a | 27 | |
Guillaume31 | 0:9696488f730a | 28 | |
Guillaume31 | 0:9696488f730a | 29 | pc.printf("Debut While(1)\n\r"); |
Guillaume31 | 0:9696488f730a | 30 | while(1) { |
Guillaume31 | 0:9696488f730a | 31 | pc.printf("%d\n\r",i++); |
Guillaume31 | 0:9696488f730a | 32 | switch(allume) |
Guillaume31 | 0:9696488f730a | 33 | { |
Guillaume31 | 0:9696488f730a | 34 | case 0: |
Guillaume31 | 0:9696488f730a | 35 | Led1 = 1; Led2 = 0; Led3 = 0; Led4 = 0; |
Guillaume31 | 0:9696488f730a | 36 | allume = 1; |
Guillaume31 | 0:9696488f730a | 37 | wait (temps); |
Guillaume31 | 0:9696488f730a | 38 | break; |
Guillaume31 | 0:9696488f730a | 39 | case 1: |
Guillaume31 | 0:9696488f730a | 40 | Led1 = 0; Led2 = 1; Led3 = 0; Led4 = 0; |
Guillaume31 | 0:9696488f730a | 41 | allume = 2; |
Guillaume31 | 0:9696488f730a | 42 | wait (temps); |
Guillaume31 | 0:9696488f730a | 43 | break; |
Guillaume31 | 0:9696488f730a | 44 | case 2: |
Guillaume31 | 0:9696488f730a | 45 | Led1 = 0; Led2 = 0; Led3 = 1; Led4 = 0; |
Guillaume31 | 0:9696488f730a | 46 | allume = 3; |
Guillaume31 | 0:9696488f730a | 47 | wait (temps); |
Guillaume31 | 0:9696488f730a | 48 | break; |
Guillaume31 | 0:9696488f730a | 49 | case 3: |
Guillaume31 | 0:9696488f730a | 50 | Led1 = 0; Led2 = 0; Led3 = 0; Led4 = 1; |
Guillaume31 | 0:9696488f730a | 51 | allume = 0; |
Guillaume31 | 0:9696488f730a | 52 | wait (temps); |
Guillaume31 | 0:9696488f730a | 53 | break; |
Guillaume31 | 0:9696488f730a | 54 | default: |
Guillaume31 | 0:9696488f730a | 55 | Led1 = 0; Led2 = 0; Led3 = 0; Led4 = 0; |
Guillaume31 | 0:9696488f730a | 56 | allume = 0; |
Guillaume31 | 0:9696488f730a | 57 | wait (temps); |
Guillaume31 | 0:9696488f730a | 58 | } |
Guillaume31 | 0:9696488f730a | 59 | |
Guillaume31 | 0:9696488f730a | 60 | if (Inter == 0) |
Guillaume31 | 0:9696488f730a | 61 | temps = 0.5; |
Guillaume31 | 0:9696488f730a | 62 | else |
Guillaume31 | 0:9696488f730a | 63 | temps = 1; |
Guillaume31 | 0:9696488f730a | 64 | } |
Guillaume31 | 0:9696488f730a | 65 | } |
Guillaume31 | 0:9696488f730a | 66 |