Revision 384
somehow solved multiplayer problem
proj/src/libs/uart/src/uart.c | ||
---|---|---|
316 | 316 |
//#define NCTP_END 0xFF |
317 | 317 |
#define NCTP_OK 0xFF |
318 | 318 |
#define NCTP_NOK 0x00 |
319 |
#define NCTP_ALIGN 8
|
|
319 |
#define NCTP_ALIGN 4
|
|
320 | 320 |
#define NCTP_FILLER 0x4E |
321 | 321 |
|
322 | 322 |
static queue_t *out = NULL; |
... | ... | |
372 | 372 |
for(size_t i = 0; i < num_fillers; ++i){ |
373 | 373 |
tmp = malloc(sizeof(uint8_t)); *tmp = NCTP_FILLER; queue_push(out, tmp); |
374 | 374 |
} |
375 |
printf("Sent message\n"); |
|
375 | 376 |
|
376 | 377 |
if(uart_transmitter_empty(COM1_ADDR)){ |
377 | 378 |
if((ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out)))) return ret; |
... | ... | |
388 | 389 |
}/*else*/ return SUCCESS; |
389 | 390 |
} |
390 | 391 |
|
391 |
static void nctp_process_received(){ |
|
392 |
static void nctp_process_received(){ printf("Process received");
|
|
392 | 393 |
uint16_t sz = 0;{ |
393 | 394 |
uint8_t sz0 = *(uint8_t*)queue_top(in); free(queue_top(in)); queue_pop(in); |
394 | 395 |
uint8_t sz1 = *(uint8_t*)queue_top(in); free(queue_top(in)); queue_pop(in); |
... | ... | |
417 | 418 |
if((ret = uart_get_char(COM1_ADDR, &c))) return ret; |
418 | 419 |
uint8_t *tmp = malloc(sizeof(uint8_t)); *tmp = c; |
419 | 420 |
|
421 |
printf("Received char 0x%02X\n", c); |
|
422 |
|
|
420 | 423 |
if (szbytes_to_receive){ // gotta receive 2nd size byte and update num_bytes |
421 | 424 |
*((uint8_t*)(&num_bytes_to_receive)+0) = size0; |
422 | 425 |
*((uint8_t*)(&num_bytes_to_receive)+1) = c; |
... | ... | |
447 | 450 |
|
448 | 451 |
static int nctp_ih_err = SUCCESS; |
449 | 452 |
int (nctp_get_ih_error)(void){ return nctp_ih_err; } |
450 |
void nctp_ih(void){ |
|
453 |
void nctp_ih(void){ printf("Got UART interrupt: ");
|
|
451 | 454 |
uint8_t iir; |
452 | 455 |
if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return; |
453 | 456 |
if(UART_GET_IF_INT_PEND(iir)){ |
454 | 457 |
switch(UART_GET_INT_PEND(iir)){ |
455 |
case uart_int_rx: nctp_receive (); break; |
|
456 |
case uart_int_tx: nctp_transmit(); break; |
|
457 |
case uart_int_receiver_line_stat: break; |
|
458 |
case uart_int_modem_stat: break; |
|
459 |
case uart_int_char_timeout_fifo: break; |
|
458 |
case uart_int_rx: printf("receive\n"); nctp_receive (); break;
|
|
459 |
case uart_int_tx: printf("transmit\n"); nctp_transmit(); break;
|
|
460 |
case uart_int_receiver_line_stat: printf("receiver line stat\n"); break;
|
|
461 |
case uart_int_modem_stat: printf("modem state\n"); break;
|
|
462 |
case uart_int_char_timeout_fifo: printf("char timeout\n"); nctp_receive (); break;
|
|
460 | 463 |
//default: break; |
461 | 464 |
} |
462 | 465 |
} |
proj/src/project/src/interrupts_func.c | ||
---|---|---|
129 | 129 |
uart_set_bits_per_character(COM1_ADDR, 8); |
130 | 130 |
uart_set_stop_bits (COM1_ADDR, 2); |
131 | 131 |
uart_set_parity (COM1_ADDR, uart_parity_even); |
132 |
uart_set_bit_rate (COM1_ADDR, 19200);
|
|
132 |
uart_set_bit_rate (COM1_ADDR, 5760);
|
|
133 | 133 |
uart_enable_int_rx (COM1_ADDR); |
134 | 134 |
uart_enable_int_tx(COM1_ADDR); |
135 | 135 |
if(subscribe_uart_interrupt(COM1_IRQ, &uart_id)) { |
proj/src/project/src/proj.c | ||
---|---|---|
368 | 368 |
break; |
369 | 369 |
|
370 | 370 |
case COM1_IRQ: |
371 |
printf("Reach\n");
|
|
371 |
printf("L371\n");
|
|
372 | 372 |
nctp_ih(); |
373 |
printf("Reach2\n");
|
|
374 |
if (bullet_info->new_bullet) { |
|
373 |
printf("L373\n");
|
|
374 |
if (bullet_info->new_bullet) { printf("L374\n");
|
|
375 | 375 |
shoot_bullet(shooter2, bullet_list, bsp_bullet); |
376 | 376 |
bullet_info->new_bullet = false; |
377 | 377 |
} |
378 |
printf("Reach1\n");
|
|
378 |
printf("L378\n");
|
|
379 | 379 |
break; |
380 | 380 |
} |
381 | 381 |
} |
Also available in: Unified diff