Skip to content

Commit e3b6a34

Browse files
Nicoobra
authored andcommitted
Visual Studio auto format
I will hit auto format later anyways, so i will do it here to get the nor relevant change first. Doing this with the 2013 version by the way.
1 parent fcdddd8 commit e3b6a34

File tree

7 files changed

+305
-299
lines changed

7 files changed

+305
-299
lines changed

plugins/KeyboardioHID/CDC.cpp

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

22

3-
/* Copyright (c) 2011, Peter Barrett
4-
**
5-
** Permission to use, copy, modify, and/or distribute this software for
6-
** any purpose with or without fee is hereby granted, provided that the
7-
** above copyright notice and this permission notice appear in all copies.
8-
**
9-
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10-
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11-
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
12-
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
13-
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
14-
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
15-
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16-
** SOFTWARE.
3+
/* Copyright (c) 2011, Peter Barrett
4+
**
5+
** Permission to use, copy, modify, and/or distribute this software for
6+
** any purpose with or without fee is hereby granted, provided that the
7+
** above copyright notice and this permission notice appear in all copies.
8+
**
9+
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10+
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11+
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
12+
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
13+
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
14+
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
15+
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16+
** SOFTWARE.
1717
*/
1818

1919
#include "USBAPI.h"
@@ -38,26 +38,26 @@ static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
3838
extern const CDCDescriptor _cdcInterface PROGMEM;
3939
const CDCDescriptor _cdcInterface =
4040
{
41-
D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),
41+
D_IAD(0, 2, CDC_COMMUNICATION_INTERFACE_CLASS, CDC_ABSTRACT_CONTROL_MODEL, 1),
4242

4343
// CDC communication interface
44-
D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
45-
D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd)
46-
D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not)
47-
D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
48-
D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0
49-
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),
44+
D_INTERFACE(CDC_ACM_INTERFACE, 1, CDC_COMMUNICATION_INTERFACE_CLASS, CDC_ABSTRACT_CONTROL_MODEL, 0),
45+
D_CDCCS(CDC_HEADER, 0x10, 0x01), // Header (1.10 bcd)
46+
D_CDCCS(CDC_CALL_MANAGEMENT, 1, 1), // Device handles call management (not)
47+
D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT, 6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
48+
D_CDCCS(CDC_UNION, CDC_ACM_INTERFACE, CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0
49+
D_ENDPOINT(USB_ENDPOINT_IN(CDC_ENDPOINT_ACM), USB_ENDPOINT_TYPE_INTERRUPT, 0x10, 0x40),
5050

5151
// CDC data interface
52-
D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
53-
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
54-
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
52+
D_INTERFACE(CDC_DATA_INTERFACE, 2, CDC_DATA_INTERFACE_CLASS, 0, 0),
53+
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT), USB_ENDPOINT_TYPE_BULK, 0x40, 0),
54+
D_ENDPOINT(USB_ENDPOINT_IN(CDC_ENDPOINT_IN), USB_ENDPOINT_TYPE_BULK, 0x40, 0)
5555
};
5656

5757
int WEAK CDC_GetInterface(u8* interfaceNum)
5858
{
5959
interfaceNum[0] += 2; // uses 2
60-
return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface));
60+
return USB_SendControl(TRANSFER_PGM, &_cdcInterface, sizeof(_cdcInterface));
6161
}
6262

6363
bool WEAK CDC_Setup(Setup& setup)
@@ -69,7 +69,7 @@ bool WEAK CDC_Setup(Setup& setup)
6969
{
7070
if (CDC_GET_LINE_CODING == r)
7171
{
72-
USB_SendControl(0,(void*)&_usbLineInfo,7);
72+
USB_SendControl(0, (void*)&_usbLineInfo, 7);
7373
return true;
7474
}
7575
}
@@ -78,7 +78,7 @@ bool WEAK CDC_Setup(Setup& setup)
7878
{
7979
if (CDC_SET_LINE_CODING == r)
8080
{
81-
USB_RecvControl((void*)&_usbLineInfo,7);
81+
USB_RecvControl((void*)&_usbLineInfo, 7);
8282
}
8383

8484
if (CDC_SET_CONTROL_LINE_STATE == r)
@@ -168,20 +168,21 @@ size_t Serial_::write(uint8_t c)
168168

169169
size_t Serial_::write(const uint8_t *buffer, size_t size)
170170
{
171-
/* only try to send bytes if the high-level CDC connection itself
171+
/* only try to send bytes if the high-level CDC connection itself
172172
is open (not just the pipe) - the OS should set lineState when the port
173173
is opened and clear lineState when the port is closed.
174174
bytes sent before the user opens the connection or after
175175
the connection is closed are lost - just like with a UART. */
176-
176+
177177
// TODO - ZE - check behavior on different OSes and test what happens if an
178178
// open connection isn't broken cleanly (cable is yanked out, host dies
179179
// or locks up, or host virtual serial port hangs)
180180
if (_usbLineInfo.lineState > 0) {
181-
int r = USB_Send(CDC_TX,buffer,size);
181+
int r = USB_Send(CDC_TX, buffer, size);
182182
if (r > 0) {
183183
return r;
184-
} else {
184+
}
185+
else {
185186
setWriteError();
186187
return 0;
187188
}
@@ -199,7 +200,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
199200
// where the port is configured (lineState != 0) but not quite opened.
200201
Serial_::operator bool() {
201202
bool result = false;
202-
if (_usbLineInfo.lineState > 0)
203+
if (_usbLineInfo.lineState > 0)
203204
result = true;
204205
delay(10);
205206
return result;

0 commit comments

Comments
 (0)