diff --git a/include/mcp2515/mcp2515.cpp b/include/mcp2515/mcp2515.cpp index a62a0b4..f7379e1 100644 --- a/include/mcp2515/mcp2515.cpp +++ b/include/mcp2515/mcp2515.cpp @@ -551,6 +551,17 @@ MCP2515::ERROR MCP2515::setClkOut(const CAN_CLKOUT divisor) return ERROR_OK; } +MCP2515::ERROR MCP2515::setSleepWakeup(const bool enable) +{ + ERROR res = setConfigMode(); + if (res != ERROR_OK) { + return res; + } + + modifyRegister(MCP_CANINTE, 0b01000000, enable * 0xFF); + return ERROR_OK; +} + void MCP2515::prepareId(uint8_t *buffer, const bool ext, const uint32_t id) { uint16_t canid = (uint16_t)(id & 0x0FFFF); diff --git a/include/mcp2515/mcp2515.h b/include/mcp2515/mcp2515.h index 026c8ef..85925d0 100644 --- a/include/mcp2515/mcp2515.h +++ b/include/mcp2515/mcp2515.h @@ -484,6 +484,7 @@ class MCP2515 { ERROR setBitrate(const CAN_SPEED canSpeed, const CAN_CLOCK canClock); ERROR setFilterMask(const MASK num, const bool ext, const uint32_t ulData); ERROR setFilter(const RXF num, const bool ext, const uint32_t ulData); + ERROR setSleepWakeup(const bool enable); ERROR sendMessage(const TXBn txbn, const struct can_frame *frame); ERROR sendMessage(const struct can_frame *frame); ERROR readMessage(const RXBn rxbn, struct can_frame *frame);