dujardin stephane
/
DUJ4-F401
programme de test pour envoyer du DUJ4 vers processing
main.cpp@0:84f30b3eb83b, 2021-01-14 (annotated)
- Committer:
- dujardin
- Date:
- Thu Jan 14 10:01:51 2021 +0000
- Revision:
- 0:84f30b3eb83b
programme de test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dujardin | 0:84f30b3eb83b | 1 | // démonstrateur DUJ4 |
dujardin | 0:84f30b3eb83b | 2 | // réception serie |
dujardin | 0:84f30b3eb83b | 3 | // 'f' pour allumer ou éteindre LED1 du F401 |
dujardin | 0:84f30b3eb83b | 4 | // 'g' pour repondre un chiffre 16 bits XXXXL |
dujardin | 0:84f30b3eb83b | 5 | // emission serie .. chaque seconde |
dujardin | 0:84f30b3eb83b | 6 | // 'a' pour dire je suis la |
dujardin | 0:84f30b3eb83b | 7 | // un int 16 bits XXXXK |
dujardin | 0:84f30b3eb83b | 8 | // un tableau de 100 12 bits XXXXXH...XXXXH finit par R |
dujardin | 0:84f30b3eb83b | 9 | |
dujardin | 0:84f30b3eb83b | 10 | #include "mbed.h" |
dujardin | 0:84f30b3eb83b | 11 | |
dujardin | 0:84f30b3eb83b | 12 | //****************** déclaration des broches utiles sur la varte *********** |
dujardin | 0:84f30b3eb83b | 13 | Serial pc(SERIAL_TX, SERIAL_RX); // laison serie en USB driver STlink |
dujardin | 0:84f30b3eb83b | 14 | DigitalOut led(LED1); |
dujardin | 0:84f30b3eb83b | 15 | |
dujardin | 0:84f30b3eb83b | 16 | |
dujardin | 0:84f30b3eb83b | 17 | |
dujardin | 0:84f30b3eb83b | 18 | //********* variables GLOBALES |
dujardin | 0:84f30b3eb83b | 19 | int flag = 0; |
dujardin | 0:84f30b3eb83b | 20 | //******** sous programmes |
dujardin | 0:84f30b3eb83b | 21 | #include "serie.h" // gestion liaison serie au protocole DUJ4 |
dujardin | 0:84f30b3eb83b | 22 | |
dujardin | 0:84f30b3eb83b | 23 | void init(void) // initialisations indispensables de la carte |
dujardin | 0:84f30b3eb83b | 24 | { |
dujardin | 0:84f30b3eb83b | 25 | //uBit.init(); |
dujardin | 0:84f30b3eb83b | 26 | pc.baud(57600); // vitesse liaison |
dujardin | 0:84f30b3eb83b | 27 | pc.attach(&interrupt, Serial::RxIrq); // gestion recept dans serie.h |
dujardin | 0:84f30b3eb83b | 28 | led = 0; // init led du L432 + carte |
dujardin | 0:84f30b3eb83b | 29 | } |
dujardin | 0:84f30b3eb83b | 30 | |
dujardin | 0:84f30b3eb83b | 31 | int main() |
dujardin | 0:84f30b3eb83b | 32 | { |
dujardin | 0:84f30b3eb83b | 33 | init(); |
dujardin | 0:84f30b3eb83b | 34 | while(1) |
dujardin | 0:84f30b3eb83b | 35 | { |
dujardin | 0:84f30b3eb83b | 36 | if ( flag == 1) |
dujardin | 0:84f30b3eb83b | 37 | { |
dujardin | 0:84f30b3eb83b | 38 | sendDL(); // // transmet DL une fois |
dujardin | 0:84f30b3eb83b | 39 | flag = 0; |
dujardin | 0:84f30b3eb83b | 40 | } |
dujardin | 0:84f30b3eb83b | 41 | |
dujardin | 0:84f30b3eb83b | 42 | if (led == 1) // boucle sans fin |
dujardin | 0:84f30b3eb83b | 43 | { |
dujardin | 0:84f30b3eb83b | 44 | THextabDR( 100 ); // transmission tableau DR |
dujardin | 0:84f30b3eb83b | 45 | wait_ms(20); |
dujardin | 0:84f30b3eb83b | 46 | sendDK(); // // transmet DK |
dujardin | 0:84f30b3eb83b | 47 | } |
dujardin | 0:84f30b3eb83b | 48 | |
dujardin | 0:84f30b3eb83b | 49 | pc.putc('a'); // je suis la |
dujardin | 0:84f30b3eb83b | 50 | wait (1); // rebouclage automatique |
dujardin | 0:84f30b3eb83b | 51 | } |
dujardin | 0:84f30b3eb83b | 52 | } |
dujardin | 0:84f30b3eb83b | 53 | |
dujardin | 0:84f30b3eb83b | 54 |