Skip to content

Commit 6a1eb08

Browse files
committed
Reformat source files with clang-format
1 parent 301c226 commit 6a1eb08

File tree

14 files changed

+141
-80
lines changed

14 files changed

+141
-80
lines changed

.clang-format

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -4
5+
ConstructorInitializerIndentWidth: 4
6+
AlignEscapedNewlinesLeft: false
7+
AlignTrailingComments: true
8+
AllowAllParametersOfDeclarationOnNextLine: true
9+
AllowShortBlocksOnASingleLine: false
10+
AllowShortIfStatementsOnASingleLine: false
11+
AllowShortLoopsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: None
13+
AlwaysBreakTemplateDeclarations: true
14+
AlwaysBreakBeforeMultilineStrings: false
15+
BreakBeforeBinaryOperators: false
16+
BreakBeforeTernaryOperators: true
17+
BreakConstructorInitializersBeforeComma: false
18+
BinPackParameters: true
19+
ColumnLimit: 100
20+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
21+
DerivePointerAlignment: false
22+
ExperimentalAutoDetectBinPacking: false
23+
IndentCaseLabels: false
24+
IndentWrappedFunctionNames: false
25+
IndentFunctionDeclarationAfterType: false
26+
MaxEmptyLinesToKeep: 1
27+
KeepEmptyLinesAtTheStartOfBlocks: true
28+
NamespaceIndentation: None
29+
ObjCSpaceAfterProperty: false
30+
ObjCSpaceBeforeProtocolList: true
31+
PenaltyBreakBeforeFirstCallParameter: 19
32+
PenaltyBreakComment: 300
33+
PenaltyBreakString: 1000
34+
PenaltyBreakFirstLessLess: 120
35+
PenaltyExcessCharacter: 1000000
36+
PenaltyReturnTypeOnItsOwnLine: 60
37+
PointerAlignment: Left
38+
SpacesBeforeTrailingComments: 1
39+
Cpp11BracedListStyle: true
40+
Standard: Cpp11
41+
IndentWidth: 4
42+
TabWidth: 8
43+
UseTab: Never
44+
BreakBeforeBraces: Allman
45+
SpacesInParentheses: false
46+
SpacesInAngles: false
47+
SpaceInEmptyParentheses: false
48+
SpacesInCStyleCastParentheses: false
49+
SpacesInContainerLiterals: true
50+
SpaceBeforeAssignmentOperators: true
51+
ContinuationIndentWidth: 4
52+
CommentPragmas: '^ IWYU pragma:'
53+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
54+
SpaceBeforeParens: ControlStatements
55+
DisableFormat: false
56+
...
57+

bootloader/src/core/dfu_usb.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ uint8_t DeviceStatus[6];
4242

4343
/* Extern variables ----------------------------------------------------------*/
4444
/* Private function prototypes -----------------------------------------------*/
45-
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);
45+
static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len);
4646

4747
/* Private functions ---------------------------------------------------------*/
4848

@@ -105,8 +105,8 @@ void Get_SerialNum(void)
105105

106106
if (Device_Serial0 != 0)
107107
{
108-
IntToUnicode (Device_Serial0, &DFU_StringSerial[2] , 8);
109-
IntToUnicode (Device_Serial1, &DFU_StringSerial[18], 4);
108+
IntToUnicode(Device_Serial0, &DFU_StringSerial[2], 8);
109+
IntToUnicode(Device_Serial1, &DFU_StringSerial[18], 4);
110110
}
111111
}
112112

@@ -116,24 +116,24 @@ void Get_SerialNum(void)
116116
* Input : None.
117117
* Return : None.
118118
*******************************************************************************/
119-
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
119+
static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len)
120120
{
121121
uint8_t idx = 0;
122122

123-
for( idx = 0 ; idx < len ; idx ++)
123+
for (idx = 0; idx < len; idx++)
124124
{
125-
if( ((value >> 28)) < 0xA )
125+
if (((value >> 28)) < 0xA)
126126
{
127-
pbuf[ 2* idx] = (value >> 28) + '0';
127+
pbuf[2 * idx] = (value >> 28) + '0';
128128
}
129129
else
130130
{
131-
pbuf[2* idx] = (value >> 28) + 'A' - 10;
131+
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
132132
}
133133

134134
value = value << 4;
135135

136-
pbuf[ 2* idx + 1] = 0;
136+
pbuf[2 * idx + 1] = 0;
137137
}
138138
}
139139

bootloader/src/stm32f2xx/bkpreg_hal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
// pull in the sources from the HAL. It's a bit of a hack, but is simpler than trying to link the full
3-
// hal library.
2+
// pull in the sources from the HAL. It's a bit of a hack, but is simpler than trying to link the
3+
// full hal library.
44
#include "../src/stm32f2xx/bkpreg_hal.c"

bootloader/src/stm32f2xx/dfu_usb.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ void HAL_DFU_USB_Init(void)
6060
{
6161
USBD_Init(&USB_OTG_dev,
6262
#ifdef USE_USB_OTG_FS
63-
USB_OTG_FS_CORE_ID,
63+
USB_OTG_FS_CORE_ID,
6464
#elif defined USE_USB_OTG_HS
65-
USB_OTG_HS_CORE_ID,
65+
USB_OTG_HS_CORE_ID,
6666
#endif
67-
&USR_desc,
68-
&DFU_cb,
69-
NULL); //Passing NULL here to reduce bootloader flash requirements
67+
&USR_desc, &DFU_cb,
68+
NULL); // Passing NULL here to reduce bootloader flash requirements
7069
}
71-

hal/src/core/bkpreg_hal.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44

55
int32_t HAL_Core_Backup_Register(uint32_t BKP_DR)
66
{
7-
switch(BKP_DR)
7+
switch (BKP_DR)
88
{
9-
case BKP_DR_01: return BKP_DR1; break;
10-
case BKP_DR_10: return BKP_DR10; break;
9+
case BKP_DR_01:
10+
return BKP_DR1;
11+
break;
12+
case BKP_DR_10:
13+
return BKP_DR10;
14+
break;
1115
}
1216
return -1;
1317
}
1418

1519
void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
1620
{
1721
uint32_t BKP_DR_Address = HAL_Core_Backup_Register(BKP_DR);
18-
if(BKP_DR_Address != -1)
22+
if (BKP_DR_Address != -1)
1923
{
2024
BKP_WriteBackupRegister(BKP_DR_Address, Data);
2125
}
@@ -24,10 +28,9 @@ void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
2428
uint32_t HAL_Core_Read_Backup_Register(uint32_t BKP_DR)
2529
{
2630
uint32_t BKP_DR_Address = HAL_Core_Backup_Register(BKP_DR);
27-
if(BKP_DR_Address != -1)
31+
if (BKP_DR_Address != -1)
2832
{
2933
return BKP_ReadBackupRegister(BKP_DR_Address);
3034
}
3135
return 0xFFFFFFFF;
3236
}
33-

hal/src/gcc/core_hal.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,9 @@ int HAL_System_Backup_Restore(size_t offset, void* buffer, size_t max_length, si
346346

347347
#endif
348348

349-
350349
int32_t HAL_Core_Backup_Register(uint32_t BKP_DR)
351350
{
352-
return -1;
351+
return -1;
353352
}
354353

355354
void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
@@ -358,6 +357,5 @@ void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
358357

359358
uint32_t HAL_Core_Read_Backup_Register(uint32_t BKP_DR)
360359
{
361-
return 0xFFFFFFFF;
360+
return 0xFFFFFFFF;
362361
}
363-

hal/src/stm32f2xx/bkpreg_hal.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33

44
int32_t HAL_Core_Backup_Register(uint32_t BKP_DR)
55
{
6-
switch(BKP_DR)
6+
switch (BKP_DR)
77
{
8-
case BKP_DR_01: return RTC_BKP_DR1; break;
9-
case BKP_DR_10: return RTC_BKP_DR10; break;
8+
case BKP_DR_01:
9+
return RTC_BKP_DR1;
10+
break;
11+
case BKP_DR_10:
12+
return RTC_BKP_DR10;
13+
break;
1014
}
1115
return -1;
1216
}
1317

1418
void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
1519
{
1620
uint32_t BKP_DR_Address = HAL_Core_Backup_Register(BKP_DR);
17-
if(BKP_DR_Address != -1)
21+
if (BKP_DR_Address != -1)
1822
{
1923
RTC_WriteBackupRegister(BKP_DR_Address, Data);
2024
}
@@ -23,7 +27,7 @@ void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
2327
uint32_t HAL_Core_Read_Backup_Register(uint32_t BKP_DR)
2428
{
2529
uint32_t BKP_DR_Address = HAL_Core_Backup_Register(BKP_DR);
26-
if(BKP_DR_Address != -1)
30+
if (BKP_DR_Address != -1)
2731
{
2832
return RTC_ReadBackupRegister(BKP_DR_Address);
2933
}

hal/src/template/core_hal.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int HAL_Set_System_Config(hal_system_config_t config_item, const void* data, uns
147147

148148
int32_t HAL_Core_Backup_Register(uint32_t BKP_DR)
149149
{
150-
return -1;
150+
return -1;
151151
}
152152

153153
void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
@@ -156,6 +156,5 @@ void HAL_Core_Write_Backup_Register(uint32_t BKP_DR, uint32_t Data)
156156

157157
uint32_t HAL_Core_Read_Backup_Register(uint32_t BKP_DR)
158158
{
159-
return 0xFFFFFFFF;
159+
return 0xFFFFFFFF;
160160
}
161-

system/inc/system_update.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@ typedef enum
102102
*/
103103
SYSTEM_FLAG_RESET_ENABLED,
104104

105-
/**
106-
* A persistent flag that when set will cause the system to startup
107-
* in listening mode if booting in safe mode. The flag is automatically
108-
* cleared on reboot.
109-
*/
110-
SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE,
105+
/**
106+
* A persistent flag that when set will cause the system to startup
107+
* in listening mode if booting in safe mode. The flag is automatically
108+
* cleared on reboot.
109+
*/
110+
SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE,
111111

112112
/**
113113
* When 0, the application code is not paused.
114114
* When 1, the application code is paused.
115115
*/
116-
//SYSTEM_FLAG_APPLICATION_PAUSED=4,
116+
// SYSTEM_FLAG_APPLICATION_PAUSED=4,
117117

118118
SYSTEM_FLAG_MAX
119119

system/inc/system_ymodem.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern "C" {
3030

3131
bool Ymodem_Serial_Flash_Update(Stream *serialObj, FileTransfer::Descriptor& desc, void*);
3232

33-
3433
#ifdef __cplusplus
3534
}
3635
#endif
@@ -40,7 +39,6 @@ class YModem
4039
Stream& stream;
4140

4241
public:
43-
4442
enum protocol_params_t
4543
{
4644
PACKET_SEQNO_INDEX = 1,
@@ -59,16 +57,16 @@ class YModem
5957

6058
enum protocol_msg_t
6159
{
62-
SOH = (0x01), /* start of 128-byte data packet */
63-
STX = (0x02), /* start of 1024-byte data packet */
64-
EOT = (0x04), /* end of transmission */
65-
ACK = (0x06), /* acknowledge */
66-
NAK = (0x15), /* negative acknowledge */
67-
CA = (0x18), /* two of these in succession aborts transfer */
60+
SOH = (0x01), /* start of 128-byte data packet */
61+
STX = (0x02), /* start of 1024-byte data packet */
62+
EOT = (0x04), /* end of transmission */
63+
ACK = (0x06), /* acknowledge */
64+
NAK = (0x15), /* negative acknowledge */
65+
CA = (0x18), /* two of these in succession aborts transfer */
6866
CRC16 = (0x43), /* 'C' == 0x43, request 16-bit CRC */
6967

7068
ABORT1 = (0x41), /* 'A' == 0x41, abort by user */
71-
ABORT2 = (0x61) /* 'a' == 0x61, abort by user */
69+
ABORT2 = (0x61) /* 'a' == 0x61, abort by user */
7270
};
7371

7472
struct file_desc_t
@@ -77,12 +75,12 @@ class YModem
7775
char file_size[FILE_SIZE_LENGTH];
7876
};
7977

80-
YModem(Stream& stream_) : stream(stream_) { }
81-
78+
YModem(Stream& stream_) : stream(stream_)
79+
{
80+
}
8281

8382
int32_t receive_file(FileTransfer::Descriptor& tx, file_desc_t& file_info);
8483

85-
8684
private:
8785
uint8_t packet_data[YModem::PACKET_1K_SIZE + YModem::PACKET_OVERHEAD];
8886
int32_t session_done, file_done, packets_received, errors, session_begin;
@@ -111,11 +109,9 @@ class YModem
111109
//#define CMD_STRING_SIZE 128
112110

113111
int32_t receive_packet(uint8_t* data, int32_t& length, uint32_t timeout);
114-
int32_t handle_packet(uint8_t* packet_data, int32_t packet_length, FileTransfer::Descriptor& tx, file_desc_t& desc);
112+
int32_t handle_packet(uint8_t* packet_data, int32_t packet_length, FileTransfer::Descriptor& tx,
113+
file_desc_t& desc);
115114
void parse_file_packet(FileTransfer::Descriptor& tx, file_desc_t& desc, uint8_t* packet_data);
116-
117115
};
118116

119-
120117
#endif /* SYSTEM_YMODEM_H */
121-

0 commit comments

Comments
 (0)