Component: CAN (Internal, MCP2515) (Comms: Interface)

From Flowcode Help
Revision as of 15:45, 20 July 2016 by BenR (talk | contribs) (XML import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


Author Matrix Ltd
Version 2.0 (Release)
Category Comms: Interface


Image 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.

Examples

No additional examples


Downloadable 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)

Parameters

This macro has no parameters


Return value

BYTE


SetTxData

Assigns one of the outgoing transmit buffers with data ready to be sent.

Parameters

BYTE Buffer
BYTE Count
BYTE d0
BYTE d1
BYTE d2
BYTE d3
BYTE d4
BYTE d5
BYTE d6
BYTE d7


Return value

This call does not return a value


SetRxMask

Allows the receive ID mask to be configured on the fly allowing different ID ranges to be received.

Parameters

BYTE Mask
Specifies which receive mask to modify. Range: 0-1
ULONG ID
The ID mask value you wish to use


Return value

This call does not return a value


GetRxData

Returns last received message data byte at position Index.

Buffer parameter is currently ignored

Parameters

BYTE Buffer
BYTE Index


Return value

BYTE


GetRxIDHi

Gets the Hi byte Rx ID in register format.

Standard ID only 0-2047.

Compatible with v5 component and previous,

Parameters

BYTE Buffer
Receive Buffer. Range 0-1


Return value

BYTE


SetTxIDSimple

Set the Tx CAN ID as a generic number.

Standard IDs only 0-2047.

Parameters

BYTE Buffer
Transmit buffer to load. Range: 0-2
UINT ID
The ID value you wish to use. Range: 0-2047


Return value

This call does not return a value


SendBuffer

Transmits one of the transmit buffers which should have already been populated with an ID and data.

Parameters

BYTE Buffer
Specifies which transmit buffer to send


Return value

This call does not return a value


GetRxDataCount

Returns last received message data length.

Buffer parameter is currently ignored

Parameters

BYTE Buffer


Return value

BYTE


SetRxFilterID

sets the Filter

Standard mode only

(for V5 compatibility only)

Parameters

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


Return value

This call does not return a value


GetRxIDLo

Gets the Lo byte Rx ID in register format.

Standard ID only 0-2047.

Compatible with v5 component and previous,

Parameters

BYTE Buffer


Return value

BYTE


SetRxMaskID

set the Mask

Standard ID mode only

(for V5 compatibility)

Parameters

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


Return value

This call does not return a value


SetRxFilter

Allows the receive ID filter to be configured on the fly allowing different ID ranges to be received.

Parameters

BYTE Filter
Specifies which receive filter to modify. Range: 0-5
ULONG ID
The ID filter value you wish to use


Return value

This call does not return a value


SetTxIdent

Set the Tx CAN ID as a generic number.

Standard and extended IDs

Standard 0-2047

Extended 2048-536870911

Parameters

BYTE Buffer
Transmit buffer to load. Range: 0-2
ULONG ID
The ID or Extended ID value you wish to use. Range: 0-536870911


Return value

This call does not return a value


CheckRx

Checks to see if any messages are available for 'Buffer' specified

Parameters

BYTE Buffer
Send buffer: 0 to 1


Return value

BYTE


GetRxIDSimple

Gets the Rx ID as a Integer

Standard ID only 0-2047.

Parameters

BYTE Buffer
Receive Buffer. Range 0-1


Return value

UINT


SetTxID

Set the Tx CAN ID in register format.

Standard ID only 0-2047.

Compatible with v5 component and previous,

Parameters

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)


Return value

This call does not return a value


ShowLEDs

Set LED state

(External CAN only)

Parameters

BYTE led1
Controls LED 1. Range: 0-1
BYTE led2
Controls LED 2. Range: 0-1


Return value

This call does not return a value


GetRxIdent

Gets the Rx ID as a Integer

Standard and Extended IDs.

Parameters

BYTE Buffer


Return value

ULONG


Initialise

Must be called before any other CAN component macros to enable and initialise the CAN peripheral.

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

SetBaud

No additional information


Parameters

This macro has no parameters


Return value

This call does not return a value



Property reference

Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

Switches between Internal CAN peripheral and External CAN controller IC MCP2515.

Controller Osc

This property is of type Fixed list of ints and can be referenced with the variable name EXT_OSC.

No additional information


Bus Rate

This property is of type Fixed list of ints and can be referenced with the variable name BUS_RATE.

Data rate of the bus specified in thousand bits per second, Kbps.

Sample Point

This property is of type Fixed list of ints and can be referenced with the variable name SAMPLE.

Point in each bit period where the incoming data is sampled.

Sync Jump Width

This property is of type Fixed list of ints and can be referenced with the variable name SJW.

Defines how far a resyncronisation may move the sample point

ID Type

This property is of type Fixed list of ints and can be referenced with the variable name EXID.

Switches between using Standard, or Standard and Extended CAN

Channel

This property is of type Fixed list of ints and can be referenced with the variable name SPIChannel.

External CAN - SPI Channel

Internal CAN - CAN Channel

Data Out MOSI / SDO

This property is of type Single digital pin and can be referenced with the variable name SDO.

External CAN Data Out Pin

Data In MISO / SDI

This property is of type Single digital pin and can be referenced with the variable name SDI.

External CAN Data In Pin

Clock SCK

This property is of type Single digital pin and can be referenced with the variable name SCK.

External CAN Clock Pin

Chip Select

This property is of type Single digital pin and can be referenced with the variable name SPI_CS.

External CAN Chip Select Pin

Message ID

This property is of type Signed integer and can be referenced with the variable name TXB0ID.

TX Buffer 0 Message Identifier

Length

This property is of type Signed integer and can be referenced with the variable name TXB0LEN.

TX Buffer 0 Number of data bytes

D0

This property is of type Signed integer and can be referenced with the variable name TXB0DB0.

TX Buffer 0 Data Byte 0

D1

This property is of type Signed integer and can be referenced with the variable name TXB0DB1.

TX Buffer 0 Data Byte 1

D2

This property is of type Signed integer and can be referenced with the variable name TXB0DB2.

TX Buffer 0 Data Byte 2

D3

This property is of type Signed integer and can be referenced with the variable name TXB0DB3.

TX Buffer 0 Data Byte 3

D4

This property is of type Signed integer and can be referenced with the variable name TXB0DB4.

TX Buffer 0 Data Byte 4

D5

This property is of type Signed integer and can be referenced with the variable name TXB0DB5.

TX Buffer 0 Data Byte 5

D6

This property is of type Signed integer and can be referenced with the variable name TXB0DB6.

TX Buffer 0 Data Byte 6

D7

This property is of type Signed integer and can be referenced with the variable name TXB0DB7.

TX Buffer 0 Data Byte 7

Message ID

This property is of type Signed integer and can be referenced with the variable name TXB1ID.

TX Buffer 1 Message Identifier

Length

This property is of type Signed integer and can be referenced with the variable name TXB1LEN.

TX Buffer 1 Number of data bytes

D0

This property is of type Signed integer and can be referenced with the variable name TXB1DB0.

TX Buffer 1 Data Byte 0

D1

This property is of type Signed integer and can be referenced with the variable name TXB1DB1.

TX Buffer 1 Data Byte 1

D2

This property is of type Signed integer and can be referenced with the variable name TXB1DB2.

TX Buffer 1 Data Byte 2

D3

This property is of type Signed integer and can be referenced with the variable name TXB1DB3.

TX Buffer 1 Data Byte 3

D4

This property is of type Signed integer and can be referenced with the variable name TXB1DB4.

TX Buffer 1 Data Byte 4

D5

This property is of type Signed integer and can be referenced with the variable name TXB1DB5.

TX Buffer 1 Data Byte 5

D6

This property is of type Signed integer and can be referenced with the variable name TXB1DB6.

TX Buffer 1 Data Byte 6

D7

This property is of type Signed integer and can be referenced with the variable name TXB1DB7.

TX Buffer 1 Data Byte 7

Message ID

This property is of type Signed integer and can be referenced with the variable name TXB2ID.

TX Buffer 2 Message Identifier

Length

This property is of type Signed integer and can be referenced with the variable name TXB2LEN.

TX Buffer 2 Number of data bytes

D0

This property is of type Signed integer and can be referenced with the variable name TXB2DB0.

TX Buffer 2 Data Byte 0

D1

This property is of type Signed integer and can be referenced with the variable name TXB2DB1.

TX Buffer 2 Data Byte 1

D2

This property is of type Signed integer and can be referenced with the variable name TXB2DB2.

TX Buffer 2 Data Byte 2

D3

This property is of type Signed integer and can be referenced with the variable name TXB2DB3.

TX Buffer 2 Data Byte 3

D4

This property is of type Signed integer and can be referenced with the variable name TXB2DB4.

TX Buffer 2 Data Byte 4

D5

This property is of type Signed integer and can be referenced with the variable name TXB2DB5.

TX Buffer 2 Data Byte 5

D6

This property is of type Signed integer and can be referenced with the variable name TXB2DB6.

TX Buffer 2 Data Byte 6

D7

This property is of type Signed integer and can be referenced with the variable name TXB2DB7.

TX Buffer 2 Data Byte 7

Settings

This property is of type Fixed list of ints and can be referenced with the variable name RXB0CFG.

RX Buffer 0 Message Receive Mode

Settings

This property is of type Fixed list of ints and can be referenced with the variable name RXB1CFG.

RX Buffer 1 Message Receive Mode

Label

This property is of type Line of text and can be referenced with the variable name label.

Comms Flasher Identification Label

Injector

This property is of type Fixed list of ints and can be referenced with the variable name Injector.

Data Injector to allow CAN data to work with simulated external devices or ID decoding