Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion FlexCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ void FlexCAN::setFilter(const CAN_filter_t &filter, uint8_t n)
}
}

// -------------------------------------------------------------
void FlexCAN::enableListenOnlyMode(void)
{
FLEXCAN0_CTRL1 |= FLEXCAN_CTRL_LOM;
}

// -------------------------------------------------------------
void FlexCAN::disableListenOnlyMode(void)
{
FLEXCAN0_CTRL1 &= ~FLEXCAN_CTRL_LOM;
}

// -------------------------------------------------------------
int FlexCAN::available(void)
Expand Down Expand Up @@ -223,4 +234,3 @@ int FlexCAN::write(const CAN_message_t &msg)

return 1;
}

2 changes: 2 additions & 0 deletions FlexCAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class FlexCAN
begin(defaultMask);
}
void setFilter(const CAN_filter_t &filter, uint8_t n);
void enableListenOnlyMode(void);
void disableListenOnlyMode(void);
void end(void);
int available(void);
int write(const CAN_message_t &msg);
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ Enable the CAN to start actively participating on the CANbus. Enable reception
**setFilter(filter, number)**
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.

**enableListenOnlyMode()**
Enable the listen only mode. Can only be set before calling begin() or after end().
In this mode, transmission is disabled, all error counters are frozen and the module
operates in a CAN Error Passive mode. Only messages acknowledged by another
CAN station will be received.

**disableListenOnlyMode()**
Disable the listen only mode. Can only be set before calling begin() or after end().

The mask and filter are **CAN_filter_t** type structures.

###Caller Blocking Support
Expand All @@ -59,4 +68,3 @@ The timeout monitoring mechanism calls **yield()** until a buffer is found or th

###In-order Transmission
Caller blocking can be used to **write()** frames guaranteed in-order to the bus. When caller blocking is selected for **write()** (non-zero timeout specified), a single hardware transmit buffer is used.

3 changes: 2 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ FlexCAN KEYWORD1

begin KEYWORD2
setFilter KEYWORD2
enableListenOnlyMode KEYWORD2
disableListenOnlyMode KEYWORD2
end KEYWORD2
read KEYWORD2
write KEYWORD2
available KEYWORD2

CAN_message_t KEYWORD1
CAN_filter_t KEYWORD1