Skip to content

Commit 0d0411a

Browse files
committed
Note on inline functions, formatting
1 parent 3494b06 commit 0d0411a

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

lib/MCP23008T/MCP23008T.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@
88
* @brief Class to interface with the MCP23008T I2C 8-Bit I/O Expander
99
* @see
1010
* https://www.digikey.com/en/products/detail/microchip-technology/MCP23008T-E-SS/736037
11+
* @details Implementation note - Most of these simple functions/methods are
12+
* marked inline, as I think it makes since to inline them. Not sure if it
13+
* helps much, and some of these functions may even default to inlined,
14+
* especially at higher optimization levels, like we tend ot use..
15+
* @see
16+
* https://stackoverflow.com/questions/1932311/when-to-use-the-inline-function-and-when-not-to-use-it
17+
* @see
18+
* https://stackoverflow.com/questions/145838/what-are-the-benefits-of-inline-functions
19+
* @see https://isocpp.org/wiki/faq/inline-functions
20+
* @see http://www.gotw.ca/gotw/033.htm
21+
* @see
22+
* https://web.archive.org/web/20221012105337/http://www.drdobbs.com/to-inline-or-not-to-inline/184405660
23+
* @details Implementation note - constexpr, inline, & static and replacing
24+
* #define for type safety
25+
* @see https://en.cppreference.com/w/cpp/language/constexpr.html
26+
* @see
27+
* https://www.geeksforgeeks.org/cpp/understanding-constexper-specifier-in-cpp/
28+
* @see
29+
* https://collab.dvb.bayern/download/attachments/63265333/Riedel%20report%20-%20Constexpr%20and%20Inline%20Variables%20in%20C%2B%2B17.pdf?version=1&modificationDate=1532345169027&api=v2
1130
*/
1231
class MCP23008T {
1332
public:
@@ -28,7 +47,7 @@ class MCP23008T {
2847
/**
2948
* Valid addresses are 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, & 0x4E
3049
*/
31-
enum I2C_ADDRESS: uint8_t {
50+
enum I2C_ADDRESS : uint8_t {
3251
I2C_ADDR_0x40 = 0x40,
3352
I2C_ADDR_0x42 = 0x42,
3453
I2C_ADDR_0x44 = 0x44,
@@ -39,7 +58,8 @@ class MCP23008T {
3958
I2C_ADDR_0x4E = 0x4E
4059
};
4160

42-
MCP23008T(I2C_ADDRESS address = I2C_ADDR_0x40, TwoWire *wire = &Wire) : device(address, wire) {}
61+
MCP23008T(I2C_ADDRESS address = I2C_ADDR_0x40, TwoWire *wire = &Wire)
62+
: device(address, wire) {}
4363

4464
bool begin() {
4565
if (!device.begin()) {

0 commit comments

Comments
 (0)