Commit cf8950d2cbeaf0dd9dd3c10a04029af421f98b45
1 parent
0f27c28b
suppression magic numbers
Showing
3 changed files
with
22 additions
and
18 deletions
Show diff stats
Pgm PC/init_USB.c
... | ... | @@ -3,9 +3,9 @@ |
3 | 3 | #include <stdlib.h> |
4 | 4 | |
5 | 5 | /* Caractéristiques du périphérique */ |
6 | -#define VENDOR_ID 0x2341 | |
7 | -#define PRODUCT_ID 0x0001 | |
8 | -#define TAB_PA_SIZE 10 | |
6 | +#define VENDOR_ID 0x2341 | |
7 | +#define PRODUCT_ID 0x0001 | |
8 | +#define TAB_PA_SIZE 10 | |
9 | 9 | |
10 | 10 | libusb_device_handle *handle=NULL; |
11 | 11 | libusb_device *device=NULL; |
... | ... | @@ -182,7 +182,7 @@ void receive_data(unsigned char tab_PA[TAB_PA_SIZE], unsigned char *boutons, uns |
182 | 182 | status = libusb_interrupt_transfer(handle, PA, joystick_xy, length, &transferred, timeout); |
183 | 183 | if(status!=0){perror("libusb_interrupt_transfer");exit(-1);} |
184 | 184 | |
185 | - //TODO Pas sûr ! | |
185 | + | |
186 | 186 | if (joystick_xy !=NULL){ |
187 | 187 | *joystick_x = joystick_xy[0]; //On sépare la data de chaque axe |
188 | 188 | *joystick_y = joystick_xy[1]; |
... | ... | @@ -214,7 +214,7 @@ int main(){ |
214 | 214 | unsigned char boutons, boutons_anc=0xff; |
215 | 215 | unsigned char joystick_x, joystick_x_anc=0xff; |
216 | 216 | unsigned char joystick_y, joystick_y_anc=0xff; |
217 | - unsigned char caractere; | |
217 | + //unsigned char caractere; | |
218 | 218 | |
219 | 219 | |
220 | 220 | //TODO boucle while(pas d'arrêt), envoi et rcpt |
... | ... | @@ -228,11 +228,12 @@ int main(){ |
228 | 228 | } |
229 | 229 | else { |
230 | 230 | */ |
231 | - //printf("début rcpt\n"); | |
231 | + | |
232 | 232 | receive_data(tab_PA, &boutons, &joystick_x, &joystick_y); //Réception des boutons et joystick |
233 | - //printf("fin rcpt\n"); | |
233 | + | |
234 | + | |
234 | 235 | printf("Boutons : %02x, Joystick_x : %02x, Joystick_y :%02x\n", boutons, joystick_x, joystick_y); //Affichage si changement |
235 | - //if ((boutons != boutons_anc) || (joystick_x != joystick_x_anc) || (joystick_y != joystick_y_anc)) printf("Boutons : %02x, Joystick_x : %02x, Joystick_y :%c\n", boutons, joystick_x, joystick_y); //Affichage si changement | |
236 | + if ((boutons != boutons_anc) || (joystick_x != joystick_x_anc) || (joystick_y != joystick_y_anc)) printf("Boutons : %02x, Joystick_x : %02x, Joystick_y :%c\n", boutons, joystick_x, joystick_y); //Affichage si changement | |
236 | 237 | |
237 | 238 | boutons_anc = boutons; |
238 | 239 | joystick_x_anc = joystick_x; | ... | ... |
lufa-master/PolytechLille/PAD/PAD.c
... | ... | @@ -38,9 +38,10 @@ |
38 | 38 | #include "PAD.h" |
39 | 39 | |
40 | 40 | |
41 | -#define debut_rcpt 0x40 //valeur arbitraire pour détecter un début de trame | |
41 | +#define debut_rcpt 0x40 //valeur arbitraire pour détecter un début de trame | |
42 | +#define DEBIT 9600 //débit liaison série en bauds | |
42 | 43 | |
43 | -uint8_t boutons=0xaa; | |
44 | +uint8_t boutons=0xaa; //arbitraire pour test de la réception série | |
44 | 45 | uint8_t joystick_x=0xbb; |
45 | 46 | uint8_t joystick_y=0xcc; |
46 | 47 | |
... | ... | @@ -78,7 +79,7 @@ void SetupHardware(void) |
78 | 79 | /**INITIALISATIONS*/ |
79 | 80 | /* Hardware Initialization */ |
80 | 81 | USB_Init(); |
81 | - Serial_Init(9600,0); //9600 Bauds, configuration | |
82 | + Serial_Init(DEBIT,0); //9600 Bauds, configuration | |
82 | 83 | |
83 | 84 | /* Initialize Relays */ |
84 | 85 | //DDRD |= ALL_RELAYS; // Port pour la liaison série | ... | ... |
... | ... | @@ -3,9 +3,11 @@ |
3 | 3 | |
4 | 4 | // For the serial port |
5 | 5 | |
6 | -#define CPU_FREQ 16000000L // Assume a CPU frequency of 16Mhz | |
7 | -#define tempo 25 | |
8 | -#define debit 9600 //débit liaison série en bauds | |
6 | +#define CPU_FREQ 16000000L // Assume a CPU frequency of 16Mhz | |
7 | +#define tempo 25 | |
8 | +#define debit 9600 //débit liaison série en bauds | |
9 | +#define ADC0 0 | |
10 | +#define ADC1 1 | |
9 | 11 | #define debut_serial_tx 0x40 //pour détecter la transmission d'une trame pour le 16u2 |
10 | 12 | |
11 | 13 | void init_serial(int speed) |
... | ... | @@ -138,8 +140,8 @@ int main(void){ |
138 | 140 | |
139 | 141 | //Récupération des valeurs des boutons et joystick, et mise en forme |
140 | 142 | boutons = get_buttons(); |
141 | - joystick_x = get_joystick(0); | |
142 | - joystick_y = get_joystick(1); | |
143 | + joystick_x = get_joystick(ADC0); | |
144 | + joystick_y = get_joystick(ADC1); | |
143 | 145 | |
144 | 146 | while(1){ |
145 | 147 | boutons_anc = boutons; |
... | ... | @@ -148,9 +150,9 @@ int main(void){ |
148 | 150 | |
149 | 151 | //Récupération des valeurs des boutons et joystick, et mise en forme |
150 | 152 | boutons = get_buttons(); |
151 | - joystick_x = get_joystick(0); | |
153 | + joystick_x = get_joystick(ADC0); | |
152 | 154 | _delay_ms(tempo); |
153 | - joystick_y = get_joystick(1); | |
155 | + joystick_y = get_joystick(ADC1); | |
154 | 156 | |
155 | 157 | //Port série libre |
156 | 158 | if ((UCSR0A & (1<<RXC0)) == 0){ | ... | ... |