Skip to content

Commit c6f535a

Browse files
author
Anton N
committed
Replace CAN clock defines with enum
1 parent 323c27e commit c6f535a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

mcp2515.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ MCP2515::ERROR MCP2515::setMode(const CANCTRL_REQOP_MODE mode)
183183

184184
}
185185

186-
MCP2515::ERROR MCP2515::setBitrate(const CAN_SPEED canSpeed, uint8_t canClock)
186+
MCP2515::ERROR MCP2515::setBitrate(const CAN_SPEED canSpeed, CAN_CLOCK canClock)
187187
{
188188
ERROR error = setConfigMode();
189189
if (error != ERROR_OK) {

mcp2515.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@
157157
#define MCP_20MHz_40kBPS_CFG2 (0xFF)
158158
#define MCP_20MHz_40kBPS_CFG3 (0x87)
159159

160-
#define MCP_20MHZ 0
161-
#define MCP_16MHZ 1
162-
#define MCP_8MHZ 2
160+
enum CAN_CLOCK {
161+
MCP_20MHZ,
162+
MCP_16MHZ,
163+
MCP_8MHZ
164+
};
163165

164166
enum CAN_SPEED {
165167
CAN_5KBPS,
@@ -439,7 +441,7 @@ class MCP2515
439441
ERROR setSleepMode();
440442
ERROR setLoopbackMode();
441443
ERROR setNormalMode();
442-
ERROR setBitrate(const CAN_SPEED canSpeed, const uint8_t canClock);
444+
ERROR setBitrate(const CAN_SPEED canSpeed, const CAN_CLOCK canClock);
443445
ERROR setFilterMask(const MASK num, const bool ext, const uint32_t ulData);
444446
ERROR setFilter(const RXF num, const bool ext, const uint32_t ulData);
445447
ERROR sendMessage(const TXBn txbn, const struct can_frame *frame);

0 commit comments

Comments
 (0)