USB CDC ACM: minor fix spacing

This commit is contained in:
King Kévin 2020-11-27 16:44:17 +01:00
parent a9284b7154
commit aae4009fbe
1 changed files with 7 additions and 7 deletions

View File

@ -259,7 +259,7 @@ static void usb_dfu_detach(usbd_device *usbd_dev, struct usb_setup_data *req)
*/
static enum usbd_request_return_codes usb_cdcacm_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
{
if (usb_dfu_interface.bInterfaceNumber==req->wIndex) { // check if request is for DFU
if (usb_dfu_interface.bInterfaceNumber == req->wIndex) { // check if request is for DFU
switch (req->bRequest) {
case DFU_DETACH: // USB detach requested
*complete = usb_dfu_detach; // detach after reply
@ -276,10 +276,10 @@ static enum usbd_request_return_codes usb_cdcacm_control_request(usbd_device *us
default: // other requests are not supported
return USBD_REQ_NOTSUPP;
}
} else if (usb_cdcacm_communication_interface.bInterfaceNumber==req->wIndex) { // check if request is for CDC
} else if (usb_cdcacm_communication_interface.bInterfaceNumber == req->wIndex) { // check if request is for CDC
switch (req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
usb_cdcacm_connecting = (0!=req->wValue); // check if terminal is open (windows set the control line state before a terminal opens the port, but with value 0)
usb_cdcacm_connecting = (0 != req->wValue); // check if terminal is open (windows set the control line state before a terminal opens the port, but with value 0)
//bool dtr = (req->wValue & (1 << 0)) ? true : false;
//bool rts = (req->wValue & (1 << 1)) ? true : false;
/* the Linux cdc_acm driver requires this to be implemented
@ -348,7 +348,7 @@ static void usb_cdcacm_data_tx_cb(usbd_device *usbd_dev, uint8_t ep)
if (!usbd_dev && usb_tx_ongoing) { // putchar is trying to send data but a transmission is already ongoing
return;
}
if (0==tx_used || !first_connection) { // verify if we can send and there is something to send
if (0 == tx_used || !first_connection) { // verify if we can send and there is something to send
usb_tx_ongoing = false; // transmission ended
return;
}
@ -356,9 +356,9 @@ static void usb_cdcacm_data_tx_cb(usbd_device *usbd_dev, uint8_t ep)
tx_lock = true; // get the lock (no dead lock should occur since putchar should not be used in interrupts)
usb_tx_ongoing = true; // remember we started transmission
uint16_t usb_length = (tx_used > USB_DATA_TRANSFER_SIZE ? USB_DATA_TRANSFER_SIZE : tx_used); // length of data to be transmitted (respect max packet size)
usb_length = (usb_length > (LENGTH(tx_buffer)-tx_i) ? LENGTH(tx_buffer)-tx_i : usb_length); // since here we use the source array not as ring buffer, only go up to the end
usb_length = (usb_length > (LENGTH(tx_buffer) - tx_i) ? LENGTH(tx_buffer) - tx_i : usb_length); // since here we use the source array not as ring buffer, only go up to the end
usb_length = usbd_ep_write_packet(usb_device, 0x82, (void*)(&tx_buffer[tx_i]), usb_length); // transmit data (put into USB FIFO)
tx_i = (tx_i+usb_length)%LENGTH(tx_buffer); // update location on buffer
tx_i = (tx_i + usb_length)%LENGTH(tx_buffer); // update location on buffer
tx_used -= usb_length; // update used size
tx_lock = false; // release lock
} else {
@ -378,7 +378,7 @@ static void usb_cdcacm_communication_cb(usbd_device *usbd_dev, uint8_t ep)
(void)usbd_dev; // not used
first_connection |= usb_cdcacm_connecting; // check if port has been opened
if (tx_used>0 && first_connection) { // if buffer is not empty
if (tx_used > 0 && first_connection) { // if buffer is not empty
usb_cdcacm_data_tx_cb(NULL, 0); // send available data
}
}