![]() |
Mbed OS Reference
|
Creates an unlocked CAN interface connected to specific pins. More...
#include <RawCAN.h>
Public Member Functions | |
| CAN (PinName rd, PinName td) | |
| Creates a CAN interface connected to specific pins. | |
| CAN (PinName rd, PinName td, int hz, int data_hz=0) | |
| Initialize CAN interface and set the frequency. | |
| CAN (const can_pinmap_t &pinmap) | |
| Initialize CAN interface. | |
| CAN (const can_pinmap_t &pinmap, int hz, int data_hz=0) | |
| Initialize CAN interface and set the frequency. | |
| int | frequency (int hz, int data_hz=0) |
| Set the frequency of the CAN interface. | |
| int | write (CANMessage msg) |
| Write a CANMessage to the bus. | |
| int | write (CANFDMessage msg) |
| Write a CANFDMessage to the bus. | |
| int | read (CANMessage &msg, int handle=0) |
| Read a CANMessage from the bus. | |
| int | read (CANFDMessage &msg, int handle=0) |
| Read a CANFDMessage from the bus. | |
| void | reset () |
| Reset CAN interface. | |
| void | monitor (bool silent) |
| Puts or removes the CAN interface into silent monitoring mode. | |
| int | mode (Mode mode) |
| Change CAN operation to the specified mode. | |
| int | filter (unsigned int id, unsigned int mask, CANFormat format=CANAny, int handle=0) |
| Filter out incoming messages. | |
| unsigned char | rderror () |
| Detects read errors - Used to detect read overflow errors. | |
| unsigned char | tderror () |
| Detects write errors - Used to detect write overflow errors. | |
| void | attach (Callback< void()> func, IrqType type=IrqType::RxIrq) |
| Attach a function to call whenever a CAN frame received interrupt is generated. | |
Creates an unlocked CAN interface connected to specific pins.
Example:
| CAN | ( | PinName | rd, |
| PinName | td | ||
| ) |
Creates a CAN interface connected to specific pins.
| rd | read from transmitter |
| td | transmit to transmitter |
Example:
| CAN | ( | PinName | rd, |
| PinName | td, | ||
| int | hz, | ||
| int | data_hz = 0 |
||
| ) |
Initialize CAN interface and set the frequency.
| rd | the read pin |
| td | the transmit pin |
| hz | the bus frequency in hertz |
| data_hz | the data frequency in hertz(CAN FD only) |
| CAN | ( | const can_pinmap_t & | pinmap | ) |
Initialize CAN interface.
| pinmap | reference to structure which holds static pinmap |
| CAN | ( | const can_pinmap_t & | pinmap, |
| int | hz, | ||
| int | data_hz = 0 |
||
| ) |
Initialize CAN interface and set the frequency.
| pinmap | reference to structure which holds static pinmap |
| hz | the bus frequency in hertz |
| data_hz | the data frequency in hertz(CAN FD only) |
|
inherited |
Set the frequency of the CAN interface.
| hz | The bus frequency in hertz |
| data_hz | the data frequency in hertz(CAN FD only) |
|
inherited |
Write a CANMessage to the bus.
| msg | The CANMessage to write. |
|
inherited |
Write a CANFDMessage to the bus.
| msg | The CANFDMessage to write. |
|
inherited |
Read a CANMessage from the bus.
| msg | A CANMessage to read to. |
| handle | message filter handle (0 for any message) |
|
inherited |
Read a CANFDMessage from the bus.
| msg | A CANFDMessage to read to. |
| handle | message filter handle (0 for any message) |
|
inherited |
Reset CAN interface.
To use after error overflow.
|
inherited |
Puts or removes the CAN interface into silent monitoring mode.
| silent | boolean indicating whether to go into silent mode or not |
|
inherited |
Change CAN operation to the specified mode.
| mode | The new operation mode (CAN::Normal, CAN::Silent, CAN::LocalTest, CAN::GlobalTest, CAN::SilentTest) |
|
inherited |
Filter out incoming messages.
| id | the id to filter on |
| mask | the mask applied to the id |
| format | format to filter on (Default CANAny) |
| handle | message filter handle (Optional) |
|
inherited |
Detects read errors - Used to detect read overflow errors.
|
inherited |
Detects write errors - Used to detect write overflow errors.
|
inherited |
Attach a function to call whenever a CAN frame received interrupt is generated.
This function locks the deep sleep while a callback is attached
| func | A pointer to a void function, or 0 to set as none |
| type | Which CAN interrupt to attach the member function to (CAN::RxIrq for message received, CAN::TxIrq for transmitted or aborted, CAN::EwIrq for error warning, CAN::DoIrq for data overrun, CAN::WuIrq for wake-up, CAN::EpIrq for error passive, CAN::AlIrq for arbitration lost, CAN::BeIrq for bus error) |