Author
|
Matrix Ltd
|
Version
|
2.10
|
Category
|
Comms: Interface
|
CAN (Internal, MCP2515) component
Low level routines for controling the CAN interface either using an external MCP2515 IC and a SPI bus connection or using an internal CAN peripheral if available on your device. Both methods will require a CAN driver IC like the MCP2551 to drive the CAN signals on the bus.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_CAN.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_CAN.fcfx
Detailed description
No detailed description exists yet for this component
Examples
No additional examples
Macro reference
|
ReadSwitches
|
Returns switch input states from the external MCP2515 device. 0 = No Switch Pressed, 1 = Switch 1 Pressed, 2 = Switch 2 Pressed, 3 = Both Pressed (External CAN only)
|
- BYTE
|
Return
|
|
SetTxData
|
Assigns one of the outgoing transmit buffers with data ready to be sent.
|
- BYTE
|
Buffer
|
|
- BYTE
|
Count
|
|
- BYTE
|
d0
|
|
- BYTE
|
d1
|
|
- BYTE
|
d2
|
|
- BYTE
|
d3
|
|
- BYTE
|
d4
|
|
- BYTE
|
d5
|
|
- BYTE
|
d6
|
|
- BYTE
|
d7
|
|
- VOID
|
Return
|
|
SetRxMask
|
Allows the receive ID mask to be configured on the fly allowing different ID ranges to be received.
|
- BYTE
|
Mask
|
Specifies which receive mask to modify. Range: 0-1
|
- ULONG
|
ID
|
The ID mask value you wish to use
|
- VOID
|
Return
|
|
GetRxData
|
Returns last received message data byte at position Index. Buffer parameter is currently ignored
|
- BYTE
|
Buffer
|
|
- BYTE
|
Index
|
|
- BYTE
|
Return
|
|
GetRxIDHi
|
Gets the Hi byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,
|
- BYTE
|
Buffer
|
Receive Buffer. Range 0-1
|
- BYTE
|
Return
|
|
SetTxIDSimple
|
Set the Tx CAN ID as a generic number. Standard IDs only 0-2047.
|
- BYTE
|
Buffer
|
Transmit buffer to load. Range: 0-2
|
- UINT
|
ID
|
The ID value you wish to use. Range: 0-2047
|
- VOID
|
Return
|
|
SendBuffer
|
Transmits one of the transmit buffers which should have already been populated with an ID and data.
|
- BYTE
|
Buffer
|
Specifies which transmit buffer to send
|
- VOID
|
Return
|
|
GetRxDataCount
|
Returns last received message data length. Buffer parameter is currently ignored
|
- BYTE
|
Buffer
|
|
- BYTE
|
Return
|
|
SetRxFilterID
|
sets the Filter Standard mode only (for V5 compatibility only)
|
- BYTE
|
Filter
|
Specifies which filter to modify. Range: 0-5
|
- BYTE
|
Hi
|
ID bits 3-10
|
- BYTE
|
Lo
|
ID bits 0-2 stored in the upper 3 bits of the byte
|
- VOID
|
Return
|
|
GetRxIDLo
|
Gets the Lo byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,
|
- BYTE
|
Buffer
|
|
- BYTE
|
Return
|
|
SetRxMaskID
|
set the Mask Standard ID mode only (for V5 compatibility)
|
- BYTE
|
Mask
|
Specifies which receive mask to modify. Range: 0-1
|
- BYTE
|
Hi
|
ID bits 3-10
|
- BYTE
|
Lo
|
ID bits 0-2 stored in the upper 3 bits of the byte
|
- VOID
|
Return
|
|
SetRxFilter
|
Allows the receive ID filter to be configured on the fly allowing different ID ranges to be received.
|
- BYTE
|
Filter
|
Specifies which receive filter to modify. Range: 0-5
|
- ULONG
|
ID
|
The ID filter value you wish to use
|
- VOID
|
Return
|
|
SetTxIdent
|
Set the Tx CAN ID as a generic number. Standard and extended IDs Standard 0-2047 Extended 2048-536870911
|
- BYTE
|
Buffer
|
Transmit buffer to load. Range: 0-2
|
- ULONG
|
ID
|
The ID or Extended ID value you wish to use. Range: 0-536870911
|
- VOID
|
Return
|
|
CheckRx
|
Checks to see if any messages are available for 'Buffer' specified
|
- BYTE
|
Buffer
|
Send buffer: 0 to 1
|
- BYTE
|
Return
|
|
ChangeRate
|
Simple attempt to alter the bus rate of the CAN. External CAN channels only,
|
- BYTE
|
Rate
|
Rate: 0-3 where 0=125, 1=250, 2=500, 3=1000
|
- VOID
|
Return
|
|
GetRxIDSimple
|
Gets the Rx ID as a Integer Standard ID only 0-2047.
|
- BYTE
|
Buffer
|
Receive Buffer. Range 0-1
|
- UINT
|
Return
|
|
SetTxID
|
Set the Tx CAN ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,
|
- BYTE
|
Buffer
|
Transmit buffer to load. Range: 0-2
|
- BYTE
|
Hi
|
ID bits 3-10 e.g. ((ID & 0x7F8) >> 3)
|
- BYTE
|
Lo
|
ID bits 0-2 stored in the upper 3 bits of the byte e.g. ((ID & 0x7) << 5)
|
- VOID
|
Return
|
|
ShowLEDs
|
Set LED state (External CAN only)
|
- BYTE
|
led1
|
Controls LED 1. Range: 0-1
|
- BYTE
|
led2
|
Controls LED 2. Range: 0-1
|
- VOID
|
Return
|
|
GetRxIdent
|
Gets the Rx ID as a Integer Standard and Extended IDs.
|
- BYTE
|
Buffer
|
|
- ULONG
|
Return
|
|
Initialise
|
Must be called before any other CAN component macros to enable and initialise the CAN peripheral.
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
Channel
|
Switches between Internal CAN peripheral and External CAN controller IC MCP2515.
|
|
Controller Osc
|
|
|
Bus Rate
|
Data rate of the bus specified in thousand bits per second, Kbps.
|
|
Sync Jump Width
|
Defines how far a resyncronisation may move the sample point
|
|
Sample Point
|
Point in each bit period where the incoming data is sampled.
|
|
ID Type
|
Switches between using Standard, or Standard and Extended CAN
|
|
One Shot Mode
|
Disabled. Messages will reattempt transmission Enabled. Message will only attempt to transmit once
|
|
Connections
|
|
SPI
|
|
CHANNEL
|
SPI Channel selector
|
|
MOSI
|
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
|
|
MISO
|
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
|
|
CLK
|
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
|
|
SS
|
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.
|
|
Prescale
|
Prescale option selector
|
|
Sample Point
|
Data bit read sample point
|
|
Config Delay
|
|
|
TX Buffer 0
|
|
Message ID
|
TX Buffer 0 Message Identifier
|
|
Length
|
TX Buffer 0 Number of data bytes
|
|
D0
|
TX Buffer 0 Data Byte 0
|
|
D1
|
TX Buffer 0 Data Byte 1
|
|
D2
|
TX Buffer 0 Data Byte 2
|
|
D3
|
TX Buffer 0 Data Byte 3
|
|
D4
|
TX Buffer 0 Data Byte 4
|
|
D5
|
TX Buffer 0 Data Byte 5
|
|
D6
|
TX Buffer 0 Data Byte 6
|
|
D7
|
TX Buffer 0 Data Byte 7
|
|
TX Buffer 1
|
|
Message ID
|
TX Buffer 1 Message Identifier
|
|
Length
|
TX Buffer 1 Number of data bytes
|
|
D0
|
TX Buffer 1 Data Byte 0
|
|
D1
|
TX Buffer 1 Data Byte 1
|
|
D2
|
TX Buffer 1 Data Byte 2
|
|
D3
|
TX Buffer 1 Data Byte 3
|
|
D4
|
TX Buffer 1 Data Byte 4
|
|
D5
|
TX Buffer 1 Data Byte 5
|
|
D6
|
TX Buffer 1 Data Byte 6
|
|
D7
|
TX Buffer 1 Data Byte 7
|
|
TX Buffer 2
|
|
Message ID
|
TX Buffer 2 Message Identifier
|
|
Length
|
TX Buffer 2 Number of data bytes
|
|
D0
|
TX Buffer 2 Data Byte 0
|
|
D1
|
TX Buffer 2 Data Byte 1
|
|
D2
|
TX Buffer 2 Data Byte 2
|
|
D3
|
TX Buffer 2 Data Byte 3
|
|
D4
|
TX Buffer 2 Data Byte 4
|
|
D5
|
TX Buffer 2 Data Byte 5
|
|
D6
|
TX Buffer 2 Data Byte 6
|
|
D7
|
TX Buffer 2 Data Byte 7
|
|
RX Buffer 0
|
|
Settings
|
RX Buffer 0 Message Receive Mode
|
|
RX Buffer 1
|
|
Settings
|
RX Buffer 1 Message Receive Mode
|
|
Simulation
|
|
Label
|
Comms Flasher Identification Label
|
|
Simulate SPI Comms
|
|