Skip to content

Commit 0c4fc22

Browse files
committed
Run the formatter.
1 parent a1faeb2 commit 0c4fc22

File tree

5 files changed

+306
-296
lines changed

5 files changed

+306
-296
lines changed

src/sfTk/sfTkISerial.h

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
/**
22
* @file sfTkISerial.h
33
* @brief Header file for the SparkFun Toolkit Base Serial Interface Definition.
4-
*
4+
*
55
* This file contains the interface declaration for basic serial read/write.
6-
*
6+
*
77
* @author SparkFun Electronics
88
* @date 2025
99
* @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
1010
*
11-
* SPDX-License-Identifier: MIT
11+
* SPDX-License-Identifier: MIT
1212
*/
1313

1414
#pragma once
15+
16+
// clang-format off
1517
#include "sfTkError.h"
1618
#include <cstdint>
19+
// clang-format on
1720

1821
/**
1922
* @brief A base value for serial errors. All serial errors are greater than this value, in the 2000 range
20-
*
23+
*
2124
*/
2225
const sfTkError_t ksfTkErrBaseSerial = 0x2000;
2326

@@ -28,41 +31,40 @@ const sfTkError_t ksfTkErrSerialNotInit = ksfTkErrFail * (ksfTkErrBaseSerial + 1
2831

2932
/**
3033
* @brief Returned when a serial interface times out.
31-
*
34+
*
3235
*/
3336
const sfTkError_t ksfTkErrSerialTimeout = ksfTkErrFail * (ksfTkErrBaseSerial + 2);
3437

3538
/**
3639
* @brief Returned when a serial interface does not respond.
37-
*
40+
*
3841
*/
3942
const sfTkError_t ksfTkErrSerialNoResponse = ksfTkErrFail * (ksfTkErrBaseSerial + 3);
4043

4144
/**
4245
* @brief Returned when the data to be sent is too long or received is too short.
43-
*
46+
*
4447
*/
4548
const sfTkError_t ksfTkErrSerialDataTooLong = ksfTkErrFail * (ksfTkErrBaseSerial + 4);
4649

4750
/**
4851
* @brief Returned when the serial settings are null, invalid, or on set/initialized.
49-
*
52+
*
5053
*/
5154
const sfTkError_t ksfTkErrSerialNullSettings = ksfTkErrFail * (ksfTkErrBaseSerial + 5);
5255

5356
/**
5457
* @brief Returned when the buffer is null or invalid.
55-
*
58+
*
5659
*/
5760
const sfTkError_t ksfTkErrSerialNullBuffer = ksfTkErrFail * (ksfTkErrBaseSerial + 6);
5861

5962
/**
6063
* @brief Returned when the bus is under read. Warning.
61-
*
64+
*
6265
*/
6366
const sfTkError_t ksfTkErrSerialUnderRead = ksfTkErrBaseSerial + 7;
6467

65-
6668
class sfTkISerial
6769
{
6870
public:
@@ -71,7 +73,7 @@ class sfTkISerial
7173

7274
/**
7375
* @brief Writes an array of bytes to the serial interface.
74-
*
76+
*
7577
* @param data The data to write
7678
* @param length The length of the data buffer
7779
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
@@ -80,7 +82,7 @@ class sfTkISerial
8082

8183
/**
8284
* @brief Writes a single byte to the serial interface.
83-
*
85+
*
8486
* @param data The data to write
8587
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
8688
*/
@@ -91,25 +93,24 @@ class sfTkISerial
9193

9294
/**
9395
* @brief Reads an array of bytes from the serial interface
94-
*
96+
*
9597
* @param data The data buffer to read into
9698
* @param length The length of the data buffer
9799
* @param readBytes[out] The number of bytes read
98100
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
99101
*/
100102
virtual sfTkError_t read(uint8_t *data, size_t length, size_t &readBytes) = 0;
101-
103+
102104
/**
103105
* @brief Read a single byte from the serial interface
104-
*
106+
*
105107
* @param data Byte to be read
106108
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
107109
*/
108110
virtual sfTkError_t read(uint8_t &data)
109111
{
110112
size_t nRead;
111-
113+
112114
return read(&data, sizeof(data), nRead);
113115
}
114-
115116
};

src/sfTk/sfTkISerialBus.h

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
/**
22
* @file sfTkISerialBus.h
33
* @brief Header file for the SparkFun Toolkit Base Serial Bus Interface Definition.
4-
*
4+
*
55
* This file contains the interface declaration for connecting sfTkISerial to the sfTkIBus.
6-
*
6+
*
77
* @author SparkFun Electronics
88
* @date 2025
99
* @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
1010
*
11-
* SPDX-License-Identifier: MIT
11+
* SPDX-License-Identifier: MIT
1212
*/
1313

1414
#pragma once
15+
16+
// clang-format off
1517
#include "sfTkError.h"
1618
#include "sfTkIBus.h"
1719
#include "sfTkISerial.h"
1820
#include <cstdint>
21+
// clang-format on
1922

2023
const uint8_t ksfTkBusTypeSerialBus = 0x03;
2124

@@ -24,26 +27,26 @@ class sfTkISerialBus : sfTkIBus
2427
public:
2528
/**
2629
* @brief Constructor for the serial bus
27-
*
30+
*
2831
*/
2932
sfTkISerialBus()
3033
{
3134
}
32-
35+
3336
virtual ~sfTkISerialBus() = default;
3437

3538
/**
3639
* @brief Writes an array of bytes to the serial interface.
37-
*
40+
*
3841
* @param data The data to write
3942
* @param length The length of the data buffer
4043
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
4144
*/
4245
virtual sfTkError_t write(const uint8_t *data, size_t length) = 0;
43-
46+
4447
/**
4548
* @brief Writes an array of bytes to a register on the target address. Supports any address size
46-
*
49+
*
4750
* @param devReg The device's register's address - can be any size, If nullptr, address is not sent
4851
* @param regLength The length of the register address. If 0, address is not sent
4952
* @param data The data to write
@@ -63,7 +66,7 @@ class sfTkISerialBus : sfTkIBus
6366

6467
/**
6568
* @brief Read an array of bytes from the serial interface
66-
*
69+
*
6770
* @param data The data buffer to read into
6871
* @param length The length of the data buffer
6972
* @param readBytes[out] The number of bytes read
@@ -73,15 +76,16 @@ class sfTkISerialBus : sfTkIBus
7376

7477
/**
7578
* @brief Reads an array of bytes to a register on the target address. Supports any address size
76-
*
79+
*
7780
* @param devReg The device's register's address - can be any size
7881
* @param regLength The length of the register address
7982
* @param data The data to buffer to read into
8083
* @param numBytes The length of the data buffer
8184
* @param readBytes[out] The number of bytes read
8285
* @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code
8386
*/
84-
virtual sfTkError_t readRegister(uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, size_t &readBytes) override
87+
virtual sfTkError_t readRegister(uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes,
88+
size_t &readBytes) override
8589
{
8690
// Buffer valid?
8791
if (!data)
@@ -93,7 +97,7 @@ class sfTkISerialBus : sfTkIBus
9397
if (devReg != nullptr && regLength > 0)
9498
retVal = write(devReg, regLength);
9599

96-
if(retVal != ksfTkErrOk)
100+
if (retVal != ksfTkErrOk)
97101
return retVal;
98102

99103
// Read the data.
@@ -104,7 +108,7 @@ class sfTkISerialBus : sfTkIBus
104108

105109
/**
106110
* @brief Get the type of the object
107-
*
111+
*
108112
* @return uint8_t The type of the object
109113
*/
110114
virtual uint8_t type(void) override

0 commit comments

Comments
 (0)