void AppProtocolTasks(CHANNEL_HANDLE h) { if (state == STATE_CLOSED) return; if (state == STATE_CLOSING && ByteQueueSize(&tx_queue) == 0) { log_printf("Finished flushing, closing the channel."); ConnectionCloseChannel(h); state = STATE_CLOSED; return; } UARTTasks(); SPITasks(); I2CTasks(); ICSPTasks(); if (ConnectionCanSend(h)) { BYTE prev = SyncInterruptLevel(1); const BYTE* data; if (bytes_out) { ByteQueuePull(&tx_queue, bytes_out); bytes_out = 0; } ByteQueuePeek(&tx_queue, &data, &bytes_out); if (bytes_out > 0) { if (bytes_out > max_packet) bytes_out = max_packet; ConnectionSend(h, data, bytes_out); } SyncInterruptLevel(prev); } }
void BootProtocolTasks() { if (USBUSARTIsTxTrfReady()) { const BYTE* data; if (bytes_out) { ByteQueuePull(&tx_queue, bytes_out); bytes_out = 0; } ByteQueuePeek(&tx_queue, &data, &bytes_out); if (bytes_out > 0) { if (bytes_out > max_packet) bytes_out = max_packet; putUSBUSART((char *) data, bytes_out); } } }
void AppProtocolTasks(ADB_CHANNEL_HANDLE h) { UARTTasks(); SPITasks(); I2CTasks(); ICSPTasks(); if (ADBChannelReady(h)) { BYTE prev = SyncInterruptLevel(1); const BYTE* data; int size; if (bytes_transmitted) { ByteQueuePull(&tx_queue, bytes_transmitted); bytes_transmitted = 0; } ByteQueuePeek(&tx_queue, &data, &size); if (size > 0) { ADBWrite(h, data, size); bytes_transmitted = size; } SyncInterruptLevel(prev); } }
void UARTTasks() { int i; for (i = 0; i < NUM_UART_MODULES; ++i) { int size1, size2; const BYTE *data1, *data2; UART_STATE* uart = &uarts[i]; BYTE_QUEUE* q = &uart->rx_queue; ByteQueuePeekMax(q, 64, &data1, &size1, &data2, &size2); if (size1) { log_printf("UART %d received %d bytes", i, size1 + size2); OUTGOING_MESSAGE msg; msg.type = UART_DATA; msg.args.uart_data.uart_num = i; msg.args.uart_data.size = size1 + size2 - 1; AppProtocolSendMessageWithVarArgSplit(&msg, data1, size1, data2, size2); ByteQueuePull(q, size1 + size2); } if (uart->num_tx_since_last_report > TX_BUF_SIZE / 2) { UARTReportTxStatus(i); } } }
void AppProtocolTasks(CHANNEL_HANDLE h) { UARTTasks(); SPITasks(); I2CTasks(); ICSPTasks(); /***********************SNES/NES****************************/ SNESTasks(); /***********************************************************/ if (ConnectionCanSend(h)) { BYTE prev = SyncInterruptLevel(1); const BYTE* data; if (bytes_out) { ByteQueuePull(&tx_queue, bytes_out); bytes_out = 0; } ByteQueuePeek(&tx_queue, &data, &bytes_out); if (bytes_out > 0) { if (bytes_out > max_packet) bytes_out = max_packet; ConnectionSend(h, data, bytes_out); } SyncInterruptLevel(prev); } }