Revision 385
improved a bit
proj/src/libs/uart/src/uart.c | ||
---|---|---|
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"); |
|
376 | 375 |
|
377 | 376 |
if(uart_transmitter_empty(COM1_ADDR)){ |
378 | 377 |
if((ret = uart_send_char(COM1_ADDR, *(uint8_t*)queue_top(out)))) return ret; |
... | ... | |
389 | 388 |
}/*else*/ return SUCCESS; |
390 | 389 |
} |
391 | 390 |
|
392 |
static void nctp_process_received(){ printf("Process received");
|
|
391 |
static void nctp_process_received(){ |
|
393 | 392 |
uint16_t sz = 0;{ |
394 | 393 |
uint8_t sz0 = *(uint8_t*)queue_top(in); free(queue_top(in)); queue_pop(in); |
395 | 394 |
uint8_t sz1 = *(uint8_t*)queue_top(in); free(queue_top(in)); queue_pop(in); |
... | ... | |
418 | 417 |
if((ret = uart_get_char(COM1_ADDR, &c))) return ret; |
419 | 418 |
uint8_t *tmp = malloc(sizeof(uint8_t)); *tmp = c; |
420 | 419 |
|
421 |
printf("Received char 0x%02X\n", c); |
|
422 |
|
|
423 | 420 |
if (szbytes_to_receive){ // gotta receive 2nd size byte and update num_bytes |
424 | 421 |
*((uint8_t*)(&num_bytes_to_receive)+0) = size0; |
425 | 422 |
*((uint8_t*)(&num_bytes_to_receive)+1) = c; |
... | ... | |
450 | 447 |
|
451 | 448 |
static int nctp_ih_err = SUCCESS; |
452 | 449 |
int (nctp_get_ih_error)(void){ return nctp_ih_err; } |
453 |
void nctp_ih(void){ printf("Got UART interrupt: ");
|
|
450 |
void nctp_ih(void){ |
|
454 | 451 |
uint8_t iir; |
455 | 452 |
if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return; |
456 | 453 |
if(UART_GET_IF_INT_PEND(iir)){ |
457 | 454 |
switch(UART_GET_INT_PEND(iir)){ |
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;
|
|
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: nctp_receive (); break; |
|
463 | 460 |
//default: break; |
464 | 461 |
} |
465 | 462 |
} |
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, 5760);
|
|
132 |
uart_set_bit_rate (COM1_ADDR, 9600);
|
|
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("L371\n"); |
|
372 | 371 |
nctp_ih(); |
373 |
printf("L373\n"); |
|
374 |
if (bullet_info->new_bullet) { printf("L374\n"); |
|
372 |
if (bullet_info->new_bullet) { |
|
375 | 373 |
shoot_bullet(shooter2, bullet_list, bsp_bullet); |
376 | 374 |
bullet_info->new_bullet = false; |
377 | 375 |
} |
378 |
printf("L378\n"); |
|
379 | 376 |
break; |
380 | 377 |
} |
381 | 378 |
} |
Also available in: Unified diff