Difference between revisions of "Component: CAN (CAL) (Peripheral CAL)"
(XML import - Pre 8.0 release) |
|||
Line 20: | Line 20: | ||
==Examples== | ==Examples== | ||
− | + | ||
+ | Example showing how to build a component using a CAL component [[Using_CAL_Components|Using CAL Components]]. | ||
Latest revision as of 11:27, 23 July 2018
Author | Matrix TSL |
Version | 2.1 (Release) |
Category | Peripheral CAL |
Contents
CAN (CAL) component
CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. Low level routines for controling the internal CAN peripheral.
Examples
Example showing how to build a component using a CAL component Using CAL Components.
Downloadable macro reference
SetTxIdentStd
Sets the ID to send along with the data in the next CAN message
Parameters
- BYTE Buffer
- Send buffer: 0 to,2
- BYTE Hi
- The high byte (bits 8-15) of the ID
- BYTE Lo
- The low byte (bits 0-7) of the ID
Return value
- This call does not return a value
SetTxIdentExd
Sets the optional 32-bit ID to send along with the standard ID and data in the next CAN message
Parameters
- BYTE Buffer
- Send buffer: 0 to,2
- BYTE ID3
- The high byte (bits 24-31) of the ID
- BYTE ID2
- The mid-high byte (bits 16-23) of the ID
- BYTE ID1
- The mid-low byte (bits 8-15) of the ID
- BYTE ID0
- The low byte (bits 0-7) of the ID
Return value
- This call does not return a value
SetTxData
Sets the CAN transmit data for the buffer specified (0, 1 or 2).
The count parameter Data_Cnt indicates the number of valid data bytes.
D0 to D7 are the payload data bytes to be loaded into the transmit buffer.
Parameters
- BYTE Buffer
- Send buffer: 0 to,2
- BYTE Data_Cnt
- The number of bytes of data to add, 0 to 8
- BYTE D0
- Data byte 0 to add
- BYTE D1
- Data byte 1 to add
- BYTE D2
- Data byte 2 to add
- BYTE D3
- Data byte 3 to add
- BYTE D4
- Data byte 4 to add
- BYTE D5
- Data byte 5 to add
- BYTE D6
- Data byte 6 to add
- BYTE D7
- Data byte 7 to add
Return value
- This call does not return a value
SetRxMask
Generic function to set Identifier.
CAN registers will be configured depending upon Std/Ext mode setting.
Parameters
- BYTE mask
- ULONG id
Return value
- This call does not return a value
GetRxData
Returns the data byte at index from the buffer specified
Parameters
- BYTE buffer
- The index of the required buffer
- BYTE index
- The index of the required data byte in the buffer
Return value
SendBuffer
Sends the contents of the buffer previously filled with Set_TX_... calls
Parameters
- BYTE Buffer
- Send buffer: 0 to,2
Return value
- This call does not return a value
GetRxDataCount
Returns the number of valid data bytes in the buffer
Parameters
- BYTE buffer
- The index of the required buffer
Return value
Init
Must be called at least once and after every Uninit call to enable the CAN instance
Parameters
- This macro has no parameters
Return value
- This call does not return a value
SetRxMaskStd
Sets the 16-bit filter as a bit-mask of the standard ID for received messages
The messages are accepted if (StdID & Mask) == Filter
Parameters
- BYTE Mask
- Mask number
- BYTE Hi
- The high byte (bits 8-15) of the ID
- BYTE Lo
- The low byte (bits 0-7) of the ID
Return value
- This call does not return a value
SetRxMaskExd
Sets the 32-bit filter as a bit-mask of the extended ID for received messages
The messages are accepted if (ExtID & Mask) == Filter
Parameters
- BYTE Mask
- Mask 0 or 1
- BYTE ID3
- The high byte (bits 24-31) of the ID
- BYTE ID2
- The mid-high byte (bits 16-23) of the ID
- BYTE ID1
- The mid-low byte (bits 8-15) of the ID
- BYTE ID0
- The low byte (bits 0-7) of the ID
Return value
- This call does not return a value
SetRxFilter
Generic function to set Identifier.
CAN registers will be configured depending upon Std/Ext mode setting.
Parameters
- BYTE filter
- ULONG id
Return value
- This call does not return a value
SetTxIdent
Generic function to set Identifier.
CAN registers will be configured depending upon Std/Ext mode setting.
Parameters
- BYTE buffer
- ULONG id
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
Uninit
Uninitialises the CAN, freeing its connections for general use
Parameters
- This macro has no parameters
Return value
- This call does not return a value
GetRxIdent
Generic function to get the received message Identifier.
Parameters
- BYTE buffer
Return value
SetRxFilterStd
Sets the 16-bit filter as a bit-mask of the standard ID for received messages
The messages are accepted if (StdID & Mask) == Filter
Parameters
- BYTE Filter
- Filter number
- BYTE Hi
- The high byte (bits 8-15) of the ID
- BYTE Lo
- The low byte (bits 0-7) of the ID
Return value
- This call does not return a value
SetRxFilterExd
Sets the 32-bit filter as a bit-mask of the extended ID for received messages
The messages are accepted if (ExtID & Mask) == Filter
Parameters
- BYTE Filter
- Send filter: 0 to 3
- BYTE ID3
- The high byte (bits 24-31) of the ID
- BYTE ID2
- The mid-high byte (bits 16-23) of the ID
- BYTE ID1
- The mid-low byte (bits 8-15) of the ID
- BYTE ID0
- The low byte (bits 0-7) of the ID
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
GetValue
Get the Value of the Named property
Parameters
- STRING Name
Return value
InitRXMask
Initialization setting for RX Mask
Parameters
- BYTE Mask
- Mask Number (0 or 1)
- ULONG Value
Return value
- This call does not return a value
InitRXFilter
Initialization setting for RX Filter
Parameters
- BYTE Filter
- ULONG Value
Return value
- This call does not return a value
InitTXBuffer
Initialization settings for TX Buffers
Parameters
- BYTE Buffer
- TX Buffer ID = 0,1 or 2
- ULONG ID
- CAN Address
- BYTE Length
- Number of bytes to send
- STRING Data
- Data Array (of Length bytes)
Return value
- This call does not return a value
SetValue
Set the Value of the Named property
Parameters
- <- STRING Name
- This parameter may be returned back to the caller
- <- STRING Value
- This parameter may be returned back to the caller
Return value
- This call does not return a value
InitRXConfig
Initialization setting for RX Buffer Config
Parameters
- BYTE Buffer
- Buffer Number (0 or 1)
- BYTE Value
- Config data byte
Return value
- This call does not return a value
GetList
Get the Filter List of the Named Property
Parameters
- STRING Name
Return value
Property reference
Channel
This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.
Selects the CAN channel to be used
TX Pin
This property is of type Single digital pin and can be referenced with the variable name TXPin.
No additional information
RX Pin
This property is of type Single digital pin and can be referenced with the variable name RXPin.
No additional information
Bus Rate
This property is of type Fixed list of ints and can be referenced with the variable name BUS_RATE.
selects the Bus Rate (KHz)
Sample Point
This property is of type Fixed list of ints and can be referenced with the variable name SAMPLE.
selects the Sample Point for bit reading
SJW
This property is of type Fixed list of ints and can be referenced with the variable name SJW.
Synchronization Jump Width adjusts the bit
clock by 1 to 4 TQ periods
Fosc
This property is of type Signed integer and can be referenced with the variable name OSC.
No additional information
BRGCON1
This property is of type Signed integer and can be referenced with the variable name BAUD1.
No additional information
BRGCON2
This property is of type Signed integer and can be referenced with the variable name BAUD2.
No additional information
BRGCON3
This property is of type Signed integer and can be referenced with the variable name BAUD3.
No additional information
ID Type
This property is of type Fixed list of ints and can be referenced with the variable name EXID.
selects the CAN ID type
Message ID
This property is of type Signed integer and can be referenced with the variable name TXB0ID.
CAN Message ID for Transmit Buffer 0
Length
This property is of type Signed integer and can be referenced with the variable name TXB0LEN.
Number of valid data bytes in the message
D0
This property is of type Signed integer and can be referenced with the variable name TXB0DB0.
Data byte 0
D1
This property is of type Signed integer and can be referenced with the variable name TXB0DB1.
Data byte 1
D2
This property is of type Signed integer and can be referenced with the variable name TXB0DB2.
Data byte 2
D3
This property is of type Signed integer and can be referenced with the variable name TXB0DB3.
Data byte 3
D4
This property is of type Signed integer and can be referenced with the variable name TXB0DB4.
Data byte 4
D5
This property is of type Signed integer and can be referenced with the variable name TXB0DB5.
Data byte 5
D6
This property is of type Signed integer and can be referenced with the variable name TXB0DB6.
Data byte 6
D7
This property is of type Signed integer and can be referenced with the variable name TXB0DB7.
Data byte 7
Message ID
This property is of type Signed integer and can be referenced with the variable name TXB1ID.
CAN Message ID for Transmit Buffer 1
Length
This property is of type Signed integer and can be referenced with the variable name TXB1LEN.
Number of valid data bytes in the message
D0
This property is of type Signed integer and can be referenced with the variable name TXB1DB0.
Data byte 0
D1
This property is of type Signed integer and can be referenced with the variable name TXB1DB1.
Data byte 1
D2
This property is of type Signed integer and can be referenced with the variable name TXB1DB2.
Data byte 2
D3
This property is of type Signed integer and can be referenced with the variable name TXB1DB3.
Data byte 3
D4
This property is of type Signed integer and can be referenced with the variable name TXB1DB4.
Data byte 4
D5
This property is of type Signed integer and can be referenced with the variable name TXB1DB5.
Data byte 5
D6
This property is of type Signed integer and can be referenced with the variable name TXB1DB6.
Data byte 6
D7
This property is of type Signed integer and can be referenced with the variable name TXB1DB7.
Data byte 7
Message ID
This property is of type Signed integer and can be referenced with the variable name TXB2ID.
CAN Message ID for Transmit Buffer 2
Length
This property is of type Signed integer and can be referenced with the variable name TXB2LEN.
Number of valid data bytes in the message
D0
This property is of type Signed integer and can be referenced with the variable name TXB2DB0.
Data byte 0
D1
This property is of type Signed integer and can be referenced with the variable name TXB2DB1.
Data byte 1
D2
This property is of type Signed integer and can be referenced with the variable name TXB2DB2.
Data byte 2
D3
This property is of type Signed integer and can be referenced with the variable name TXB2DB3.
Data byte 3
D4
This property is of type Signed integer and can be referenced with the variable name TXB2DB4.
Data byte 4
D5
This property is of type Signed integer and can be referenced with the variable name TXB2DB5.
Data byte 5
D6
This property is of type Signed integer and can be referenced with the variable name TXB2DB6.
Data byte 6
D7
This property is of type Signed integer and can be referenced with the variable name TXB2DB7.
Data byte 7
Settings
This property is of type Fixed list of ints and can be referenced with the variable name RXB0CFG.
Filter setting for Receive Buffer 0
Mask
This property is of type Signed integer and can be referenced with the variable name RXM0.
Value for Receive Mask 0
Filter 0
This property is of type Signed integer and can be referenced with the variable name RXF0.
Value for Filter 0
Filter 1
This property is of type Signed integer and can be referenced with the variable name RXF1.
Value for Filter 1
Settings
This property is of type Fixed list of ints and can be referenced with the variable name RXB1CFG.
Filter setting for Receive Buffer 1
Mask
This property is of type Signed integer and can be referenced with the variable name RXM1.
Value for Receive Mask 1
Filter 2
This property is of type Signed integer and can be referenced with the variable name RXF2.
Value for Filter 2
Filter 3
This property is of type Signed integer and can be referenced with the variable name RXF3.
Value for Filter 3
Filter 4
This property is of type Signed integer and can be referenced with the variable name RXF4.
Value for Filter 4
Filter 5
This property is of type Signed integer and can be referenced with the variable name RXF5.
Value for Filter 5