#include // for the input/output register // For the serial port #define CPU_FREQ 16000000L // Assume a CPU frequency of 16Mhz void init_serial(int speed) { /* Set baud rate */ UBRR0 = CPU_FREQ/(((unsigned long int)speed)<<4)-1; /* Enable transmitter & receiver */ UCSR0B = (1<>2) | 0b00100000; return(boutons); } /* Met en forme l'octet de l'axe pos du joystick */ int shape_joy(unsigned char pos){ pos = (pos >> 3) | 0b00100000; return(pos); } /* Récupération de la valeur de l'axe du joystick sur la chaîne channel du CAN */ int get_joystick(int channel){ unsigned char axis; ad_init(channel); axis = ad_sample(); shape_joy(axis); return(axis); } /* Dummy main */ int main(void){ init_serial(9600); output_init(); input_init(); unsigned char boutons, boutons_anc; unsigned char joystick_x, joystick_x_anc; unsigned char joystick_y, joystick_y_anc; //Récupération des valeurs des boutons et joystick, et mise en forme boutons = get_buttons(); joystick_x = get_joystick(1); joystick_y = get_joystick(0); //send_serial(boutons); while(1){ boutons_anc = boutons; joystick_x_anc = joystick_x; joystick_y_anc = joystick_y; //Récupération des valeurs des boutons et joystick, et mise en forme boutons = get_buttons(); joystick_x = get_joystick(1); joystick_y = get_joystick(0); send_serial(boutons+2); //retour chariot send_serial(0x0a); send_serial(0x0d); //Cas où aucun caractère n'est reçu if ((UCSR0A & (1<