Fork de Timer après le match à 61 points

Dependencies:   RoboClaw mbed

Fork of Timer by ARES

Committer:
sype
Date:
Mon Apr 25 12:38:58 2016 +0000
Revision:
46:5658af4e5149
Parent:
45:b53ae54062c6
Child:
48:03da1aead032
ajout de la carte boutons ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sype 41:b5a2fbc20beb 1 #include "func.h"
sype 0:ad9600df4a70 2
sype 10:ae3178aa94e9 3 #define ATTENTE 0
sype 10:ae3178aa94e9 4 #define GO 1
sype 10:ae3178aa94e9 5 #define STOP 2
sype 46:5658af4e5149 6 #define ADR 0x80
sype 46:5658af4e5149 7 #define dt 10000
sype 0:ad9600df4a70 8
sype 41:b5a2fbc20beb 9 /* Déclaration des différents éléments de l'IHM */
sype 46:5658af4e5149 10
sype 46:5658af4e5149 11 /* Carte boutons, la NUCLEO n'arrive pas à récupérer les signaux CAMP et START */
sype 46:5658af4e5149 12 InterruptIn CAMP(PH_0);
sype 46:5658af4e5149 13 InterruptIn START(PH_1);
sype 46:5658af4e5149 14 DigitalOut LEDR(PC_2);
sype 46:5658af4e5149 15 DigitalOut LEDV(PC_3);
sype 46:5658af4e5149 16
sype 10:ae3178aa94e9 17 InterruptIn mybutton(USER_BUTTON);
sype 10:ae3178aa94e9 18 DigitalIn button(USER_BUTTON);
sype 46:5658af4e5149 19
sype 46:5658af4e5149 20 DigitalIn ChannelA1(PA_1);
sype 46:5658af4e5149 21 DigitalIn ChannelB1(PA_0);
sype 46:5658af4e5149 22 DigitalIn ChannelA2(PA_5);
sype 46:5658af4e5149 23 DigitalIn ChannelB2(PA_6);
sype 46:5658af4e5149 24
sype 41:b5a2fbc20beb 25 DigitalOut bleu(PC_5);
sype 41:b5a2fbc20beb 26 DigitalOut blanc(PC_6);
sype 41:b5a2fbc20beb 27 DigitalOut rouge(PC_8);
sype 41:b5a2fbc20beb 28
sype 46:5658af4e5149 29 /* AX12 - non fonctionnels, je pense que le souci vient de la bibliothèque car la trame n'est pas correcte (analyseur logique) */
sype 46:5658af4e5149 30 AX12 left_hand(PA_9, PA_10, 4, 250000);
sype 46:5658af4e5149 31 AX12 right_hand(PA_9, PA_10, 1, 250000);
sype 41:b5a2fbc20beb 32
sype 41:b5a2fbc20beb 33 /* Sharp */
sype 41:b5a2fbc20beb 34 AnalogIn capt1(PA_4);
sype 41:b5a2fbc20beb 35 AnalogIn capt2(PB_0);
sype 41:b5a2fbc20beb 36 AnalogIn capt3(PC_1);
sype 41:b5a2fbc20beb 37 AnalogIn capt4(PC_0);
sype 41:b5a2fbc20beb 38
sype 41:b5a2fbc20beb 39 /* Moteurs pas à pas */
sype 46:5658af4e5149 40 Stepper RMot(NC, PA_8, PC_7);
sype 46:5658af4e5149 41 Stepper ZMot(NC, PB_4, PB_10);
sype 46:5658af4e5149 42 Stepper LMot(NC, PB_5, PB_3);
sype 41:b5a2fbc20beb 43 /* Fins de course */
sype 41:b5a2fbc20beb 44 InterruptIn EndR(PB_15);
sype 41:b5a2fbc20beb 45 InterruptIn EndZ(PB_14);
sype 41:b5a2fbc20beb 46 InterruptIn EndL(PB_13);
sype 41:b5a2fbc20beb 47
sype 0:ad9600df4a70 48 Ticker ticker;
sype 41:b5a2fbc20beb 49
sype 41:b5a2fbc20beb 50 Serial logger(USBTX, USBRX);
sype 46:5658af4e5149 51 //Serial logger(PA_2, PA_3);
sype 46:5658af4e5149 52 RoboClaw roboclaw(ADR, 460800, PA_11, PA_12);
IceTeam 39:309f38d1e49c 53 Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw);
sype 10:ae3178aa94e9 54
sype 46:5658af4e5149 55 int SIMON_i = 0, SIMON_state = 0;
sype 46:5658af4e5149 56 bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false;
sype 0:ad9600df4a70 57
sype 2:abdf8c6823a1 58 void init(void);
sype 46:5658af4e5149 59 void update_main(void);
sype 0:ad9600df4a70 60
sype 43:d5aaff7d2bec 61 /* Debut du programme */
sype 0:ad9600df4a70 62 int main(void)
sype 10:ae3178aa94e9 63 {
sype 37:da3a2c781672 64 init();
sype 44:b1fd7489369f 65 while(1) JPO();
sype 2:abdf8c6823a1 66 }
sype 2:abdf8c6823a1 67
sype 2:abdf8c6823a1 68 void init(void)
sype 0:ad9600df4a70 69 {
sype 37:da3a2c781672 70 logger.baud(9600);
sype 37:da3a2c781672 71 logger.printf("Hello from main !\n\r");
sype 46:5658af4e5149 72 roboclaw.ForwardM1(0);
sype 46:5658af4e5149 73 roboclaw.ForwardM2(0);
sype 46:5658af4e5149 74 LEDV = 1;
sype 10:ae3178aa94e9 75 while(button);
sype 46:5658af4e5149 76 LEDV = 0;
sype 46:5658af4e5149 77 roboclaw.ResetEnc();
sype 44:b1fd7489369f 78 init_interrupt();
sype 46:5658af4e5149 79 ticker.attach_us(&update_main, dt); // 100 Hz
sype 41:b5a2fbc20beb 80 wait_ms(100);
IceTeam 39:309f38d1e49c 81 logger.printf("End init\n\r");
sype 0:ad9600df4a70 82 }
sype 46:5658af4e5149 83
sype 46:5658af4e5149 84 void update_main(void)
sype 46:5658af4e5149 85 {
sype 46:5658af4e5149 86 odo.update_odo();
sype 46:5658af4e5149 87 //checkAround();
sype 46:5658af4e5149 88 }