Skip to content

Commit cc54148

Browse files
committed
Add support for listen only mode
1 parent 3a2caf2 commit cc54148

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

FlexCAN.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ void FlexCAN::setFilter(const CAN_filter_t &filter, uint8_t n)
115115
}
116116
}
117117

118+
// -------------------------------------------------------------
119+
void FlexCAN::setListenOnlyMode(void)
120+
{
121+
FLEXCAN0_CTRL1 |= FLEXCAN_CTRL_LOM;
122+
}
118123

119124
// -------------------------------------------------------------
120125
int FlexCAN::available(void)

FlexCAN.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class FlexCAN
3535
begin(defaultMask);
3636
}
3737
void setFilter(const CAN_filter_t &filter, uint8_t n);
38+
void setListenOnlyMode(void);
3839
void end(void);
3940
int available(void);
4041
int write(const CAN_message_t &msg);

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ Enable the CAN to start actively participating on the CANbus. Enable reception
4646
**setFilter(filter, number)**
4747
Set the receive filter selected by number, 0-7. When using filters it is required to set them all. If the application uses less than 8 filters, duplicate one filter for the unused ones.
4848

49+
**setListenOnlyMode()**
50+
Enable the listen only mode. Can only be set before calling begin() or after end().
51+
In this mode, transmission is disabled, all error counters are frozen and the module
52+
operates in a CAN Error Passive mode. Only messages acknowledged by another
53+
CAN station will be received.
54+
4955
The mask and filter are **CAN_filter_t** type structures.
5056

5157
###Caller Blocking Support

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FlexCAN KEYWORD1
22

33
begin KEYWORD2
44
setFilter KEYWORD2
5+
setListenOnlyMode KEYWORD2
56
end KEYWORD2
67
read KEYWORD2
78
write KEYWORD2

0 commit comments

Comments
 (0)