CANopen Slave Documentation
Version 7.00.00
|
This module holds all functions for the initialization and control of the CANopen slave. Some functions of this module need to be adopted to the target application:
These functions are located in the cos_user.c file. Please refer to Initialization Process for details about the CosMgrInit() function and also check the Complete Startup Process for reference.
Macros | |
#define | COS_CONF_SLAVE ((uint16_t) 0x0000) |
#define | COS_CONF_MASTER ((uint16_t) 0x0001) |
#define | COS_CONF_AUTOSTART ((uint16_t) 0x0002) |
#define | COS_CONF_FD ((uint16_t) 0x0004) |
#define | COS_CONF_J1939 ((uint16_t) 0x0010) |
Functions | |
uint8_t | CosMgrGetBitrate (void) |
uint16_t | CosMgrGetConfiguration (void) |
int32_t | CosMgrGetDataBitrate (void) |
uint8_t | CosMgrGetFrameFormat (void) |
uint8_t | CosMgrGetNodeId (void) |
int32_t | CosMgrGetNominalBitrate (void) |
uint32_t | CosMgrGetProductCode (void) |
uint32_t | CosMgrGetSerialNumber (void) |
uint8_t | CosMgrInit (uint8_t ubCanIfV, uint16_t uwConfigV) |
void | CosMgrOnBootUp (void) |
void | CosMgrOnStart (uint8_t ubCallerResultV) |
uint8_t | CosMgrProcess (void) |
void | CosMgrProfileUpdate (uint16_t uwIndexV, uint8_t ubSubIndexV) |
uint8_t | CosMgrRelease (void) |
uint8_t | CosMgrStart (uint8_t ubNodeIdV, int32_t slBitrateNomSelV, int32_t slBitrateDatSelV) |
uint8_t CosMgrGetBitrate | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine checks for the bit-rate. The code of this routine has to be adopted to the specific target. The function returns a constant for the bit-rate that is specified in the canpie.h file.
uint16_t CosMgrGetConfiguration | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine evaluates the protocol stack configuration. The code of this routine has to be adopted to the specific target. The function returns the CANopen Slave protocol stacks configuration.
int32_t CosMgrGetDataBitrate | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine checks for the data bit rate. The code of this routine has to be adopted to the specific target. The function returns a constant for the bit rate that is specified in the canpie.h
file. If CAN FD is not supported, the function shall return eCP_BITRATE_NONE.
uint8_t CosMgrGetFrameFormat | ( | void | ) |
This function returns the CAN message frame format that shall be used for message buffer configuration. The value depends on the the stack configuration as shown in the table:
CosMgrInit() - uwConfigV | data bit rate | Frame Format |
---|---|---|
COS_CONF_FD not set | not evaluated | CP_MSG_FORMAT_CBFF |
COS_CONF_FD set | eCP_BITRATE_NONE | CP_MSG_FORMAT_FBFF |
COS_CONF_FD set | valid bit-rate | CP_MSG_FORMAT_FBFF | CP_MSG_CTRL_BRS_BIT |
uint8_t CosMgrGetNodeId | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine checks for the node-ID. The code of this routine has to be adopted to the specific target. The function returns a value in the range from 1 to 127.
int32_t CosMgrGetNominalBitrate | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine checks for the nominal bit rate. The code of this routine has to be adopted to the specific target. The function returns a constant for the bit rate that is specified in the canpie.h
file.
uint32_t CosMgrGetProductCode | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine returns the Product Code of the module. The Product Number is used within in Identity Object (index 1018:02h).
uint32_t CosMgrGetSerialNumber | ( | void | ) |
cos_user.c
provides an example and has to be adopted to the application.This routine returns the Serial Number of the module, which must be a unique value for a product family. The Serial Number is used within the Identity Object (index 1018:04h).
uint8_t CosMgrInit | ( | uint8_t | ubCanIfV, |
uint16_t | uwConfigV ) |
Initialize the CANopen Slave.
ubCanIfV | - Physical CAN interface |
uwConfigV | - Initial configuration |
The function returns eCOS_ERR_NONE on success. It is responsible for the following tasks:
Possible values for uwConfigV are:
void CosMgrOnBootUp | ( | void | ) |
This event is called after successful transmission of the Boot-up message.
void CosMgrOnStart | ( | uint8_t | ubCallerResultV | ) |
[in] | ubCallerResultV | Result of CANopen service initialization |
This event is called during the initialization of CANopen services (refer to CosMgrStart()). The parameter ubCallerResultV holds the state of the initialization process. Possible values are defined by the CosErr_e enumeration. On successful initialization the value for ubCallerResultV is eCOS_ERR_NONE.
The following example shows how to change default settings for the heartbeat and the SYNC producer, as well as registration of EMCY codes.
uint8_t CosMgrProcess | ( | void | ) |
Process CANopen message queue.
This function has to called within the main loop of the application. It is responsible to handle NVM operations and to check the requested NMT state. Possible return values are:
void CosMgrProfileUpdate | ( | uint16_t | uwIndexV, |
uint8_t | ubSubIndexV ) |
Update parameter of device profile.
uwIndexV | parameter index |
ubSubIndexV | parameter sub-index |
This function is called by the stack when a parameter of a device profile is modified. It can be used to control the interaction between the CANopen slave stack and the application. The implementation of this function depends on the application.
uint8_t CosMgrRelease | ( | void | ) |
Release the CANopen Slave protocol stack.
This routine stops the CANopen protocol stack. The function returns CosErr_OK on success.
uint8_t CosMgrStart | ( | uint8_t | ubNodeIdV, |
int32_t | slBitrateNomSelV, | ||
int32_t | slBitrateDatSelV ) |
ubNodeIdV | - Device node-ID (NID) |
slBitrateNomSelV | - Nominal bit rate value |
slBitrateDatSelV | - Data bit rate value |
This routine starts the CANopen protocol stack on the given node-ID and bit rate. The initialization routines from other CANopen services are called and the Boot-up message is sent. The function returns eCOS_ERR_NONE on success.
In case the device shall be started in classical CANopen mode the parameter slBitrateDatSelV
must be set to eCP_BITRATE_NONE.