renaming function and variables
changing indent size
This commit is contained in:
Jan Dümpelmann 2020-05-04 07:59:13 +02:00
parent 59ff208c65
commit fd69cc3dcc
1 changed files with 38 additions and 38 deletions

View File

@ -539,7 +539,7 @@ static void receive_packet(xfer_ctl_t * xfer, /* USB_OTG_OUTEndpointTypeDef * ou
}
// Write a single data packet to EPIN FIFO
static void transmit_fifo_packet(uint8_t fifo_num, uint8_t * src, uint16_t len){
static void write_fifo_packet(uint8_t fifo_num, uint8_t * src, uint16_t len){
usb_fifo_t tx_fifo = FIFO_BASE(fifo_num);
// Pushing full available 32 bit words to fifo
@ -652,6 +652,7 @@ static void handle_epin_ints(USB_OTG_DeviceTypeDef * dev, USB_OTG_INEndpointType
if ( dev->DAINT & (1 << (USB_OTG_DAINT_IEPINT_Pos + n)) )
{
// IN XFER complete (entire xfer).
if ( in_ep[n].DIEPINT & USB_OTG_DIEPINT_XFRC )
{
@ -667,15 +668,13 @@ static void handle_epin_ints(USB_OTG_DeviceTypeDef * dev, USB_OTG_INEndpointType
// - 64 bytes or
// - Half of TX FIFO size (configured by DIEPTXF)
// Packets to be processed
uint16_t tx_packet_amount = (in_ep[n].DIEPTSIZ & USB_OTG_DIEPTSIZ_PKTCNT_Msk) >> USB_OTG_DIEPTSIZ_PKTCNT_Pos;
uint16_t remaining_packets = (in_ep[n].DIEPTSIZ & USB_OTG_DIEPTSIZ_PKTCNT_Msk) >> USB_OTG_DIEPTSIZ_PKTCNT_Pos;
// Process every single packet (only whole packets can be written to fifo)
for(uint16_t i = 0; i < tx_packet_amount; i++){
// amount of bytes EP still needs to transfer
uint16_t tx_remaining = (in_ep[n].DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ_Msk) >> USB_OTG_DIEPTSIZ_XFRSIZ_Pos;
for(uint16_t i = 0; i < remaining_packets; i++){
uint16_t remaining_bytes = (in_ep[n].DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ_Msk) >> USB_OTG_DIEPTSIZ_XFRSIZ_Pos;
// Packet can not be larger than ep max size
uint16_t packet_size = (tx_remaining > xfer->max_size) ? xfer->max_size : tx_remaining;
uint16_t packet_size = tu_min16(remaining_bytes, xfer->max_size);
// It's only possible to write full packets into FIFO. Therefore DTXFSTS register of current
// EP has to be checked if the buffer can take another WHOLE packet
@ -683,10 +682,11 @@ static void handle_epin_ints(USB_OTG_DeviceTypeDef * dev, USB_OTG_INEndpointType
break;
}
xfer->queued_len = xfer->total_len - tx_remaining;
// TODO: queued_len can be removed later
xfer->queued_len = xfer->total_len - remaining_bytes;
// Push packet to Tx-FIFO
transmit_fifo_packet(n, (xfer->buffer + xfer->queued_len), packet_size);
write_fifo_packet(n, (xfer->buffer + xfer->queued_len), packet_size);
}
// Turn off TXFE if all bytes are written.