Skip to content

Commit 2fd52af

Browse files
author
Qinghao Shi
committed
apply astyle reformat
1 parent 8ed6943 commit 2fd52af

File tree

26 files changed

+149
-112
lines changed

26 files changed

+149
-112
lines changed

APIs_Drivers/BufferedSerial_echo/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ static DigitalOut led(LED1);
1414
// Create a BufferedSerial object with a default baud rate.
1515
static BufferedSerial serial_port(USBTX, USBRX);
1616

17-
int main(void) {
17+
int main(void)
18+
{
1819
// Set desired properties (9600-8-N-1).
1920
serial_port.set_baud(9600);
2021
serial_port.set_format(

APIs_Drivers/BufferedSerial_printf/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
// Create a BufferedSerial object to be used by the system I/O retarget code.
1313
static BufferedSerial serial_port(TARGET_TX_PIN, TARGET_RX_PIN, 9600);
1414

15-
FileHandle *mbed::mbed_override_console(int fd) {
15+
FileHandle *mbed::mbed_override_console(int fd)
16+
{
1617
return &serial_port;
1718
}
1819

19-
int main(void) {
20+
int main(void)
21+
{
2022
// print to the console using the `serial_port` object.
2123
printf(
2224
"Mbed OS version %d.%d.%d\n",

APIs_Drivers/QSPI/main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static bool mem_ready()
5757
} while ((status_value[0] & BIT_WIP) != 0 && retries);
5858

5959
if ((status_value[0] & BIT_WIP) != 0) {
60-
printf ("mem_ready FALSE: status value = 0x%x\n", (int)status_value[0]);
60+
printf("mem_ready FALSE: status value = 0x%x\n", (int)status_value[0]);
6161
mem_ready = false;
6262
}
6363
return mem_ready;
@@ -138,8 +138,7 @@ static int sector_erase(unsigned int flash_addr)
138138
return -1;
139139
}
140140

141-
if (QSPI_STATUS_OK!= qspi_device.command_transfer(CMD_ERASE, (((int)flash_addr) & 0x00FFF000), NULL, 0, NULL, 0))
142-
{
141+
if (QSPI_STATUS_OK != qspi_device.command_transfer(CMD_ERASE, (((int)flash_addr) & 0x00FFF000), NULL, 0, NULL, 0)) {
143142
printf("Erase failed\n");
144143
return -1;
145144
}
@@ -152,22 +151,23 @@ static int sector_erase(unsigned int flash_addr)
152151
return 0;
153152
}
154153

155-
int main() {
154+
int main()
155+
{
156156
char tx_buf[BUF_SIZE] = { 'h', 'e', 'l', 'l', 'o', '\0' };
157157
char rx_buf[BUF_SIZE] = {0};
158158
size_t buf_len = sizeof(tx_buf);
159159
qspi_status_t result;
160160
uint32_t address = 0x1000;
161161

162162
result = qspi_device.configure_format(QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_SINGLE,
163-
QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
164-
QSPI_CFG_ALT_SIZE_8, QSPI_CFG_BUS_SINGLE, 0);
163+
QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_BUS_SINGLE,
164+
QSPI_CFG_ALT_SIZE_8, QSPI_CFG_BUS_SINGLE, 0);
165165
if (result != QSPI_STATUS_OK) {
166166
printf("Config format failed\n");
167167
}
168168

169169
if (QSPI_STATUS_OK != flash_init()) {
170-
printf ("Init failed\n");
170+
printf("Init failed\n");
171171
return -1;
172172
}
173173

@@ -198,6 +198,6 @@ int main() {
198198
return result;
199199
}
200200

201-
printf ("Data Read = %s\n", rx_buf);
201+
printf("Data Read = %s\n", rx_buf);
202202
return 0;
203203
}

APIs_Drivers/UnbufferedSerial/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ static DigitalOut led(LED1);
1111
// Create a UnbufferedSerial object with a default baud rate.
1212
static UnbufferedSerial serial_port(USBTX, USBRX);
1313

14-
void on_rx_interrupt() {
14+
void on_rx_interrupt()
15+
{
1516
char c;
1617

1718
// Toggle the LED.
@@ -24,7 +25,8 @@ void on_rx_interrupt() {
2425
}
2526
}
2627

27-
int main(void) {
28+
int main(void)
29+
{
2830
// Set desired properties (9600-8-N-1).
2931
serial_port.baud(9600);
3032
serial_port.format(

APIs_RTOS/EventQueue_ex_1/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@ Thread t;
1313
// It's safe to use UnbufferedSerial in ISR context
1414
UnbufferedSerial console(USBTX, USBRX);
1515

16-
void rise_handler(void) {
16+
void rise_handler(void)
17+
{
1718
char buf[64];
1819
sprintf(buf, "rise_handler in context %p\n", ThisThread::get_id());
1920
console.write(buf, strlen(buf));
2021
// Toggle LED
2122
led1 = !led1;
2223
}
2324

24-
void fall_handler(void) {
25+
void fall_handler(void)
26+
{
2527
printf("rise_handler in context %p\n", ThisThread::get_id());
2628
// Toggle LED
2729
led1 = !led1;
2830
}
2931

30-
int main() {
32+
int main()
33+
{
3134
// Start the event queue
3235
t.start(callback(&queue, &EventQueue::dispatch_forever));
3336
printf("Starting in context %p\r\n", ThisThread::get_id());

APIs_RTOS/Kernel_get_ms_count/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ int main()
44
{
55
// 64-bit time doesn't wrap for half a billion years, at least
66
uint64_t now = Kernel::get_ms_count();
7-
7+
88
// wait a while
9-
ThisThread::sleep_for(10);
9+
ThisThread::sleep_for(10);
1010

1111
uint64_t later = Kernel::get_ms_count();
1212

1313
//calculate millisecs elapsed
1414
uint64_t elapsed_ms = later - now;
15-
15+
1616
printf("Elapsed ms: %u \r\n", (uint32_t)elapsed_ms);
1717
}

APIs_RTOS/UserAllocatedEvent_ex_1/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ auto event2 = make_user_allocated_event(handler, 2);
2929
// Creates event bound to the specified event queue
3030
auto event3 = queue.make_user_allocated_event(handler, 3);
3131
auto event4 = queue.make_user_allocated_event(handler, 4);
32-
33-
void handler(int count) {
32+
33+
void handler(int count)
34+
{
3435
printf("UserAllocatedEvent = %d \n", count);
3536
return;
3637
}
37-
38-
void post_events(void)
38+
39+
void post_events(void)
3940
{
4041
// Single instance of user allocated event can be posted only once.
4142
// Event can be posted again if the previous dispatch has finished or event has been canceled.
@@ -64,7 +65,7 @@ void post_events(void)
6465
event4();
6566
}
6667

67-
int main()
68+
int main()
6869
{
6970
printf("*** start ***\n");
7071
Thread event_thread;

APIs_Security/DeviceKey/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int inject_rot_key()
3333
memset(key, 0, DEVICE_KEY_16BYTE);
3434
memcpy(key, "ABCDEF1234567890", DEVICE_KEY_16BYTE);
3535
int size = DEVICE_KEY_16BYTE;
36-
DeviceKey& devkey = DeviceKey::get_instance();
36+
DeviceKey &devkey = DeviceKey::get_instance();
3737
return devkey.device_inject_root_of_trust(key, size);
3838
}
3939

@@ -47,7 +47,7 @@ int main()
4747
printf("\nMbed OS DeviceKey example \n");
4848

4949
// DeviceKey is a singleton
50-
DeviceKey& devkey = DeviceKey::get_instance();
50+
DeviceKey &devkey = DeviceKey::get_instance();
5151

5252
#if !defined(DEVICE_TRNG)
5353

@@ -59,7 +59,7 @@ int main()
5959
return -1;
6060
}
6161

62-
if ( DEVICEKEY_ALREADY_EXIST == ret ) {
62+
if (DEVICEKEY_ALREADY_EXIST == ret) {
6363
printf("ROT Key already exists in the persistent memory.\n", ret);
6464
} else {
6565
printf("ROT Key injected and stored in persistent memory.\n", ret);

APIs_Storage/BlockDevice/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <stdio.h>
1919
#include <algorithm>
2020

21-
// This takes the system's default block device.
21+
// This takes the system's default block device.
2222
BlockDevice *bd = BlockDevice::get_default_instance();
2323

2424
// Instead of the default block device, you can define your own block device.
@@ -27,7 +27,8 @@ BlockDevice *bd = BlockDevice::get_default_instance();
2727
// BlockDevice *bd = new HeapBlockDevice(2048, 1, 1, 512);
2828

2929
// Entry point for the example:
30-
int main() {
30+
int main()
31+
{
3132
printf("--- Mbed OS block device example ---\n");
3233

3334
// Initialize the block device.
@@ -51,7 +52,7 @@ int main() {
5152
// Allocate a block with enough space for our data, aligned to the
5253
// nearest program_size. This is the minimum size necessary to write
5354
// data to a block.
54-
size_t buffer_size = sizeof("Hello Storage!") + program_size-1;
55+
size_t buffer_size = sizeof("Hello Storage!") + program_size - 1;
5556
buffer_size = buffer_size - (buffer_size % program_size);
5657
char *buffer = new char[buffer_size];
5758

@@ -80,8 +81,8 @@ int main() {
8081
printf("--- Stored data ---\n");
8182
for (size_t i = 0; i < buffer_size; i += 16) {
8283
for (size_t j = 0; j < 16; j++) {
83-
if (i+j < buffer_size) {
84-
printf("%02x ", buffer[i+j]);
84+
if (i + j < buffer_size) {
85+
printf("%02x ", buffer[i + j]);
8586
} else {
8687
printf(" ");
8788
}

APIs_Storage/BufferedBlockDevice/main.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@
2020

2121
int main()
2222
{
23-
// Define a HeapBlockDevice with program size 512 bytes and read size 256
24-
HeapBlockDevice heap_bd(1024, 256, 512, 512);
25-
// BufferedBlockDevice is used to program or read a much smaller amount of data than the minimum program or read size supported by the underlying block device
26-
BufferedBlockDevice buf_bd(&heap_bd);
27-
28-
// This initializes the buffered block device (as well as the underlying heap block device)
29-
int err = buf_bd.init();
30-
31-
uint8_t buf[8];
32-
for (uint8_t i = 0; i < sizeof(buf); i++) {
33-
buf[i] = i;
34-
}
35-
36-
// Now we can program an 8-byte buffer (we couldn't do that in the underlying block device, which had a 512-byte program size)
37-
err = buf_bd.program(buf, 0, sizeof(buf));
38-
39-
40-
// Now read any amount of data from any address (for example, the last three bytes of data from address 5)
41-
memset(buf,0,8);
42-
err = buf_bd.read(buf, 5, 3);
43-
44-
printf("Read Data (Expected 5,6,7): %d %d %d\n", (int)(buf[0]), (int)(buf[1]), (int)(buf[2]));
45-
46-
// Ensure programmed data is flushed to the underlying block device
47-
err = buf_bd.sync();
48-
49-
// Finally, deinint the BufferedBlockDevice (which also deinits its underlying block device)
50-
err = buf_bd.deinit();
23+
// Define a HeapBlockDevice with program size 512 bytes and read size 256
24+
HeapBlockDevice heap_bd(1024, 256, 512, 512);
25+
// BufferedBlockDevice is used to program or read a much smaller amount of data than the minimum program or read size supported by the underlying block device
26+
BufferedBlockDevice buf_bd(&heap_bd);
27+
28+
// This initializes the buffered block device (as well as the underlying heap block device)
29+
int err = buf_bd.init();
30+
31+
uint8_t buf[8];
32+
for (uint8_t i = 0; i < sizeof(buf); i++) {
33+
buf[i] = i;
34+
}
35+
36+
// Now we can program an 8-byte buffer (we couldn't do that in the underlying block device, which had a 512-byte program size)
37+
err = buf_bd.program(buf, 0, sizeof(buf));
38+
39+
40+
// Now read any amount of data from any address (for example, the last three bytes of data from address 5)
41+
memset(buf, 0, 8);
42+
err = buf_bd.read(buf, 5, 3);
43+
44+
printf("Read Data (Expected 5,6,7): %d %d %d\n", (int)(buf[0]), (int)(buf[1]), (int)(buf[2]));
45+
46+
// Ensure programmed data is flushed to the underlying block device
47+
err = buf_bd.sync();
48+
49+
// Finally, deinint the BufferedBlockDevice (which also deinits its underlying block device)
50+
err = buf_bd.deinit();
5151
}

APIs_Storage/FlashIAPBlockDevice/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// Create flash IAP block device
55
FlashIAPBlockDevice bd;
66

7-
int main() {
7+
int main()
8+
{
89
printf("FlashIAPBlockDevice test\n");
910

1011
// Initialize the flash IAP block device and print the memory layout
@@ -15,7 +16,7 @@ int main() {
1516
printf("Flash block device erase size: %llu\n", bd.get_erase_size());
1617

1718
// Write "Hello World!" to the first block
18-
char *buffer = (char*)malloc(bd.get_erase_size());
19+
char *buffer = (char *)malloc(bd.get_erase_size());
1920
sprintf(buffer, "Hello World!\n");
2021
bd.erase(0, bd.get_erase_size());
2122
bd.program(buffer, 0, bd.get_erase_size());

APIs_Storage/FlashSimBlockDevice/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes.
2424
uint8_t block[BLOCK_SIZE] = "Hello World!\n";
2525

26-
int main() {
26+
int main()
27+
{
2728

2829
int erase_unit_size = 512;
2930
HeapBlockDevice heap_bd(4 * erase_unit_size, 1, 4, erase_unit_size);

APIs_Storage/MBRBlockDevice_ex_1/main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
#include "HeapBlockDevice.h"
33
#include "MBRBlockDevice.h"
44

5-
int main(void) {
5+
int main(void)
6+
{
67
// Create a block device with 64 blocks of size 512
78
printf("Create a block device with 64 blocks of size 512\n");
8-
HeapBlockDevice mem(64*512, 512);
9+
HeapBlockDevice mem(64 * 512, 512);
910

1011
// Partition into two partitions with ~half the blocks
1112
printf("Partition into two partitions with ~half the blocks\n");
12-
MBRBlockDevice::partition(&mem, 1, 0x83, 0*512, 32*512);
13-
MBRBlockDevice::partition(&mem, 2, 0x83, 32*512);
13+
MBRBlockDevice::partition(&mem, 1, 0x83, 0 * 512, 32 * 512);
14+
MBRBlockDevice::partition(&mem, 2, 0x83, 32 * 512);
1415

1516
// Create a block device that maps to the first 32 blocks (excluding MBR block)
1617
printf("Create a block device that maps to the first 32 blocks (excluding MBR block)\n");

APIs_Storage/MBRBlockDevice_ex_2/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
#include "MBRBlockDevice.h"
44
#include "FATFileSystem.h"
55

6-
int main(void) {
6+
int main(void)
7+
{
78
// Create an SD card
89
printf("Creating SD block device\n");
910
SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
1011

1112
// Create a partition with 1 GB of space
1213
printf("Creating a partition with 1GB of space\n");
13-
MBRBlockDevice::partition(&sd, 1, 0x83, 0, 1024*1024);
14+
MBRBlockDevice::partition(&sd, 1, 0x83, 0, 1024 * 1024);
1415

1516
// Create the block device that represents the partition
1617
printf("Create the block device that represents the partition\n");

APIs_Storage/ProfilingBlockDevice/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes
88
uint8_t block[BLOCK_SIZE] = "Hello World!\n";
99

10-
int main() {
10+
int main()
11+
{
1112
ProfilingBlockDevice profiler(&bd);
1213
profiler.init();
1314
profiler.erase(0, BLOCK_SIZE);

0 commit comments

Comments
 (0)