LTlib LaurTec Library
4.0.0 Beta
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
|
#include "module_CAN.h"
Go to the source code of this file.
Functions | |
void | CAN_open (BYTE propSeg, BYTE phaseSeg1, BYTE phaseSeg2, BYTE SJW, BYTE BRP, enum CAN_CONFIG_FLAGS flags) |
void | CAN_close (void) |
void | CAN_write_message (unsigned long identifier, BYTE *data, BYTE dataLength, enum CAN_TX_MSG_FLAGS flags) |
unsigned char | CAN_read_message (CANmessage *msg) |
void | CAN_set_mask (enum CAN_MASK mask_number, unsigned long mask, enum CAN_CONFIG_FLAGS type) |
void | CAN_set_filter (enum CAN_FILTER filter_number, unsigned long filter, enum CAN_CONFIG_FLAGS type) |
void | CAN_operation_mode (enum CAN_OP_MODE mode) |
void | CAN_abort_messages (void) |
BYTE | CAN_is_BUS_OFF (void) |
BYTE | CAN_is_TX_passive (void) |
BYTE | CAN_is_RX_passive (void) |
BYTE | CAN_is_TX_warning_ON (void) |
BYTE | CAN_is_RX_warning_ON (void) |
BYTE | CAN_get_TX_error_count (void) |
BYTE | CAN_get_RX_error_count (void) |
BYTE | CAN_is_TX_ready (void) |
BYTE | CAN_is_RX_ready (void) |
void CAN_abort_messages | ( | void | ) |
This function let the CAN module discard all the TX messages.
none |
Definition at line 1034 of file module_CAN.c.
void CAN_close | ( | void | ) |
This function disable the CAN module setting it in SLEEP mode.
void |
Definition at line 138 of file module_CAN.c.
References CAN_OP_MODE_SLEEP, and CAN_operation_mode().
BYTE CAN_get_RX_error_count | ( | void | ) |
This function returns the number of RX errors.
none |
Definition at line 1087 of file module_CAN.c.
BYTE CAN_get_TX_error_count | ( | void | ) |
This function returns the number of TX errors.
none |
Definition at line 1079 of file module_CAN.c.
BYTE CAN_is_BUS_OFF | ( | void | ) |
This function is used to check if the mdoule is in BUS OFF. The module gets to BUSS OFF once the error counter reaches 255.
none |
Definition at line 1042 of file module_CAN.c.
BYTE CAN_is_RX_passive | ( | void | ) |
This function returns the RX BUS passive status. The device gets in passive mode once the error counter has exceeded the error limit of 127.
none |
Definition at line 1057 of file module_CAN.c.
BYTE CAN_is_RX_ready | ( | void | ) |
This function checks if there is any data within the RX buffer.
none |
Definition at line 1104 of file module_CAN.c.
BYTE CAN_is_RX_warning_ON | ( | void | ) |
This function returns RX warning status.It gets ON once the error counter reaches the value 96. While the warning is ON the CAN modules still operates properly.
none |
Definition at line 1071 of file module_CAN.c.
BYTE CAN_is_TX_passive | ( | void | ) |
This function returns the TX BUS passive status. The device gets in passive mode once the error counter has exceeded the error limit of 127.
none |
Definition at line 1049 of file module_CAN.c.
BYTE CAN_is_TX_ready | ( | void | ) |
This function checks if there is any free slot within the TX buffer.
none |
Definition at line 1095 of file module_CAN.c.
BYTE CAN_is_TX_warning_ON | ( | void | ) |
This function returns TX warning status. It gets ON once the error counter reaches the value 96. While the warning is ON the CAN modules still operates properly.
none |
Definition at line 1064 of file module_CAN.c.
void CAN_open | ( | BYTE | propSeg, |
BYTE | phaseSeg1, | ||
BYTE | phaseSeg2, | ||
BYTE | SJW, | ||
BYTE | BRP, | ||
enum CAN_CONFIG_FLAGS | flags | ||
) |
This function is used to initialize the module. It should be the first function to be calles.
propSeg | Propagation Segment, PROP_SEG as per CAN specifications [value: 1...8] |
phaseSeg1 | PHASE_SEG1 as per CAN specifications [value: 1...8] |
phaseSeg2 | PHASE_SEG2 as per CAN specifications [value: 1...8] |
SJW | Synchronized Jump Width as per CAN specifications [value: 1...4] |
BRP | Baud Rate Prescaler [value: 0...63] |
flags | CAN Module configuration [use the CAN_CONFIG_FLAGS values] |
Definition at line 53 of file module_CAN.c.
References CAN_CONFIG_DBL_BUFFER_BIT, CAN_CONFIG_DBL_BUFFER_ON, CAN_CONFIG_LINE_FILTER_BIT, CAN_CONFIG_MSG_BITS, CAN_CONFIG_PHSEG2_PRG_BIT, CAN_CONFIG_SAMPLE_BIT, CAN_CONFIG_STD_MSG, CAN_CONFIG_VALID_STD_MSG, CAN_CONFIG_VALID_XTD_MSG, CAN_CONFIG_XTD_MSG, CAN_FILTER_B1_F1, CAN_FILTER_B1_F2, CAN_FILTER_B2_F1, CAN_FILTER_B2_F2, CAN_FILTER_B2_F3, CAN_FILTER_B2_F4, CAN_MASK_B1, CAN_MASK_B2, CAN_OP_MODE_CONFIG, CAN_OP_MODE_NORMAL, CAN_operation_mode(), CAN_set_filter(), and CAN_set_mask().
void CAN_operation_mode | ( | enum CAN_OP_MODE | mode | ) |
This function changes the CAN module operational mode.
mode | Mode to be set for the CAN module [ |
for the mode you have to use one of the folowing constants: CAN_OP_MODE_NORMAL CAN_OP_MODE_SLEEP, CAN_OP_MODE_LOOP, CAN_OP_MODE_LISTEN, CAN_OP_MODE_CONFIG
Definition at line 1024 of file module_CAN.c.
unsigned char CAN_read_message | ( | CANmessage * | msg | ) |
This function reads a message from the RX buffer. The data is stored within a CANmessage structure.
msg | Pointer to a CANmessage structure. |
Definition at line 402 of file module_CAN.c.
References CAN_RX_BUFFER_1_OVFL, CAN_RX_BUFFER_2_OVFL, CANmessage::data, CANmessage::identifier, CANmessage::length, CANmessage::RTR, and CANmessage::type.
void CAN_set_filter | ( | enum CAN_FILTER | filter_number, |
unsigned long | val, | ||
enum CAN_CONFIG_FLAGS | type | ||
) |
This function sets filters used to filter the incoming messages.
filter_number | select the filter number [CAN_FILTER_B1_F1, CAN_FILTER_B1_F2,CAN_FILTER_B2_F1...CAN_FILTER_B2_F4] |
val | Filter value |
type | Filter type, either Standard or Extended [CAN_CONFIG_STD_MSG, CAN_CONFIG_XTD_MSG] |
Definition at line 653 of file module_CAN.c.
References CAN_CONFIG_STD_MSG, CAN_CONFIG_XTD_MSG, CAN_FILTER_B1_F1, CAN_FILTER_B1_F2, CAN_FILTER_B2_F1, CAN_FILTER_B2_F2, CAN_FILTER_B2_F3, and CAN_FILTER_B2_F4.
void CAN_set_mask | ( | enum CAN_MASK | mask_number, |
unsigned long | val, | ||
enum CAN_CONFIG_FLAGS | type | ||
) |
This function sets the MASK used to filter the incoming messages.
mask_number | select the mask number [CAN_MASK_B1, CAN_MASK_B2] |
val | Mask value. |
type | Mask type, either Standard or Extended [CAN_CONFIG_STD_MSG, CAN_CONFIG_XTD_MSG] |
Definition at line 539 of file module_CAN.c.
References CAN_CONFIG_STD_MSG, CAN_CONFIG_XTD_MSG, CAN_MASK_B1, and CAN_MASK_B2.
void CAN_write_message | ( | unsigned long | identifier, |
BYTE * | data, | ||
BYTE | dataLength, | ||
enum CAN_TX_MSG_FLAGS | flags | ||
) |
This function writes a message within the TX buffer.
identifier | Message Identifier. |
data | Data Byte poiter to an array of BYTE [max. 8 Bytes] |
dataLength | Number of bytes to be sent [1...8] |
flags | MEssage configuration (Use the CAN_TX_MSG_FLAGS values) |
Definition at line 147 of file module_CAN.c.
References CAN_TX_FRAME_MASK.